Import asyncpg_0.8.4.orig.tar.gz
authorPiotr Ożarowski <piotr@debian.org>
Tue, 10 Jan 2017 19:19:24 +0000 (19:19 +0000)
committerPiotr Ożarowski <piotr@debian.org>
Tue, 10 Jan 2017 19:19:24 +0000 (19:19 +0000)
[dgit import orig asyncpg_0.8.4.orig.tar.gz]

89 files changed:
LICENSE [new file with mode: 0644]
MANIFEST.in [new file with mode: 0644]
Makefile [new file with mode: 0644]
PKG-INFO [new file with mode: 0644]
README.rst [new file with mode: 0644]
asyncpg.egg-info/PKG-INFO [new file with mode: 0644]
asyncpg.egg-info/SOURCES.txt [new file with mode: 0644]
asyncpg.egg-info/dependency_links.txt [new file with mode: 0644]
asyncpg.egg-info/top_level.txt [new file with mode: 0644]
asyncpg/__init__.py [new file with mode: 0644]
asyncpg/_testbase.py [new file with mode: 0644]
asyncpg/cluster.py [new file with mode: 0644]
asyncpg/compat.py [new file with mode: 0644]
asyncpg/connection.py [new file with mode: 0644]
asyncpg/cursor.py [new file with mode: 0644]
asyncpg/exceptions/__init__.py [new file with mode: 0644]
asyncpg/exceptions/_base.py [new file with mode: 0644]
asyncpg/introspection.py [new file with mode: 0644]
asyncpg/pool.py [new file with mode: 0644]
asyncpg/prepared_stmt.py [new file with mode: 0644]
asyncpg/protocol/__init__.py [new file with mode: 0644]
asyncpg/protocol/buffer.pxd [new file with mode: 0644]
asyncpg/protocol/buffer.pyx [new file with mode: 0644]
asyncpg/protocol/codecs/__init__.py [new file with mode: 0644]
asyncpg/protocol/codecs/array.pyx [new file with mode: 0644]
asyncpg/protocol/codecs/base.pxd [new file with mode: 0644]
asyncpg/protocol/codecs/base.pyx [new file with mode: 0644]
asyncpg/protocol/codecs/bits.pyx [new file with mode: 0644]
asyncpg/protocol/codecs/bytea.pyx [new file with mode: 0644]
asyncpg/protocol/codecs/datetime.pyx [new file with mode: 0644]
asyncpg/protocol/codecs/float.pyx [new file with mode: 0644]
asyncpg/protocol/codecs/geometry.pyx [new file with mode: 0644]
asyncpg/protocol/codecs/hstore.pyx [new file with mode: 0644]
asyncpg/protocol/codecs/int.pyx [new file with mode: 0644]
asyncpg/protocol/codecs/json.pyx [new file with mode: 0644]
asyncpg/protocol/codecs/misc.pyx [new file with mode: 0644]
asyncpg/protocol/codecs/money.pyx [new file with mode: 0644]
asyncpg/protocol/codecs/network.pyx [new file with mode: 0644]
asyncpg/protocol/codecs/numeric.pyx [new file with mode: 0644]
asyncpg/protocol/codecs/range.pyx [new file with mode: 0644]
asyncpg/protocol/codecs/record.pyx [new file with mode: 0644]
asyncpg/protocol/codecs/text.pyx [new file with mode: 0644]
asyncpg/protocol/codecs/textutils.pyx [new file with mode: 0644]
asyncpg/protocol/codecs/tsearch.pyx [new file with mode: 0644]
asyncpg/protocol/codecs/txid.pyx [new file with mode: 0644]
asyncpg/protocol/codecs/uuid.pyx [new file with mode: 0644]
asyncpg/protocol/consts.pxi [new file with mode: 0644]
asyncpg/protocol/coreproto.pxd [new file with mode: 0644]
asyncpg/protocol/coreproto.pyx [new file with mode: 0644]
asyncpg/protocol/debug.h [new file with mode: 0644]
asyncpg/protocol/debug.pxd [new file with mode: 0644]
asyncpg/protocol/encodings.pyx [new file with mode: 0644]
asyncpg/protocol/hton.pxd [new file with mode: 0644]
asyncpg/protocol/pgtypes.pxi [new file with mode: 0644]
asyncpg/protocol/prepared_stmt.pxd [new file with mode: 0644]
asyncpg/protocol/prepared_stmt.pyx [new file with mode: 0644]
asyncpg/protocol/protocol.c [new file with mode: 0644]
asyncpg/protocol/protocol.pxd [new file with mode: 0644]
asyncpg/protocol/protocol.pyx [new file with mode: 0644]
asyncpg/protocol/python.pxd [new file with mode: 0644]
asyncpg/protocol/record/__init__.pxd [new file with mode: 0644]
asyncpg/protocol/record/recordobj.c [new file with mode: 0644]
asyncpg/protocol/record/recordobj.h [new file with mode: 0644]
asyncpg/protocol/settings.pxd [new file with mode: 0644]
asyncpg/protocol/settings.pyx [new file with mode: 0644]
asyncpg/serverversion.py [new file with mode: 0644]
asyncpg/transaction.py [new file with mode: 0644]
asyncpg/types.py [new file with mode: 0644]
docs/api/index.rst [new file with mode: 0644]
docs/conf.py [new file with mode: 0644]
docs/examples.rst [new file with mode: 0644]
docs/index.rst [new file with mode: 0644]
docs/installation.rst [new file with mode: 0644]
performance.png [new file with mode: 0644]
setup.cfg [new file with mode: 0644]
setup.py [new file with mode: 0644]
tests/test_cancellation.py [new file with mode: 0644]
tests/test_codecs.py [new file with mode: 0644]
tests/test_connect.py [new file with mode: 0644]
tests/test_cursor.py [new file with mode: 0644]
tests/test_exceptions.py [new file with mode: 0644]
tests/test_execute.py [new file with mode: 0644]
tests/test_listeners.py [new file with mode: 0644]
tests/test_pool.py [new file with mode: 0644]
tests/test_prepare.py [new file with mode: 0644]
tests/test_record.py [new file with mode: 0644]
tests/test_test.py [new file with mode: 0644]
tests/test_timeout.py [new file with mode: 0644]
tests/test_transaction.py [new file with mode: 0644]

diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..418b71e
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,189 @@
+   Copyright (c) 2016-present MagicStack Inc.  http://magic.io
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644 (file)
index 0000000..e4cfbc3
--- /dev/null
@@ -0,0 +1,5 @@
+recursive-include docs *.py *.rst
+recursive-include examples *.py
+recursive-include tests *.py *.pem
+recursive-include asyncpg *.pyx *.pxd *.pxi *.py *.c *.h
+include LICENSE README.rst Makefile performance.png
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..2f310e4
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,49 @@
+.PHONY: compile debug test quicktest clean all
+
+
+PYTHON ?= python
+
+
+all: compile
+
+
+clean:
+       rm -fr dist/ doc/_build/
+       rm -fr asyncpg/protocol/*.c asyncpg/protocol/*.html
+       rm -fr asyncpg/protocol/*.so build *.egg-info
+       rm -fr asyncpg/protocol/codecs/*.html
+       find . -name '__pycache__' | xargs rm -rf
+
+
+compile:
+       $(PYTHON) setup.py build_ext --inplace --cython-always
+
+
+debug:
+       $(PYTHON) setup.py build_ext --inplace --debug \
+               --cython-always \
+               --cython-annotate \
+               --cython-directives="linetrace=True" \
+               --define ASYNCPG_DEBUG,CYTHON_TRACE,CYTHON_TRACE_NOGIL
+
+
+test:
+       PYTHONASYNCIODEBUG=1 $(PYTHON) -m unittest discover -s tests
+       $(PYTHON) -m unittest discover -s tests
+       USE_UVLOOP=1 $(PYTHON) -m unittest discover -s tests
+
+
+quicktest:
+       $(PYTHON) -m unittest discover -s tests
+
+
+sdist: clean compile test
+       $(PYTHON) setup.py sdist
+
+
+release: clean compile test
+       $(PYTHON) setup.py sdist upload
+
+
+htmldocs: compile
+       $(MAKE) -C docs html
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644 (file)
index 0000000..eef00cf
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,110 @@
+Metadata-Version: 1.1
+Name: asyncpg
+Version: 0.8.4
+Summary: An asyncio PosgtreSQL driver
+Home-page: https://github.com/MagicStack/asyncpg
+Author: MagicStack Inc
+Author-email: hello@magic.io
+License: Apache License, Version 2.0
+Description: asyncpg -- A fast PostgreSQL Database Client Library for Python/asyncio
+        =======================================================================
+        
+        .. image:: https://travis-ci.org/MagicStack/asyncpg.svg?branch=master
+            :target: https://travis-ci.org/MagicStack/asyncpg
+        
+        .. image:: https://ci.appveyor.com/api/projects/status/9rwppnxphgc8bqoj/branch/master?svg=true
+            :target: https://ci.appveyor.com/project/magicstack/asyncpg
+        
+        .. image:: https://img.shields.io/pypi/v/asyncpg.svg
+            :target: https://pypi.python.org/pypi/asyncpg
+        
+        **asyncpg** is a database interface library designed specifically for
+        PostgreSQL and Python/asyncio.  asyncpg is an efficient, clean implementation
+        of PostgreSQL server binary protocol for use with Python's ``asyncio``
+        framework.  You can read more about asyncpg in an introductory
+        `blog post <http://magic.io/blog/asyncpg-1m-rows-from-postgres-to-python/>`_.
+        
+        asyncpg requires Python 3.5 or later and is supported for PostgreSQL
+        versions 9.1 to 9.6.
+        
+        
+        Documentation
+        -------------
+        
+        The project documentation can be found
+        `here <https://magicstack.github.io/asyncpg/current/>`_.
+        
+        
+        Performance
+        -----------
+        
+        In our testing asyncpg is, on average, **3x** faster than psycopg2
+        (and its asyncio variant -- aiopg).
+        
+        .. image:: performance.png
+            :target: http://magic.io/blog/asyncpg-1m-rows-from-postgres-to-python/
+        
+        The above results are a geometric mean of benchmarks obtained with PostgreSQL
+        `client driver benchmarking toolbench <https://github.com/MagicStack/pgbench>`_.
+        
+        
+        Features
+        --------
+        
+        asyncpg implements PostgreSQL server protocol natively and exposes its
+        features directly, as opposed to hiding them behind a generic facade
+        like DB-API.
+        
+        This enables asyncpg to have easy-to-use support for:
+        
+        * **prepared statements**
+        * **scrollable cursors**
+        * **partial iteration** on query results
+        * automatic encoding and decoding of composite types, arrays,
+          and any combination of those
+        * straightforward support for custom data types
+        
+        
+        Installation
+        ------------
+        
+        asyncpg is available on PyPI and has no dependencies.
+        Use pip to install::
+        
+            $ pip install asyncpg
+        
+        
+        Basic Usage
+        -----------
+        
+        .. code-block:: python
+        
+            import asyncio
+            import asyncpg
+        
+            async def run():
+                conn = await asyncpg.connect(user='user', password='password',
+                                             database='database', host='127.0.0.1')
+                values = await conn.fetch('''SELECT * FROM mytable''')
+                await conn.close()
+        
+            loop = asyncio.get_event_loop()
+            loop.run_until_complete(run())
+        
+        
+        License
+        -------
+        
+        asyncpg is developed and distributed under the Apache 2.0 license.
+        
+Platform: POSIX
+Classifier: License :: OSI Approved :: Apache Software License
+Classifier: Intended Audience :: Developers
+Classifier: Programming Language :: Python :: 3 :: Only
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
+Classifier: Operating System :: POSIX
+Classifier: Operating System :: MacOS :: MacOS X
+Classifier: Operating System :: Microsoft :: Windows
+Classifier: Development Status :: 4 - Beta
+Provides: asyncpg
diff --git a/README.rst b/README.rst
new file mode 100644 (file)
index 0000000..8730e0f
--- /dev/null
@@ -0,0 +1,90 @@
+asyncpg -- A fast PostgreSQL Database Client Library for Python/asyncio
+=======================================================================
+
+.. image:: https://travis-ci.org/MagicStack/asyncpg.svg?branch=master
+    :target: https://travis-ci.org/MagicStack/asyncpg
+
+.. image:: https://ci.appveyor.com/api/projects/status/9rwppnxphgc8bqoj/branch/master?svg=true
+    :target: https://ci.appveyor.com/project/magicstack/asyncpg
+
+.. image:: https://img.shields.io/pypi/v/asyncpg.svg
+    :target: https://pypi.python.org/pypi/asyncpg
+
+**asyncpg** is a database interface library designed specifically for
+PostgreSQL and Python/asyncio.  asyncpg is an efficient, clean implementation
+of PostgreSQL server binary protocol for use with Python's ``asyncio``
+framework.  You can read more about asyncpg in an introductory
+`blog post <http://magic.io/blog/asyncpg-1m-rows-from-postgres-to-python/>`_.
+
+asyncpg requires Python 3.5 or later and is supported for PostgreSQL
+versions 9.1 to 9.6.
+
+
+Documentation
+-------------
+
+The project documentation can be found
+`here <https://magicstack.github.io/asyncpg/current/>`_.
+
+
+Performance
+-----------
+
+In our testing asyncpg is, on average, **3x** faster than psycopg2
+(and its asyncio variant -- aiopg).
+
+.. image:: performance.png
+    :target: http://magic.io/blog/asyncpg-1m-rows-from-postgres-to-python/
+
+The above results are a geometric mean of benchmarks obtained with PostgreSQL
+`client driver benchmarking toolbench <https://github.com/MagicStack/pgbench>`_.
+
+
+Features
+--------
+
+asyncpg implements PostgreSQL server protocol natively and exposes its
+features directly, as opposed to hiding them behind a generic facade
+like DB-API.
+
+This enables asyncpg to have easy-to-use support for:
+
+* **prepared statements**
+* **scrollable cursors**
+* **partial iteration** on query results
+* automatic encoding and decoding of composite types, arrays,
+  and any combination of those
+* straightforward support for custom data types
+
+
+Installation
+------------
+
+asyncpg is available on PyPI and has no dependencies.
+Use pip to install::
+
+    $ pip install asyncpg
+
+
+Basic Usage
+-----------
+
+.. code-block:: python
+
+    import asyncio
+    import asyncpg
+
+    async def run():
+        conn = await asyncpg.connect(user='user', password='password',
+                                     database='database', host='127.0.0.1')
+        values = await conn.fetch('''SELECT * FROM mytable''')
+        await conn.close()
+
+    loop = asyncio.get_event_loop()
+    loop.run_until_complete(run())
+
+
+License
+-------
+
+asyncpg is developed and distributed under the Apache 2.0 license.
diff --git a/asyncpg.egg-info/PKG-INFO b/asyncpg.egg-info/PKG-INFO
new file mode 100644 (file)
index 0000000..eef00cf
--- /dev/null
@@ -0,0 +1,110 @@
+Metadata-Version: 1.1
+Name: asyncpg
+Version: 0.8.4
+Summary: An asyncio PosgtreSQL driver
+Home-page: https://github.com/MagicStack/asyncpg
+Author: MagicStack Inc
+Author-email: hello@magic.io
+License: Apache License, Version 2.0
+Description: asyncpg -- A fast PostgreSQL Database Client Library for Python/asyncio
+        =======================================================================
+        
+        .. image:: https://travis-ci.org/MagicStack/asyncpg.svg?branch=master
+            :target: https://travis-ci.org/MagicStack/asyncpg
+        
+        .. image:: https://ci.appveyor.com/api/projects/status/9rwppnxphgc8bqoj/branch/master?svg=true
+            :target: https://ci.appveyor.com/project/magicstack/asyncpg
+        
+        .. image:: https://img.shields.io/pypi/v/asyncpg.svg
+            :target: https://pypi.python.org/pypi/asyncpg
+        
+        **asyncpg** is a database interface library designed specifically for
+        PostgreSQL and Python/asyncio.  asyncpg is an efficient, clean implementation
+        of PostgreSQL server binary protocol for use with Python's ``asyncio``
+        framework.  You can read more about asyncpg in an introductory
+        `blog post <http://magic.io/blog/asyncpg-1m-rows-from-postgres-to-python/>`_.
+        
+        asyncpg requires Python 3.5 or later and is supported for PostgreSQL
+        versions 9.1 to 9.6.
+        
+        
+        Documentation
+        -------------
+        
+        The project documentation can be found
+        `here <https://magicstack.github.io/asyncpg/current/>`_.
+        
+        
+        Performance
+        -----------
+        
+        In our testing asyncpg is, on average, **3x** faster than psycopg2
+        (and its asyncio variant -- aiopg).
+        
+        .. image:: performance.png
+            :target: http://magic.io/blog/asyncpg-1m-rows-from-postgres-to-python/
+        
+        The above results are a geometric mean of benchmarks obtained with PostgreSQL
+        `client driver benchmarking toolbench <https://github.com/MagicStack/pgbench>`_.
+        
+        
+        Features
+        --------
+        
+        asyncpg implements PostgreSQL server protocol natively and exposes its
+        features directly, as opposed to hiding them behind a generic facade
+        like DB-API.
+        
+        This enables asyncpg to have easy-to-use support for:
+        
+        * **prepared statements**
+        * **scrollable cursors**
+        * **partial iteration** on query results
+        * automatic encoding and decoding of composite types, arrays,
+          and any combination of those
+        * straightforward support for custom data types
+        
+        
+        Installation
+        ------------
+        
+        asyncpg is available on PyPI and has no dependencies.
+        Use pip to install::
+        
+            $ pip install asyncpg
+        
+        
+        Basic Usage
+        -----------
+        
+        .. code-block:: python
+        
+            import asyncio
+            import asyncpg
+        
+            async def run():
+                conn = await asyncpg.connect(user='user', password='password',
+                                             database='database', host='127.0.0.1')
+                values = await conn.fetch('''SELECT * FROM mytable''')
+                await conn.close()
+        
+            loop = asyncio.get_event_loop()
+            loop.run_until_complete(run())
+        
+        
+        License
+        -------
+        
+        asyncpg is developed and distributed under the Apache 2.0 license.
+        
+Platform: POSIX
+Classifier: License :: OSI Approved :: Apache Software License
+Classifier: Intended Audience :: Developers
+Classifier: Programming Language :: Python :: 3 :: Only
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
+Classifier: Operating System :: POSIX
+Classifier: Operating System :: MacOS :: MacOS X
+Classifier: Operating System :: Microsoft :: Windows
+Classifier: Development Status :: 4 - Beta
+Provides: asyncpg
diff --git a/asyncpg.egg-info/SOURCES.txt b/asyncpg.egg-info/SOURCES.txt
new file mode 100644 (file)
index 0000000..1a18c5c
--- /dev/null
@@ -0,0 +1,87 @@
+LICENSE
+MANIFEST.in
+Makefile
+README.rst
+performance.png
+setup.py
+asyncpg/__init__.py
+asyncpg/_testbase.py
+asyncpg/cluster.py
+asyncpg/compat.py
+asyncpg/connection.py
+asyncpg/cursor.py
+asyncpg/introspection.py
+asyncpg/pool.py
+asyncpg/prepared_stmt.py
+asyncpg/serverversion.py
+asyncpg/transaction.py
+asyncpg/types.py
+asyncpg.egg-info/PKG-INFO
+asyncpg.egg-info/SOURCES.txt
+asyncpg.egg-info/dependency_links.txt
+asyncpg.egg-info/top_level.txt
+asyncpg/exceptions/__init__.py
+asyncpg/exceptions/_base.py
+asyncpg/protocol/__init__.py
+asyncpg/protocol/buffer.pxd
+asyncpg/protocol/buffer.pyx
+asyncpg/protocol/consts.pxi
+asyncpg/protocol/coreproto.pxd
+asyncpg/protocol/coreproto.pyx
+asyncpg/protocol/debug.h
+asyncpg/protocol/debug.pxd
+asyncpg/protocol/encodings.pyx
+asyncpg/protocol/hton.pxd
+asyncpg/protocol/pgtypes.pxi
+asyncpg/protocol/prepared_stmt.pxd
+asyncpg/protocol/prepared_stmt.pyx
+asyncpg/protocol/protocol.c
+asyncpg/protocol/protocol.pxd
+asyncpg/protocol/protocol.pyx
+asyncpg/protocol/python.pxd
+asyncpg/protocol/settings.pxd
+asyncpg/protocol/settings.pyx
+asyncpg/protocol/codecs/__init__.py
+asyncpg/protocol/codecs/array.pyx
+asyncpg/protocol/codecs/base.pxd
+asyncpg/protocol/codecs/base.pyx
+asyncpg/protocol/codecs/bits.pyx
+asyncpg/protocol/codecs/bytea.pyx
+asyncpg/protocol/codecs/datetime.pyx
+asyncpg/protocol/codecs/float.pyx
+asyncpg/protocol/codecs/geometry.pyx
+asyncpg/protocol/codecs/hstore.pyx
+asyncpg/protocol/codecs/int.pyx
+asyncpg/protocol/codecs/json.pyx
+asyncpg/protocol/codecs/misc.pyx
+asyncpg/protocol/codecs/money.pyx
+asyncpg/protocol/codecs/network.pyx
+asyncpg/protocol/codecs/numeric.pyx
+asyncpg/protocol/codecs/range.pyx
+asyncpg/protocol/codecs/record.pyx
+asyncpg/protocol/codecs/text.pyx
+asyncpg/protocol/codecs/textutils.pyx
+asyncpg/protocol/codecs/tsearch.pyx
+asyncpg/protocol/codecs/txid.pyx
+asyncpg/protocol/codecs/uuid.pyx
+asyncpg/protocol/record/__init__.pxd
+asyncpg/protocol/record/recordobj.c
+asyncpg/protocol/record/recordobj.h
+docs/conf.py
+docs/examples.rst
+docs/index.rst
+docs/installation.rst
+docs/api/index.rst
+tests/test_cancellation.py
+tests/test_codecs.py
+tests/test_connect.py
+tests/test_cursor.py
+tests/test_exceptions.py
+tests/test_execute.py
+tests/test_listeners.py
+tests/test_pool.py
+tests/test_prepare.py
+tests/test_record.py
+tests/test_test.py
+tests/test_timeout.py
+tests/test_transaction.py
\ No newline at end of file
diff --git a/asyncpg.egg-info/dependency_links.txt b/asyncpg.egg-info/dependency_links.txt
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/asyncpg.egg-info/top_level.txt b/asyncpg.egg-info/top_level.txt
new file mode 100644 (file)
index 0000000..5789edd
--- /dev/null
@@ -0,0 +1 @@
+asyncpg
diff --git a/asyncpg/__init__.py b/asyncpg/__init__.py
new file mode 100644 (file)
index 0000000..5488318
--- /dev/null
@@ -0,0 +1,14 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+from .connection import connect  # NOQA
+from .exceptions import *  # NOQA
+from .pool import create_pool  # NOQA
+from .types import *  # NOQA
+
+
+__all__ = ('connect', 'create_pool') + exceptions.__all__  # NOQA
diff --git a/asyncpg/_testbase.py b/asyncpg/_testbase.py
new file mode 100644 (file)
index 0000000..daf9cdf
--- /dev/null
@@ -0,0 +1,167 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import asyncio
+import atexit
+import contextlib
+import functools
+import inspect
+import logging
+import os
+import time
+import unittest
+
+
+from asyncpg import cluster as pg_cluster
+from asyncpg import pool as pg_pool
+
+
+@contextlib.contextmanager
+def silence_asyncio_long_exec_warning():
+    def flt(log_record):
+        msg = log_record.getMessage()
+        return not msg.startswith('Executing ')
+
+    logger = logging.getLogger('asyncio')
+    logger.addFilter(flt)
+    try:
+        yield
+    finally:
+        logger.removeFilter(flt)
+
+
+class TestCaseMeta(type(unittest.TestCase)):
+
+    @staticmethod
+    def _iter_methods(bases, ns):
+        for base in bases:
+            for methname in dir(base):
+                if not methname.startswith('test_'):
+                    continue
+
+                meth = getattr(base, methname)
+                if not inspect.iscoroutinefunction(meth):
+                    continue
+
+                yield methname, meth
+
+        for methname, meth in ns.items():
+            if not methname.startswith('test_'):
+                continue
+
+            if not inspect.iscoroutinefunction(meth):
+                continue
+
+            yield methname, meth
+
+    def __new__(mcls, name, bases, ns):
+        for methname, meth in mcls._iter_methods(bases, ns):
+            @functools.wraps(meth)
+            def wrapper(self, *args, __meth__=meth, **kwargs):
+                self.loop.run_until_complete(__meth__(self, *args, **kwargs))
+            ns[methname] = wrapper
+
+        return super().__new__(mcls, name, bases, ns)
+
+
+class TestCase(unittest.TestCase, metaclass=TestCaseMeta):
+
+    @classmethod
+    def setUpClass(cls):
+        if os.environ.get('USE_UVLOOP'):
+            import uvloop
+            asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
+
+        loop = asyncio.new_event_loop()
+        asyncio.set_event_loop(None)
+        cls.loop = loop
+
+    @classmethod
+    def tearDownClass(cls):
+        cls.loop.close()
+        asyncio.set_event_loop(None)
+
+    @contextlib.contextmanager
+    def assertRunUnder(self, delta):
+        st = time.monotonic()
+        try:
+            yield
+        finally:
+            if time.monotonic() - st > delta:
+                raise AssertionError(
+                    'running block took longer than {}'.format(delta))
+
+
+_default_cluster = None
+
+
+def _start_cluster(ClusterCls, cluster_kwargs, server_settings):
+    cluster = ClusterCls(**cluster_kwargs)
+    cluster.init()
+    cluster.trust_local_connections()
+    cluster.start(port='dynamic', server_settings=server_settings)
+    atexit.register(_shutdown_cluster, cluster)
+    return cluster
+
+
+def _start_default_cluster(server_settings={}):
+    global _default_cluster
+
+    if _default_cluster is None:
+        pg_host = os.environ.get('PGHOST')
+        if pg_host:
+            # Using existing cluster, assuming it is initialized and running
+            _default_cluster = pg_cluster.RunningCluster()
+        else:
+            _default_cluster = _start_cluster(
+                pg_cluster.TempCluster, {}, server_settings)
+
+    return _default_cluster
+
+
+def _shutdown_cluster(cluster):
+    cluster.stop()
+    cluster.destroy()
+
+
+class ClusterTestCase(TestCase):
+    @classmethod
+    def setUpClass(cls):
+        super().setUpClass()
+        cls.cluster = _start_default_cluster({
+            'log_connections': 'on'
+        })
+
+    def create_pool(self, **kwargs):
+        conn_spec = self.cluster.get_connection_spec()
+        conn_spec.update(kwargs)
+        return pg_pool.create_pool(loop=self.loop, **conn_spec)
+
+    @classmethod
+    def start_cluster(cls, ClusterCls, *,
+                      cluster_kwargs={}, server_settings={}):
+        return _start_cluster(ClusterCls, cluster_kwargs, server_settings)
+
+
+class ConnectedTestCase(ClusterTestCase):
+
+    def getExtraConnectOptions(self):
+        return {}
+
+    def setUp(self):
+        super().setUp()
+        opts = self.getExtraConnectOptions()
+        self.con = self.loop.run_until_complete(
+            self.cluster.connect(database='postgres', loop=self.loop, **opts))
+        self.server_version = self.con.get_server_version()
+
+    def tearDown(self):
+        try:
+            self.loop.run_until_complete(self.con.close())
+            self.con = None
+        finally:
+            super().tearDown()
diff --git a/asyncpg/cluster.py b/asyncpg/cluster.py
new file mode 100644 (file)
index 0000000..b9601b5
--- /dev/null
@@ -0,0 +1,605 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import asyncio
+import errno
+import os
+import os.path
+import platform
+import random
+import re
+import shutil
+import socket
+import subprocess
+import tempfile
+import textwrap
+import time
+
+import asyncpg
+from asyncpg import serverversion
+
+
+_system = platform.uname().system
+
+if _system == 'Windows':
+    def platform_exe(name):
+        if name.endswith('.exe'):
+            return name
+        return name + '.exe'
+else:
+    def platform_exe(name):
+        return name
+
+
+if _system == 'Linux':
+    def ensure_dead_with_parent():
+        import ctypes
+        import signal
+
+        try:
+            PR_SET_PDEATHSIG = 1
+            libc = ctypes.CDLL(ctypes.util.find_library('c'))
+            libc.prctl(PR_SET_PDEATHSIG, signal.SIGKILL)
+        except Exception as e:
+            print(e)
+else:
+    ensure_dead_with_parent = None
+
+
+def find_available_port(port_range=(49152, 65535), max_tries=1000):
+    low, high = port_range
+
+    port = low
+    try_no = 0
+
+    while try_no < max_tries:
+        try_no += 1
+        port = random.randint(low, high)
+        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        try:
+            sock.bind(('127.0.0.1', port))
+        except socket.error as e:
+            if e.errno == errno.EADDRINUSE:
+                continue
+        finally:
+            sock.close()
+
+        break
+    else:
+        port = None
+
+    return port
+
+
+class ClusterError(Exception):
+    pass
+
+
+class Cluster:
+    def __init__(self, data_dir, *, pg_config_path=None):
+        self._data_dir = data_dir
+        self._pg_config_path = pg_config_path
+        self._pg_config = None
+        self._pg_config_data = None
+        self._pg_ctl = None
+        self._daemon_pid = None
+        self._daemon_process = None
+        self._connection_addr = None
+        self._connection_spec_override = None
+
+    def is_managed(self):
+        return True
+
+    def get_data_dir(self):
+        return self._data_dir
+
+    def get_status(self):
+        if self._pg_ctl is None:
+            self._init_env()
+
+        process = subprocess.run(
+            [self._pg_ctl, 'status', '-D', self._data_dir],
+            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+        stdout, stderr = process.stdout, process.stderr
+
+        if process.returncode == 4 or not os.listdir(self._data_dir):
+            return 'not-initialized'
+        elif process.returncode == 3:
+            return 'stopped'
+        elif process.returncode == 0:
+            r = re.match(r'.*PID\s?:\s+(\d+).*', stdout.decode())
+            if not r:
+                raise ClusterError(
+                    'could not parse pg_ctl status output: {}'.format(
+                        stdout.decode()))
+            self._daemon_pid = int(r.group(1))
+            return self._test_connection(timeout=0)
+        else:
+            raise ClusterError(
+                'pg_ctl status exited with status {:d}: {}'.format(
+                    process.returncode, stderr))
+
+    async def connect(self, loop=None, **kwargs):
+        conn_info = self.get_connection_spec()
+        conn_info.update(kwargs)
+        return await asyncpg.connect(loop=loop, **conn_info)
+
+    def init(self, **settings):
+        """Initialize cluster."""
+        if self.get_status() != 'not-initialized':
+            raise ClusterError(
+                'cluster in {!r} has already been initialized'.format(
+                    self._data_dir))
+
+        if settings:
+            settings_args = ['--{}={}'.format(k, v)
+                             for k, v in settings.items()]
+            extra_args = ['-o'] + [' '.join(settings_args)]
+        else:
+            extra_args = []
+
+        process = subprocess.run(
+            [self._pg_ctl, 'init', '-D', self._data_dir] + extra_args,
+            stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+
+        output = process.stdout
+
+        if process.returncode != 0:
+            raise ClusterError(
+                'pg_ctl init exited with status {:d}:\n{}'.format(
+                    process.returncode, output.decode()))
+
+        return output.decode()
+
+    def start(self, wait=60, *, server_settings={}, **opts):
+        """Start the cluster."""
+        status = self.get_status()
+        if status == 'running':
+            return
+        elif status == 'not-initialized':
+            raise ClusterError(
+                'cluster in {!r} has not been initialized'.format(
+                    self._data_dir))
+
+        port = opts.pop('port', None)
+        if port == 'dynamic':
+            port = find_available_port()
+
+        extra_args = ['--{}={}'.format(k, v) for k, v in opts.items()]
+        extra_args.append('--port={}'.format(port))
+
+        sockdir = server_settings.get('unix_socket_directories')
+        if sockdir is None:
+            sockdir = server_settings.get('unix_socket_directory')
+        if sockdir is None:
+            sockdir = '/tmp'
+
+        if self._pg_version < (9, 3):
+            sockdir_opt = 'unix_socket_directory'
+        else:
+            sockdir_opt = 'unix_socket_directories'
+
+        server_settings[sockdir_opt] = sockdir
+
+        for k, v in server_settings.items():
+            extra_args.extend(['-c', '{}={}'.format(k, v)])
+
+        if _system == 'Windows':
+            # On Windows we have to use pg_ctl as direct execution
+            # of postgres daemon under an Administrative account
+            # is not permitted and there is no easy way to drop
+            # privileges.
+            process = subprocess.run(
+                [self._pg_ctl, 'start', '-D', self._data_dir,
+                 '-o', ' '.join(extra_args)],
+                stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
+            stderr = process.stderr
+
+            if process.returncode != 0:
+                raise ClusterError(
+                    'pg_ctl start exited with status {:d}: {}'.format(
+                        process.returncode, stderr.decode()))
+        else:
+            self._daemon_process = \
+                subprocess.Popen(
+                    [self._postgres, '-D', self._data_dir, *extra_args],
+                    stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
+                    preexec_fn=ensure_dead_with_parent)
+
+            self._daemon_pid = self._daemon_process.pid
+
+        self._test_connection(timeout=wait)
+
+    def reload(self):
+        """Reload server configuration."""
+        status = self.get_status()
+        if status != 'running':
+            raise ClusterError('cannot reload: cluster is not running')
+
+        process = subprocess.run(
+            [self._pg_ctl, 'reload', '-D', self._data_dir],
+            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+
+        stderr = process.stderr
+
+        if process.returncode != 0:
+            raise ClusterError(
+                'pg_ctl stop exited with status {:d}: {}'.format(
+                    process.returncode, stderr.decode()))
+
+    def stop(self, wait=60):
+        process = subprocess.run(
+            [self._pg_ctl, 'stop', '-D', self._data_dir, '-t', str(wait),
+             '-m', 'fast'],
+            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+
+        stderr = process.stderr
+
+        if process.returncode != 0:
+            raise ClusterError(
+                'pg_ctl stop exited with status {:d}: {}'.format(
+                    process.returncode, stderr.decode()))
+
+        if (self._daemon_process is not None and
+                self._daemon_process.returncode is None):
+            self._daemon_process.kill()
+
+    def destroy(self):
+        status = self.get_status()
+        if status == 'stopped' or status == 'not-initialized':
+            shutil.rmtree(self._data_dir)
+        else:
+            raise ClusterError('cannot destroy {} cluster'.format(status))
+
+    def _get_connection_spec(self):
+        if self._connection_addr is None:
+            self._connection_addr = self._connection_addr_from_pidfile()
+
+        if self._connection_addr is not None:
+            if self._connection_spec_override:
+                args = self._connection_addr.copy()
+                args.update(self._connection_spec_override)
+                return args
+            else:
+                return self._connection_addr
+
+    def get_connection_spec(self):
+        status = self.get_status()
+        if status != 'running':
+            raise ClusterError('cluster is not running')
+
+        return self._get_connection_spec()
+
+    def override_connection_spec(self, **kwargs):
+        self._connection_spec_override = kwargs
+
+    def reset_hba(self):
+        """Remove all records from pg_hba.conf."""
+        status = self.get_status()
+        if status == 'not-initialized':
+            raise ClusterError(
+                'cannot modify HBA records: cluster is not initialized')
+
+        pg_hba = os.path.join(self._data_dir, 'pg_hba.conf')
+
+        try:
+            with open(pg_hba, 'w'):
+                pass
+        except IOError as e:
+            raise ClusterError(
+                'cannot modify HBA records: {}'.format(e)) from e
+
+    def add_hba_entry(self, *, type='host', database, user, address=None,
+                      auth_method, auth_options=None):
+        """Add a record to pg_hba.conf."""
+        status = self.get_status()
+        if status == 'not-initialized':
+            raise ClusterError(
+                'cannot modify HBA records: cluster is not initialized')
+
+        if type not in {'local', 'host', 'hostssl', 'hostnossl'}:
+            raise ValueError('invalid HBA record type: {!r}'.format(type))
+
+        pg_hba = os.path.join(self._data_dir, 'pg_hba.conf')
+
+        record = '{} {} {}'.format(type, database, user)
+
+        if type != 'local':
+            if address is None:
+                raise ValueError(
+                    '{!r} entry requires a valid address'.format(type))
+            else:
+                record += ' {}'.format(address)
+
+        record += ' {}'.format(auth_method)
+
+        if auth_options is not None:
+            record += ' ' + ' '.join(
+                '{}={}'.format(k, v) for k, v in auth_options)
+
+        try:
+            with open(pg_hba, 'a') as f:
+                print(record, file=f)
+        except IOError as e:
+            raise ClusterError(
+                'cannot modify HBA records: {}'.format(e)) from e
+
+    def trust_local_connections(self):
+        self.reset_hba()
+
+        if _system != 'Windows':
+            self.add_hba_entry(type='local', database='all',
+                               user='all', auth_method='trust')
+        self.add_hba_entry(type='host', address='127.0.0.1/32',
+                           database='all', user='all',
+                           auth_method='trust')
+        self.add_hba_entry(type='host', address='::1/128',
+                           database='all', user='all',
+                           auth_method='trust')
+        status = self.get_status()
+        if status == 'running':
+            self.reload()
+
+    def trust_local_replication_by(self, user):
+        if _system != 'Windows':
+            self.add_hba_entry(type='local', database='replication',
+                               user=user, auth_method='trust')
+        self.add_hba_entry(type='host', address='127.0.0.1/32',
+                           database='replication', user=user,
+                           auth_method='trust')
+        self.add_hba_entry(type='host', address='::1/128',
+                           database='replication', user=user,
+                           auth_method='trust')
+        status = self.get_status()
+        if status == 'running':
+            self.reload()
+
+    def _init_env(self):
+        self._pg_config = self._find_pg_config(self._pg_config_path)
+        self._pg_config_data = self._run_pg_config(self._pg_config)
+        self._pg_version = self._get_pg_version()
+        self._pg_ctl = self._find_pg_binary('pg_ctl')
+        self._postgres = self._find_pg_binary('postgres')
+
+    def _connection_addr_from_pidfile(self):
+        pidfile = os.path.join(self._data_dir, 'postmaster.pid')
+
+        try:
+            with open(pidfile, 'rt') as f:
+                piddata = f.read()
+        except FileNotFoundError:
+            return None
+
+        lines = piddata.splitlines()
+
+        if len(lines) < 6:
+            # A complete postgres pidfile is at least 6 lines
+            return None
+
+        pmpid = int(lines[0])
+        if self._daemon_pid and pmpid != self._daemon_pid:
+            # This might be an old pidfile left from previous postgres
+            # daemon run.
+            return None
+
+        portnum = lines[3]
+        sockdir = lines[4]
+        hostaddr = lines[5]
+
+        if sockdir:
+            if sockdir[0] != '/':
+                # Relative sockdir
+                sockdir = os.path.normpath(
+                    os.path.join(self._data_dir, sockdir))
+            host_str = sockdir
+        else:
+            host_str = hostaddr
+
+        if host_str == '*':
+            host_str = 'localhost'
+        elif host_str == '0.0.0.0':
+            host_str = '127.0.0.1'
+        elif host_str == '::':
+            host_str = '::1'
+
+        return {
+            'host': host_str,
+            'port': portnum
+        }
+
+    def _test_connection(self, timeout=60):
+        self._connection_addr = None
+
+        loop = asyncio.new_event_loop()
+
+        try:
+            for i in range(timeout):
+                if self._connection_addr is None:
+                    conn_spec = self._get_connection_spec()
+                    if conn_spec is None:
+                        time.sleep(1)
+                        continue
+
+                try:
+                    con = loop.run_until_complete(
+                        asyncpg.connect(database='postgres',
+                                        timeout=5, loop=loop,
+                                        **self._connection_addr))
+                except (OSError, asyncio.TimeoutError,
+                        asyncpg.CannotConnectNowError,
+                        asyncpg.PostgresConnectionError):
+                    time.sleep(1)
+                    continue
+                except asyncpg.PostgresError:
+                    # Any other error other than ServerNotReadyError or
+                    # ConnectionError is interpreted to indicate the server is
+                    # up.
+                    break
+                else:
+                    loop.run_until_complete(con.close())
+                    break
+        finally:
+            loop.close()
+
+        return 'running'
+
+    def _run_pg_config(self, pg_config_path):
+        process = subprocess.run(
+            pg_config_path, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+        stdout, stderr = process.stdout, process.stderr
+
+        if process.returncode != 0:
+            raise ClusterError('pg_config exited with status {:d}: {}'.format(
+                process.returncode, stderr))
+        else:
+            config = {}
+
+            for line in stdout.splitlines():
+                k, eq, v = line.decode('utf-8').partition('=')
+                if eq:
+                    config[k.strip().lower()] = v.strip()
+
+            return config
+
+    def _find_pg_config(self, pg_config_path):
+        if pg_config_path is None:
+            pg_install = os.environ.get('PGINSTALLATION')
+            if pg_install:
+                pg_config_path = platform_exe(
+                    os.path.join(pg_install, 'pg_config'))
+            else:
+                pathenv = os.environ.get('PATH').split(os.pathsep)
+                for path in pathenv:
+                    pg_config_path = platform_exe(
+                        os.path.join(path, 'pg_config'))
+                    if os.path.exists(pg_config_path):
+                        break
+                else:
+                    pg_config_path = None
+
+        if not pg_config_path:
+            raise ClusterError('could not find pg_config executable')
+
+        if not os.path.isfile(pg_config_path):
+            raise ClusterError('{!r} is not an executable')
+
+        return pg_config_path
+
+    def _find_pg_binary(self, binary):
+        bindir = self._pg_config_data.get('bindir')
+        if not bindir:
+            raise ClusterError(
+                'could not find {} executable: '.format(binary) +
+                'pg_config output did not provide the BINDIR value')
+
+        bpath = platform_exe(os.path.join(bindir, binary))
+
+        if not os.path.isfile(bpath):
+            raise ClusterError(
+                'could not find {} executable: '.format(binary) +
+                '{!r} does not exist or is not a file'.format(bpath))
+
+        return bpath
+
+    def _get_pg_version(self):
+        version_string = self._pg_config_data.get('version')
+        if not version_string:
+            raise ClusterError('could not determine PostgreSQL version')
+
+        return serverversion.split_server_version_string(version_string)
+
+
+class TempCluster(Cluster):
+    def __init__(self, *,
+                 data_dir_suffix=None, data_dir_prefix=None,
+                 data_dir_parent=None, pg_config_path=None):
+        self._data_dir = tempfile.mkdtemp(suffix=data_dir_suffix,
+                                          prefix=data_dir_prefix,
+                                          dir=data_dir_parent)
+        super().__init__(self._data_dir, pg_config_path=pg_config_path)
+
+
+class HotStandbyCluster(TempCluster):
+    def __init__(self, *,
+                 master, replication_user,
+                 data_dir_suffix=None, data_dir_prefix=None,
+                 data_dir_parent=None, pg_config_path=None):
+        self._master = master
+        self._repl_user = replication_user
+        super().__init__(
+            data_dir_suffix=data_dir_suffix,
+            data_dir_prefix=data_dir_prefix,
+            data_dir_parent=data_dir_parent,
+            pg_config_path=pg_config_path)
+
+    def _init_env(self):
+        super()._init_env()
+        self._pg_basebackup = self._find_pg_binary('pg_basebackup')
+
+    def init(self, **settings):
+        """Initialize cluster."""
+        if self.get_status() != 'not-initialized':
+            raise ClusterError(
+                'cluster in {!r} has already been initialized'.format(
+                    self._data_dir))
+
+        process = subprocess.run(
+            [self._pg_basebackup, '-h', self._master['host'],
+             '-p', self._master['port'], '-D', self._data_dir,
+             '-U', self._repl_user],
+            stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+
+        output = process.stdout
+
+        if process.returncode != 0:
+            raise ClusterError(
+                'pg_basebackup init exited with status {:d}:\n{}'.format(
+                    process.returncode, output.decode()))
+
+        with open(os.path.join(self._data_dir, 'recovery.conf'), 'w') as f:
+            f.write(textwrap.dedent("""\
+                standby_mode = 'on'
+                primary_conninfo = 'host={host} port={port} user={user}'
+            """.format(
+                host=self._master['host'],
+                port=self._master['port'],
+                user=self._repl_user)))
+
+        return output.decode()
+
+
+class RunningCluster(Cluster):
+    def __init__(self, **kwargs):
+        self.conn_spec = kwargs
+
+    def is_managed(self):
+        return False
+
+    def get_connection_spec(self):
+        return dict(self.conn_spec)
+
+    def get_status(self):
+        return 'running'
+
+    def init(self, **settings):
+        pass
+
+    def start(self, wait=60, **settings):
+        pass
+
+    def stop(self, wait=60):
+        pass
+
+    def destroy(self):
+        pass
+
+    def reset_hba(self):
+        raise ClusterError('cannot modify HBA records of unmanaged cluster')
+
+    def add_hba_entry(self, *, type='host', database, user, address=None,
+                      auth_method, auth_options=None):
+        raise ClusterError('cannot modify HBA records of unmanaged cluster')
diff --git a/asyncpg/compat.py b/asyncpg/compat.py
new file mode 100644 (file)
index 0000000..1d330a4
--- /dev/null
@@ -0,0 +1,20 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import functools
+import sys
+
+
+if sys.version_info < (3, 5, 2):
+    def aiter_compat(func):
+        @functools.wraps(func)
+        async def wrapper(self):
+            return func(self)
+        return wrapper
+else:
+    def aiter_compat(func):
+        return func
diff --git a/asyncpg/connection.py b/asyncpg/connection.py
new file mode 100644 (file)
index 0000000..9445a9b
--- /dev/null
@@ -0,0 +1,731 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import asyncio
+import collections
+import getpass
+import os
+import socket
+import struct
+import urllib.parse
+
+from . import cursor
+from . import introspection
+from . import prepared_stmt
+from . import protocol
+from . import serverversion
+from . import transaction
+
+
+class Connection:
+    """A representation of a database session.
+
+    Connections are created by calling :func:`~asyncpg.connection.connect`.
+    """
+
+    __slots__ = ('_protocol', '_transport', '_loop', '_types_stmt',
+                 '_type_by_name_stmt', '_top_xact', '_uid', '_aborted',
+                 '_stmt_cache_max_size', '_stmt_cache', '_stmts_to_close',
+                 '_addr', '_opts', '_command_timeout', '_listeners',
+                 '_server_version', '_intro_query')
+
+    def __init__(self, protocol, transport, loop, addr, opts, *,
+                 statement_cache_size, command_timeout):
+        self._protocol = protocol
+        self._transport = transport
+        self._loop = loop
+        self._types_stmt = None
+        self._type_by_name_stmt = None
+        self._top_xact = None
+        self._uid = 0
+        self._aborted = False
+
+        self._addr = addr
+        self._opts = opts
+
+        self._stmt_cache_max_size = statement_cache_size
+        self._stmt_cache = collections.OrderedDict()
+        self._stmts_to_close = set()
+
+        self._command_timeout = command_timeout
+
+        self._listeners = {}
+
+        ver_string = self._protocol.get_settings().server_version
+        self._server_version = \
+            serverversion.split_server_version_string(ver_string)
+
+        if self._server_version < (9, 2):
+            self._intro_query = introspection.INTRO_LOOKUP_TYPES_91
+        else:
+            self._intro_query = introspection.INTRO_LOOKUP_TYPES
+
+    async def add_listener(self, channel, callback):
+        """Add a listener for Postgres notifications.
+
+        :param str channel: Channel to listen on.
+        :param callable callback:
+                A callable receiving the following arguments:
+                **connection**: a Connection the callback is registered with;
+                **pid**: PID of the Postgres server that sent the notification;
+                **channel**: name of the channel the notification was sent to;
+                **payload**: the payload.
+        """
+        if channel not in self._listeners:
+            await self.fetch('LISTEN {}'.format(channel))
+            self._listeners[channel] = set()
+        self._listeners[channel].add(callback)
+
+    async def remove_listener(self, channel, callback):
+        """Remove a listening callback on the specified channel."""
+        if channel not in self._listeners:
+            return
+        if callback not in self._listeners[channel]:
+            return
+        self._listeners[channel].remove(callback)
+        if not self._listeners[channel]:
+            del self._listeners[channel]
+            await self.fetch('UNLISTEN {}'.format(channel))
+
+    def get_server_pid(self):
+        """Return the PID of the Postgres server the connection is bound to."""
+        return self._protocol.get_server_pid()
+
+    def get_server_version(self):
+        """Return the version of the connected PostgreSQL server.
+
+        The returned value is a named tuple similar to that in
+        ``sys.version_info``:
+
+        .. code-block:: pycon
+
+            >>> con.get_server_version()
+            ServerVersion(major=9, minor=6, micro=1,
+                          releaselevel='final', serial=0)
+
+        """
+        return self._server_version
+
+    def get_settings(self):
+        """Return connection settings.
+
+        :return: :class:`~asyncpg.ConnectionSettings`.
+        """
+        return self._protocol.get_settings()
+
+    def transaction(self, *, isolation='read_committed', readonly=False,
+                    deferrable=False):
+        """Create a :class:`~transaction.Transaction` object.
+
+        Refer to `PostgreSQL documentation`_ on the meaning of transaction
+        parameters.
+
+        :param isolation: Transaction isolation mode, can be one of:
+                          `'serializable'`, `'repeatable_read'`,
+                          `'read_committed'`.
+
+        :param readonly: Specifies whether or not this transaction is
+                         read-only.
+
+        :param deferrable: Specifies whether or not this transaction is
+                           deferrable.
+
+        .. _`PostgreSQL documentation`: https://www.postgresql.org/docs/current/static/sql-set-transaction.html
+        """
+        return transaction.Transaction(self, isolation, readonly, deferrable)
+
+    async def execute(self, query: str, *args, timeout: float=None) -> str:
+        """Execute an SQL command (or commands).
+
+        This method can execute many SQL commands at once, when no arguments
+        are provided.
+
+        Example:
+
+        .. code-block:: pycon
+
+            >>> await con.execute('''
+            ...     CREATE TABLE mytab (a int);
+            ...     INSERT INTO mytab (a) VALUES (100), (200), (300);
+            ... ''')
+            INSERT 0 3
+
+            >>> await con.execute('''
+            ...     INSERT INTO mytab (a) VALUES ($1), ($2)
+            ... ''', 10, 20)
+            INSERT 0 2
+
+        :param args: Query arguments.
+        :param float timeout: Optional timeout value in seconds.
+        :return str: Status of the last SQL command.
+
+        .. versionchanged:: 0.5.4
+           Made it possible to pass query arguments.
+        """
+        if not args:
+            return await self._protocol.query(query, timeout)
+
+        stmt = await self._get_statement(query, timeout)
+        _, status, _ = await self._protocol.bind_execute(stmt, args, '', 0,
+                                                         True, timeout)
+        return status.decode()
+
+    async def executemany(self, command: str, args, timeout: float=None):
+        """Execute an SQL *command* for each sequence of arguments in *args*.
+
+        Example:
+
+        .. code-block:: pycon
+
+            >>> await con.executemany('''
+            ...     INSERT INTO mytab (a) VALUES ($1, $2, $3);
+            ... ''', [(1, 2, 3), (4, 5, 6)])
+
+        :param command: Command to execute.
+        :args: An iterable containing sequences of arguments.
+        :param float timeout: Optional timeout value in seconds.
+        :return None: This method discards the results of the operations.
+
+        .. versionadded:: 0.7.0
+        """
+        stmt = await self._get_statement(command, timeout)
+        return await self._protocol.bind_execute_many(stmt, args, '', timeout)
+
+    async def _get_statement(self, query, timeout):
+        cache = self._stmt_cache_max_size > 0
+
+        if cache:
+            try:
+                state = self._stmt_cache[query]
+            except KeyError:
+                pass
+            else:
+                self._stmt_cache.move_to_end(query, last=True)
+                if not state.closed:
+                    return state
+
+        protocol = self._protocol
+        state = await protocol.prepare(None, query, timeout)
+
+        ready = state._init_types()
+        if ready is not True:
+            if self._types_stmt is None:
+                self._types_stmt = await self.prepare(self._intro_query)
+
+            types = await self._types_stmt.fetch(list(ready))
+            protocol.get_settings().register_data_types(types)
+
+        if cache:
+            if len(self._stmt_cache) > self._stmt_cache_max_size - 1:
+                old_query, old_state = self._stmt_cache.popitem(last=False)
+                self._maybe_gc_stmt(old_state)
+            self._stmt_cache[query] = state
+
+        # If we've just created a new statement object, check if there
+        # are any statements for GC.
+        if self._stmts_to_close:
+            await self._cleanup_stmts()
+
+        return state
+
+    def cursor(self, query, *args, prefetch=None, timeout=None):
+        """Return a *cursor factory* for the specified query.
+
+        :param args: Query arguments.
+        :param int prefetch: The number of rows the *cursor iterator*
+                             will prefetch (defaults to ``50``.)
+        :param float timeout: Optional timeout in seconds.
+
+        :return: A :class:`~cursor.CursorFactory` object.
+        """
+        return cursor.CursorFactory(self, query, None, args,
+                                    prefetch, timeout)
+
+    async def prepare(self, query, *, timeout=None):
+        """Create a *prepared statement* for the specified query.
+
+        :param str query: Text of the query to create a prepared statement for.
+        :param float timeout: Optional timeout value in seconds.
+
+        :return: A :class:`~prepared_stmt.PreparedStatement` instance.
+        """
+        stmt = await self._get_statement(query, timeout)
+        return prepared_stmt.PreparedStatement(self, query, stmt)
+
+    async def fetch(self, query, *args, timeout=None) -> list:
+        """Run a query and return the results as a list of :class:`Record`.
+
+        :param str query: Query text.
+        :param args: Query arguments.
+        :param float timeout: Optional timeout value in seconds.
+
+        :return list: A list of :class:`Record` instances.
+        """
+        stmt = await self._get_statement(query, timeout)
+        data = await self._protocol.bind_execute(stmt, args, '', 0,
+                                                 False, timeout)
+        return data
+
+    async def fetchval(self, query, *args, column=0, timeout=None):
+        """Run a query and return a value in the first row.
+
+        :param str query: Query text.
+        :param args: Query arguments.
+        :param int column: Numeric index within the record of the value to
+                           return (defaults to 0).
+        :param float timeout: Optional timeout value in seconds.
+                            If not specified, defaults to the value of
+                            ``command_timeout`` argument to the ``Connection``
+                            instance constructor.
+
+        :return: The value of the specified column of the first record.
+        """
+        stmt = await self._get_statement(query, timeout)
+        data = await self._protocol.bind_execute(stmt, args, '', 1,
+                                                 False, timeout)
+        if not data:
+            return None
+        return data[0][column]
+
+    async def fetchrow(self, query, *args, timeout=None):
+        """Run a query and return the first row.
+
+        :param str query: Query text
+        :param args: Query arguments
+        :param float timeout: Optional timeout value in seconds.
+
+        :return: The first row as a :class:`Record` instance.
+        """
+        stmt = await self._get_statement(query, timeout)
+        data = await self._protocol.bind_execute(stmt, args, '', 1,
+                                                 False, timeout)
+        if not data:
+            return None
+        return data[0]
+
+    async def set_type_codec(self, typename, *,
+                             schema='public', encoder, decoder, binary=False):
+        """Set an encoder/decoder pair for the specified data type.
+
+        :param typename:  Name of the data type the codec is for.
+        :param schema:  Schema name of the data type the codec is for
+                        (defaults to 'public')
+        :param encoder:  Callable accepting a single argument and returning
+                         a string or a bytes object (if `binary` is True).
+        :param decoder:  Callable accepting a single string or bytes argument
+                         and returning a decoded object.
+        :param binary:  Specifies whether the codec is able to handle binary
+                        data.  If ``False`` (the default), the data is
+                        expected to be encoded/decoded in text.
+        """
+        if self._type_by_name_stmt is None:
+            self._type_by_name_stmt = await self.prepare(
+                introspection.TYPE_BY_NAME)
+
+        typeinfo = await self._type_by_name_stmt.fetchrow(
+            typename, schema)
+        if not typeinfo:
+            raise ValueError('unknown type: {}.{}'.format(schema, typename))
+
+        oid = typeinfo['oid']
+        if typeinfo['kind'] != b'b' or typeinfo['elemtype']:
+            raise ValueError(
+                'cannot use custom codec on non-scalar type {}.{}'.format(
+                    schema, typename))
+
+        self._protocol.get_settings().add_python_codec(
+            oid, typename, schema, 'scalar',
+            encoder, decoder, binary)
+
+    async def set_builtin_type_codec(self, typename, *,
+                                     schema='public', codec_name):
+        """Set a builtin codec for the specified data type.
+
+        :param typename:  Name of the data type the codec is for.
+        :param schema:  Schema name of the data type the codec is for
+                        (defaults to 'public')
+        :param codec_name:  The name of the builtin codec.
+        """
+        if self._type_by_name_stmt is None:
+            self._type_by_name_stmt = await self.prepare(
+                introspection.TYPE_BY_NAME)
+
+        typeinfo = await self._type_by_name_stmt.fetchrow(
+            typename, schema)
+        if not typeinfo:
+            raise ValueError('unknown type: {}.{}'.format(schema, typename))
+
+        oid = typeinfo['oid']
+        if typeinfo['kind'] != b'b' or typeinfo['elemtype']:
+            raise ValueError(
+                'cannot alias non-scalar type {}.{}'.format(
+                    schema, typename))
+
+        self._protocol.get_settings().set_builtin_type_codec(
+            oid, typename, schema, 'scalar', codec_name)
+
+    def is_closed(self):
+        """Return ``True`` if the connection is closed, ``False`` otherwise.
+
+        :return bool: ``True`` if the connection is closed, ``False``
+                      otherwise.
+        """
+        return not self._protocol.is_connected() or self._aborted
+
+    async def close(self):
+        """Close the connection gracefully."""
+        if self.is_closed():
+            return
+        self._close_stmts()
+        self._listeners = {}
+        self._aborted = True
+        await self._protocol.close()
+
+    def terminate(self):
+        """Terminate the connection without waiting for pending data."""
+        self._close_stmts()
+        self._listeners = {}
+        self._aborted = True
+        self._protocol.abort()
+
+    async def reset(self):
+        self._listeners = {}
+
+        await self.execute('''
+            DO $$
+            BEGIN
+                PERFORM * FROM pg_listening_channels() LIMIT 1;
+                IF FOUND THEN
+                    UNLISTEN *;
+                END IF;
+            END;
+            $$;
+            SET SESSION AUTHORIZATION DEFAULT;
+            RESET ALL;
+            CLOSE ALL;
+            SELECT pg_advisory_unlock_all();
+        ''')
+
+    def _get_unique_id(self):
+        self._uid += 1
+        return 'id{}'.format(self._uid)
+
+    def _close_stmts(self):
+        for stmt in self._stmt_cache.values():
+            stmt.mark_closed()
+
+        for stmt in self._stmts_to_close:
+            stmt.mark_closed()
+
+        self._stmt_cache.clear()
+        self._stmts_to_close.clear()
+
+    def _maybe_gc_stmt(self, stmt):
+        if stmt.refs == 0 and stmt.query not in self._stmt_cache:
+            stmt.mark_closed()
+            self._stmts_to_close.add(stmt)
+
+    async def _cleanup_stmts(self):
+        to_close = self._stmts_to_close
+        self._stmts_to_close = set()
+        for stmt in to_close:
+            await self._protocol.close_statement(stmt, False)
+
+    def _request_portal_name(self):
+        return self._get_unique_id()
+
+    def _cancel_current_command(self, waiter):
+        async def cancel():
+            try:
+                # Open new connection to the server
+                if isinstance(self._addr, str):
+                    r, w = await asyncio.open_unix_connection(
+                        self._addr, loop=self._loop)
+                else:
+                    r, w = await asyncio.open_connection(
+                        *self._addr, loop=self._loop)
+
+                    sock = w.transport.get_extra_info('socket')
+                    sock.setsockopt(socket.IPPROTO_TCP,
+                                    socket.TCP_NODELAY, 1)
+
+                # Pack CancelRequest message
+                msg = struct.pack('!llll', 16, 80877102,
+                                  self._protocol.backend_pid,
+                                  self._protocol.backend_secret)
+            except Exception as ex:
+                waiter.set_exception(ex)
+                return
+
+            try:
+                w.write(msg)
+                await r.read()  # Wait until EOF
+            except ConnectionResetError:
+                # On some systems Postgres will reset the connection
+                # after processing the cancellation command.
+                pass
+            except Exception as ex:
+                waiter.set_exception(ex)
+            finally:
+                if not waiter.done():  # Ensure set_exception wasn't called.
+                    waiter.set_result(None)
+                w.close()
+
+        self._loop.create_task(cancel())
+
+    def _notify(self, pid, channel, payload):
+        if channel not in self._listeners:
+            return
+
+        for cb in self._listeners[channel]:
+            try:
+                cb(self, pid, channel, payload)
+            except Exception as ex:
+                self._loop.call_exception_handler({
+                    'message': 'Unhandled exception in asyncpg notification '
+                               'listener callback {!r}'.format(cb),
+                    'exception': ex
+                })
+
+
+async def connect(dsn=None, *,
+                  host=None, port=None,
+                  user=None, password=None,
+                  database=None,
+                  loop=None,
+                  timeout=60,
+                  statement_cache_size=100,
+                  command_timeout=None,
+                  **opts):
+    """A coroutine to establish a connection to a PostgreSQL server.
+
+    Returns a new :class:`~asyncpg.connection.Connection` object.
+
+    :param dsn: Connection arguments specified using as a single string in the
+                following format:
+                ``postgres://user:pass@host:port/database?option=value``
+
+    :param host: database host address or a path to the directory containing
+                 database server UNIX socket (defaults to the default UNIX
+                 socket, or the value of the ``PGHOST`` environment variable,
+                 if set).
+
+    :param port: connection port number (defaults to ``5432``, or the value of
+                 the ``PGPORT`` environment variable, if set)
+
+    :param user: the name of the database role used for authentication
+                 (defaults to the name of the effective user of the process
+                 making the connection, or the value of ``PGUSER`` environment
+                 variable, if set)
+
+    :param database: the name of the database (defaults to the value of
+                     ``PGDATABASE`` environment variable, if set.)
+
+    :param password: password used for authentication
+
+    :param loop: An asyncio event loop instance.  If ``None``, the default
+                 event loop will be used.
+
+    :param float timeout: connection timeout in seconds.
+
+    :param float command_timeout: the default timeout for operations on
+                          this connection (the default is no timeout).
+
+    :param int statement_cache_size: the size of prepared statement LRU cache.
+
+    :return: A :class:`~asyncpg.connection.Connection` instance.
+
+    Example:
+
+    .. code-block:: pycon
+
+        >>> import asyncpg
+        >>> import asyncio
+        >>> async def run():
+        ...     con = await asyncpg.connect(user='postgres')
+        ...     types = await con.fetch('SELECT * FROM pg_type')
+        ...     print(types)
+        >>> asyncio.get_event_loop().run_until_complete(run())
+        [<Record typname='bool' typnamespace=11 ...
+    """
+    if loop is None:
+        loop = asyncio.get_event_loop()
+
+    host, port, opts = _parse_connect_params(
+        dsn=dsn, host=host, port=port, user=user, password=password,
+        database=database, opts=opts)
+
+    last_ex = None
+    addr = None
+    for h in host:
+        connected = _create_future(loop)
+        unix = h.startswith('/')
+
+        if unix:
+            # UNIX socket name
+            addr = h
+            if '.s.PGSQL.' not in addr:
+                addr = os.path.join(addr, '.s.PGSQL.{}'.format(port))
+            conn = loop.create_unix_connection(
+                lambda: protocol.Protocol(addr, connected, opts, loop),
+                addr)
+        else:
+            addr = (h, port)
+            conn = loop.create_connection(
+                lambda: protocol.Protocol(addr, connected, opts, loop),
+                h, port)
+
+        try:
+            tr, pr = await asyncio.wait_for(conn, timeout=timeout, loop=loop)
+        except (OSError, asyncio.TimeoutError) as ex:
+            last_ex = ex
+        else:
+            break
+    else:
+        raise last_ex
+
+    try:
+        await connected
+    except:
+        tr.close()
+        raise
+
+    con = Connection(pr, tr, loop, addr, opts,
+                     statement_cache_size=statement_cache_size,
+                     command_timeout=command_timeout)
+    pr.set_connection(con)
+    return con
+
+
+def _parse_connect_params(*, dsn, host, port, user,
+                          password, database, opts):
+
+    if dsn:
+        parsed = urllib.parse.urlparse(dsn)
+
+        if parsed.scheme not in {'postgresql', 'postgres'}:
+            raise ValueError(
+                'invalid DSN: scheme is expected to be either of '
+                '"postgresql" or "postgres", got {!r}'.format(parsed.scheme))
+
+        if parsed.port and port is None:
+            port = int(parsed.port)
+
+        if parsed.hostname and host is None:
+            host = parsed.hostname
+
+        if parsed.path and database is None:
+            database = parsed.path
+            if database.startswith('/'):
+                database = database[1:]
+
+        if parsed.username and user is None:
+            user = parsed.username
+
+        if parsed.password and password is None:
+            password = parsed.password
+
+        if parsed.query:
+            query = urllib.parse.parse_qs(parsed.query, strict_parsing=True)
+            for key, val in query.items():
+                if isinstance(val, list):
+                    query[key] = val[-1]
+
+            if 'host' in query:
+                val = query.pop('host')
+                if host is None:
+                    host = val
+
+            if 'port' in query:
+                val = int(query.pop('port'))
+                if port is None:
+                    port = val
+
+            if 'dbname' in query:
+                val = query.pop('dbname')
+                if database is None:
+                    database = val
+
+            if 'database' in query:
+                val = query.pop('database')
+                if database is None:
+                    database = val
+
+            if 'user' in query:
+                val = query.pop('user')
+                if user is None:
+                    user = val
+
+            if 'password' in query:
+                val = query.pop('password')
+                if password is None:
+                    password = val
+
+            if query:
+                opts = {**query, **opts}
+
+    # On env-var -> connection parameter conversion read here:
+    # https://www.postgresql.org/docs/current/static/libpq-envars.html
+    # Note that env values may be an empty string in cases when
+    # the variable is "unset" by setting it to an empty value
+    #
+    if host is None:
+        host = os.getenv('PGHOST')
+        if not host:
+            host = ['/tmp', '/private/tmp',
+                    '/var/pgsql_socket', '/run/postgresql',
+                    'localhost']
+    if not isinstance(host, list):
+        host = [host]
+
+    if port is None:
+        port = os.getenv('PGPORT')
+        if port:
+            port = int(port)
+        else:
+            port = 5432
+    else:
+        port = int(port)
+
+    if user is None:
+        user = os.getenv('PGUSER')
+        if not user:
+            user = getpass.getuser()
+
+    if password is None:
+        password = os.getenv('PGPASSWORD')
+
+    if database is None:
+        database = os.getenv('PGDATABASE')
+
+    if user is not None:
+        opts['user'] = user
+    if password is not None:
+        opts['password'] = password
+    if database is not None:
+        opts['database'] = database
+
+    for param in opts:
+        if not isinstance(param, str):
+            raise ValueError(
+                'invalid connection parameter {!r} (str expected)'
+                .format(param))
+        if not isinstance(opts[param], str):
+            raise ValueError(
+                'invalid connection parameter {!r}: {!r} (str expected)'
+                .format(param, opts[param]))
+
+    return host, port, opts
+
+
+def _create_future(loop):
+    try:
+        create_future = loop.create_future
+    except AttributeError:
+        return asyncio.Future(loop=loop)
+    else:
+        return create_future()
diff --git a/asyncpg/cursor.py b/asyncpg/cursor.py
new file mode 100644 (file)
index 0000000..a0731d6
--- /dev/null
@@ -0,0 +1,254 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import collections
+
+from . import compat
+from . import exceptions
+
+
+class CursorFactory:
+    """A cursor interface for the results of a query.
+
+    A cursor interface can be used to initiate efficient traversal of the
+    results of a large query.
+    """
+
+    __slots__ = ('_state', '_connection', '_args', '_prefetch',
+                 '_query', '_timeout')
+
+    def __init__(self, connection, query, state, args, prefetch, timeout):
+        self._connection = connection
+        self._args = args
+        self._prefetch = prefetch
+        self._query = query
+        self._timeout = timeout
+        self._state = state
+        if state is not None:
+            state.attach()
+
+    @compat.aiter_compat
+    def __aiter__(self):
+        prefetch = 50 if self._prefetch is None else self._prefetch
+        return CursorIterator(self._connection,
+                              self._query, self._state,
+                              self._args, prefetch,
+                              self._timeout)
+
+    def __await__(self):
+        if self._prefetch is not None:
+            raise exceptions.InterfaceError(
+                'prefetch argument can only be specified for iterable cursor')
+        cursor = Cursor(self._connection, self._query,
+                        self._state, self._args)
+        return cursor._init(self._timeout).__await__()
+
+    def __del__(self):
+        if self._state is not None:
+            self._state.detach()
+            self._connection._maybe_gc_stmt(self._state)
+
+
+class BaseCursor:
+
+    __slots__ = ('_state', '_connection', '_args', '_portal_name',
+                 '_exhausted', '_query')
+
+    def __init__(self, connection, query, state, args):
+        self._args = args
+        self._connection = connection
+        self._state = state
+        if state is not None:
+            state.attach()
+        self._portal_name = None
+        self._exhausted = False
+        self._query = query
+
+    def _check_ready(self):
+        if self._state is None:
+            raise exceptions.InterfaceError(
+                'cursor: no associated prepared statement')
+
+        if self._state.closed:
+            raise exceptions.InterfaceError(
+                'cursor: the prepared statement is closed')
+
+        if not self._connection._top_xact:
+            raise exceptions.NoActiveSQLTransactionError(
+                'cursor cannot be created outside of a transaction')
+
+    async def _bind_exec(self, n, timeout):
+        self._check_ready()
+
+        if self._portal_name:
+            raise exceptions.InterfaceError(
+                'cursor already has an open portal')
+
+        con = self._connection
+        protocol = con._protocol
+
+        self._portal_name = con._request_portal_name()
+        buffer, _, self._exhausted = await protocol.bind_execute(
+            self._state, self._args, self._portal_name, n, True, timeout)
+        return buffer
+
+    async def _bind(self, timeout):
+        self._check_ready()
+
+        if self._portal_name:
+            raise exceptions.InterfaceError(
+                'cursor already has an open portal')
+
+        con = self._connection
+        protocol = con._protocol
+
+        self._portal_name = con._request_portal_name()
+        buffer = await protocol.bind(self._state, self._args,
+                                     self._portal_name,
+                                     timeout)
+        return buffer
+
+    async def _exec(self, n, timeout):
+        self._check_ready()
+
+        if not self._portal_name:
+            raise exceptions.InterfaceError(
+                'cursor does not have an open portal')
+
+        protocol = self._connection._protocol
+        buffer, _, self._exhausted = await protocol.execute(
+            self._state, self._portal_name, n, True, timeout)
+        return buffer
+
+    def __repr__(self):
+        attrs = []
+        if self._exhausted:
+            attrs.append('exhausted')
+        attrs.append('')  # to separate from id
+
+        if self.__class__.__module__.startswith('asyncpg.'):
+            mod = 'asyncpg'
+        else:
+            mod = self.__class__.__module__
+
+        return '<{}.{} "{!s:.30}" {}{:#x}>'.format(
+            mod, self.__class__.__name__,
+            self._state.query,
+            ' '.join(attrs), id(self))
+
+    def __del__(self):
+        if self._state is not None:
+            self._state.detach()
+            self._connection._maybe_gc_stmt(self._state)
+
+
+class CursorIterator(BaseCursor):
+
+    __slots__ = ('_buffer', '_prefetch', '_timeout')
+
+    def __init__(self, connection, query, state, args, prefetch, timeout):
+        super().__init__(connection, query, state, args)
+
+        if prefetch <= 0:
+            raise exceptions.InterfaceError(
+                'prefetch argument must be greater than zero')
+
+        self._buffer = collections.deque()
+        self._prefetch = prefetch
+        self._timeout = timeout
+
+    @compat.aiter_compat
+    def __aiter__(self):
+        return self
+
+    async def __anext__(self):
+        if self._state is None:
+            self._state = await self._connection._get_statement(
+                self._query, self._timeout)
+            self._state.attach()
+
+        if not self._portal_name:
+            buffer = await self._bind_exec(self._prefetch, self._timeout)
+            self._buffer.extend(buffer)
+
+        if not self._buffer and not self._exhausted:
+            buffer = await self._exec(self._prefetch, self._timeout)
+            self._buffer.extend(buffer)
+
+        if self._buffer:
+            return self._buffer.popleft()
+
+        raise StopAsyncIteration
+
+
+class Cursor(BaseCursor):
+    """An open *portal* into the results of a query."""
+
+    __slots__ = ()
+
+    async def _init(self, timeout):
+        if self._state is None:
+            self._state = await self._connection._get_statement(
+                self._query, timeout)
+            self._state.attach()
+        self._check_ready()
+        await self._bind(timeout)
+        return self
+
+    async def fetch(self, n, *, timeout=None):
+        r"""Return the next *n* rows as a list of :class:`Record` objects.
+
+        :param float timeout: Optional timeout value in seconds.
+
+        :return: A list of :class:`Record` instances.
+        """
+        self._check_ready()
+        if n <= 0:
+            raise exceptions.InterfaceError('n must be greater than zero')
+        if self._exhausted:
+            return []
+        recs = await self._exec(n, timeout)
+        if len(recs) < n:
+            self._exhausted = True
+        return recs
+
+    async def fetchrow(self, *, timeout=None):
+        r"""Return the next row.
+
+        :param float timeout: Optional timeout value in seconds.
+
+        :return: A :class:`Record` instance.
+        """
+        self._check_ready()
+        if self._exhausted:
+            return None
+        recs = await self._exec(1, timeout)
+        if len(recs) < 1:
+            self._exhausted = True
+            return None
+        return recs[0]
+
+    async def forward(self, n, *, timeout=None) -> int:
+        r"""Skip over the next *n* rows.
+
+        :param float timeout: Optional timeout value in seconds.
+
+        :return: A number of rows actually skipped over (<= *n*).
+        """
+        self._check_ready()
+        if n <= 0:
+            raise exceptions.InterfaceError('n must be greater than zero')
+
+        protocol = self._connection._protocol
+        status = await protocol.query('MOVE FORWARD {:d} {}'.format(
+            n, self._portal_name), timeout)
+
+        advanced = int(status.split()[1])
+        if advanced < n:
+            self._exhausted = True
+
+        return advanced
diff --git a/asyncpg/exceptions/__init__.py b/asyncpg/exceptions/__init__.py
new file mode 100644 (file)
index 0000000..07d5413
--- /dev/null
@@ -0,0 +1,1097 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+# GENERATED FROM postgresql/src/backend/utils/errcodes.txt
+# DO NOT MODIFY, use tools/generate_exceptions.py to update
+
+from ._base import *  # NOQA
+from . import _base
+
+
+class PostgresWarning(Warning, _base.PostgresMessage):
+    sqlstate = '01000'
+
+
+class DynamicResultSetsReturned(PostgresWarning):
+    sqlstate = '0100C'
+
+
+class ImplicitZeroBitPadding(PostgresWarning):
+    sqlstate = '01008'
+
+
+class NullValueEliminatedInSetFunction(PostgresWarning):
+    sqlstate = '01003'
+
+
+class PrivilegeNotGranted(PostgresWarning):
+    sqlstate = '01007'
+
+
+class PrivilegeNotRevoked(PostgresWarning):
+    sqlstate = '01006'
+
+
+class StringDataRightTruncation(PostgresWarning):
+    sqlstate = '01004'
+
+
+class DeprecatedFeature(PostgresWarning):
+    sqlstate = '01P01'
+
+
+class NoData(PostgresWarning):
+    sqlstate = '02000'
+
+
+class NoAdditionalDynamicResultSetsReturned(NoData):
+    sqlstate = '02001'
+
+
+class SQLStatementNotYetCompleteError(_base.PostgresError):
+    sqlstate = '03000'
+
+
+class PostgresConnectionError(_base.PostgresError):
+    sqlstate = '08000'
+
+
+class ConnectionDoesNotExistError(PostgresConnectionError):
+    sqlstate = '08003'
+
+
+class ConnectionFailureError(PostgresConnectionError):
+    sqlstate = '08006'
+
+
+class ClientCannotConnectError(PostgresConnectionError):
+    sqlstate = '08001'
+
+
+class ConnectionRejectionError(PostgresConnectionError):
+    sqlstate = '08004'
+
+
+class TransactionResolutionUnknownError(PostgresConnectionError):
+    sqlstate = '08007'
+
+
+class ProtocolViolationError(PostgresConnectionError):
+    sqlstate = '08P01'
+
+
+class TriggeredActionError(_base.PostgresError):
+    sqlstate = '09000'
+
+
+class FeatureNotSupportedError(_base.PostgresError):
+    sqlstate = '0A000'
+
+
+class InvalidTransactionInitiationError(_base.PostgresError):
+    sqlstate = '0B000'
+
+
+class LocatorError(_base.PostgresError):
+    sqlstate = '0F000'
+
+
+class InvalidLocatorSpecificationError(LocatorError):
+    sqlstate = '0F001'
+
+
+class InvalidGrantorError(_base.PostgresError):
+    sqlstate = '0L000'
+
+
+class InvalidGrantOperationError(InvalidGrantorError):
+    sqlstate = '0LP01'
+
+
+class InvalidRoleSpecificationError(_base.PostgresError):
+    sqlstate = '0P000'
+
+
+class DiagnosticsError(_base.PostgresError):
+    sqlstate = '0Z000'
+
+
+class StackedDiagnosticsAccessedWithoutActiveHandlerError(DiagnosticsError):
+    sqlstate = '0Z002'
+
+
+class CaseNotFoundError(_base.PostgresError):
+    sqlstate = '20000'
+
+
+class CardinalityViolationError(_base.PostgresError):
+    sqlstate = '21000'
+
+
+class DataError(_base.PostgresError):
+    sqlstate = '22000'
+
+
+class ArraySubscriptError(DataError):
+    sqlstate = '2202E'
+
+
+class CharacterNotInRepertoireError(DataError):
+    sqlstate = '22021'
+
+
+class DatetimeFieldOverflowError(DataError):
+    sqlstate = '22008'
+
+
+class DivisionByZeroError(DataError):
+    sqlstate = '22012'
+
+
+class ErrorInAssignmentError(DataError):
+    sqlstate = '22005'
+
+
+class EscapeCharacterConflictError(DataError):
+    sqlstate = '2200B'
+
+
+class IndicatorOverflowError(DataError):
+    sqlstate = '22022'
+
+
+class IntervalFieldOverflowError(DataError):
+    sqlstate = '22015'
+
+
+class InvalidArgumentForLogarithmError(DataError):
+    sqlstate = '2201E'
+
+
+class InvalidArgumentForNtileFunctionError(DataError):
+    sqlstate = '22014'
+
+
+class InvalidArgumentForNthValueFunctionError(DataError):
+    sqlstate = '22016'
+
+
+class InvalidArgumentForPowerFunctionError(DataError):
+    sqlstate = '2201F'
+
+
+class InvalidArgumentForWidthBucketFunctionError(DataError):
+    sqlstate = '2201G'
+
+
+class InvalidCharacterValueForCastError(DataError):
+    sqlstate = '22018'
+
+
+class InvalidDatetimeFormatError(DataError):
+    sqlstate = '22007'
+
+
+class InvalidEscapeCharacterError(DataError):
+    sqlstate = '22019'
+
+
+class InvalidEscapeOctetError(DataError):
+    sqlstate = '2200D'
+
+
+class InvalidEscapeSequenceError(DataError):
+    sqlstate = '22025'
+
+
+class NonstandardUseOfEscapeCharacterError(DataError):
+    sqlstate = '22P06'
+
+
+class InvalidIndicatorParameterValueError(DataError):
+    sqlstate = '22010'
+
+
+class InvalidParameterValueError(DataError):
+    sqlstate = '22023'
+
+
+class InvalidRegularExpressionError(DataError):
+    sqlstate = '2201B'
+
+
+class InvalidRowCountInLimitClauseError(DataError):
+    sqlstate = '2201W'
+
+
+class InvalidRowCountInResultOffsetClauseError(DataError):
+    sqlstate = '2201X'
+
+
+class InvalidTablesampleArgumentError(DataError):
+    sqlstate = '2202H'
+
+
+class InvalidTablesampleRepeatError(DataError):
+    sqlstate = '2202G'
+
+
+class InvalidTimeZoneDisplacementValueError(DataError):
+    sqlstate = '22009'
+
+
+class InvalidUseOfEscapeCharacterError(DataError):
+    sqlstate = '2200C'
+
+
+class MostSpecificTypeMismatchError(DataError):
+    sqlstate = '2200G'
+
+
+class NullValueNotAllowedError(DataError):
+    sqlstate = '22004'
+
+
+class NullValueNoIndicatorParameterError(DataError):
+    sqlstate = '22002'
+
+
+class NumericValueOutOfRangeError(DataError):
+    sqlstate = '22003'
+
+
+class StringDataLengthMismatchError(DataError):
+    sqlstate = '22026'
+
+
+class StringDataRightTruncationError(DataError):
+    sqlstate = '22001'
+
+
+class SubstringError(DataError):
+    sqlstate = '22011'
+
+
+class TrimError(DataError):
+    sqlstate = '22027'
+
+
+class UnterminatedCStringError(DataError):
+    sqlstate = '22024'
+
+
+class ZeroLengthCharacterStringError(DataError):
+    sqlstate = '2200F'
+
+
+class PostgresFloatingPointError(DataError):
+    sqlstate = '22P01'
+
+
+class InvalidTextRepresentationError(DataError):
+    sqlstate = '22P02'
+
+
+class InvalidBinaryRepresentationError(DataError):
+    sqlstate = '22P03'
+
+
+class BadCopyFileFormatError(DataError):
+    sqlstate = '22P04'
+
+
+class UntranslatableCharacterError(DataError):
+    sqlstate = '22P05'
+
+
+class NotAnXmlDocumentError(DataError):
+    sqlstate = '2200L'
+
+
+class InvalidXmlDocumentError(DataError):
+    sqlstate = '2200M'
+
+
+class InvalidXmlContentError(DataError):
+    sqlstate = '2200N'
+
+
+class InvalidXmlCommentError(DataError):
+    sqlstate = '2200S'
+
+
+class InvalidXmlProcessingInstructionError(DataError):
+    sqlstate = '2200T'
+
+
+class IntegrityConstraintViolationError(_base.PostgresError):
+    sqlstate = '23000'
+
+
+class RestrictViolationError(IntegrityConstraintViolationError):
+    sqlstate = '23001'
+
+
+class NotNullViolationError(IntegrityConstraintViolationError):
+    sqlstate = '23502'
+
+
+class ForeignKeyViolationError(IntegrityConstraintViolationError):
+    sqlstate = '23503'
+
+
+class UniqueViolationError(IntegrityConstraintViolationError):
+    sqlstate = '23505'
+
+
+class CheckViolationError(IntegrityConstraintViolationError):
+    sqlstate = '23514'
+
+
+class ExclusionViolationError(IntegrityConstraintViolationError):
+    sqlstate = '23P01'
+
+
+class InvalidCursorStateError(_base.PostgresError):
+    sqlstate = '24000'
+
+
+class InvalidTransactionStateError(_base.PostgresError):
+    sqlstate = '25000'
+
+
+class ActiveSQLTransactionError(InvalidTransactionStateError):
+    sqlstate = '25001'
+
+
+class BranchTransactionAlreadyActiveError(InvalidTransactionStateError):
+    sqlstate = '25002'
+
+
+class HeldCursorRequiresSameIsolationLevelError(InvalidTransactionStateError):
+    sqlstate = '25008'
+
+
+class InappropriateAccessModeForBranchTransactionError(
+        InvalidTransactionStateError):
+    sqlstate = '25003'
+
+
+class InappropriateIsolationLevelForBranchTransactionError(
+        InvalidTransactionStateError):
+    sqlstate = '25004'
+
+
+class NoActiveSQLTransactionForBranchTransactionError(
+        InvalidTransactionStateError):
+    sqlstate = '25005'
+
+
+class ReadOnlySQLTransactionError(InvalidTransactionStateError):
+    sqlstate = '25006'
+
+
+class SchemaAndDataStatementMixingNotSupportedError(
+        InvalidTransactionStateError):
+    sqlstate = '25007'
+
+
+class NoActiveSQLTransactionError(InvalidTransactionStateError):
+    sqlstate = '25P01'
+
+
+class InFailedSQLTransactionError(InvalidTransactionStateError):
+    sqlstate = '25P02'
+
+
+class IdleInTransactionSessionTimeoutError(InvalidTransactionStateError):
+    sqlstate = '25P03'
+
+
+class InvalidSQLStatementNameError(_base.PostgresError):
+    sqlstate = '26000'
+
+
+class TriggeredDataChangeViolationError(_base.PostgresError):
+    sqlstate = '27000'
+
+
+class InvalidAuthorizationSpecificationError(_base.PostgresError):
+    sqlstate = '28000'
+
+
+class InvalidPasswordError(InvalidAuthorizationSpecificationError):
+    sqlstate = '28P01'
+
+
+class DependentPrivilegeDescriptorsStillExistError(_base.PostgresError):
+    sqlstate = '2B000'
+
+
+class DependentObjectsStillExistError(
+        DependentPrivilegeDescriptorsStillExistError):
+    sqlstate = '2BP01'
+
+
+class InvalidTransactionTerminationError(_base.PostgresError):
+    sqlstate = '2D000'
+
+
+class SQLRoutineError(_base.PostgresError):
+    sqlstate = '2F000'
+
+
+class FunctionExecutedNoReturnStatementError(SQLRoutineError):
+    sqlstate = '2F005'
+
+
+class ModifyingSQLDataNotPermittedError(SQLRoutineError):
+    sqlstate = '2F002'
+
+
+class ProhibitedSQLStatementAttemptedError(SQLRoutineError):
+    sqlstate = '2F003'
+
+
+class ReadingSQLDataNotPermittedError(SQLRoutineError):
+    sqlstate = '2F004'
+
+
+class InvalidCursorNameError(_base.PostgresError):
+    sqlstate = '34000'
+
+
+class ExternalRoutineError(_base.PostgresError):
+    sqlstate = '38000'
+
+
+class ContainingSQLNotPermittedError(ExternalRoutineError):
+    sqlstate = '38001'
+
+
+class ModifyingExternalRoutineSQLDataNotPermittedError(ExternalRoutineError):
+    sqlstate = '38002'
+
+
+class ProhibitedExternalRoutineSQLStatementAttemptedError(
+        ExternalRoutineError):
+    sqlstate = '38003'
+
+
+class ReadingExternalRoutineSQLDataNotPermittedError(ExternalRoutineError):
+    sqlstate = '38004'
+
+
+class ExternalRoutineInvocationError(_base.PostgresError):
+    sqlstate = '39000'
+
+
+class InvalidSqlstateReturnedError(ExternalRoutineInvocationError):
+    sqlstate = '39001'
+
+
+class NullValueInExternalRoutineNotAllowedError(
+        ExternalRoutineInvocationError):
+    sqlstate = '39004'
+
+
+class TriggerProtocolViolatedError(ExternalRoutineInvocationError):
+    sqlstate = '39P01'
+
+
+class SrfProtocolViolatedError(ExternalRoutineInvocationError):
+    sqlstate = '39P02'
+
+
+class EventTriggerProtocolViolatedError(ExternalRoutineInvocationError):
+    sqlstate = '39P03'
+
+
+class SavepointError(_base.PostgresError):
+    sqlstate = '3B000'
+
+
+class InvalidSavepointSpecificationError(SavepointError):
+    sqlstate = '3B001'
+
+
+class InvalidCatalogNameError(_base.PostgresError):
+    sqlstate = '3D000'
+
+
+class InvalidSchemaNameError(_base.PostgresError):
+    sqlstate = '3F000'
+
+
+class TransactionRollbackError(_base.PostgresError):
+    sqlstate = '40000'
+
+
+class TransactionIntegrityConstraintViolationError(TransactionRollbackError):
+    sqlstate = '40002'
+
+
+class SerializationError(TransactionRollbackError):
+    sqlstate = '40001'
+
+
+class StatementCompletionUnknownError(TransactionRollbackError):
+    sqlstate = '40003'
+
+
+class DeadlockDetectedError(TransactionRollbackError):
+    sqlstate = '40P01'
+
+
+class SyntaxOrAccessError(_base.PostgresError):
+    sqlstate = '42000'
+
+
+class PostgresSyntaxError(SyntaxOrAccessError):
+    sqlstate = '42601'
+
+
+class InsufficientPrivilegeError(SyntaxOrAccessError):
+    sqlstate = '42501'
+
+
+class CannotCoerceError(SyntaxOrAccessError):
+    sqlstate = '42846'
+
+
+class GroupingError(SyntaxOrAccessError):
+    sqlstate = '42803'
+
+
+class WindowingError(SyntaxOrAccessError):
+    sqlstate = '42P20'
+
+
+class InvalidRecursionError(SyntaxOrAccessError):
+    sqlstate = '42P19'
+
+
+class InvalidForeignKeyError(SyntaxOrAccessError):
+    sqlstate = '42830'
+
+
+class InvalidNameError(SyntaxOrAccessError):
+    sqlstate = '42602'
+
+
+class NameTooLongError(SyntaxOrAccessError):
+    sqlstate = '42622'
+
+
+class ReservedNameError(SyntaxOrAccessError):
+    sqlstate = '42939'
+
+
+class DatatypeMismatchError(SyntaxOrAccessError):
+    sqlstate = '42804'
+
+
+class IndeterminateDatatypeError(SyntaxOrAccessError):
+    sqlstate = '42P18'
+
+
+class CollationMismatchError(SyntaxOrAccessError):
+    sqlstate = '42P21'
+
+
+class IndeterminateCollationError(SyntaxOrAccessError):
+    sqlstate = '42P22'
+
+
+class WrongObjectTypeError(SyntaxOrAccessError):
+    sqlstate = '42809'
+
+
+class UndefinedColumnError(SyntaxOrAccessError):
+    sqlstate = '42703'
+
+
+class UndefinedFunctionError(SyntaxOrAccessError):
+    sqlstate = '42883'
+
+
+class UndefinedTableError(SyntaxOrAccessError):
+    sqlstate = '42P01'
+
+
+class UndefinedParameterError(SyntaxOrAccessError):
+    sqlstate = '42P02'
+
+
+class UndefinedObjectError(SyntaxOrAccessError):
+    sqlstate = '42704'
+
+
+class DuplicateColumnError(SyntaxOrAccessError):
+    sqlstate = '42701'
+
+
+class DuplicateCursorError(SyntaxOrAccessError):
+    sqlstate = '42P03'
+
+
+class DuplicateDatabaseError(SyntaxOrAccessError):
+    sqlstate = '42P04'
+
+
+class DuplicateFunctionError(SyntaxOrAccessError):
+    sqlstate = '42723'
+
+
+class DuplicatePreparedStatementError(SyntaxOrAccessError):
+    sqlstate = '42P05'
+
+
+class DuplicateSchemaError(SyntaxOrAccessError):
+    sqlstate = '42P06'
+
+
+class DuplicateTableError(SyntaxOrAccessError):
+    sqlstate = '42P07'
+
+
+class DuplicateAliasError(SyntaxOrAccessError):
+    sqlstate = '42712'
+
+
+class DuplicateObjectError(SyntaxOrAccessError):
+    sqlstate = '42710'
+
+
+class AmbiguousColumnError(SyntaxOrAccessError):
+    sqlstate = '42702'
+
+
+class AmbiguousFunctionError(SyntaxOrAccessError):
+    sqlstate = '42725'
+
+
+class AmbiguousParameterError(SyntaxOrAccessError):
+    sqlstate = '42P08'
+
+
+class AmbiguousAliasError(SyntaxOrAccessError):
+    sqlstate = '42P09'
+
+
+class InvalidColumnReferenceError(SyntaxOrAccessError):
+    sqlstate = '42P10'
+
+
+class InvalidColumnDefinitionError(SyntaxOrAccessError):
+    sqlstate = '42611'
+
+
+class InvalidCursorDefinitionError(SyntaxOrAccessError):
+    sqlstate = '42P11'
+
+
+class InvalidDatabaseDefinitionError(SyntaxOrAccessError):
+    sqlstate = '42P12'
+
+
+class InvalidFunctionDefinitionError(SyntaxOrAccessError):
+    sqlstate = '42P13'
+
+
+class InvalidPreparedStatementDefinitionError(SyntaxOrAccessError):
+    sqlstate = '42P14'
+
+
+class InvalidSchemaDefinitionError(SyntaxOrAccessError):
+    sqlstate = '42P15'
+
+
+class InvalidTableDefinitionError(SyntaxOrAccessError):
+    sqlstate = '42P16'
+
+
+class InvalidObjectDefinitionError(SyntaxOrAccessError):
+    sqlstate = '42P17'
+
+
+class WithCheckOptionViolationError(_base.PostgresError):
+    sqlstate = '44000'
+
+
+class InsufficientResourcesError(_base.PostgresError):
+    sqlstate = '53000'
+
+
+class DiskFullError(InsufficientResourcesError):
+    sqlstate = '53100'
+
+
+class OutOfMemoryError(InsufficientResourcesError):
+    sqlstate = '53200'
+
+
+class TooManyConnectionsError(InsufficientResourcesError):
+    sqlstate = '53300'
+
+
+class ConfigurationLimitExceededError(InsufficientResourcesError):
+    sqlstate = '53400'
+
+
+class ProgramLimitExceededError(_base.PostgresError):
+    sqlstate = '54000'
+
+
+class StatementTooComplexError(ProgramLimitExceededError):
+    sqlstate = '54001'
+
+
+class TooManyColumnsError(ProgramLimitExceededError):
+    sqlstate = '54011'
+
+
+class TooManyArgumentsError(ProgramLimitExceededError):
+    sqlstate = '54023'
+
+
+class ObjectNotInPrerequisiteStateError(_base.PostgresError):
+    sqlstate = '55000'
+
+
+class ObjectInUseError(ObjectNotInPrerequisiteStateError):
+    sqlstate = '55006'
+
+
+class CantChangeRuntimeParamError(ObjectNotInPrerequisiteStateError):
+    sqlstate = '55P02'
+
+
+class LockNotAvailableError(ObjectNotInPrerequisiteStateError):
+    sqlstate = '55P03'
+
+
+class OperatorInterventionError(_base.PostgresError):
+    sqlstate = '57000'
+
+
+class QueryCanceledError(OperatorInterventionError):
+    sqlstate = '57014'
+
+
+class AdminShutdownError(OperatorInterventionError):
+    sqlstate = '57P01'
+
+
+class CrashShutdownError(OperatorInterventionError):
+    sqlstate = '57P02'
+
+
+class CannotConnectNowError(OperatorInterventionError):
+    sqlstate = '57P03'
+
+
+class DatabaseDroppedError(OperatorInterventionError):
+    sqlstate = '57P04'
+
+
+class PostgresSystemError(_base.PostgresError):
+    sqlstate = '58000'
+
+
+class PostgresIOError(PostgresSystemError):
+    sqlstate = '58030'
+
+
+class UndefinedFileError(PostgresSystemError):
+    sqlstate = '58P01'
+
+
+class DuplicateFileError(PostgresSystemError):
+    sqlstate = '58P02'
+
+
+class SnapshotTooOldError(_base.PostgresError):
+    sqlstate = '72000'
+
+
+class ConfigFileError(_base.PostgresError):
+    sqlstate = 'F0000'
+
+
+class LockFileExistsError(ConfigFileError):
+    sqlstate = 'F0001'
+
+
+class FDWError(_base.PostgresError):
+    sqlstate = 'HV000'
+
+
+class FDWColumnNameNotFoundError(FDWError):
+    sqlstate = 'HV005'
+
+
+class FDWDynamicParameterValueNeededError(FDWError):
+    sqlstate = 'HV002'
+
+
+class FDWFunctionSequenceError(FDWError):
+    sqlstate = 'HV010'
+
+
+class FDWInconsistentDescriptorInformationError(FDWError):
+    sqlstate = 'HV021'
+
+
+class FDWInvalidAttributeValueError(FDWError):
+    sqlstate = 'HV024'
+
+
+class FDWInvalidColumnNameError(FDWError):
+    sqlstate = 'HV007'
+
+
+class FDWInvalidColumnNumberError(FDWError):
+    sqlstate = 'HV008'
+
+
+class FDWInvalidDataTypeError(FDWError):
+    sqlstate = 'HV004'
+
+
+class FDWInvalidDataTypeDescriptorsError(FDWError):
+    sqlstate = 'HV006'
+
+
+class FDWInvalidDescriptorFieldIdentifierError(FDWError):
+    sqlstate = 'HV091'
+
+
+class FDWInvalidHandleError(FDWError):
+    sqlstate = 'HV00B'
+
+
+class FDWInvalidOptionIndexError(FDWError):
+    sqlstate = 'HV00C'
+
+
+class FDWInvalidOptionNameError(FDWError):
+    sqlstate = 'HV00D'
+
+
+class FDWInvalidStringLengthOrBufferLengthError(FDWError):
+    sqlstate = 'HV090'
+
+
+class FDWInvalidStringFormatError(FDWError):
+    sqlstate = 'HV00A'
+
+
+class FDWInvalidUseOfNullPointerError(FDWError):
+    sqlstate = 'HV009'
+
+
+class FDWTooManyHandlesError(FDWError):
+    sqlstate = 'HV014'
+
+
+class FDWOutOfMemoryError(FDWError):
+    sqlstate = 'HV001'
+
+
+class FDWNoSchemasError(FDWError):
+    sqlstate = 'HV00P'
+
+
+class FDWOptionNameNotFoundError(FDWError):
+    sqlstate = 'HV00J'
+
+
+class FDWReplyHandleError(FDWError):
+    sqlstate = 'HV00K'
+
+
+class FDWSchemaNotFoundError(FDWError):
+    sqlstate = 'HV00Q'
+
+
+class FDWTableNotFoundError(FDWError):
+    sqlstate = 'HV00R'
+
+
+class FDWUnableToCreateExecutionError(FDWError):
+    sqlstate = 'HV00L'
+
+
+class FDWUnableToCreateReplyError(FDWError):
+    sqlstate = 'HV00M'
+
+
+class FDWUnableToEstablishConnectionError(FDWError):
+    sqlstate = 'HV00N'
+
+
+class PLPGSQLError(_base.PostgresError):
+    sqlstate = 'P0000'
+
+
+class RaiseError(PLPGSQLError):
+    sqlstate = 'P0001'
+
+
+class NoDataFoundError(PLPGSQLError):
+    sqlstate = 'P0002'
+
+
+class TooManyRowsError(PLPGSQLError):
+    sqlstate = 'P0003'
+
+
+class AssertError(PLPGSQLError):
+    sqlstate = 'P0004'
+
+
+class InternalServerError(_base.PostgresError):
+    sqlstate = 'XX000'
+
+
+class DataCorruptedError(InternalServerError):
+    sqlstate = 'XX001'
+
+
+class IndexCorruptedError(InternalServerError):
+    sqlstate = 'XX002'
+
+
+__all__ = _base.__all__ + (
+    'ActiveSQLTransactionError', 'AdminShutdownError',
+    'AmbiguousAliasError', 'AmbiguousColumnError',
+    'AmbiguousFunctionError', 'AmbiguousParameterError',
+    'ArraySubscriptError', 'AssertError', 'BadCopyFileFormatError',
+    'BranchTransactionAlreadyActiveError', 'CannotCoerceError',
+    'CannotConnectNowError', 'CantChangeRuntimeParamError',
+    'CardinalityViolationError', 'CaseNotFoundError',
+    'CharacterNotInRepertoireError', 'CheckViolationError',
+    'ClientCannotConnectError', 'CollationMismatchError',
+    'ConfigFileError', 'ConfigurationLimitExceededError',
+    'ConnectionDoesNotExistError', 'ConnectionFailureError',
+    'ConnectionRejectionError', 'ContainingSQLNotPermittedError',
+    'CrashShutdownError', 'DataCorruptedError', 'DataError',
+    'DatabaseDroppedError', 'DatatypeMismatchError',
+    'DatetimeFieldOverflowError', 'DeadlockDetectedError',
+    'DependentObjectsStillExistError',
+    'DependentPrivilegeDescriptorsStillExistError', 'DeprecatedFeature',
+    'DiagnosticsError', 'DiskFullError', 'DivisionByZeroError',
+    'DuplicateAliasError', 'DuplicateColumnError', 'DuplicateCursorError',
+    'DuplicateDatabaseError', 'DuplicateFileError',
+    'DuplicateFunctionError', 'DuplicateObjectError',
+    'DuplicatePreparedStatementError', 'DuplicateSchemaError',
+    'DuplicateTableError', 'DynamicResultSetsReturned',
+    'ErrorInAssignmentError', 'EscapeCharacterConflictError',
+    'EventTriggerProtocolViolatedError', 'ExclusionViolationError',
+    'ExternalRoutineError', 'ExternalRoutineInvocationError',
+    'FDWColumnNameNotFoundError', 'FDWDynamicParameterValueNeededError',
+    'FDWError', 'FDWFunctionSequenceError',
+    'FDWInconsistentDescriptorInformationError',
+    'FDWInvalidAttributeValueError', 'FDWInvalidColumnNameError',
+    'FDWInvalidColumnNumberError', 'FDWInvalidDataTypeDescriptorsError',
+    'FDWInvalidDataTypeError', 'FDWInvalidDescriptorFieldIdentifierError',
+    'FDWInvalidHandleError', 'FDWInvalidOptionIndexError',
+    'FDWInvalidOptionNameError', 'FDWInvalidStringFormatError',
+    'FDWInvalidStringLengthOrBufferLengthError',
+    'FDWInvalidUseOfNullPointerError', 'FDWNoSchemasError',
+    'FDWOptionNameNotFoundError', 'FDWOutOfMemoryError',
+    'FDWReplyHandleError', 'FDWSchemaNotFoundError',
+    'FDWTableNotFoundError', 'FDWTooManyHandlesError',
+    'FDWUnableToCreateExecutionError', 'FDWUnableToCreateReplyError',
+    'FDWUnableToEstablishConnectionError', 'FeatureNotSupportedError',
+    'ForeignKeyViolationError', 'FunctionExecutedNoReturnStatementError',
+    'GroupingError', 'HeldCursorRequiresSameIsolationLevelError',
+    'IdleInTransactionSessionTimeoutError', 'ImplicitZeroBitPadding',
+    'InFailedSQLTransactionError',
+    'InappropriateAccessModeForBranchTransactionError',
+    'InappropriateIsolationLevelForBranchTransactionError',
+    'IndeterminateCollationError', 'IndeterminateDatatypeError',
+    'IndexCorruptedError', 'IndicatorOverflowError',
+    'InsufficientPrivilegeError', 'InsufficientResourcesError',
+    'IntegrityConstraintViolationError', 'InternalServerError',
+    'IntervalFieldOverflowError', 'InvalidArgumentForLogarithmError',
+    'InvalidArgumentForNthValueFunctionError',
+    'InvalidArgumentForNtileFunctionError',
+    'InvalidArgumentForPowerFunctionError',
+    'InvalidArgumentForWidthBucketFunctionError',
+    'InvalidAuthorizationSpecificationError',
+    'InvalidBinaryRepresentationError', 'InvalidCatalogNameError',
+    'InvalidCharacterValueForCastError', 'InvalidColumnDefinitionError',
+    'InvalidColumnReferenceError', 'InvalidCursorDefinitionError',
+    'InvalidCursorNameError', 'InvalidCursorStateError',
+    'InvalidDatabaseDefinitionError', 'InvalidDatetimeFormatError',
+    'InvalidEscapeCharacterError', 'InvalidEscapeOctetError',
+    'InvalidEscapeSequenceError', 'InvalidForeignKeyError',
+    'InvalidFunctionDefinitionError', 'InvalidGrantOperationError',
+    'InvalidGrantorError', 'InvalidIndicatorParameterValueError',
+    'InvalidLocatorSpecificationError', 'InvalidNameError',
+    'InvalidObjectDefinitionError', 'InvalidParameterValueError',
+    'InvalidPasswordError', 'InvalidPreparedStatementDefinitionError',
+    'InvalidRecursionError', 'InvalidRegularExpressionError',
+    'InvalidRoleSpecificationError', 'InvalidRowCountInLimitClauseError',
+    'InvalidRowCountInResultOffsetClauseError',
+    'InvalidSQLStatementNameError', 'InvalidSavepointSpecificationError',
+    'InvalidSchemaDefinitionError', 'InvalidSchemaNameError',
+    'InvalidSqlstateReturnedError', 'InvalidTableDefinitionError',
+    'InvalidTablesampleArgumentError', 'InvalidTablesampleRepeatError',
+    'InvalidTextRepresentationError',
+    'InvalidTimeZoneDisplacementValueError',
+    'InvalidTransactionInitiationError', 'InvalidTransactionStateError',
+    'InvalidTransactionTerminationError',
+    'InvalidUseOfEscapeCharacterError', 'InvalidXmlCommentError',
+    'InvalidXmlContentError', 'InvalidXmlDocumentError',
+    'InvalidXmlProcessingInstructionError', 'LocatorError',
+    'LockFileExistsError', 'LockNotAvailableError',
+    'ModifyingExternalRoutineSQLDataNotPermittedError',
+    'ModifyingSQLDataNotPermittedError', 'MostSpecificTypeMismatchError',
+    'NameTooLongError', 'NoActiveSQLTransactionError',
+    'NoActiveSQLTransactionForBranchTransactionError',
+    'NoAdditionalDynamicResultSetsReturned', 'NoData', 'NoDataFoundError',
+    'NonstandardUseOfEscapeCharacterError', 'NotAnXmlDocumentError',
+    'NotNullViolationError', 'NullValueEliminatedInSetFunction',
+    'NullValueInExternalRoutineNotAllowedError',
+    'NullValueNoIndicatorParameterError', 'NullValueNotAllowedError',
+    'NumericValueOutOfRangeError', 'ObjectInUseError',
+    'ObjectNotInPrerequisiteStateError', 'OperatorInterventionError',
+    'OutOfMemoryError', 'PLPGSQLError', 'PostgresConnectionError',
+    'PostgresFloatingPointError', 'PostgresIOError',
+    'PostgresSyntaxError', 'PostgresSystemError', 'PostgresWarning',
+    'PrivilegeNotGranted', 'PrivilegeNotRevoked',
+    'ProgramLimitExceededError',
+    'ProhibitedExternalRoutineSQLStatementAttemptedError',
+    'ProhibitedSQLStatementAttemptedError', 'ProtocolViolationError',
+    'QueryCanceledError', 'RaiseError', 'ReadOnlySQLTransactionError',
+    'ReadingExternalRoutineSQLDataNotPermittedError',
+    'ReadingSQLDataNotPermittedError', 'ReservedNameError',
+    'RestrictViolationError', 'SQLRoutineError',
+    'SQLStatementNotYetCompleteError', 'SavepointError',
+    'SchemaAndDataStatementMixingNotSupportedError', 'SerializationError',
+    'SnapshotTooOldError', 'SrfProtocolViolatedError',
+    'StackedDiagnosticsAccessedWithoutActiveHandlerError',
+    'StatementCompletionUnknownError', 'StatementTooComplexError',
+    'StringDataLengthMismatchError', 'StringDataRightTruncation',
+    'StringDataRightTruncationError', 'SubstringError',
+    'SyntaxOrAccessError', 'TooManyArgumentsError', 'TooManyColumnsError',
+    'TooManyConnectionsError', 'TooManyRowsError',
+    'TransactionIntegrityConstraintViolationError',
+    'TransactionResolutionUnknownError', 'TransactionRollbackError',
+    'TriggerProtocolViolatedError', 'TriggeredActionError',
+    'TriggeredDataChangeViolationError', 'TrimError',
+    'UndefinedColumnError', 'UndefinedFileError',
+    'UndefinedFunctionError', 'UndefinedObjectError',
+    'UndefinedParameterError', 'UndefinedTableError',
+    'UniqueViolationError', 'UnterminatedCStringError',
+    'UntranslatableCharacterError', 'WindowingError',
+    'WithCheckOptionViolationError', 'WrongObjectTypeError',
+    'ZeroLengthCharacterStringError'
+)
diff --git a/asyncpg/exceptions/_base.py b/asyncpg/exceptions/_base.py
new file mode 100644 (file)
index 0000000..c2d1e7e
--- /dev/null
@@ -0,0 +1,109 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import sys
+
+
+__all__ = ('PostgresError', 'FatalPostgresError', 'UnknownPostgresError',
+           'InterfaceError')
+
+
+class PostgresMessageMeta(type):
+    _message_map = {}
+    _field_map = {
+        'S': 'severity',
+        'C': 'sqlstate',
+        'M': 'message',
+        'D': 'detail',
+        'H': 'hint',
+        'P': 'position',
+        'p': 'internal_position',
+        'q': 'internal_query',
+        'W': 'context',
+        's': 'schema_name',
+        't': 'table_name',
+        'c': 'column_name',
+        'd': 'data_type_name',
+        'n': 'constraint_name',
+        'F': 'server_source_filename',
+        'L': 'server_source_line',
+        'R': 'server_source_function'
+    }
+
+    def __new__(mcls, name, bases, dct):
+        cls = super().__new__(mcls, name, bases, dct)
+        if cls.__module__ == mcls.__module__ and name == 'PostgresMessage':
+            for f in mcls._field_map.values():
+                setattr(cls, f, None)
+
+        if (cls.__module__ == 'asyncpg' or
+                cls.__module__.startswith('asyncpg.')):
+            mod = sys.modules[cls.__module__]
+            if hasattr(mod, name):
+                raise RuntimeError('exception class redefinition: {}'.format(
+                    name))
+
+        code = dct.get('sqlstate')
+        if code is not None:
+            existing = mcls._message_map.get(code)
+            if existing is not None:
+                raise TypeError('{} has duplicate SQLSTATE code, which is'
+                                'already defined by {}'.format(
+                                    name, existing.__name__))
+            mcls._message_map[code] = cls
+
+        return cls
+
+    @classmethod
+    def get_message_class_for_sqlstate(mcls, code):
+        return mcls._message_map.get(code, UnknownPostgresError)
+
+
+class PostgresMessage(metaclass=PostgresMessageMeta):
+    def __str__(self):
+        msg = self.message
+        if self.detail:
+            msg += '\nDETAIL:  {}'.format(self.detail)
+        if self.hint:
+            msg += '\nHINT:  {}'.format(self.hint)
+
+        return msg
+
+    @classmethod
+    def new(cls, fields, query=None):
+        errcode = fields.get('C')
+        mcls = cls.__class__
+        exccls = mcls.get_message_class_for_sqlstate(errcode)
+        mapped = {
+            'query': query
+        }
+
+        for k, v in fields.items():
+            field = mcls._field_map.get(k)
+            if field:
+                mapped[field] = v
+
+        e = exccls(mapped.get('message'))
+        e.__dict__.update(mapped)
+
+        return e
+
+
+class PostgresError(Exception, PostgresMessage):
+    """Base class for all Postgres errors."""
+
+
+class FatalPostgresError(PostgresError):
+    """A fatal error that should result in server disconnection."""
+
+
+class UnknownPostgresError(FatalPostgresError):
+    """An error with an unknown SQLSTATE code."""
+
+
+class InterfaceError(Exception):
+    """An error caused by improper use of asyncpg API."""
diff --git a/asyncpg/introspection.py b/asyncpg/introspection.py
new file mode 100644 (file)
index 0000000..a9050d9
--- /dev/null
@@ -0,0 +1,269 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+INTRO_LOOKUP_TYPES = '''\
+WITH RECURSIVE typeinfo_tree(
+    oid, ns, name, kind, basetype, has_bin_io, elemtype, elemdelim,
+    range_subtype, elem_has_bin_io, attrtypoids, attrnames, depth)
+AS (
+    WITH composite_attrs
+    AS (
+        SELECT
+            c.reltype                                        AS comptype_oid,
+            array_agg(ia.atttypid ORDER BY ia.attnum)        AS typoids,
+            array_agg(ia.attname::text ORDER BY ia.attnum)   AS names
+        FROM
+            pg_attribute ia
+            INNER JOIN pg_class c
+                ON (ia.attrelid = c.oid)
+        WHERE
+            ia.attnum > 0 AND NOT ia.attisdropped
+        GROUP BY
+            c.reltype
+    ),
+
+    typeinfo
+    AS (
+        SELECT
+            t.oid                           AS oid,
+            ns.nspname                      AS ns,
+            t.typname                       AS name,
+            t.typtype                       AS kind,
+            (CASE WHEN t.typtype = 'd' THEN
+                (WITH RECURSIVE typebases(oid, depth) AS (
+                    SELECT
+                        t2.typbasetype      AS oid,
+                        0                   AS depth
+                    FROM
+                        pg_type t2
+                    WHERE
+                        t2.oid = t.oid
+
+                    UNION ALL
+
+                    SELECT
+                        t2.typbasetype      AS oid,
+                        tb.depth + 1        AS depth
+                    FROM
+                        pg_type t2,
+                        typebases tb
+                    WHERE
+                       tb.oid = t2.oid
+                       AND t2.typbasetype != 0
+               ) SELECT oid FROM typebases ORDER BY depth DESC LIMIT 1)
+
+               ELSE NULL
+            END)                            AS basetype,
+            t.typreceive::oid != 0 AND t.typsend::oid != 0
+                                            AS has_bin_io,
+            t.typelem                       AS elemtype,
+            elem_t.typdelim                 AS elemdelim,
+            range_t.rngsubtype              AS range_subtype,
+            (CASE WHEN t.typtype = 'r' THEN
+                (SELECT
+                    range_elem_t.typreceive::oid != 0 AND
+                        range_elem_t.typsend::oid != 0
+                FROM
+                    pg_catalog.pg_type AS range_elem_t
+                WHERE
+                    range_elem_t.oid = range_t.rngsubtype)
+            ELSE
+                elem_t.typreceive::oid != 0 AND
+                    elem_t.typsend::oid != 0
+            END)                            AS elem_has_bin_io,
+            (CASE WHEN t.typtype = 'c' THEN
+                (SELECT ca.typoids
+                FROM composite_attrs AS ca
+                WHERE ca.comptype_oid = t.oid)
+
+                ELSE NULL
+            END)                            AS attrtypoids,
+            (CASE WHEN t.typtype = 'c' THEN
+                (SELECT ca.names
+                FROM composite_attrs AS ca
+                WHERE ca.comptype_oid = t.oid)
+
+                ELSE NULL
+            END)                            AS attrnames
+        FROM
+            pg_catalog.pg_type AS t
+            INNER JOIN pg_catalog.pg_namespace ns ON (
+                ns.oid = t.typnamespace)
+            LEFT JOIN pg_type elem_t ON (
+                t.typlen = -1 AND
+                t.typelem != 0 AND
+                t.typelem = elem_t.oid
+            )
+            LEFT JOIN pg_range range_t ON (
+                t.oid = range_t.rngtypid
+            )
+    )
+
+    SELECT
+        ti.oid, ti.ns, ti.name, ti.kind, ti.basetype, ti.has_bin_io,
+        ti.elemtype, ti.elemdelim, ti.range_subtype, ti.elem_has_bin_io,
+        ti.attrtypoids, ti.attrnames, 0
+    FROM
+        typeinfo AS ti
+    WHERE
+        ti.oid = any($1::oid[])
+
+    UNION ALL
+
+    SELECT
+        ti.oid, ti.ns, ti.name, ti.kind, ti.basetype, ti.has_bin_io,
+        ti.elemtype, ti.elemdelim, ti.range_subtype, ti.elem_has_bin_io,
+        ti.attrtypoids, ti.attrnames, tt.depth + 1
+    FROM
+        typeinfo ti,
+        typeinfo_tree tt
+    WHERE
+        (tt.elemtype IS NOT NULL AND ti.oid = tt.elemtype)
+        OR (tt.attrtypoids IS NOT NULL AND ti.oid = any(tt.attrtypoids))
+        OR (tt.range_subtype IS NOT NULL AND ti.oid = tt.range_subtype)
+)
+
+SELECT DISTINCT
+    *
+FROM
+    typeinfo_tree
+ORDER BY
+    depth DESC
+'''
+
+
+# Prior to 9.2 PostgreSQL did not have range types.
+INTRO_LOOKUP_TYPES_91 = '''\
+WITH RECURSIVE typeinfo_tree(
+    oid, ns, name, kind, basetype, has_bin_io, elemtype, elemdelim,
+    range_subtype, elem_has_bin_io, attrtypoids, attrnames, depth)
+AS (
+    WITH composite_attrs
+    AS (
+        SELECT
+            c.reltype                                        AS comptype_oid,
+            array_agg(ia.atttypid ORDER BY ia.attnum)        AS typoids,
+            array_agg(ia.attname::text ORDER BY ia.attnum)   AS names
+        FROM
+            pg_attribute ia
+            INNER JOIN pg_class c
+                ON (ia.attrelid = c.oid)
+        WHERE
+            ia.attnum > 0 AND NOT ia.attisdropped
+        GROUP BY
+            c.reltype
+    ),
+
+    typeinfo
+    AS (
+        SELECT
+            t.oid                           AS oid,
+            ns.nspname                      AS ns,
+            t.typname                       AS name,
+            t.typtype                       AS kind,
+            (CASE WHEN t.typtype = 'd' THEN
+                (WITH RECURSIVE typebases(oid, depth) AS (
+                    SELECT
+                        t2.typbasetype      AS oid,
+                        0                   AS depth
+                    FROM
+                        pg_type t2
+                    WHERE
+                        t2.oid = t.oid
+
+                    UNION ALL
+
+                    SELECT
+                        t2.typbasetype      AS oid,
+                        tb.depth + 1        AS depth
+                    FROM
+                        pg_type t2,
+                        typebases tb
+                    WHERE
+                       tb.oid = t2.oid
+                       AND t2.typbasetype != 0
+               ) SELECT oid FROM typebases ORDER BY depth DESC LIMIT 1)
+
+               ELSE NULL
+            END)                            AS basetype,
+            t.typreceive::oid != 0 AND t.typsend::oid != 0
+                                            AS has_bin_io,
+            t.typelem                       AS elemtype,
+            elem_t.typdelim                 AS elemdelim,
+            NULL::oid                       AS range_subtype,
+            elem_t.typreceive::oid != 0 AND
+                elem_t.typsend::oid != 0
+                                            AS elem_has_bin_io,
+            (CASE WHEN t.typtype = 'c' THEN
+                (SELECT ca.typoids
+                FROM composite_attrs AS ca
+                WHERE ca.comptype_oid = t.oid)
+
+                ELSE NULL
+            END)                            AS attrtypoids,
+            (CASE WHEN t.typtype = 'c' THEN
+                (SELECT ca.names
+                FROM composite_attrs AS ca
+                WHERE ca.comptype_oid = t.oid)
+
+                ELSE NULL
+            END)                            AS attrnames
+        FROM
+            pg_catalog.pg_type AS t
+            INNER JOIN pg_catalog.pg_namespace ns ON (
+                ns.oid = t.typnamespace)
+            LEFT JOIN pg_type elem_t ON (
+                t.typlen = -1 AND
+                t.typelem != 0 AND
+                t.typelem = elem_t.oid
+            )
+    )
+
+    SELECT
+        ti.oid, ti.ns, ti.name, ti.kind, ti.basetype, ti.has_bin_io,
+        ti.elemtype, ti.elemdelim, ti.range_subtype, ti.elem_has_bin_io,
+        ti.attrtypoids, ti.attrnames, 0
+    FROM
+        typeinfo AS ti
+    WHERE
+        ti.oid = any($1::oid[])
+
+    UNION ALL
+
+    SELECT
+        ti.oid, ti.ns, ti.name, ti.kind, ti.basetype, ti.has_bin_io,
+        ti.elemtype, ti.elemdelim, ti.range_subtype, ti.elem_has_bin_io,
+        ti.attrtypoids, ti.attrnames, tt.depth + 1
+    FROM
+        typeinfo ti,
+        typeinfo_tree tt
+    WHERE
+        (tt.elemtype IS NOT NULL AND ti.oid = tt.elemtype)
+        OR (tt.attrtypoids IS NOT NULL AND ti.oid = any(tt.attrtypoids))
+        OR (tt.range_subtype IS NOT NULL AND ti.oid = tt.range_subtype)
+)
+
+SELECT DISTINCT
+    *
+FROM
+    typeinfo_tree
+ORDER BY
+    depth DESC
+'''
+
+
+TYPE_BY_NAME = '''\
+SELECT
+    t.oid,
+    t.typelem     AS elemtype,
+    t.typtype     AS kind
+FROM
+    pg_catalog.pg_type AS t
+    INNER JOIN pg_catalog.pg_namespace ns ON (ns.oid = t.typnamespace)
+WHERE
+    t.typname = $1 AND ns.nspname = $2
+'''
diff --git a/asyncpg/pool.py b/asyncpg/pool.py
new file mode 100644 (file)
index 0000000..259dced
--- /dev/null
@@ -0,0 +1,311 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import asyncio
+
+from . import connection
+from . import exceptions
+
+
+class Pool:
+    """A connection pool.
+
+    Connection pool can be used to manage a set of connections to the database.
+    Connections are first acquired from the pool, then used, and then released
+    back to the pool.  Once a connection is released, it's reset to close all
+    open cursors and other resources *except* prepared statements.
+
+    Pools are created by calling :func:`~asyncpg.pool.create_pool`.
+    """
+
+    __slots__ = ('_queue', '_loop', '_minsize', '_maxsize',
+                 '_connect_args', '_connect_kwargs',
+                 '_working_addr', '_working_opts',
+                 '_con_count', '_max_queries', '_connections',
+                 '_initialized', '_closed', '_setup')
+
+    def __init__(self, *connect_args,
+                 min_size,
+                 max_size,
+                 max_queries,
+                 setup,
+                 loop,
+                 **connect_kwargs):
+
+        if loop is None:
+            loop = asyncio.get_event_loop()
+        self._loop = loop
+
+        if max_size <= 0:
+            raise ValueError('max_size is expected to be greater than zero')
+
+        if min_size <= 0:
+            raise ValueError('min_size is expected to be greater than zero')
+
+        if min_size > max_size:
+            raise ValueError('min_size is greater than max_size')
+
+        if max_queries <= 0:
+            raise ValueError('max_queries is expected to be greater than zero')
+
+        self._minsize = min_size
+        self._maxsize = max_size
+        self._max_queries = max_queries
+
+        self._setup = setup
+
+        self._connect_args = connect_args
+        self._connect_kwargs = connect_kwargs
+
+        self._working_addr = None
+        self._working_opts = None
+
+        self._reset()
+
+        self._closed = False
+
+    async def _new_connection(self):
+        if self._working_addr is None:
+            con = await connection.connect(*self._connect_args,
+                                           loop=self._loop,
+                                           **self._connect_kwargs)
+
+            self._working_addr = con._addr
+            self._working_opts = con._opts
+
+        else:
+            if isinstance(self._working_addr, str):
+                host = self._working_addr
+                port = 0
+            else:
+                host, port = self._working_addr
+
+            con = await connection.connect(host=host, port=port,
+                                           loop=self._loop,
+                                           **self._working_opts)
+
+        self._connections.add(con)
+        return con
+
+    async def _init(self):
+        if self._initialized:
+            return
+        if self._closed:
+            raise exceptions.InterfaceError('pool is closed')
+
+        for _ in range(self._minsize):
+            self._con_count += 1
+            try:
+                con = await self._new_connection()
+            except:
+                self._con_count -= 1
+                raise
+            self._queue.put_nowait(con)
+
+        self._initialized = True
+        return self
+
+    def acquire(self, *, timeout=None):
+        """Acquire a database connection from the pool.
+
+        :param float timeout: A timeout for acquiring a Connection.
+        :return: An instance of :class:`~asyncpg.connection.Connection`.
+
+        Can be used in an ``await`` expression or with an ``async with`` block.
+
+        .. code-block:: python
+
+            async with pool.acquire() as con:
+                await con.execute(...)
+
+        Or:
+
+        .. code-block:: python
+
+            con = await pool.acquire()
+            try:
+                await con.execute(...)
+            finally:
+                await pool.release(con)
+        """
+        return PoolAcquireContext(self, timeout)
+
+    async def _acquire(self, timeout):
+        if timeout is None:
+            return await self._acquire_impl()
+        else:
+            return await asyncio.wait_for(self._acquire_impl(),
+                                          timeout=timeout,
+                                          loop=self._loop)
+
+    async def _acquire_impl(self):
+        self._check_init()
+
+        try:
+            con = self._queue.get_nowait()
+        except asyncio.QueueEmpty:
+            con = None
+
+        if con is None:
+            if self._con_count < self._maxsize:
+                self._con_count += 1
+                try:
+                    con = await self._new_connection()
+                except:
+                    self._con_count -= 1
+                    raise
+            else:
+                con = await self._queue.get()
+
+        if self._setup is not None:
+            try:
+                await self._setup(con)
+            except:
+                await self.release(con)
+                raise
+
+        return con
+
+    async def release(self, connection):
+        """Release a database connection back to the pool."""
+        self._check_init()
+        if connection.is_closed():
+            self._con_count -= 1
+            self._connections.remove(connection)
+        elif connection._protocol.queries_count >= self._max_queries:
+            self._con_count -= 1
+            self._connections.remove(connection)
+            await connection.close()
+        else:
+            await connection.reset()
+            self._queue.put_nowait(connection)
+
+    async def close(self):
+        """Gracefully close all connections in the pool."""
+        if self._closed:
+            return
+        self._check_init()
+        self._closed = True
+        coros = []
+        for con in self._connections:
+            coros.append(con.close())
+        await asyncio.gather(*coros, loop=self._loop)
+        self._reset()
+
+    def terminate(self):
+        """Terminate all connections in the pool."""
+        if self._closed:
+            return
+        self._check_init()
+        self._closed = True
+        for con in self._connections:
+            con.terminate()
+        self._reset()
+
+    def _check_init(self):
+        if not self._initialized:
+            raise exceptions.InterfaceError('pool is not initialized')
+        if self._closed:
+            raise exceptions.InterfaceError('pool is closed')
+
+    def _reset(self):
+        self._connections = set()
+        self._con_count = 0
+        self._initialized = False
+        self._queue = asyncio.Queue(maxsize=self._maxsize, loop=self._loop)
+
+    def __await__(self):
+        return self._init().__await__()
+
+    async def __aenter__(self):
+        await self._init()
+        return self
+
+    async def __aexit__(self, *exc):
+        await self.close()
+
+
+class PoolAcquireContext:
+
+    __slots__ = ('timeout', 'connection', 'done', 'pool')
+
+    def __init__(self, pool, timeout):
+        self.pool = pool
+        self.timeout = timeout
+        self.connection = None
+        self.done = False
+
+    async def __aenter__(self):
+        if self.connection is not None or self.done:
+            raise exceptions.InterfaceError('a connection is already acquired')
+        self.connection = await self.pool._acquire(self.timeout)
+        return self.connection
+
+    async def __aexit__(self, *exc):
+        self.done = True
+        con = self.connection
+        self.connection = None
+        await self.pool.release(con)
+
+    def __await__(self):
+        self.done = True
+        return self.pool._acquire(self.timeout).__await__()
+
+
+def create_pool(dsn=None, *,
+                min_size=10,
+                max_size=10,
+                max_queries=50000,
+                setup=None,
+                loop=None,
+                **connect_kwargs):
+    r"""Create a connection pool.
+
+    Can be used either with an ``async with`` block:
+
+    .. code-block:: python
+
+        async with asyncpg.create_pool(user='postgres',
+                                       command_timeout=60) as pool:
+            async with pool.acquire() as con:
+                await con.fetch('SELECT 1')
+
+    Or directly with ``await``:
+
+    .. code-block:: python
+
+        pool = await asyncpg.create_pool(user='postgres', command_timeout=60)
+        con = await pool.acquire()
+        try:
+            await con.fetch('SELECT 1')
+        finally:
+            await pool.release(con)
+
+    :param str dsn: Connection arguments specified using as a single string in
+                    the following format:
+                    ``postgres://user:pass@host:port/database?option=value``.
+
+    :param \*\*connect_kwargs: Keyword arguments for the
+                               :func:`~asyncpg.connection.connect` function.
+    :param int min_size: Number of connection the pool will be initialized
+                         with.
+    :param int max_size: Max number of connections in the pool.
+    :param int max_queries: Number of queries after a connection is closed
+                            and replaced with a new connection.
+    :param coroutine setup: A coroutine to initialize a connection right before
+                            it is returned from :meth:`~pool.Pool.acquire`.
+                            An example use case would be to automatically
+                            set up notifications listeners for all connections
+                            of a pool.
+    :param loop: An asyncio event loop instance.  If ``None``, the default
+                 event loop will be used.
+    :return: An instance of :class:`~asyncpg.pool.Pool`.
+    """
+    return Pool(dsn,
+                min_size=min_size, max_size=max_size,
+                max_queries=max_queries, loop=loop, setup=setup,
+                **connect_kwargs)
diff --git a/asyncpg/prepared_stmt.py b/asyncpg/prepared_stmt.py
new file mode 100644 (file)
index 0000000..fa35c9d
--- /dev/null
@@ -0,0 +1,210 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import json
+
+from . import cursor
+from . import exceptions
+
+
+class PreparedStatement:
+    """A representation of a prepared statement."""
+
+    __slots__ = ('_connection', '_state', '_query', '_last_status')
+
+    def __init__(self, connection, query, state):
+        self._connection = connection
+        self._state = state
+        self._query = query
+        state.attach()
+        self._last_status = None
+
+    def get_query(self) -> str:
+        """Return the text of the query for this prepared statement.
+
+        Example::
+
+            stmt = await connection.prepare('SELECT $1::int')
+            assert stmt.get_query() == "SELECT $1::int"
+        """
+        return self._query
+
+    def get_statusmsg(self) -> str:
+        """Return the status of the executed command.
+
+        Example::
+
+            stmt = await connection.prepare('CREATE TABLE mytab (a int)')
+            await stmt.fetch()
+            assert stmt.get_statusmsg() == "CREATE TABLE"
+        """
+        if self._last_status is None:
+            return self._last_status
+        return self._last_status.decode()
+
+    def get_parameters(self):
+        """Return a description of statement parameters types.
+
+        :return: A tuple of :class:`asyncpg.types.Type`.
+
+        Example::
+
+            stmt = await connection.prepare('SELECT ($1::int, $2::text)')
+            print(stmt.get_parameters())
+
+            # Will print:
+            #   (Type(oid=23, name='int4', kind='scalar', schema='pg_catalog'),
+            #    Type(oid=25, name='text', kind='scalar', schema='pg_catalog'))
+        """
+        self.__check_open()
+        return self._state._get_parameters()
+
+    def get_attributes(self):
+        """Return a description of relation attributes (columns).
+
+        :return: A tuple of :class:`asyncpg.types.Attribute`.
+
+        Example::
+
+            st = await self.con.prepare('''
+                SELECT typname, typnamespace FROM pg_type
+            ''')
+            print(st.get_attributes())
+
+            # Will print:
+            #   (Attribute(
+            #       name='typname',
+            #       type=Type(oid=19, name='name', kind='scalar',
+            #                 schema='pg_catalog')),
+            #    Attribute(
+            #       name='typnamespace',
+            #       type=Type(oid=26, name='oid', kind='scalar',
+            #                 schema='pg_catalog')))
+        """
+        self.__check_open()
+        return self._state._get_attributes()
+
+    def cursor(self, *args, prefetch=None,
+               timeout=None) -> cursor.CursorFactory:
+        """Return a *cursor factory* for the prepared statement.
+
+        :param args: Query arguments.
+        :param int prefetch: The number of rows the *cursor iterator*
+                             will prefetch (defaults to ``50``.)
+        :param float timeout: Optional timeout in seconds.
+
+        :return: A :class:`~cursor.CursorFactory` object.
+        """
+        self.__check_open()
+        return cursor.CursorFactory(self._connection, self._query,
+                                    self._state, args, prefetch,
+                                    timeout)
+
+    async def explain(self, *args, analyze=False):
+        """Return the execution plan of the statement.
+
+        :param args: Query arguments.
+        :param analyze: If ``True``, the statement will be executed and
+                        the run time statitics added to the return value.
+
+        :return: An object representing the execution plan.  This value
+                 is actually a deserialized JSON output of the SQL
+                 ``EXPLAIN`` command.
+        """
+        query = 'EXPLAIN (FORMAT JSON, VERBOSE'
+        if analyze:
+            query += ', ANALYZE) '
+        else:
+            query += ') '
+        query += self._state.query
+
+        if analyze:
+            # From PostgreSQL docs:
+            # Important: Keep in mind that the statement is actually
+            # executed when the ANALYZE option is used. Although EXPLAIN
+            # will discard any output that a SELECT would return, other
+            # side effects of the statement will happen as usual. If you
+            # wish to use EXPLAIN ANALYZE on an INSERT, UPDATE, DELETE,
+            # CREATE TABLE AS, or EXECUTE statement without letting the
+            # command affect your data, use this approach:
+            #     BEGIN;
+            #     EXPLAIN ANALYZE ...;
+            #     ROLLBACK;
+            tr = self._connection.transaction()
+            await tr.start()
+            try:
+                data = await self._connection.fetchval(query, *args)
+            finally:
+                await tr.rollback()
+        else:
+            data = await self._connection.fetchval(query, *args)
+
+        return json.loads(data)
+
+    async def fetch(self, *args, timeout=None):
+        r"""Execute the statement and return a list of :class:`Record` objects.
+
+        :param str query: Query text
+        :param args: Query arguments
+        :param float timeout: Optional timeout value in seconds.
+
+        :return: A list of :class:`Record` instances.
+        """
+        self.__check_open()
+        protocol = self._connection._protocol
+        data, status, _ = await protocol.bind_execute(
+            self._state, args, '', 0, True, timeout)
+        self._last_status = status
+        return data
+
+    async def fetchval(self, *args, column=0, timeout=None):
+        """Execute the statement and return a value in the first row.
+
+        :param args: Query arguments.
+        :param int column: Numeric index within the record of the value to
+                           return (defaults to 0).
+        :param float timeout: Optional timeout value in seconds.
+                            If not specified, defaults to the value of
+                            ``command_timeout`` argument to the ``Connection``
+                            instance constructor.
+
+        :return: The value of the specified column of the first record.
+        """
+        self.__check_open()
+        protocol = self._connection._protocol
+        data, status, _ = await protocol.bind_execute(
+            self._state, args, '', 1, True, timeout)
+        self._last_status = status
+        if not data:
+            return None
+        return data[0][column]
+
+    async def fetchrow(self, *args, timeout=None):
+        """Execute the statement and return the first row.
+
+        :param str query: Query text
+        :param args: Query arguments
+        :param float timeout: Optional timeout value in seconds.
+
+        :return: The first row as a :class:`Record` instance.
+        """
+        self.__check_open()
+        protocol = self._connection._protocol
+        data, status, _ = await protocol.bind_execute(
+            self._state, args, '', 1, True, timeout)
+        self._last_status = status
+        if not data:
+            return None
+        return data[0]
+
+    def __check_open(self):
+        if self._state.closed:
+            raise exceptions.InterfaceError('prepared statement is closed')
+
+    def __del__(self):
+        self._state.detach()
+        self._connection._maybe_gc_stmt(self._state)
diff --git a/asyncpg/protocol/__init__.py b/asyncpg/protocol/__init__.py
new file mode 100644 (file)
index 0000000..44ac549
--- /dev/null
@@ -0,0 +1,8 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+from .protocol import Protocol
diff --git a/asyncpg/protocol/buffer.pxd b/asyncpg/protocol/buffer.pxd
new file mode 100644 (file)
index 0000000..6687e8e
--- /dev/null
@@ -0,0 +1,131 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+cdef class Memory:
+    cdef:
+        char* buf
+        object owner
+        ssize_t length
+
+    cdef as_bytes(self)
+
+    @staticmethod
+    cdef inline Memory new(char* buf, object owner, ssize_t length)
+
+
+cdef class WriteBuffer:
+    cdef:
+        # Preallocated small buffer
+        bint _smallbuf_inuse
+        char _smallbuf[_BUFFER_INITIAL_SIZE]
+
+        char *_buf
+
+        # Allocated size
+        ssize_t _size
+
+        # Length of data in the buffer
+        ssize_t _length
+
+        # Number of memoryviews attached to the buffer
+        int _view_count
+
+        # True is start_message was used
+        bint _message_mode
+
+    cdef inline _check_readonly(self)
+    cdef inline len(self)
+    cdef inline _ensure_alloced(self, ssize_t extra_length)
+    cdef _reallocate(self, ssize_t new_size)
+    cdef inline start_message(self, char type)
+    cdef inline end_message(self)
+    cdef write_buffer(self, WriteBuffer buf)
+    cdef write_byte(self, char b)
+    cdef write_bytes(self, bytes data)
+    cdef write_bytestring(self, bytes string)
+    cdef write_str(self, str string, str encoding)
+    cdef write_cstr(self, char *data, ssize_t len)
+    cdef write_int16(self, int16_t i)
+    cdef write_int32(self, int32_t i)
+    cdef write_int64(self, int64_t i)
+    cdef write_float(self, float f)
+    cdef write_double(self, double d)
+
+    @staticmethod
+    cdef WriteBuffer new_message(char type)
+
+    @staticmethod
+    cdef WriteBuffer new()
+
+
+cdef class ReadBuffer:
+    cdef:
+        # A deque of buffers (bytes objects)
+        object _bufs
+        object _bufs_append
+        object _bufs_popleft
+
+        # A pointer to the first buffer in `_bufs`
+        bytes _buf0
+
+        # A pointer to the previous first buffer
+        # (used to prolong the life of _buf0 when using
+        # methods like _try_read_bytes)
+        bytes _buf0_prev
+
+        # Number of buffers in `_bufs`
+        int32_t _bufs_len
+
+        # A read position in the first buffer in `_bufs`
+        ssize_t _pos0
+
+        # Length of the first buffer in `_bufs`
+        ssize_t _len0
+
+        # A total number of buffered bytes in ReadBuffer
+        ssize_t _length
+
+        char _current_message_type
+        int _current_message_len
+        ssize_t _current_message_len_unread
+        bint _current_message_ready
+
+    cdef feed_data(self, data)
+    cdef inline _ensure_first_buf(self)
+    cdef _switch_to_next_buf(self)
+    cdef inline read_byte(self)
+    cdef inline char* _try_read_bytes(self, ssize_t nbytes)
+    cdef inline read(self, ssize_t nbytes)
+    cdef inline read_bytes(self, ssize_t n)
+    cdef inline read_int32(self)
+    cdef inline read_int16(self)
+    cdef inline read_cstr(self)
+    cdef int32_t has_message(self) except -1
+    cdef inline char* try_consume_message(self, ssize_t* len)
+    cdef Memory consume_message(self)
+    cdef discard_message(self)
+    cdef inline _discard_message(self)
+    cdef inline char get_message_type(self)
+    cdef inline int32_t get_message_length(self)
+
+    @staticmethod
+    cdef ReadBuffer new_message_parser(object data)
+
+
+cdef class FastReadBuffer:
+    cdef:
+        const char* buf
+        ssize_t len
+
+    cdef inline const char* read(self, ssize_t n) except NULL
+    cdef inline const char* read_all(self)
+    cdef inline FastReadBuffer slice_from(self, FastReadBuffer source,
+                                          ssize_t len)
+    cdef _raise_ins_err(self, ssize_t n, ssize_t len)
+
+    @staticmethod
+    cdef FastReadBuffer new()
diff --git a/asyncpg/protocol/buffer.pyx b/asyncpg/protocol/buffer.pyx
new file mode 100644 (file)
index 0000000..e999b7a
--- /dev/null
@@ -0,0 +1,616 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+from cpython cimport Py_buffer
+from libc.string cimport memcpy
+
+
+class BufferError(Exception):
+    pass
+
+@cython.no_gc_clear
+@cython.final
+@cython.freelist(_MEMORY_FREELIST_SIZE)
+cdef class Memory:
+
+    cdef as_bytes(self):
+        return cpython.PyBytes_FromStringAndSize(self.buf, self.length)
+
+    @staticmethod
+    cdef inline Memory new(char* buf, object owner, ssize_t length):
+        cdef Memory mem
+        mem = Memory.__new__(Memory)
+        mem.buf = buf
+        mem.owner = owner
+        mem.length = length
+        return mem
+
+
+@cython.no_gc_clear
+@cython.final
+@cython.freelist(_BUFFER_FREELIST_SIZE)
+cdef class WriteBuffer:
+
+    def __cinit__(self):
+        self._smallbuf_inuse = True
+        self._buf = self._smallbuf
+        self._size = _BUFFER_INITIAL_SIZE
+        self._length = 0
+        self._message_mode = 0
+
+    def __dealloc__(self):
+        if self._buf is not NULL and not self._smallbuf_inuse:
+            PyMem_Free(self._buf)
+            self._buf = NULL
+            self._size = 0
+
+        if self._view_count:
+            raise RuntimeError(
+                'Deallocating buffer with attached memoryviews')
+
+    def __getbuffer__(self, Py_buffer *buffer, int flags):
+        self._view_count += 1
+
+        PyBuffer_FillInfo(
+            buffer, self, self._buf, self._length,
+            1,  # read-only
+            flags)
+
+    def __releasebuffer__(self, Py_buffer *buffer):
+        self._view_count -= 1
+
+    cdef inline _check_readonly(self):
+        if self._view_count:
+            raise BufferError('the buffer is in read-only mode')
+
+    cdef inline len(self):
+        return self._length
+
+    cdef inline _ensure_alloced(self, ssize_t extra_length):
+        cdef ssize_t new_size = extra_length + self._length
+
+        if new_size > self._size:
+            self._reallocate(new_size)
+
+    cdef _reallocate(self, ssize_t new_size):
+        cdef char *new_buf
+
+        if new_size < _BUFFER_MAX_GROW:
+            new_size = _BUFFER_MAX_GROW
+        else:
+            # Add a little extra
+            new_size += _BUFFER_INITIAL_SIZE
+
+        if self._smallbuf_inuse:
+            new_buf = <char*>PyMem_Malloc(sizeof(char) * <size_t>new_size)
+            if new_buf is NULL:
+                self._buf = NULL
+                self._size = 0
+                self._length = 0
+                raise MemoryError
+            memcpy(new_buf, self._buf, <size_t>self._size)
+            self._size = new_size
+            self._buf = new_buf
+            self._smallbuf_inuse = False
+        else:
+            new_buf = <char*>PyMem_Realloc(<void*>self._buf, <size_t>new_size)
+            if new_buf is NULL:
+                PyMem_Free(self._buf)
+                self._buf = NULL
+                self._size = 0
+                self._length = 0
+                raise MemoryError
+            self._buf = new_buf
+            self._size = new_size
+
+    cdef inline start_message(self, char type):
+        if self._length != 0:
+            raise BufferError('cannot start_message for a non-empty buffer')
+        self._ensure_alloced(5)
+        self._message_mode = 1
+        self._buf[0] = type
+        self._length = 5
+
+    cdef inline end_message(self):
+        # "length-1" to exclude the message type byte
+        cdef ssize_t mlen = self._length - 1
+
+        self._check_readonly()
+        if not self._message_mode:
+            raise BufferError(
+                'end_message can only be called with start_message')
+        if self._length < 5:
+            raise BufferError('end_message: buffer is too small')
+        if mlen > _MAXINT32:
+            raise BufferError('end_message: message is too large')
+
+        hton.pack_int32(&self._buf[1], <int32_t>mlen)
+        return self
+
+    cdef write_buffer(self, WriteBuffer buf):
+        self._check_readonly()
+
+        if not buf._length:
+            return
+
+        self._ensure_alloced(buf._length)
+        memcpy(self._buf + self._length,
+               <void*>buf._buf,
+               <size_t>buf._length)
+        self._length += buf._length
+
+    cdef write_byte(self, char b):
+        self._check_readonly()
+
+        self._ensure_alloced(1)
+        self._buf[self._length] = b
+        self._length += 1
+
+    cdef write_bytes(self, bytes data):
+        cdef char* buf
+        cdef ssize_t len
+
+        cpython.PyBytes_AsStringAndSize(data, &buf, &len)
+        self.write_cstr(buf, len)
+
+    cdef write_bytestring(self, bytes string):
+        cdef char* buf
+        cdef ssize_t len
+
+        cpython.PyBytes_AsStringAndSize(string, &buf, &len)
+        # PyBytes_AsStringAndSize returns a null-terminated buffer,
+        # but the null byte is not counted in len. hence the + 1
+        self.write_cstr(buf, len + 1)
+
+    cdef write_str(self, str string, str encoding):
+        self.write_bytestring(string.encode(encoding))
+
+    cdef write_cstr(self, char *data, ssize_t len):
+        self._check_readonly()
+        self._ensure_alloced(len)
+
+        memcpy(self._buf + self._length, <void*>data, <size_t>len)
+        self._length += len
+
+    cdef write_int16(self, int16_t i):
+        self._check_readonly()
+        self._ensure_alloced(2)
+
+        hton.pack_int16(&self._buf[self._length], i)
+        self._length += 2
+
+    cdef write_int32(self, int32_t i):
+        self._check_readonly()
+        self._ensure_alloced(4)
+
+        hton.pack_int32(&self._buf[self._length], i)
+        self._length += 4
+
+    cdef write_int64(self, int64_t i):
+        self._check_readonly()
+        self._ensure_alloced(8)
+
+        hton.pack_int64(&self._buf[self._length], i)
+        self._length += 8
+
+    cdef write_float(self, float f):
+        self._check_readonly()
+        self._ensure_alloced(4)
+
+        hton.pack_float(&self._buf[self._length], f)
+        self._length += 4
+
+    cdef write_double(self, double d):
+        self._check_readonly()
+        self._ensure_alloced(8)
+
+        hton.pack_double(&self._buf[self._length], d)
+        self._length += 8
+
+    @staticmethod
+    cdef WriteBuffer new_message(char type):
+        cdef WriteBuffer buf
+        buf = WriteBuffer.__new__(WriteBuffer)
+        buf.start_message(type)
+        return buf
+
+    @staticmethod
+    cdef WriteBuffer new():
+        cdef WriteBuffer buf
+        buf = WriteBuffer.__new__(WriteBuffer)
+        return buf
+
+
+@cython.no_gc_clear
+@cython.final
+@cython.freelist(_BUFFER_FREELIST_SIZE)
+cdef class ReadBuffer:
+
+    def __cinit__(self):
+        self._bufs = collections.deque()
+        self._bufs_append = self._bufs.append
+        self._bufs_popleft = self._bufs.popleft
+        self._bufs_len = 0
+        self._buf0 = None
+        self._buf0_prev = None
+        self._pos0 = 0
+        self._len0 = 0
+        self._length = 0
+
+        self._current_message_type = 0
+        self._current_message_len = 0
+        self._current_message_len_unread = 0
+        self._current_message_ready = 0
+
+    cdef feed_data(self, data):
+        cdef:
+            ssize_t dlen
+            bytes data_bytes
+
+        if not cpython.PyBytes_CheckExact(data):
+            raise BufferError('feed_data: bytes object expected')
+        data_bytes = <bytes>data
+
+        dlen = cpython.Py_SIZE(data_bytes)
+        if dlen == 0:
+            # EOF?
+            return
+
+        self._bufs_append(data_bytes)
+        self._length += dlen
+
+        if self._bufs_len == 0:
+            # First buffer
+            self._len0 = dlen
+            self._buf0 = data_bytes
+
+        self._bufs_len += 1
+
+    cdef inline _ensure_first_buf(self):
+        if self._len0 == 0:
+            raise BufferError('empty first buffer')
+
+        if self._pos0 == self._len0:
+            self._switch_to_next_buf()
+
+    cdef _switch_to_next_buf(self):
+        # The first buffer is fully read, discard it
+        self._bufs_popleft()
+        self._bufs_len -= 1
+
+        # Shouldn't fail, since we've checked that `_length >= 1`
+        # in _ensure_first_buf()
+        self._buf0_prev = self._buf0
+        self._buf0 = <bytes>self._bufs[0]
+
+        self._pos0 = 0
+        self._len0 = len(self._buf0)
+
+        if ASYNCPG_DEBUG:
+            if self._len0 < 1:
+                raise RuntimeError(
+                    'debug: second buffer of ReadBuffer is empty')
+
+    cdef inline char* _try_read_bytes(self, ssize_t nbytes):
+        # Important: caller must call _ensure_first_buf() prior
+        # to calling try_read_bytes, and must not overread
+
+        cdef:
+            char * result
+
+        if ASYNCPG_DEBUG:
+            if nbytes > self._length:
+                return NULL
+
+        if self._current_message_ready:
+            if self._current_message_len_unread < nbytes:
+                return NULL
+
+        if self._pos0 + nbytes <= self._len0:
+            result = cpython.PyBytes_AS_STRING(self._buf0)
+            result += self._pos0
+            self._pos0 += nbytes
+            self._length -= nbytes
+            if self._current_message_ready:
+                self._current_message_len_unread -= nbytes
+            return result
+        else:
+            return NULL
+
+    cdef inline read(self, ssize_t nbytes):
+        cdef:
+            object result
+            ssize_t nread
+            char *buf
+
+        self._ensure_first_buf()
+        buf = self._try_read_bytes(nbytes)
+        if buf != NULL:
+            return Memory.new(buf, self._buf0, nbytes)
+
+        if nbytes > self._length:
+            raise BufferError(
+                'not enough data to read {} bytes'.format(nbytes))
+
+        if self._current_message_ready:
+            self._current_message_len_unread -= nbytes
+            if self._current_message_len_unread < 0:
+                raise BufferError('buffer overread')
+
+        result = bytearray()
+        while True:
+            if self._pos0 + nbytes > self._len0:
+                result.extend(self._buf0[self._pos0:])
+                nread = self._len0 - self._pos0
+                self._pos0 = self._len0
+                self._length -= nread
+                nbytes -= nread
+                self._ensure_first_buf()
+
+            else:
+                result.extend(self._buf0[self._pos0:self._pos0 + nbytes])
+                self._pos0 += nbytes
+                self._length -= nbytes
+                return Memory.new(
+                    PyByteArray_AsString(result),
+                    result,
+                    len(result))
+
+    cdef inline read_byte(self):
+        cdef char* first_byte
+
+        if ASYNCPG_DEBUG:
+            if not self._buf0:
+                raise RuntimeError(
+                    'debug: first buffer of ReadBuffer is empty')
+
+        self._ensure_first_buf()
+        first_byte = self._try_read_bytes(1)
+        if first_byte is NULL:
+            raise BufferError('not enough data to read one byte')
+
+        return first_byte[0]
+
+    cdef inline read_bytes(self, ssize_t n):
+        cdef:
+            Memory mem
+            char *cbuf
+
+        self._ensure_first_buf()
+        cbuf = self._try_read_bytes(n)
+        if cbuf != NULL:
+            return cbuf
+        else:
+            mem = <Memory>(self.read(n))
+            return mem.buf
+
+    cdef inline read_int32(self):
+        cdef:
+            Memory mem
+            char *cbuf
+
+        self._ensure_first_buf()
+        cbuf = self._try_read_bytes(4)
+        if cbuf != NULL:
+            return hton.unpack_int32(cbuf)
+        else:
+            mem = <Memory>(self.read(4))
+            return hton.unpack_int32(mem.buf)
+
+    cdef inline read_int16(self):
+        cdef:
+            Memory mem
+            char *cbuf
+
+        self._ensure_first_buf()
+        cbuf = self._try_read_bytes(2)
+        if cbuf != NULL:
+            return hton.unpack_int16(cbuf)
+        else:
+            mem = <Memory>(self.read(2))
+            return hton.unpack_int16(mem.buf)
+
+    cdef inline read_cstr(self):
+        if not self._current_message_ready:
+            raise BufferError(
+                'read_cstr only works when the message guaranteed '
+                'to be in the buffer')
+
+        cdef:
+            ssize_t pos
+            ssize_t nread
+            bytes result
+            char* buf
+            char* buf_start
+
+        self._ensure_first_buf()
+
+        buf_start = cpython.PyBytes_AS_STRING(self._buf0)
+        buf = buf_start + self._pos0
+        while buf - buf_start < self._len0:
+            if buf[0] == 0:
+                pos = buf - buf_start
+                nread = pos - self._pos0
+                buf = self._try_read_bytes(nread + 1)
+                if buf != NULL:
+                    return cpython.PyBytes_FromStringAndSize(buf, nread)
+                else:
+                    break
+            else:
+                buf += 1
+
+        result = b''
+        while True:
+            pos = self._buf0.find(b'\x00', self._pos0)
+            if pos >= 0:
+                result += self._buf0[self._pos0 : pos]
+                nread = pos - self._pos0 + 1
+                self._pos0 = pos + 1
+                self._length -= nread
+
+                self._current_message_len_unread -= nread
+                if self._current_message_len_unread < 0:
+                    raise BufferError('read_cstr: buffer overread')
+
+                return result
+
+            else:
+                result += self._buf0[self._pos0:]
+                nread = self._len0 - self._pos0
+                self._pos0 = self._len0
+                self._length -= nread
+
+                self._current_message_len_unread -= nread
+                if self._current_message_len_unread < 0:
+                    raise BufferError('read_cstr: buffer overread')
+
+                self._ensure_first_buf()
+
+    cdef int32_t has_message(self) except -1:
+        cdef:
+            char* cbuf
+
+        if self._current_message_ready:
+            return 1
+
+        if self._current_message_type == 0:
+            if self._length < 1:
+                return 0
+            self._ensure_first_buf()
+            cbuf = self._try_read_bytes(1)
+            if cbuf == NULL:
+                raise BufferError(
+                    'failed to read one byte on a non-empty buffer')
+            self._current_message_type = cbuf[0]
+
+        if self._current_message_len == 0:
+            if self._length < 4:
+                return 0
+
+            self._ensure_first_buf()
+            cbuf = self._try_read_bytes(4)
+            if cbuf != NULL:
+                self._current_message_len = hton.unpack_int32(cbuf)
+            else:
+                self._current_message_len = self.read_int32()
+
+            self._current_message_len_unread = self._current_message_len - 4
+
+        if self._length < self._current_message_len_unread:
+            return 0
+
+        self._current_message_ready = 1
+        return 1
+
+    cdef inline char* try_consume_message(self, ssize_t* len):
+        cdef ssize_t buf_len
+
+        if not self._current_message_ready:
+            return NULL
+
+        self._ensure_first_buf()
+        buf_len = self._current_message_len_unread
+        buf = self._try_read_bytes(buf_len)
+        if buf != NULL:
+            len[0] = buf_len
+            self._discard_message()
+        return buf
+
+    cdef Memory consume_message(self):
+        if not self._current_message_ready:
+            raise BufferError('no message to consume')
+        if self._current_message_len_unread > 0:
+            mem = self.read(self._current_message_len_unread)
+        else:
+            mem = None
+        self._discard_message()
+        return mem
+
+    cdef discard_message(self):
+        if self._current_message_type == 0:
+            # Already discarded
+            return
+
+        if not self._current_message_ready:
+            raise BufferError('no message to discard')
+
+        if self._current_message_len_unread:
+            if ASYNCPG_DEBUG:
+                mtype = chr(self._current_message_type)
+
+            discarded = self.consume_message()
+
+            if ASYNCPG_DEBUG:
+                print('!!! discarding message {!r} unread data: {!r}'.format(
+                    mtype,
+                    (<Memory>discarded).as_bytes()))
+
+        self._discard_message()
+
+    cdef inline _discard_message(self):
+        self._current_message_type = 0
+        self._current_message_len = 0
+        self._current_message_ready = 0
+        self._current_message_len_unread = 0
+
+    cdef inline char get_message_type(self):
+        return self._current_message_type
+
+    cdef inline int32_t get_message_length(self):
+        return self._current_message_len
+
+    @staticmethod
+    cdef ReadBuffer new_message_parser(object data):
+        cdef ReadBuffer buf
+
+        buf = ReadBuffer.__new__(ReadBuffer)
+        buf.feed_data(data)
+
+        buf._current_message_ready = 1
+        buf._current_message_len_unread = buf._len0
+
+        return buf
+
+
+@cython.no_gc_clear
+@cython.final
+@cython.freelist(_BUFFER_FREELIST_SIZE)
+cdef class FastReadBuffer:
+
+    cdef inline const char* read(self, ssize_t n) except NULL:
+        cdef const char *result
+
+        if n > self.len:
+            self._raise_ins_err(n, self.len)
+
+        result = self.buf
+        self.buf += n
+        self.len -= n
+
+        return result
+
+    cdef inline const char* read_all(self):
+        cdef const char *result
+        result = self.buf
+        self.buf += self.len
+        self.len = 0
+        return result
+
+    cdef inline FastReadBuffer slice_from(self, FastReadBuffer source,
+                                          ssize_t len):
+        self.buf = source.read(len)
+        self.len = len
+        return self
+
+    cdef _raise_ins_err(self, ssize_t n, ssize_t len):
+        raise BufferError(
+            'insufficient data in buffer: requested {}, remaining {}'.
+                format(n, self.len))
+
+    @staticmethod
+    cdef FastReadBuffer new():
+        return FastReadBuffer.__new__(FastReadBuffer)
diff --git a/asyncpg/protocol/codecs/__init__.py b/asyncpg/protocol/codecs/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/asyncpg/protocol/codecs/array.pyx b/asyncpg/protocol/codecs/array.pyx
new file mode 100644 (file)
index 0000000..5c13b2e
--- /dev/null
@@ -0,0 +1,789 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+from collections.abc import Container as ContainerABC
+
+
+DEF ARRAY_MAXDIM = 6  # defined in postgresql/src/includes/c.h
+
+# "NULL"
+cdef Py_UCS4 *APG_NULL = [0x004E, 0x0055, 0x004C, 0x004C, 0x0000]
+
+
+ctypedef object (*encode_func_ex)(ConnectionSettings settings,
+                                  WriteBuffer buf,
+                                  object obj,
+                                  const void *arg)
+
+
+ctypedef object (*decode_func_ex)(ConnectionSettings settings,
+                                  FastReadBuffer buf,
+                                  const void *arg)
+
+
+cdef inline bint _is_trivial_container(object obj):
+    return cpython.PyUnicode_Check(obj) or cpython.PyBytes_Check(obj) or \
+            PyByteArray_Check(obj) or PyMemoryView_Check(obj)
+
+
+cdef inline _is_container(object obj):
+    return not _is_trivial_container(obj) and isinstance(obj, ContainerABC)
+
+
+cdef inline _is_sub_array(object obj):
+    return not _is_trivial_container(obj) and isinstance(obj, ContainerABC) \
+            and not cpython.PyTuple_Check(obj)
+
+
+cdef _get_array_shape(object obj, int32_t *dims, int32_t *ndims):
+    cdef:
+        ssize_t mylen = len(obj)
+        ssize_t elemlen = -2
+        object it
+
+    if mylen > _MAXINT32:
+        raise ValueError('too many elements in array value')
+
+    if ndims[0] > ARRAY_MAXDIM:
+        raise ValueError(
+            'number of array dimensions ({}) exceed the maximum expected ({})'.
+                format(ndims[0], ARRAY_MAXDIM))
+
+    dims[ndims[0] - 1] = <int32_t>mylen
+
+    for elem in obj:
+        if _is_sub_array(elem):
+            if elemlen == -2:
+                elemlen = len(elem)
+                if elemlen > _MAXINT32:
+                    raise ValueError('too many elements in array value')
+                ndims[0] += 1
+                _get_array_shape(elem, dims, ndims)
+            else:
+                if len(elem) != elemlen:
+                    raise ValueError('non-homogeneous array')
+        else:
+            if elemlen >= 0:
+                raise ValueError('non-homogeneous array')
+            else:
+                elemlen = -1
+
+
+cdef _write_array_data(ConnectionSettings settings, object obj, int32_t ndims,
+                       int32_t dim, WriteBuffer elem_data,
+                       encode_func_ex encoder, const void *encoder_arg):
+    if dim < ndims - 1:
+        for item in obj:
+            _write_array_data(settings, item, ndims, dim + 1, elem_data,
+                              encoder, encoder_arg)
+    else:
+        for item in obj:
+            if item is None:
+                elem_data.write_int32(-1)
+            else:
+                try:
+                    encoder(settings, elem_data, item, encoder_arg)
+                except TypeError as e:
+                    raise ValueError(
+                        'invalid array element: {}'.format(e.args[0])) from None
+
+
+cdef inline array_encode(ConnectionSettings settings, WriteBuffer buf,
+                         object obj, uint32_t elem_oid,
+                         encode_func_ex encoder, const void *encoder_arg):
+    cdef:
+        WriteBuffer elem_data
+        int32_t dims[ARRAY_MAXDIM]
+        int32_t ndims = 1
+        int32_t i
+
+    if not _is_container(obj):
+        raise TypeError(
+            'a non-trivial iterable expected (got type {!r})'.format(
+                type(obj).__name__))
+
+    _get_array_shape(obj, dims, &ndims)
+
+    elem_data = WriteBuffer.new()
+
+    if ndims > 1:
+        _write_array_data(settings, obj, ndims, 0, elem_data,
+                          encoder, encoder_arg)
+    else:
+        for i, item in enumerate(obj):
+            if item is None:
+                elem_data.write_int32(-1)
+            else:
+                try:
+                    encoder(settings, elem_data, item, encoder_arg)
+                except TypeError as e:
+                    raise ValueError(
+                        'invalid array element at index {}: {}'.format(
+                            i, e.args[0])) from None
+
+    buf.write_int32(12 + 8 * ndims + elem_data.len())
+    # Number of dimensions
+    buf.write_int32(ndims)
+    # flags
+    buf.write_int32(0)
+    # element type
+    buf.write_int32(<int32_t>elem_oid)
+    # upper / lower bounds
+    for i in range(ndims):
+        buf.write_int32(dims[i])
+        buf.write_int32(1)
+    # element data
+    buf.write_buffer(elem_data)
+
+
+cdef inline array_decode(ConnectionSettings settings, FastReadBuffer buf,
+                         decode_func_ex decoder, const void *decoder_arg):
+    cdef:
+        int32_t ndims = hton.unpack_int32(buf.read(4))
+        int32_t flags = hton.unpack_int32(buf.read(4))
+        uint32_t elem_oid = <uint32_t>hton.unpack_int32(buf.read(4))
+        list result
+        int i
+        int32_t elem_len
+        int32_t elem_count = 1
+        FastReadBuffer elem_buf = FastReadBuffer.new()
+        int32_t dims[ARRAY_MAXDIM]
+        Codec elem_codec
+
+    if ndims == 0:
+        result = cpython.PyList_New(0)
+        return result
+
+    if ndims > ARRAY_MAXDIM:
+        raise RuntimeError(
+            'number of array dimensions ({}) exceed the maximum expected ({})'.
+            format(ndims, ARRAY_MAXDIM))
+
+    if decoder == NULL:
+        # No decoder is known beforehand, look it up
+
+        elem_codec = settings.get_data_codec(elem_oid)
+        if elem_codec is None or not elem_codec.has_decoder():
+            raise RuntimeError(
+                'no decoder for type OID {}'.format(elem_oid))
+
+        decoder = codec_decode_func_ex
+        decoder_arg = <void*>(<cpython.PyObject>elem_codec)
+
+    for i in range(ndims):
+        dims[i] = hton.unpack_int32(buf.read(4))
+        # Ignore the lower bound information
+        buf.read(4)
+
+    if ndims == 1:
+        # Fast path for flat arrays
+        elem_count = dims[0]
+        result = cpython.PyList_New(elem_count)
+
+        for i in range(elem_count):
+            elem_len = hton.unpack_int32(buf.read(4))
+            if elem_len == -1:
+                elem = None
+            else:
+                elem_buf.slice_from(buf, elem_len)
+                elem = decoder(settings, elem_buf, decoder_arg)
+
+            cpython.Py_INCREF(elem)
+            cpython.PyList_SET_ITEM(result, i, elem)
+
+    else:
+        result = _nested_array_decode(settings, buf,
+                                      decoder, decoder_arg, ndims, dims,
+                                      elem_buf)
+
+    return result
+
+
+cdef inline _nested_array_decode(ConnectionSettings settings,
+                                 FastReadBuffer buf,
+                                 decode_func_ex decoder,
+                                 const void *decoder_arg,
+                                 int32_t ndims, int32_t *dims,
+                                 FastReadBuffer elem_buf):
+
+    cdef:
+        int32_t elem_len
+        int32_t d1, d2, d3, d4, d5, d6
+        list result
+        object elem
+        list stride1, stride2, stride3, stride4, stride5
+
+    # Nested array.  The approach here is dumb, but fast: rely
+    # on the dimension limit and shape data using nested loops.
+    # Alas, Cython doesn't have preprocessor macros.
+    #
+    result = cpython.PyList_New(dims[0])
+
+    for d1 in range(dims[0]):
+        stride1 = cpython.PyList_New(dims[1])
+        cpython.Py_INCREF(stride1)
+        cpython.PyList_SET_ITEM(result, d1, stride1)
+
+        for d2 in range(dims[1]):
+            if ndims == 2:
+                elem_len = hton.unpack_int32(buf.read(4))
+                if elem_len == -1:
+                    elem = None
+                else:
+                    elem = decoder(settings,
+                                   elem_buf.slice_from(buf, elem_len),
+                                   decoder_arg)
+
+                cpython.Py_INCREF(elem)
+                cpython.PyList_SET_ITEM(stride1, d2, elem)
+
+            else:
+                stride2 = cpython.PyList_New(dims[2])
+                cpython.Py_INCREF(stride2)
+                cpython.PyList_SET_ITEM(stride1, d2, stride2)
+
+                for d3 in range(dims[2]):
+                    if ndims == 3:
+                        elem_len = hton.unpack_int32(buf.read(4))
+                        if elem_len == -1:
+                            elem = None
+                        else:
+                            elem = decoder(settings,
+                                           elem_buf.slice_from(buf, elem_len),
+                                           decoder_arg)
+
+                        cpython.Py_INCREF(elem)
+                        cpython.PyList_SET_ITEM(stride2, d3, elem)
+
+                    else:
+                        stride3 = cpython.PyList_New(dims[3])
+                        cpython.Py_INCREF(stride3)
+                        cpython.PyList_SET_ITEM(stride2, d3, stride3)
+
+                        for d4 in range(dims[3]):
+                            if ndims == 4:
+                                elem_len = hton.unpack_int32(buf.read(4))
+                                if elem_len == -1:
+                                    elem = None
+                                else:
+                                    elem = decoder(settings,
+                                                   elem_buf.slice_from(buf, elem_len),
+                                                   decoder_arg)
+
+                                cpython.Py_INCREF(elem)
+                                cpython.PyList_SET_ITEM(stride3, d4, elem)
+
+                            else:
+                                stride4 = cpython.PyList_New(dims[4])
+                                cpython.Py_INCREF(stride4)
+                                cpython.PyList_SET_ITEM(stride3, d4, stride4)
+
+                                for d5 in range(dims[4]):
+                                    if ndims == 5:
+                                        elem_len = hton.unpack_int32(buf.read(4))
+                                        if elem_len == -1:
+                                            elem = None
+                                        else:
+                                            elem = decoder(settings,
+                                                           elem_buf.slice_from(buf, elem_len),
+                                                           decoder_arg)
+
+                                        cpython.Py_INCREF(elem)
+                                        cpython.PyList_SET_ITEM(stride4, d5, elem)
+
+                                    else:
+                                        stride5 = cpython.PyList_New(dims[5])
+                                        cpython.Py_INCREF(stride5)
+                                        cpython.PyList_SET_ITEM(stride4, d5, stride5)
+
+                                        for d6 in range(dims[5]):
+                                            elem_len = hton.unpack_int32(buf.read(4))
+                                            if elem_len == -1:
+                                                elem = None
+                                            else:
+                                                elem = decoder(settings,
+                                                               elem_buf.slice_from(buf, elem_len),
+                                                               decoder_arg)
+
+                                            cpython.Py_INCREF(elem)
+                                            cpython.PyList_SET_ITEM(stride5, d6, elem)
+
+    return result
+
+
+cdef textarray_decode(ConnectionSettings settings, FastReadBuffer buf,
+                      decode_func_ex decoder, const void *decoder_arg,
+                      Py_UCS4 typdelim):
+    cdef:
+        Py_UCS4 *array_text
+        str s
+
+    # Make a copy of array data since we will be mutating it for
+    # the purposes of element decoding.
+    s = text_decode(settings, buf)
+    array_text = PyUnicode_AsUCS4Copy(s)
+
+    try:
+        return _textarray_decode(
+            settings, array_text, decoder, decoder_arg, typdelim)
+    except ValueError as e:
+        raise ValueError(
+            'malformed array literal {!r}: {}'.format(s, e.args[0]))
+    finally:
+        PyMem_Free(array_text)
+
+
+cdef _textarray_decode(ConnectionSettings settings,
+                       Py_UCS4 *array_text,
+                       decode_func_ex decoder,
+                       const void *decoder_arg,
+                       Py_UCS4 typdelim):
+
+    cdef:
+        bytearray array_bytes
+        list result
+        list new_stride
+        Py_UCS4 *ptr
+        int32_t ndims = 0
+        int32_t ubound = 0
+        int32_t lbound = 0
+        int32_t dims[ARRAY_MAXDIM]
+        int32_t inferred_dims[ARRAY_MAXDIM]
+        int32_t inferred_ndims = 0
+        void *strides[ARRAY_MAXDIM]
+        int32_t indexes[ARRAY_MAXDIM]
+        int32_t nest_level = 0
+        int32_t item_level = 0
+        bint end_of_array = False
+
+        bint end_of_item = False
+        bint has_quoting = False
+        bint strip_spaces = False
+        bint in_quotes = False
+        Py_UCS4 *item_start
+        Py_UCS4 *item_ptr
+        Py_UCS4 *item_end
+
+        int i
+        object item
+        str item_text
+        FastReadBuffer item_buf = FastReadBuffer.new()
+        char *pg_item_str
+        ssize_t pg_item_len
+
+    ptr = array_text
+
+    while True:
+        while apg_ascii_isspace(ptr[0]):
+            ptr += 1
+
+        if ptr[0] != '[':
+            # Finished parsing dimensions spec.
+            break
+
+        ptr += 1  # '['
+
+        if ndims > ARRAY_MAXDIM:
+            raise ValueError(
+                'number of array dimensions ({}) exceed the '
+                'maximum expected ({})'.format(ndims, ARRAY_MAXDIM))
+
+        ptr = apg_parse_int32(ptr, &ubound)
+        if ptr == NULL:
+            raise ValueError('missing array dimension value')
+
+        if ptr[0] == ':':
+            ptr += 1
+            lbound = ubound
+
+            # [lower:upper] spec.  We disregard the lbound for decoding.
+            ptr = apg_parse_int32(ptr, &ubound)
+            if ptr == NULL:
+                raise ValueError('missing array dimension value')
+        else:
+            lbound = 1
+
+        if ptr[0] != ']':
+            raise ValueError('missing \']\' after array dimensions')
+
+        ptr += 1  # ']'
+
+        dims[ndims] = ubound - lbound + 1
+        ndims += 1
+
+    if ndims != 0:
+        # If dimensions were given, the '=' token is expected.
+        if ptr[0] != '=':
+            raise ValueError('missing \'=\' after array dimensions')
+
+        ptr += 1  # '='
+
+        # Skip any whitespace after the '=', whitespace
+        # before was consumed in the above loop.
+        while apg_ascii_isspace(ptr[0]):
+            ptr += 1
+
+        # Infer the dimensions from the brace structure in the
+        # array literal body, and check that it matches the explicit
+        # spec.  This also validates that the array literal is sane.
+        _infer_array_dims(ptr, typdelim, inferred_dims, &inferred_ndims)
+
+        if inferred_ndims != ndims:
+            raise ValueError(
+                'specified array dimensions do not match array content')
+
+        for i in range(ndims):
+            if inferred_dims[i] != dims[i]:
+                raise ValueError(
+                    'specified array dimensions do not match array content')
+    else:
+        # Infer the dimensions from the brace structure in the array literal
+        # body.  This also validates that the array literal is sane.
+        _infer_array_dims(ptr, typdelim, dims, &ndims)
+
+    while not end_of_array:
+        # We iterate over the literal character by character
+        # and modify the string in-place removing the array-specific
+        # quoting and determining the boundaries of each element.
+        end_of_item = has_quoting = in_quotes = False
+        strip_spaces = True
+
+        # Pointers to array element start, end, and the current pointer
+        # tracking the position where characters are written when
+        # escaping is folded.
+        item_start = item_end = item_ptr = ptr
+        item_level = 0
+
+        while not end_of_item:
+            if ptr[0] == '"':
+                in_quotes = not in_quotes
+                if in_quotes:
+                    strip_spaces = False
+                else:
+                    item_end = item_ptr
+                has_quoting = True
+
+            elif ptr[0] == '\\':
+                # Quoted character, collapse the backslash.
+                ptr += 1
+                has_quoting = True
+                item_ptr[0] = ptr[0]
+                item_ptr += 1
+                strip_spaces = False
+                item_end = item_ptr
+
+            elif in_quotes:
+                # Consume the string until we see the closing quote.
+                item_ptr[0] = ptr[0]
+                item_ptr += 1
+
+            elif ptr[0] == '{':
+                # Nesting level increase.
+                nest_level += 1
+
+                indexes[nest_level - 1] = 0
+                new_stride = cpython.PyList_New(dims[nest_level - 1])
+                strides[nest_level - 1] = \
+                    <void*>(<cpython.PyObject>new_stride)
+
+                if nest_level > 1:
+                    cpython.Py_INCREF(new_stride)
+                    cpython.PyList_SET_ITEM(
+                        <object><cpython.PyObject*>strides[nest_level - 2],
+                        indexes[nest_level - 2],
+                        new_stride)
+                else:
+                    result = new_stride
+
+            elif ptr[0] == '}':
+                if item_level == 0:
+                    # Make sure we keep track of which nesting
+                    # level the item belongs to, as the loop
+                    # will continue to consume closing braces
+                    # until the delimiter or the end of input.
+                    item_level = nest_level
+
+                nest_level -= 1
+
+                if nest_level == 0:
+                    end_of_array = end_of_item = True
+
+            elif ptr[0] == typdelim:
+                # Array element delimiter,
+                end_of_item = True
+                if item_level == 0:
+                    item_level = nest_level
+
+            elif apg_ascii_isspace(ptr[0]):
+                if not strip_spaces:
+                    item_ptr[0] = ptr[0]
+                    item_ptr += 1
+                # Ignore the leading literal whitespace.
+
+            else:
+                item_ptr[0] = ptr[0]
+                item_ptr += 1
+                strip_spaces = False
+                item_end = item_ptr
+
+            ptr += 1
+
+        # end while not end_of_item
+
+        if item_end == item_start:
+            # Empty array
+            continue
+
+        item_end[0] = '\0'
+
+        if not has_quoting and apg_strcasecmp(item_start, APG_NULL) == 0:
+            # NULL element.
+            item = None
+        else:
+            # XXX: find a way to avoid the redundant encode/decode
+            # cycle here.
+            item_text = PyUnicode_FromKindAndData(
+                PyUnicode_4BYTE_KIND,
+                <void *>item_start,
+                item_end - item_start)
+
+            # Prepare the element buffer and call the text decoder
+            # for the element type.
+            as_pg_string_and_size(
+                settings, item_text, &pg_item_str, &pg_item_len)
+            item_buf.buf = pg_item_str
+            item_buf.len = pg_item_len
+            item = decoder(settings, item_buf, decoder_arg)
+
+        # Place the decoded element in the array.
+        cpython.Py_INCREF(item)
+        cpython.PyList_SET_ITEM(
+            <object><cpython.PyObject*>strides[item_level - 1],
+            indexes[item_level - 1],
+            item)
+
+        indexes[nest_level - 1] += 1
+
+    return result
+
+
+cdef enum _ArrayParseState:
+    APS_START = 1
+    APS_STRIDE_STARTED = 2
+    APS_STRIDE_DONE = 3
+    APS_STRIDE_DELIMITED = 4
+    APS_ELEM_STARTED = 5
+    APS_ELEM_DELIMITED = 6
+
+
+cdef _UnexpectedCharacter(const Py_UCS4 *array_text, const Py_UCS4 *ptr):
+    return ValueError('unexpected character {!r} at position {}'.format(
+        cpython.PyUnicode_FromOrdinal(<int>ptr[0]), ptr - array_text + 1))
+
+
+cdef _infer_array_dims(const Py_UCS4 *array_text,
+                       Py_UCS4 typdelim,
+                       int32_t *dims,
+                       int32_t *ndims):
+    cdef:
+        const Py_UCS4 *ptr = array_text
+        int i
+        int nest_level = 0
+        bint end_of_array = False
+        bint end_of_item = False
+        bint in_quotes = False
+        bint array_is_empty = True
+        int stride_len[ARRAY_MAXDIM]
+        int prev_stride_len[ARRAY_MAXDIM]
+        _ArrayParseState parse_state = APS_START
+
+    for i in range(ARRAY_MAXDIM):
+        dims[i] = prev_stride_len[i] = 0
+        stride_len[i] = 1
+
+    while not end_of_array:
+        end_of_item = False
+
+        while not end_of_item:
+            if ptr[0] == '\0':
+                raise ValueError('unexpected end of string')
+
+            elif ptr[0] == '"':
+                if (parse_state not in (APS_STRIDE_STARTED,
+                                        APS_ELEM_DELIMITED) and
+                        not (parse_state == APS_ELEM_STARTED and in_quotes)):
+                    raise _UnexpectedCharacter(array_text, ptr)
+
+                in_quotes = not in_quotes
+                if in_quotes:
+                    parse_state = APS_ELEM_STARTED
+                    array_is_empty = False
+
+            elif ptr[0] == '\\':
+                if parse_state not in (APS_STRIDE_STARTED,
+                                       APS_ELEM_STARTED,
+                                       APS_ELEM_DELIMITED):
+                    raise _UnexpectedCharacter(array_text, ptr)
+
+                parse_state = APS_ELEM_STARTED
+                array_is_empty = False
+
+                if ptr[1] != '\0':
+                    ptr += 1
+                else:
+                    raise ValueError('unexpected end of string')
+
+            elif in_quotes:
+                # Ignore everything inside the quotes.
+                pass
+
+            elif ptr[0] == '{':
+                if parse_state not in (APS_START,
+                                       APS_STRIDE_STARTED,
+                                       APS_STRIDE_DELIMITED):
+                    raise _UnexpectedCharacter(array_text, ptr)
+
+                parse_state = APS_STRIDE_STARTED
+                if nest_level >= ARRAY_MAXDIM:
+                    raise ValueError(
+                        'number of array dimensions ({}) exceed the '
+                        'maximum expected ({})'.format(
+                            nest_level, ARRAY_MAXDIM))
+
+                dims[nest_level] = 0
+                nest_level += 1
+                if ndims[0] < nest_level:
+                    ndims[0] = nest_level
+
+            elif ptr[0] == '}':
+                if (parse_state not in (APS_ELEM_STARTED, APS_STRIDE_DONE) and
+                        not (nest_level == 1 and
+                             parse_state == APS_STRIDE_STARTED)):
+                    raise _UnexpectedCharacter(array_text, ptr)
+
+                parse_state = APS_STRIDE_DONE
+
+                if nest_level == 0:
+                    raise _UnexpectedCharacter(array_text, ptr)
+
+                nest_level -= 1
+
+                if (prev_stride_len[nest_level] != 0 and
+                        stride_len[nest_level] != prev_stride_len[nest_level]):
+                    raise ValueError(
+                        'inconsistent sub-array dimensions'
+                        ' at position {}'.format(
+                            ptr - array_text + 1))
+
+                prev_stride_len[nest_level] = stride_len[nest_level]
+                stride_len[nest_level] = 1
+                if nest_level == 0:
+                    end_of_array = end_of_item = True
+                else:
+                    dims[nest_level - 1] += 1
+
+            elif ptr[0] == typdelim:
+                if parse_state not in (APS_ELEM_STARTED, APS_STRIDE_DONE):
+                    raise _UnexpectedCharacter(array_text, ptr)
+
+                if parse_state == APS_STRIDE_DONE:
+                    parse_state = APS_STRIDE_DELIMITED
+                else:
+                    parse_state = APS_ELEM_DELIMITED
+                end_of_item = True
+                stride_len[nest_level - 1] += 1
+
+            elif not apg_ascii_isspace(ptr[0]):
+                if parse_state not in (APS_STRIDE_STARTED,
+                                       APS_ELEM_STARTED,
+                                       APS_ELEM_DELIMITED):
+                    raise _UnexpectedCharacter(array_text, ptr)
+
+                parse_state = APS_ELEM_STARTED
+                array_is_empty = False
+
+            if not end_of_item:
+                ptr += 1
+
+        if not array_is_empty:
+            dims[ndims[0] - 1] += 1
+
+        ptr += 1
+
+    # only whitespace is allowed after the closing brace
+    while ptr[0] != '\0':
+        if not apg_ascii_isspace(ptr[0]):
+            raise _UnexpectedCharacter(array_text, ptr)
+
+        ptr += 1
+
+    if array_is_empty:
+        ndims[0] = 0
+
+
+cdef int4_encode_ex(ConnectionSettings settings, WriteBuffer buf, object obj,
+                    const void *arg):
+    return int4_encode(settings, buf, obj)
+
+
+cdef int4_decode_ex(ConnectionSettings settings, FastReadBuffer buf,
+                    const void *arg):
+    return int4_decode(settings, buf)
+
+
+cdef arrayoid_encode(ConnectionSettings settings, WriteBuffer buf, items):
+    array_encode(settings, buf, items, OIDOID,
+                 <encode_func_ex>&int4_encode_ex, NULL)
+
+
+cdef arrayoid_decode(ConnectionSettings settings, FastReadBuffer buf):
+    return array_decode(settings, buf, <decode_func_ex>&int4_decode_ex, NULL)
+
+
+cdef text_encode_ex(ConnectionSettings settings, WriteBuffer buf, object obj,
+                    const void *arg):
+    return text_encode(settings, buf, obj)
+
+
+cdef text_decode_ex(ConnectionSettings settings, FastReadBuffer buf,
+                    const void *arg):
+    return text_decode(settings, buf)
+
+
+cdef arraytext_encode(ConnectionSettings settings, WriteBuffer buf, items):
+    array_encode(settings, buf, items, TEXTOID,
+                 <encode_func_ex>&text_encode_ex, NULL)
+
+
+cdef arraytext_decode(ConnectionSettings settings, FastReadBuffer buf):
+    return array_decode(settings, buf, <decode_func_ex>&text_decode_ex, NULL)
+
+
+cdef anyarray_decode(ConnectionSettings settings, FastReadBuffer buf):
+    return array_decode(settings, buf, NULL, NULL)
+
+
+cdef init_array_codecs():
+    register_core_codec(ANYARRAYOID,
+                        NULL,
+                        <decode_func>&anyarray_decode,
+                        PG_FORMAT_BINARY)
+
+    # oid[] and text[] are registered as core codecs
+    # to make type introspection query work
+    #
+    register_core_codec(_OIDOID,
+                        <encode_func>&arrayoid_encode,
+                        <decode_func>&arrayoid_decode,
+                        PG_FORMAT_BINARY)
+
+    register_core_codec(_TEXTOID,
+                        <encode_func>&arraytext_encode,
+                        <decode_func>&arraytext_decode,
+                        PG_FORMAT_BINARY)
+
+init_array_codecs()
diff --git a/asyncpg/protocol/codecs/base.pxd b/asyncpg/protocol/codecs/base.pxd
new file mode 100644 (file)
index 0000000..fe5d7b0
--- /dev/null
@@ -0,0 +1,159 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+ctypedef object (*encode_func)(ConnectionSettings settings,
+                               WriteBuffer buf,
+                               object obj)
+
+ctypedef object (*decode_func)(ConnectionSettings settings,
+                               FastReadBuffer buf)
+
+ctypedef object (*codec_encode_func)(Codec codec,
+                                     ConnectionSettings settings,
+                                     WriteBuffer buf,
+                                     object obj)
+
+ctypedef object (*codec_decode_func)(Codec codec,
+                                     ConnectionSettings settings,
+                                     FastReadBuffer buf)
+
+
+cdef enum CodecType:
+    CODEC_UNDEFINED = 0
+    CODEC_C         = 1
+    CODEC_PY        = 2
+    CODEC_ARRAY     = 3
+    CODEC_COMPOSITE = 4
+    CODEC_RANGE     = 5
+
+
+cdef enum CodecFormat:
+    PG_FORMAT_ANY = -1
+    PG_FORMAT_TEXT = 0
+    PG_FORMAT_BINARY = 1
+
+
+cdef class Codec:
+    cdef:
+        uint32_t        oid
+
+        str             name
+        str             schema
+        str             kind
+
+        CodecType       type
+        CodecFormat     format
+
+        encode_func     c_encoder
+        decode_func     c_decoder
+
+        object          py_encoder
+        object          py_decoder
+
+        # arrays
+        Codec           element_codec
+        Py_UCS4         element_delimiter
+
+        # composite types
+        tuple           element_type_oids
+        object          element_names
+        list            element_codecs
+
+        # Pointers to actual encoder/decoder functions for this codec
+        codec_encode_func encoder
+        codec_decode_func decoder
+
+    cdef init(self, str name, str schema, str kind,
+              CodecType type, CodecFormat format,
+              encode_func c_encoder, decode_func c_decoder,
+              object py_encoder, object py_decoder,
+              Codec element_codec, tuple element_type_oids,
+              object element_names, list element_codecs,
+              Py_UCS4 element_delimiter)
+
+    cdef encode_scalar(self, ConnectionSettings settings, WriteBuffer buf,
+                       object obj)
+
+    cdef encode_array(self, ConnectionSettings settings, WriteBuffer buf,
+                      object obj)
+
+    cdef encode_range(self, ConnectionSettings settings, WriteBuffer buf,
+                      object obj)
+
+    cdef encode_composite(self, ConnectionSettings settings, WriteBuffer buf,
+                          object obj)
+
+    cdef encode_in_python(self, ConnectionSettings settings, WriteBuffer buf,
+                          object obj)
+
+    cdef decode_scalar(self, ConnectionSettings settings, FastReadBuffer buf)
+
+    cdef decode_array(self, ConnectionSettings settings, FastReadBuffer buf)
+
+    cdef decode_array_text(self, ConnectionSettings settings,
+                           FastReadBuffer buf)
+
+    cdef decode_range(self, ConnectionSettings settings, FastReadBuffer buf)
+
+    cdef decode_composite(self, ConnectionSettings settings,
+                          FastReadBuffer buf)
+
+    cdef decode_in_python(self, ConnectionSettings settings,
+                          FastReadBuffer buf)
+
+    cdef inline encode(self,
+                       ConnectionSettings settings,
+                       WriteBuffer buf,
+                       object obj)
+
+    cdef inline decode(self,
+                       ConnectionSettings settings,
+                       FastReadBuffer buf)
+
+    cdef has_encoder(self)
+    cdef has_decoder(self)
+    cdef is_binary(self)
+
+    cdef inline Codec copy(self)
+
+    @staticmethod
+    cdef Codec new_array_codec(uint32_t oid,
+                               str name,
+                               str schema,
+                               Codec element_codec,
+                               Py_UCS4 element_delimiter)
+
+    @staticmethod
+    cdef Codec new_range_codec(uint32_t oid,
+                               str name,
+                               str schema,
+                               Codec element_codec)
+
+    @staticmethod
+    cdef Codec new_composite_codec(uint32_t oid,
+                                   str name,
+                                   str schema,
+                                   list element_codecs,
+                                   tuple element_type_oids,
+                                   object element_names)
+
+    @staticmethod
+    cdef Codec new_python_codec(uint32_t oid,
+                                str name,
+                                str schema,
+                                str kind,
+                                object encoder,
+                                object decoder,
+                                CodecFormat format)
+
+
+cdef class DataCodecConfig:
+    cdef:
+        dict _type_codecs_cache
+        dict _local_type_codecs
+
+    cdef inline Codec get_codec(self, uint32_t oid, CodecFormat format)
diff --git a/asyncpg/protocol/codecs/base.pyx b/asyncpg/protocol/codecs/base.pyx
new file mode 100644 (file)
index 0000000..2da7424
--- /dev/null
@@ -0,0 +1,598 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+cdef void* binary_codec_map[MAXSUPPORTEDOID + 1]
+cdef void* text_codec_map[MAXSUPPORTEDOID + 1]
+cdef dict TYPE_CODECS_CACHE = {}
+cdef dict EXTRA_CODECS = {}
+
+
+@cython.final
+cdef class Codec:
+
+    def __cinit__(self, uint32_t oid):
+        self.oid = oid
+        self.type = CODEC_UNDEFINED
+
+    cdef init(self, str name, str schema, str kind,
+              CodecType type, CodecFormat format,
+              encode_func c_encoder, decode_func c_decoder,
+              object py_encoder, object py_decoder,
+              Codec element_codec, tuple element_type_oids,
+              object element_names, list element_codecs,
+              Py_UCS4 element_delimiter):
+
+        self.name = name
+        self.schema = schema
+        self.kind = kind
+        self.type = type
+        self.format = format
+        self.c_encoder = c_encoder
+        self.c_decoder = c_decoder
+        self.py_encoder = py_encoder
+        self.py_decoder = py_decoder
+        self.element_codec = element_codec
+        self.element_type_oids = element_type_oids
+        self.element_codecs = element_codecs
+        self.element_delimiter = element_delimiter
+
+        if element_names is not None:
+            self.element_names = record.ApgRecordDesc_New(
+                element_names, tuple(element_names))
+        else:
+            self.element_names = None
+
+        if type == CODEC_C:
+            self.encoder = <codec_encode_func>&self.encode_scalar
+            self.decoder = <codec_decode_func>&self.decode_scalar
+        elif type == CODEC_ARRAY:
+            self.encoder = <codec_encode_func>&self.encode_array
+            if format == PG_FORMAT_BINARY:
+                self.decoder = <codec_decode_func>&self.decode_array
+            else:
+                self.decoder = <codec_decode_func>&self.decode_array_text
+        elif type == CODEC_RANGE:
+            self.encoder = <codec_encode_func>&self.encode_range
+            self.decoder = <codec_decode_func>&self.decode_range
+        elif type == CODEC_COMPOSITE:
+            self.encoder = <codec_encode_func>&self.encode_composite
+            self.decoder = <codec_decode_func>&self.decode_composite
+        elif type == CODEC_PY:
+            self.encoder = <codec_encode_func>&self.encode_in_python
+            self.decoder = <codec_decode_func>&self.decode_in_python
+        else:
+            raise RuntimeError('unexpected codec type: {}'.format(type))
+
+    cdef Codec copy(self):
+        cdef Codec codec
+
+        codec = Codec(self.oid)
+        codec.init(self.name, self.schema, self.kind,
+                   self.type, self.format,
+                   self.c_encoder, self.c_decoder,
+                   self.py_encoder, self.py_decoder,
+                   self.element_codec,
+                   self.element_type_oids, self.element_names,
+                   self.element_codecs, self.element_delimiter)
+
+        return codec
+
+    cdef encode_scalar(self, ConnectionSettings settings, WriteBuffer buf,
+                       object obj):
+        self.c_encoder(settings, buf, obj)
+
+    cdef encode_array(self, ConnectionSettings settings, WriteBuffer buf,
+                      object obj):
+        array_encode(settings, buf, obj, self.element_codec.oid,
+                     codec_encode_func_ex,
+                     <void*>(<cpython.PyObject>self.element_codec))
+
+    cdef encode_range(self, ConnectionSettings settings, WriteBuffer buf,
+                      object obj):
+        range_encode(settings, buf, obj, self.element_codec.oid,
+                     codec_encode_func_ex,
+                     <void*>(<cpython.PyObject>self.element_codec))
+
+    cdef encode_composite(self, ConnectionSettings settings, WriteBuffer buf,
+                          object obj):
+        cdef:
+            WriteBuffer elem_data
+            int i
+            list elem_codecs = self.element_codecs
+            ssize_t count
+
+        count = len(obj)
+        if count > _MAXINT32:
+            raise ValueError('too many elements in composite type record')
+
+        elem_data = WriteBuffer.new()
+        i = 0
+        for item in obj:
+            elem_data.write_int32(<int32_t>self.element_type_oids[i])
+            if item is None:
+                elem_data.write_int32(-1)
+            else:
+                (<Codec>elem_codecs[i]).encode(settings, elem_data, item)
+            i += 1
+
+        record_encode_frame(settings, buf, elem_data, <int32_t>count)
+
+    cdef encode_in_python(self, ConnectionSettings settings, WriteBuffer buf,
+                          object obj):
+        bb = self.py_encoder(obj)
+        if self.format == PG_FORMAT_BINARY:
+            bytea_encode(settings, buf, bb)
+        else:
+            text_encode(settings, buf, bb)
+
+    cdef encode(self, ConnectionSettings settings, WriteBuffer buf,
+                object obj):
+        return self.encoder(self, settings, buf, obj)
+
+    cdef decode_scalar(self, ConnectionSettings settings, FastReadBuffer buf):
+        return self.c_decoder(settings, buf)
+
+    cdef decode_array(self, ConnectionSettings settings, FastReadBuffer buf):
+        return array_decode(settings, buf, codec_decode_func_ex,
+                            <void*>(<cpython.PyObject>self.element_codec))
+
+    cdef decode_array_text(self, ConnectionSettings settings,
+                           FastReadBuffer buf):
+        return textarray_decode(settings, buf, codec_decode_func_ex,
+                                <void*>(<cpython.PyObject>self.element_codec),
+                                self.element_delimiter)
+
+    cdef decode_range(self, ConnectionSettings settings, FastReadBuffer buf):
+        return range_decode(settings, buf, codec_decode_func_ex,
+                            <void*>(<cpython.PyObject>self.element_codec))
+
+    cdef decode_composite(self, ConnectionSettings settings,
+                          FastReadBuffer buf):
+        cdef:
+            object result
+            uint32_t elem_count
+            uint32_t i
+            int32_t elem_len
+            uint32_t elem_typ
+            uint32_t received_elem_typ
+            Codec elem_codec
+            FastReadBuffer elem_buf = FastReadBuffer.new()
+
+        elem_count = <uint32_t>hton.unpack_int32(buf.read(4))
+        result = record.ApgRecord_New(self.element_names, elem_count)
+        for i in range(elem_count):
+            elem_typ = self.element_type_oids[i]
+            received_elem_typ = <uint32_t>hton.unpack_int32(buf.read(4))
+
+            if received_elem_typ != elem_typ:
+                raise RuntimeError(
+                    'unexpected data type of composite type attribute {}: '
+                    '{!r}, expected {!r}'
+                        .format(
+                            i,
+                            TYPEMAP.get(received_elem_typ, received_elem_typ),
+                            TYPEMAP.get(elem_typ, elem_typ)
+                        )
+                )
+
+            elem_len = hton.unpack_int32(buf.read(4))
+            if elem_len == -1:
+                elem = None
+            else:
+                elem_codec = self.element_codecs[i]
+                elem = elem_codec.decode(settings,
+                                         elem_buf.slice_from(buf, elem_len))
+
+            cpython.Py_INCREF(elem)
+            record.ApgRecord_SET_ITEM(result, i, elem)
+
+        return result
+
+    cdef decode_in_python(self, ConnectionSettings settings,
+                          FastReadBuffer buf):
+        if self.format == PG_FORMAT_BINARY:
+            bb = bytea_decode(settings, buf)
+        else:
+            bb = text_decode(settings, buf)
+
+        return self.py_decoder(bb)
+
+    cdef inline decode(self, ConnectionSettings settings, FastReadBuffer buf):
+        return self.decoder(self, settings, buf)
+
+    cdef inline has_encoder(self):
+        cdef Codec elem_codec
+
+        if self.c_encoder is not NULL or self.py_encoder is not None:
+            return True
+
+        elif self.type == CODEC_ARRAY or self.type == CODEC_RANGE:
+            return self.element_codec.has_encoder()
+
+        elif self.type == CODEC_COMPOSITE:
+            for elem_codec in self.element_codecs:
+                if not elem_codec.has_encoder():
+                    return False
+            return True
+
+        else:
+            return False
+
+    cdef has_decoder(self):
+        cdef Codec elem_codec
+
+        if self.c_decoder is not NULL or self.py_decoder is not None:
+            return True
+
+        elif self.type == CODEC_ARRAY or self.type == CODEC_RANGE:
+            return self.element_codec.has_decoder()
+
+        elif self.type == CODEC_COMPOSITE:
+            for elem_codec in self.element_codecs:
+                if not elem_codec.has_decoder():
+                    return False
+            return True
+
+        else:
+            return False
+
+    cdef is_binary(self):
+        return self.format == PG_FORMAT_BINARY
+
+    def __repr__(self):
+        return '<Codec oid={} elem_oid={} core={}>'.format(
+            self.oid,
+            'NA' if self.element_codec is None else self.element_codec.oid,
+            has_core_codec(self.oid))
+
+    @staticmethod
+    cdef Codec new_array_codec(uint32_t oid,
+                               str name,
+                               str schema,
+                               Codec element_codec,
+                               Py_UCS4 element_delimiter):
+        cdef Codec codec
+        codec = Codec(oid)
+        codec.init(name, schema, 'array', CODEC_ARRAY, element_codec.format,
+                   NULL, NULL, None, None, element_codec, None, None, None,
+                   element_delimiter)
+        return codec
+
+    @staticmethod
+    cdef Codec new_range_codec(uint32_t oid,
+                               str name,
+                               str schema,
+                               Codec element_codec):
+        cdef Codec codec
+        codec = Codec(oid)
+        codec.init(name, schema, 'range', CODEC_RANGE, PG_FORMAT_BINARY,
+                   NULL, NULL, None, None, element_codec, None, None, None,
+                   0)
+        return codec
+
+    @staticmethod
+    cdef Codec new_composite_codec(uint32_t oid,
+                                   str name,
+                                   str schema,
+                                   list element_codecs,
+                                   tuple element_type_oids,
+                                   object element_names):
+        cdef Codec codec
+        codec = Codec(oid)
+        codec.init(name, schema, 'composite', CODEC_COMPOSITE,
+                   PG_FORMAT_BINARY, NULL, NULL, None, None, None,
+                   element_type_oids, element_names, element_codecs, 0)
+        return codec
+
+    @staticmethod
+    cdef Codec new_python_codec(uint32_t oid,
+                                str name,
+                                str schema,
+                                str kind,
+                                object encoder,
+                                object decoder,
+                                CodecFormat format):
+        cdef Codec codec
+        codec = Codec(oid)
+        codec.init(name, schema, kind, CODEC_PY, format, NULL, NULL,
+                   encoder, decoder, None, None, None, None, 0)
+        return codec
+
+
+# Encode callback for arrays
+cdef codec_encode_func_ex(ConnectionSettings settings, WriteBuffer buf,
+                          object obj, const void *arg):
+    return (<Codec>arg).encode(settings, buf, obj)
+
+
+# Decode callback for arrays
+cdef codec_decode_func_ex(ConnectionSettings settings, FastReadBuffer buf,
+                          const void *arg):
+    return (<Codec>arg).decode(settings, buf)
+
+
+cdef class DataCodecConfig:
+    def __init__(self, cache_key):
+        try:
+            self._type_codecs_cache = TYPE_CODECS_CACHE[cache_key]
+        except KeyError:
+            self._type_codecs_cache = TYPE_CODECS_CACHE[cache_key] = {}
+
+        self._local_type_codecs = {}
+
+    def add_types(self, types):
+        cdef:
+            Codec elem_codec
+            list comp_elem_codecs
+            CodecFormat format
+            CodecFormat elem_format
+            bint has_text_elements
+            Py_UCS4 elem_delim
+
+        for ti in types:
+            oid = ti['oid']
+
+            if not ti['has_bin_io']:
+                format = PG_FORMAT_TEXT
+            else:
+                format = PG_FORMAT_BINARY
+
+            has_text_elements = False
+
+            if self.get_codec(oid, format) is not None:
+                continue
+
+            name = ti['name']
+            schema = ti['ns']
+            array_element_oid = ti['elemtype']
+            range_subtype_oid = ti['range_subtype']
+            if ti['attrtypoids']:
+                comp_type_attrs = tuple(ti['attrtypoids'])
+            else:
+                comp_type_attrs = None
+            base_type = ti['basetype']
+
+            if array_element_oid:
+                # Array type (note, there is no separate 'kind' for arrays)
+
+                # Canonicalize type name to "elemtype[]"
+                if name.startswith('_'):
+                    name = name[1:]
+                name = '{}[]'.format(name)
+
+                if ti['elem_has_bin_io']:
+                    elem_format = PG_FORMAT_BINARY
+                else:
+                    elem_format = PG_FORMAT_TEXT
+                elem_codec = self.get_codec(array_element_oid, elem_format)
+                if elem_codec is None:
+                    raise RuntimeError(
+                        'no codec for array element type {}'.format(
+                            array_element_oid))
+
+                elem_delim = <Py_UCS4>ti['elemdelim'][0]
+
+                self._type_codecs_cache[oid, elem_format] = \
+                    Codec.new_array_codec(
+                        oid, name, schema, elem_codec, elem_delim)
+
+            elif ti['kind'] == b'c':
+                if not comp_type_attrs:
+                    raise RuntimeError(
+                        'type record missing field types for '
+                        'composite {}'.format(oid))
+
+                # Composite type
+
+                comp_elem_codecs = []
+
+                for typoid in comp_type_attrs:
+                    elem_codec = self.get_codec(typoid, PG_FORMAT_BINARY)
+                    if elem_codec is None:
+                        elem_codec = self.get_codec(typoid, PG_FORMAT_TEXT)
+                        has_text_elements = True
+                    if elem_codec is None:
+                        raise RuntimeError(
+                            'no codec for composite attribute type {}'.format(
+                                typoid))
+                    comp_elem_codecs.append(elem_codec)
+
+                element_names = collections.OrderedDict()
+                for i, attrname in enumerate(ti['attrnames']):
+                    element_names[attrname] = i
+
+                if has_text_elements:
+                    format = PG_FORMAT_TEXT
+
+                self._type_codecs_cache[oid, format] = \
+                    Codec.new_composite_codec(
+                        oid, name, schema, comp_elem_codecs,
+                        comp_type_attrs,
+                        element_names)
+
+            elif ti['kind'] == b'd':
+                # Domain type
+
+                if not base_type:
+                    raise RuntimeError(
+                        'type record missing base type for domain {}'.format(
+                            oid))
+
+                elem_codec = self.get_codec(base_type, format)
+                if elem_codec is None:
+                    raise RuntimeError(
+                        'no codec for domain base type {}'.format(base_type))
+
+                self._type_codecs_cache[oid, format] = elem_codec
+
+            elif ti['kind'] == b'r':
+                # Range type
+
+                if not range_subtype_oid:
+                    raise RuntimeError(
+                        'type record missing base type for range {}'.format(
+                            oid))
+
+                if ti['elem_has_bin_io']:
+                    elem_format = PG_FORMAT_BINARY
+                else:
+                    elem_format = PG_FORMAT_TEXT
+                elem_codec = self.get_codec(range_subtype_oid, elem_format)
+                if elem_codec is None:
+                    raise RuntimeError(
+                        'no codec for range element type {}'.format(
+                            range_subtype_oid))
+
+                self._type_codecs_cache[oid, elem_format] = \
+                    Codec.new_range_codec(oid, name, schema, elem_codec)
+
+            else:
+                if oid <= MAXBUILTINOID:
+                    # This is a non-BKI type, for which ayncpg has no
+                    # defined codec.  This should only happen for newly
+                    # added builtin types, for which this version of
+                    # asyncpg is lacking support.
+                    #
+                    raise NotImplementedError(
+                        'unhandled standard data type {!r} (OID {})'.format(
+                            name, oid))
+                else:
+                    # This is a non-BKI type, and as such, has no
+                    # stable OID, so no possibility of a builtin codec.
+                    # In this case, fallback to text format.  Applications
+                    # can avoid this by specifying a codec for this type
+                    # using Connection.set_type_codec().
+                    #
+                    self.set_builtin_type_codec(oid, name, schema, 'scalar',
+                                                UNKNOWNOID)
+
+    def add_python_codec(self, typeoid, typename, typeschema, typekind,
+                         encoder, decoder, binary):
+        format = PG_FORMAT_BINARY if binary else PG_FORMAT_TEXT
+
+        if self.get_codec(typeoid, format) is not None:
+            raise ValueError('cannot override codec for type {}'.format(
+                typeoid))
+
+        self._local_type_codecs[typeoid, format] = \
+            Codec.new_python_codec(typeoid, typename, typeschema, typekind,
+                                   encoder, decoder, format)
+
+    def set_builtin_type_codec(self, typeoid, typename, typeschema, typekind,
+                               alias_to):
+        cdef:
+            Codec codec
+            Codec target_codec
+
+        for format in (PG_FORMAT_BINARY, PG_FORMAT_TEXT):
+            if self.get_codec(typeoid, format) is not None:
+                raise ValueError('cannot override codec for type {}'.format(
+                    typeoid))
+
+            if isinstance(alias_to, int):
+                target_codec = self.get_codec(alias_to, format)
+            else:
+                target_codec = get_extra_codec(alias_to, format)
+
+            if target_codec is None:
+                continue
+
+            codec = target_codec.copy()
+            codec.oid = typeoid
+            codec.name = typename
+            codec.schema = typeschema
+            codec.kind = typekind
+
+            self._local_type_codecs[typeoid, format] = codec
+
+        if ((typeoid, PG_FORMAT_BINARY) not in self._local_type_codecs and
+                (typeoid, PG_FORMAT_TEXT) not in self._local_type_codecs):
+            raise ValueError('unknown alias target: {}'.format(alias_to))
+
+    def clear_type_cache(self):
+        self._type_codecs_cache.clear()
+
+    cdef inline Codec get_codec(self, uint32_t oid, CodecFormat format):
+        cdef Codec codec
+
+        codec = get_core_codec(oid, format)
+        if codec is not None:
+            return codec
+
+        try:
+            return self._type_codecs_cache[oid, format]
+        except KeyError:
+            try:
+                return self._local_type_codecs[oid, format]
+            except KeyError:
+                return None
+
+
+cdef inline Codec get_core_codec(uint32_t oid, CodecFormat format):
+    cdef void *ptr
+    if oid > MAXSUPPORTEDOID:
+        return None
+    if format == PG_FORMAT_BINARY:
+        ptr = binary_codec_map[oid]
+    else:
+        ptr = text_codec_map[oid]
+    if ptr is NULL:
+        return None
+    return <Codec>ptr
+
+
+cdef inline int has_core_codec(uint32_t oid):
+    return binary_codec_map[oid] != NULL or text_codec_map[oid] != NULL
+
+
+cdef register_core_codec(uint32_t oid,
+                         encode_func encode,
+                         decode_func decode,
+                         CodecFormat format):
+
+    if oid > MAXSUPPORTEDOID:
+        raise RuntimeError(
+            'cannot register core codec for OID {}: it is greater '
+            'than MAXSUPPORTEDOID ({})'.format(oid, MAXSUPPORTEDOID))
+
+    cdef:
+        Codec codec
+        str name
+        str kind
+
+    name = TYPEMAP[oid]
+    kind = 'array' if oid in ARRAY_TYPES else 'scalar'
+
+    codec = Codec(oid)
+    codec.init(name, 'pg_catalog', kind, CODEC_C, format, encode,
+               decode, None, None, None, None, None, None, 0)
+    cpython.Py_INCREF(codec)  # immortalize
+
+    if format == PG_FORMAT_BINARY:
+        binary_codec_map[oid] = <void*>codec
+    else:
+        text_codec_map[oid] = <void*>codec
+
+
+cdef register_extra_codec(str name,
+                          encode_func encode,
+                          decode_func decode,
+                          CodecFormat format):
+    cdef:
+        Codec codec
+        str kind
+
+    kind = 'scalar'
+
+    codec = Codec(INVALIDOID)
+    codec.init(name, None, kind, CODEC_C, format, encode,
+               decode, None, None, None, None, None, None, 0)
+    EXTRA_CODECS[name, format] = codec
+
+
+cdef inline Codec get_extra_codec(str name, CodecFormat format):
+    return EXTRA_CODECS.get((name, format))
diff --git a/asyncpg/protocol/codecs/bits.pyx b/asyncpg/protocol/codecs/bits.pyx
new file mode 100644 (file)
index 0000000..8c2a3f4
--- /dev/null
@@ -0,0 +1,64 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+from asyncpg.types import BitString
+
+
+cdef bits_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):
+    cdef:
+        Py_buffer pybuf
+        bint pybuf_used = False
+        char *buf
+        ssize_t len
+        ssize_t bitlen
+
+    if cpython.PyBytes_CheckExact(obj):
+        buf = cpython.PyBytes_AS_STRING(obj)
+        len = cpython.Py_SIZE(obj)
+        bitlen = len * 8
+    elif isinstance(obj, BitString):
+        cpython.PyBytes_AsStringAndSize(obj.bytes, &buf, &len)
+        bitlen = obj.__len__()
+    else:
+        cpython.PyObject_GetBuffer(obj, &pybuf, cpython.PyBUF_SIMPLE)
+        pybuf_used = True
+        buf = <char*>pybuf.buf
+        len = pybuf.len
+        bitlen = len * 8
+
+    try:
+        if bitlen > _MAXINT32:
+            raise ValueError('bit value too long')
+        wbuf.write_int32(4 + <int32_t>len)
+        wbuf.write_int32(<int32_t>bitlen)
+        wbuf.write_cstr(buf, len)
+    finally:
+        if pybuf_used:
+            cpython.PyBuffer_Release(&pybuf)
+
+
+cdef bits_decode(ConnectionSettings settings, FastReadBuffer buf):
+    cdef:
+        int32_t bitlen = hton.unpack_int32(buf.read(4))
+        ssize_t buf_len = buf.len
+
+    bytes_ = cpython.PyBytes_FromStringAndSize(buf.read_all(), buf_len)
+    return BitString.frombytes(bytes_, bitlen)
+
+
+cdef init_bits_codecs():
+    register_core_codec(BITOID,
+                        <encode_func>&bits_encode,
+                        <decode_func>&bits_decode,
+                        PG_FORMAT_BINARY)
+
+    register_core_codec(VARBITOID,
+                        <encode_func>&bits_encode,
+                        <decode_func>&bits_decode,
+                        PG_FORMAT_BINARY)
+
+init_bits_codecs()
diff --git a/asyncpg/protocol/codecs/bytea.pyx b/asyncpg/protocol/codecs/bytea.pyx
new file mode 100644 (file)
index 0000000..04fe5ed
--- /dev/null
@@ -0,0 +1,48 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+cdef bytea_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):
+    cdef:
+        Py_buffer pybuf
+        bint pybuf_used = False
+        char *buf
+        ssize_t len
+
+    if cpython.PyBytes_CheckExact(obj):
+        buf = cpython.PyBytes_AS_STRING(obj)
+        len = cpython.Py_SIZE(obj)
+    else:
+        cpython.PyObject_GetBuffer(obj, &pybuf, cpython.PyBUF_SIMPLE)
+        pybuf_used = True
+        buf = <char*>pybuf.buf
+        len = pybuf.len
+
+    try:
+        wbuf.write_int32(<int32_t>len)
+        wbuf.write_cstr(buf, len)
+    finally:
+        if pybuf_used:
+            cpython.PyBuffer_Release(&pybuf)
+
+
+cdef bytea_decode(ConnectionSettings settings, FastReadBuffer buf):
+    cdef ssize_t buf_len = buf.len
+    return cpython.PyBytes_FromStringAndSize(buf.read_all(), buf_len)
+
+
+cdef init_bytea_codecs():
+    register_core_codec(BYTEAOID,
+                        <encode_func>&bytea_encode,
+                        <decode_func>&bytea_decode,
+                        PG_FORMAT_BINARY)
+
+    register_core_codec(CHAROID,
+                        <encode_func>&bytea_encode,
+                        <decode_func>&bytea_decode,
+                        PG_FORMAT_BINARY)
+
+init_bytea_codecs()
diff --git a/asyncpg/protocol/codecs/datetime.pyx b/asyncpg/protocol/codecs/datetime.pyx
new file mode 100644 (file)
index 0000000..0a8d367
--- /dev/null
@@ -0,0 +1,311 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import datetime
+
+utc = datetime.timezone.utc
+date_from_ordinal = datetime.date.fromordinal
+timedelta = datetime.timedelta
+
+pg_epoch_datetime = datetime.datetime(2000, 1, 1)
+cdef int32_t pg_epoch_datetime_ts = \
+    <int32_t>cpython.PyLong_AsLong(int(pg_epoch_datetime.timestamp()))
+
+pg_epoch_datetime_utc = datetime.datetime(2000, 1, 1, tzinfo=utc)
+cdef int32_t pg_epoch_datetime_utc_ts = \
+    <int32_t>cpython.PyLong_AsLong(pg_epoch_datetime_utc.timestamp())
+
+pg_epoch_date = datetime.date(2000, 1, 1)
+cdef int32_t pg_date_offset_ord = \
+    <int32_t>cpython.PyLong_AsLong(pg_epoch_date.toordinal())
+
+# Binary representations of infinity for datetimes.
+cdef int64_t pg_time64_infinity = 0x7fffffffffffffff
+cdef int64_t pg_time64_negative_infinity = <int64_t>0x8000000000000000
+cdef int32_t pg_date_infinity = 0x7fffffff
+cdef int32_t pg_date_negative_infinity = <int32_t>0x80000000
+
+infinity_datetime = datetime.datetime(
+    datetime.MAXYEAR, 12, 31, 23, 59, 59, 999999)
+
+cdef int32_t infinity_datetime_ord = <int32_t>cpython.PyLong_AsLong(
+    infinity_datetime.toordinal())
+
+cdef int64_t infinity_datetime_ts = 252455615999999999
+
+negative_infinity_datetime = datetime.datetime(
+    datetime.MINYEAR, 1, 1, 0, 0, 0, 0)
+
+cdef int32_t negative_infinity_datetime_ord = <int32_t>cpython.PyLong_AsLong(
+    negative_infinity_datetime.toordinal())
+
+cdef int64_t negative_infinity_datetime_ts = -63082281600000000
+
+infinity_date = datetime.date(datetime.MAXYEAR, 12, 31)
+
+cdef int32_t infinity_date_ord = <int32_t>cpython.PyLong_AsLong(
+    infinity_date.toordinal())
+
+negative_infinity_date = datetime.date(datetime.MINYEAR, 1, 1)
+
+cdef int32_t negative_infinity_date_ord = <int32_t>cpython.PyLong_AsLong(
+    negative_infinity_date.toordinal())
+
+
+cdef inline _encode_time(WriteBuffer buf, int64_t seconds,
+                         int32_t microseconds):
+    # XXX: add support for double timestamps
+    # int64 timestamps,
+    cdef int64_t ts = seconds * 1000000 + microseconds
+
+    if ts == infinity_datetime_ts:
+        buf.write_int64(pg_time64_infinity)
+    elif ts == negative_infinity_datetime_ts:
+        buf.write_int64(pg_time64_negative_infinity)
+    else:
+        buf.write_int64(ts)
+
+
+cdef inline int32_t _decode_time(FastReadBuffer buf, int64_t *seconds,
+                                 uint32_t *microseconds):
+    # XXX: add support for double timestamps
+    # int64 timestamps,
+    cdef int64_t ts = hton.unpack_int64(buf.read(8))
+
+    if ts == pg_time64_infinity:
+        return 1
+    elif ts == pg_time64_negative_infinity:
+        return -1
+
+    seconds[0] = <int64_t>(ts / 1000000)
+    microseconds[0] = <uint32_t>(ts % 1000000)
+
+    return 0
+
+
+cdef date_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+    cdef:
+        int32_t ordinal = <int32_t>cpython.PyLong_AsLong(obj.toordinal())
+        int32_t pg_ordinal
+
+    if ordinal == infinity_date_ord:
+        pg_ordinal = pg_date_infinity
+    elif ordinal == negative_infinity_date_ord:
+        pg_ordinal = pg_date_negative_infinity
+    else:
+        pg_ordinal = ordinal - pg_date_offset_ord
+
+    buf.write_int32(4)
+    buf.write_int32(pg_ordinal)
+
+
+cdef date_decode(ConnectionSettings settings, FastReadBuffer buf):
+    cdef int32_t pg_ordinal = hton.unpack_int32(buf.read(4))
+
+    if pg_ordinal == pg_date_infinity:
+        return infinity_date
+    elif pg_ordinal == pg_date_negative_infinity:
+        return negative_infinity_date
+    else:
+        return date_from_ordinal(pg_ordinal + pg_date_offset_ord)
+
+
+cdef timestamp_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+    delta = obj - pg_epoch_datetime
+    cdef:
+        int64_t seconds = cpython.PyLong_AsLongLong(delta.days) * 86400 + \
+                                cpython.PyLong_AsLong(delta.seconds)
+        int32_t microseconds = <int32_t>cpython.PyLong_AsLong(
+                                    delta.microseconds)
+
+    buf.write_int32(8)
+    _encode_time(buf, seconds, microseconds)
+
+
+cdef timestamp_decode(ConnectionSettings settings, FastReadBuffer buf):
+    cdef:
+        int64_t seconds = 0
+        uint32_t microseconds = 0
+        int32_t inf = _decode_time(buf, &seconds, &microseconds)
+
+    if inf > 0:
+        # positive infinity
+        return infinity_datetime
+    elif inf < 0:
+        # negative infinity
+        return negative_infinity_datetime
+    else:
+        return pg_epoch_datetime.__add__(
+            timedelta(0, seconds, microseconds))
+
+
+cdef timestamptz_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+    buf.write_int32(8)
+
+    if obj == infinity_datetime:
+        buf.write_int64(pg_time64_infinity)
+        return
+    elif obj == negative_infinity_datetime:
+        buf.write_int64(pg_time64_negative_infinity)
+        return
+
+    delta = obj.astimezone(utc) - pg_epoch_datetime_utc
+    cdef:
+        int64_t seconds = cpython.PyLong_AsLongLong(delta.days) * 86400 + \
+                                cpython.PyLong_AsLong(delta.seconds)
+        int32_t microseconds = <int32_t>cpython.PyLong_AsLong(
+                                    delta.microseconds)
+
+    _encode_time(buf, seconds, microseconds)
+
+
+cdef timestamptz_decode(ConnectionSettings settings, FastReadBuffer buf):
+    cdef:
+        int64_t seconds = 0
+        uint32_t microseconds = 0
+        int32_t inf = _decode_time(buf, &seconds, &microseconds)
+
+    if inf > 0:
+        # positive infinity
+        return infinity_datetime
+    elif inf < 0:
+        # negative infinity
+        return negative_infinity_datetime
+    else:
+        return pg_epoch_datetime_utc.__add__(
+            timedelta(0, seconds, microseconds))
+
+
+cdef time_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+    cdef:
+        int64_t seconds = cpython.PyLong_AsLong(obj.hour) * 3600 + \
+                            cpython.PyLong_AsLong(obj.minute) * 60 + \
+                            cpython.PyLong_AsLong(obj.second)
+        int32_t microseconds = <int32_t>cpython.PyLong_AsLong(obj.microsecond)
+
+    buf.write_int32(8)
+    _encode_time(buf, seconds, microseconds)
+
+
+cdef time_decode(ConnectionSettings settings, FastReadBuffer buf):
+    cdef:
+        int64_t seconds = 0
+        uint32_t microseconds = 0
+
+    _decode_time(buf, &seconds, &microseconds)
+
+    cdef:
+        int64_t minutes = <int64_t>(seconds / 60)
+        int64_t sec = seconds % 60
+        int64_t hours = <int64_t>(minutes / 60)
+        int64_t min = minutes % 60
+
+    return datetime.time(hours, min, sec, microseconds)
+
+
+cdef timetz_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+    offset = obj.tzinfo.utcoffset(None)
+
+    cdef:
+        int32_t offset_sec = \
+            <int32_t>cpython.PyLong_AsLong(offset.days) * 24 * 60 * 60 + \
+            <int32_t>cpython.PyLong_AsLong(offset.seconds)
+
+        int64_t seconds = cpython.PyLong_AsLong(obj.hour) * 3600 + \
+                            cpython.PyLong_AsLong(obj.minute) * 60 + \
+                            cpython.PyLong_AsLong(obj.second)
+
+        int32_t microseconds = <int32_t>cpython.PyLong_AsLong(obj.microsecond)
+
+    buf.write_int32(12)
+    _encode_time(buf, seconds, microseconds)
+    buf.write_int32(offset_sec)
+
+
+cdef timetz_decode(ConnectionSettings settings, FastReadBuffer buf):
+    time = time_decode(settings, buf)
+    cdef int32_t offset = <int32_t>(hton.unpack_int32(buf.read(4)) / 60)
+    return time.replace(tzinfo=datetime.timezone(timedelta(minutes=offset)))
+
+
+cdef interval_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+    cdef:
+        int32_t days = <int32_t>cpython.PyLong_AsLong(obj.days)
+        int64_t seconds = cpython.PyLong_AsLongLong(obj.seconds)
+        int32_t microseconds = <int32_t>cpython.PyLong_AsLong(obj.microseconds)
+
+    buf.write_int32(16)
+    _encode_time(buf, seconds, microseconds)
+    buf.write_int32(days)
+    buf.write_int32(0) # Months
+
+
+cdef interval_decode(ConnectionSettings settings, FastReadBuffer buf):
+    cdef:
+        int32_t days
+        int32_t months
+        int64_t seconds = 0
+        uint32_t microseconds = 0
+
+    _decode_time(buf, &seconds, &microseconds)
+    days = hton.unpack_int32(buf.read(4))
+    months = hton.unpack_int32(buf.read(4))
+
+    return datetime.timedelta(days=days + months * 30, seconds=seconds,
+                              microseconds=microseconds)
+
+
+cdef init_datetime_codecs():
+    register_core_codec(DATEOID,
+                        <encode_func>&date_encode,
+                        <decode_func>&date_decode,
+                        PG_FORMAT_BINARY)
+
+    register_core_codec(TIMEOID,
+                        <encode_func>&time_encode,
+                        <decode_func>&time_decode,
+                        PG_FORMAT_BINARY)
+
+    register_core_codec(TIMETZOID,
+                        <encode_func>&timetz_encode,
+                        <decode_func>&timetz_decode,
+                        PG_FORMAT_BINARY)
+
+    register_core_codec(TIMESTAMPOID,
+                        <encode_func>&timestamp_encode,
+                        <decode_func>&timestamp_decode,
+                        PG_FORMAT_BINARY)
+
+    register_core_codec(TIMESTAMPTZOID,
+                        <encode_func>&timestamptz_encode,
+                        <decode_func>&timestamptz_decode,
+                        PG_FORMAT_BINARY)
+
+    register_core_codec(INTERVALOID,
+                        <encode_func>&interval_encode,
+                        <decode_func>&interval_decode,
+                        PG_FORMAT_BINARY)
+
+    # For obsolete abstime/reltime/tinterval, we do not bother to
+    # interpret the value, and simply return and pass it as text.
+    #
+    register_core_codec(ABSTIMEOID,
+                        <encode_func>&text_encode,
+                        <decode_func>&text_decode,
+                        PG_FORMAT_TEXT)
+
+    register_core_codec(RELTIMEOID,
+                        <encode_func>&text_encode,
+                        <decode_func>&text_decode,
+                        PG_FORMAT_TEXT)
+
+    register_core_codec(TINTERVALOID,
+                        <encode_func>&text_encode,
+                        <decode_func>&text_decode,
+                        PG_FORMAT_TEXT)
+
+init_datetime_codecs()
diff --git a/asyncpg/protocol/codecs/float.pyx b/asyncpg/protocol/codecs/float.pyx
new file mode 100644 (file)
index 0000000..9ad2c23
--- /dev/null
@@ -0,0 +1,49 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+from libc cimport math
+
+
+cdef float4_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+    cdef double dval = cpython.PyFloat_AsDouble(obj)
+    cdef float fval = <float>dval
+    if math.isinf(fval) and not math.isinf(dval):
+        raise ValueError('float value too large to be encoded as FLOAT4')
+
+    buf.write_int32(4)
+    buf.write_float(fval)
+
+
+cdef float4_decode(ConnectionSettings settings, FastReadBuffer buf):
+    cdef float f = hton.unpack_float(buf.read(4))
+    return cpython.PyFloat_FromDouble(f)
+
+
+cdef float8_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+    cdef double dval = cpython.PyFloat_AsDouble(obj)
+    buf.write_int32(8)
+    buf.write_double(dval)
+
+
+cdef float8_decode(ConnectionSettings settings, FastReadBuffer buf):
+    cdef double f = hton.unpack_double(buf.read(8))
+    return cpython.PyFloat_FromDouble(f)
+
+
+cdef init_float_codecs():
+    register_core_codec(FLOAT4OID,
+                        <encode_func>&float4_encode,
+                        <decode_func>&float4_decode,
+                        PG_FORMAT_BINARY)
+
+    register_core_codec(FLOAT8OID,
+                        <encode_func>&float8_encode,
+                        <decode_func>&float8_decode,
+                        PG_FORMAT_BINARY)
+
+
+init_float_codecs()
diff --git a/asyncpg/protocol/codecs/geometry.pyx b/asyncpg/protocol/codecs/geometry.pyx
new file mode 100644 (file)
index 0000000..c4188e3
--- /dev/null
@@ -0,0 +1,205 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+from asyncpg.types import Box, Line, LineSegment, Path, Point, Polygon, Circle
+
+
+cdef inline _encode_points(WriteBuffer wbuf, object points):
+    cdef object point
+
+    for point in points:
+        wbuf.write_double(point[0])
+        wbuf.write_double(point[1])
+
+
+cdef inline _decode_points(FastReadBuffer buf):
+    cdef:
+        int32_t npts = hton.unpack_int32(buf.read(4))
+        pts = cpython.PyTuple_New(npts)
+        int32_t i
+        object point
+        double x
+        double y
+
+    for i in range(npts):
+        x = hton.unpack_double(buf.read(8))
+        y = hton.unpack_double(buf.read(8))
+        point = Point(x, y)
+        cpython.Py_INCREF(point)
+        cpython.PyTuple_SET_ITEM(pts, i, point)
+
+    return pts
+
+
+cdef box_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):
+    wbuf.write_int32(32)
+    _encode_points(wbuf, (obj[0], obj[1]))
+
+
+cdef box_decode(ConnectionSettings settings, FastReadBuffer buf):
+    cdef:
+        double high_x = hton.unpack_double(buf.read(8))
+        double high_y = hton.unpack_double(buf.read(8))
+        double low_x = hton.unpack_double(buf.read(8))
+        double low_y = hton.unpack_double(buf.read(8))
+
+    return Box(Point(high_x, high_y), Point(low_x, low_y))
+
+
+cdef line_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):
+    wbuf.write_int32(24)
+    wbuf.write_double(obj[0])
+    wbuf.write_double(obj[1])
+    wbuf.write_double(obj[2])
+
+
+cdef line_decode(ConnectionSettings settings, FastReadBuffer buf):
+    cdef:
+        double A = hton.unpack_double(buf.read(8))
+        double B = hton.unpack_double(buf.read(8))
+        double C = hton.unpack_double(buf.read(8))
+
+    return Line(A, B, C)
+
+
+cdef lseg_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):
+    wbuf.write_int32(32)
+    _encode_points(wbuf, (obj[0], obj[1]))
+
+
+cdef lseg_decode(ConnectionSettings settings, FastReadBuffer buf):
+    cdef:
+        double p1_x = hton.unpack_double(buf.read(8))
+        double p1_y = hton.unpack_double(buf.read(8))
+        double p2_x = hton.unpack_double(buf.read(8))
+        double p2_y = hton.unpack_double(buf.read(8))
+
+    return LineSegment((p1_x, p1_y), (p2_x, p2_y))
+
+
+cdef point_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):
+    wbuf.write_int32(16)
+    wbuf.write_double(obj[0])
+    wbuf.write_double(obj[1])
+
+
+cdef point_decode(ConnectionSettings settings, FastReadBuffer buf):
+    cdef:
+        double x = hton.unpack_double(buf.read(8))
+        double y = hton.unpack_double(buf.read(8))
+
+    return Point(x, y)
+
+
+cdef path_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):
+    cdef:
+        int8_t is_closed = 0
+        ssize_t npts
+        ssize_t encoded_len
+        int32_t i
+
+    if cpython.PyTuple_Check(obj):
+        is_closed = 1
+    elif cpython.PyList_Check(obj):
+        is_closed = 0
+    elif isinstance(obj, Path):
+        is_closed = obj.is_closed
+
+    npts = len(obj)
+    encoded_len = 1 + 4 + 16 * npts
+    if encoded_len > _MAXINT32:
+        raise ValueError('path value too long')
+
+    wbuf.write_int32(<int32_t>encoded_len)
+    wbuf.write_byte(is_closed)
+    wbuf.write_int32(<int32_t>npts)
+
+    _encode_points(wbuf, obj)
+
+
+cdef path_decode(ConnectionSettings settings, FastReadBuffer buf):
+    cdef:
+        int8_t is_closed = <int8_t>buf.read(1)[0]
+
+    return Path(*_decode_points(buf), is_closed=is_closed == 1)
+
+
+cdef poly_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):
+    cdef:
+        bint is_closed
+        ssize_t npts
+        ssize_t encoded_len
+        int32_t i
+
+    npts = len(obj)
+    encoded_len = 4 + 16 * npts
+    if encoded_len > _MAXINT32:
+        raise ValueError('polygon value too long')
+
+    wbuf.write_int32(<int32_t>encoded_len)
+    wbuf.write_int32(<int32_t>npts)
+    _encode_points(wbuf, obj)
+
+
+cdef poly_decode(ConnectionSettings settings, FastReadBuffer buf):
+    return Polygon(*_decode_points(buf))
+
+
+cdef circle_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):
+    wbuf.write_int32(24)
+    wbuf.write_double(obj[0][0])
+    wbuf.write_double(obj[0][1])
+    wbuf.write_double(obj[1])
+
+
+cdef circle_decode(ConnectionSettings settings, FastReadBuffer buf):
+    cdef:
+        double center_x = hton.unpack_double(buf.read(8))
+        double center_y = hton.unpack_double(buf.read(8))
+        double radius = hton.unpack_double(buf.read(8))
+
+    return Circle((center_x, center_y), radius)
+
+
+cdef init_geometry_codecs():
+    register_core_codec(BOXOID,
+                        <encode_func>&box_encode,
+                        <decode_func>&box_decode,
+                        PG_FORMAT_BINARY)
+
+    register_core_codec(LINEOID,
+                        <encode_func>&line_encode,
+                        <decode_func>&line_decode,
+                        PG_FORMAT_BINARY)
+
+    register_core_codec(LSEGOID,
+                        <encode_func>&lseg_encode,
+                        <decode_func>&lseg_decode,
+                        PG_FORMAT_BINARY)
+
+    register_core_codec(POINTOID,
+                        <encode_func>&point_encode,
+                        <decode_func>&point_decode,
+                        PG_FORMAT_BINARY)
+
+    register_core_codec(PATHOID,
+                        <encode_func>&path_encode,
+                        <decode_func>&path_decode,
+                        PG_FORMAT_BINARY)
+
+    register_core_codec(POLYGONOID,
+                        <encode_func>&poly_encode,
+                        <decode_func>&poly_decode,
+                        PG_FORMAT_BINARY)
+
+    register_core_codec(CIRCLEOID,
+                        <encode_func>&circle_encode,
+                        <decode_func>&circle_decode,
+                        PG_FORMAT_BINARY)
+
+
+init_geometry_codecs()
diff --git a/asyncpg/protocol/codecs/hstore.pyx b/asyncpg/protocol/codecs/hstore.pyx
new file mode 100644 (file)
index 0000000..0bbdc66
--- /dev/null
@@ -0,0 +1,82 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+cdef hstore_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+    cdef:
+        char *str
+        ssize_t size
+        ssize_t count
+        object items
+        WriteBuffer item_buf = WriteBuffer.new()
+
+    count = len(obj)
+    if count > _MAXINT32:
+        raise ValueError('hstore value is too large')
+    item_buf.write_int32(<int32_t>count)
+
+    if hasattr(obj, 'items'):
+        items = obj.items()
+    else:
+        items = obj
+
+    for k, v in items:
+        if k is None:
+            raise ValueError('null value not allowed in hstore key')
+        as_pg_string_and_size(settings, k, &str, &size)
+        item_buf.write_int32(<int32_t>size)
+        item_buf.write_cstr(str, size)
+        if v is None:
+            item_buf.write_int32(<int32_t>-1)
+        else:
+            as_pg_string_and_size(settings, v, &str, &size)
+            item_buf.write_int32(<int32_t>size)
+            item_buf.write_cstr(str, size)
+
+    buf.write_int32(item_buf.len())
+    buf.write_buffer(item_buf)
+
+
+cdef hstore_decode(ConnectionSettings settings, FastReadBuffer buf):
+    cdef:
+        dict result
+        uint32_t elem_count
+        int32_t elem_len
+        uint32_t i
+        str k
+        str v
+
+    result = {}
+
+    elem_count = <uint32_t>hton.unpack_int32(buf.read(4))
+    if elem_count == 0:
+        return result
+
+    for i in range(elem_count):
+        elem_len = hton.unpack_int32(buf.read(4))
+        if elem_len < 0:
+            raise ValueError('null value not allowed in hstore key')
+
+        k = decode_pg_string(settings, buf.read(elem_len), elem_len)
+
+        elem_len = hton.unpack_int32(buf.read(4))
+        if elem_len < 0:
+            v = None
+        else:
+            v = decode_pg_string(settings, buf.read(elem_len), elem_len)
+
+        result[k] = v
+
+    return result
+
+
+cdef init_hstore_codecs():
+    register_extra_codec('pg_contrib.hstore',
+                         <encode_func>&hstore_encode,
+                         <decode_func>&hstore_decode,
+                         PG_FORMAT_BINARY)
+
+init_hstore_codecs()
diff --git a/asyncpg/protocol/codecs/int.pyx b/asyncpg/protocol/codecs/int.pyx
new file mode 100644 (file)
index 0000000..9b95fee
--- /dev/null
@@ -0,0 +1,79 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+cdef bool_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+    if not cpython.PyBool_Check(obj):
+        raise TypeError('a boolean is required (got type {})'.format(
+            type(obj).__name__))
+
+    buf.write_int32(1)
+    buf.write_byte(b'\x01' if obj is True else b'\x00')
+
+
+cdef bool_decode(ConnectionSettings settings, FastReadBuffer buf):
+    return buf.read(1)[0] is b'\x01'
+
+
+cdef int2_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+    cdef long val = cpython.PyLong_AsLong(obj)
+    if val < -32767 or val > 32767:
+        raise ValueError(
+            'integer too large to be encoded as INT2: {!r}'.format(val))
+
+    buf.write_int32(2)
+    buf.write_int16(<int16_t>val)
+
+
+cdef int2_decode(ConnectionSettings settings, FastReadBuffer buf):
+    return cpython.PyLong_FromLong(hton.unpack_int16(buf.read(2)))
+
+
+cdef int4_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+    cdef int32_t val = <int32_t>cpython.PyLong_AsLong(obj)
+
+    buf.write_int32(4)
+    buf.write_int32(val)
+
+
+cdef int4_decode(ConnectionSettings settings, FastReadBuffer buf):
+    return cpython.PyLong_FromLong(hton.unpack_int32(buf.read(4)))
+
+
+cdef int8_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+    cdef int64_t val = cpython.PyLong_AsLongLong(obj)
+    buf.write_int32(8)
+    buf.write_int64(val)
+
+
+cdef int8_decode(ConnectionSettings settings, FastReadBuffer buf):
+    return cpython.PyLong_FromLongLong(hton.unpack_int64(buf.read(8)))
+
+
+cdef init_int_codecs():
+
+    register_core_codec(BOOLOID,
+                        <encode_func>&bool_encode,
+                        <decode_func>&bool_decode,
+                        PG_FORMAT_BINARY)
+
+    register_core_codec(INT2OID,
+                        <encode_func>&int2_encode,
+                        <decode_func>&int2_decode,
+                        PG_FORMAT_BINARY)
+
+    register_core_codec(INT4OID,
+                        <encode_func>&int4_encode,
+                        <decode_func>&int4_decode,
+                        PG_FORMAT_BINARY)
+
+    register_core_codec(INT8OID,
+                        <encode_func>&int8_encode,
+                        <decode_func>&int8_decode,
+                        PG_FORMAT_BINARY)
+
+
+init_int_codecs()
diff --git a/asyncpg/protocol/codecs/json.pyx b/asyncpg/protocol/codecs/json.pyx
new file mode 100644 (file)
index 0000000..6773d41
--- /dev/null
@@ -0,0 +1,42 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+cdef jsonb_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+    cdef:
+        char *str
+        ssize_t size
+
+    as_pg_string_and_size(settings, obj, &str, &size)
+
+    if size > 0x7fffffff - 1:
+        raise ValueError('string too long')
+
+    buf.write_int32(<int32_t>size + 1)
+    buf.write_byte(1)  # JSONB format version
+    buf.write_cstr(str, size)
+
+
+cdef jsonb_decode(ConnectionSettings settings, FastReadBuffer buf):
+    cdef uint8_t format = <uint8_t>buf.read(1)[0]
+
+    if format != 1:
+        raise ValueError('unexpected JSONB format: {}'.format(format))
+
+    return text_decode(settings, buf)
+
+
+cdef init_json_codecs():
+    register_core_codec(JSONOID,
+                        <encode_func>&text_encode,
+                        <decode_func>&text_decode,
+                        PG_FORMAT_BINARY)
+    register_core_codec(JSONBOID,
+                        <encode_func>&jsonb_encode,
+                        <decode_func>&jsonb_decode,
+                        PG_FORMAT_BINARY)
+
+init_json_codecs()
diff --git a/asyncpg/protocol/codecs/misc.pyx b/asyncpg/protocol/codecs/misc.pyx
new file mode 100644 (file)
index 0000000..01f4a5d
--- /dev/null
@@ -0,0 +1,108 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+cdef void_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+    # Void is zero bytes
+    buf.write_int32(0)
+
+
+cdef void_decode(ConnectionSettings settings, FastReadBuffer buf):
+    # Do nothing; void will be passed as NULL so this function
+    # will never be called.
+    pass
+
+
+cdef init_pseudo_codecs():
+    # Void type is returned by SELECT void_returning_function()
+    register_core_codec(VOIDOID,
+                        <encode_func>&void_encode,
+                        <decode_func>&void_decode,
+                        PG_FORMAT_BINARY)
+
+    # Unknown type, always decoded as text
+    register_core_codec(UNKNOWNOID,
+                        <encode_func>&text_encode,
+                        <decode_func>&text_decode,
+                        PG_FORMAT_TEXT)
+
+    # OID and friends
+    oid_types = [
+        OIDOID, TIDOID, XIDOID, CIDOID
+    ]
+
+    for oid_type in oid_types:
+        register_core_codec(oid_type,
+                            <encode_func>&int4_encode,
+                            <decode_func>&int4_decode,
+                            PG_FORMAT_BINARY)
+
+    # reg* types -- these are really system catalog OIDs, but
+    # allow the catalog object name as an input.  We could just
+    # decode these as OIDs, but handling them as text seems more
+    # useful.
+    #
+    reg_types = [
+        REGPROCOID, REGPROCEDUREOID, REGOPEROID, REGOPERATOROID,
+        REGCLASSOID, REGTYPEOID, REGCONFIGOID, REGDICTIONARYOID,
+        REGNAMESPACEOID, REGROLEOID, REFCURSOROID
+    ]
+
+    for reg_type in reg_types:
+        register_core_codec(reg_type,
+                            <encode_func>&text_encode,
+                            <decode_func>&text_decode,
+                            PG_FORMAT_TEXT)
+
+    # cstring type is used by Postgres' I/O functions
+    register_core_codec(CSTRINGOID,
+                        <encode_func>&text_encode,
+                        <decode_func>&text_decode,
+                        PG_FORMAT_BINARY)
+
+    # various system pseudotypes with no I/O
+    no_io_types = [
+        ANYOID, TRIGGEROID, EVENT_TRIGGEROID, LANGUAGE_HANDLEROID,
+        FDW_HANDLEROID, TSM_HANDLEROID, INTERNALOID, OPAQUEOID,
+        ANYELEMENTOID, ANYNONARRAYOID, PG_DDL_COMMANDOID,
+    ]
+
+    register_core_codec(ANYENUMOID,
+                        NULL,
+                        <decode_func>&text_decode,
+                        PG_FORMAT_TEXT)
+
+    for no_io_type in no_io_types:
+        register_core_codec(no_io_type,
+                            NULL,
+                            NULL,
+                            PG_FORMAT_BINARY)
+
+    # ACL specification string
+    register_core_codec(ACLITEMOID,
+                        <encode_func>&text_encode,
+                        <decode_func>&text_decode,
+                        PG_FORMAT_TEXT)
+
+    # Postgres' serialized expression tree type
+    register_core_codec(PG_NODE_TREEOID,
+                        NULL,
+                        <decode_func>&text_decode,
+                        PG_FORMAT_TEXT)
+
+    # pg_lsn type -- a pointer to a location in the XLOG.
+    register_core_codec(PG_LSNOID,
+                        <encode_func>&int8_encode,
+                        <decode_func>&int8_decode,
+                        PG_FORMAT_BINARY)
+
+    register_core_codec(SMGROID,
+                        <encode_func>&text_encode,
+                        <decode_func>&text_decode,
+                        PG_FORMAT_TEXT)
+
+
+init_pseudo_codecs()
diff --git a/asyncpg/protocol/codecs/money.pyx b/asyncpg/protocol/codecs/money.pyx
new file mode 100644 (file)
index 0000000..edc340b
--- /dev/null
@@ -0,0 +1,20 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+cdef init_monetary_codecs():
+    moneyoids = [
+        MONEYOID,
+    ]
+
+    for oid in moneyoids:
+        register_core_codec(oid,
+                            <encode_func>&text_encode,
+                            <decode_func>&text_decode,
+                            PG_FORMAT_TEXT)
+
+
+init_monetary_codecs()
diff --git a/asyncpg/protocol/codecs/network.pyx b/asyncpg/protocol/codecs/network.pyx
new file mode 100644 (file)
index 0000000..336442d
--- /dev/null
@@ -0,0 +1,111 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import ipaddress
+
+
+# defined in postgresql/src/include/inet.h
+#
+DEF PGSQL_AF_INET = 2  # AF_INET
+DEF PGSQL_AF_INET6 = 3  # AF_INET + 1
+
+
+_ipaddr = ipaddress.ip_address
+_ipnet = ipaddress.ip_network
+
+
+cdef inline _net_encode(WriteBuffer buf, int32_t version, uint8_t bits,
+                        int8_t is_cidr, bytes addr):
+
+    cdef:
+        char *addrbytes
+        ssize_t addrlen
+        int8_t family
+
+    family = PGSQL_AF_INET if version == 4 else PGSQL_AF_INET6
+    cpython.PyBytes_AsStringAndSize(addr, &addrbytes, &addrlen)
+
+    buf.write_int32(4 + <int32_t>addrlen)
+    buf.write_byte(family)
+    buf.write_byte(<int8_t>bits)
+    buf.write_byte(is_cidr)
+    buf.write_byte(<int8_t>addrlen)
+    buf.write_cstr(addrbytes, addrlen)
+
+
+cdef net_decode(ConnectionSettings settings, FastReadBuffer buf):
+    cdef:
+        int32_t family = <int32_t>buf.read(1)[0]
+        uint8_t bits = <uint8_t>buf.read(1)[0]
+        uint32_t is_cidr = <uint32_t>buf.read(1)[0]
+        uint32_t addrlen = <uint32_t>buf.read(1)[0]
+        bytes addr
+
+    if family != PGSQL_AF_INET and family != PGSQL_AF_INET6:
+        raise ValueError('invalid address family in "{}" value'.format(
+            'cidr' if is_cidr else 'inet'
+        ))
+
+    if bits > (32 if family == PGSQL_AF_INET else 128):
+        raise ValueError('invalid bits in "{}" value'.format(
+            'cidr' if is_cidr else 'inet'
+        ))
+
+    if addrlen != (4 if family == PGSQL_AF_INET else 16):
+        raise ValueError('invalid length in "{}" value'.format(
+            'cidr' if is_cidr else 'inet'
+        ))
+
+    addr = cpython.PyBytes_FromStringAndSize(buf.read(addrlen), addrlen)
+
+    if is_cidr or bits > 0:
+        return _ipnet(addr).supernet(new_prefix=cpython.PyLong_FromLong(bits))
+    else:
+        return _ipaddr(addr)
+
+
+cdef cidr_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+    cdef:
+        object ipnet
+
+    ipnet = _ipnet(obj)
+    _net_encode(buf, ipnet.version, ipnet.prefixlen, 1,
+                ipnet.network_address.packed)
+
+
+cdef inet_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+    cdef:
+        object ipaddr
+
+    try:
+        ipaddr = _ipaddr(obj)
+    except ValueError:
+        # PostgreSQL accepts *both* CIDR and host values
+        # for the host datatype.
+        cidr_encode(settings, buf, obj)
+    else:
+        _net_encode(buf, ipaddr.version, 0, 0, ipaddr.packed)
+
+
+cdef init_network_codecs():
+    register_core_codec(CIDROID,
+                        <encode_func>&cidr_encode,
+                        <decode_func>&net_decode,
+                        PG_FORMAT_BINARY)
+
+    register_core_codec(INETOID,
+                        <encode_func>&inet_encode,
+                        <decode_func>&net_decode,
+                        PG_FORMAT_BINARY)
+
+    register_core_codec(MACADDROID,
+                        <encode_func>&text_encode,
+                        <decode_func>&text_decode,
+                        PG_FORMAT_TEXT)
+
+
+init_network_codecs()
diff --git a/asyncpg/protocol/codecs/numeric.pyx b/asyncpg/protocol/codecs/numeric.pyx
new file mode 100644 (file)
index 0000000..bcc2389
--- /dev/null
@@ -0,0 +1,28 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import decimal
+
+
+_Dec = decimal.Decimal
+
+
+cdef numeric_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+    text_encode(settings, buf, str(obj))
+
+
+cdef numeric_decode(ConnectionSettings settings, FastReadBuffer buf):
+    return _Dec(text_decode(settings, buf))
+
+
+cdef init_numeric_codecs():
+    register_core_codec(NUMERICOID,
+                        <encode_func>&numeric_encode,
+                        <decode_func>&numeric_decode,
+                        PG_FORMAT_TEXT)
+
+init_numeric_codecs()
diff --git a/asyncpg/protocol/codecs/range.pyx b/asyncpg/protocol/codecs/range.pyx
new file mode 100644 (file)
index 0000000..979caf1
--- /dev/null
@@ -0,0 +1,149 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+from asyncpg import types as apg_types
+
+# defined in postgresql/src/include/utils/rangetypes.h
+DEF RANGE_EMPTY  = 0x01  # range is empty
+DEF RANGE_LB_INC = 0x02  # lower bound is inclusive
+DEF RANGE_UB_INC = 0x04  # upper bound is inclusive
+DEF RANGE_LB_INF = 0x08  # lower bound is -infinity
+DEF RANGE_UB_INF = 0x10  # upper bound is +infinity
+
+
+cdef enum _RangeArgumentType:
+    _RANGE_ARGUMENT_INVALID = 0
+    _RANGE_ARGUMENT_TUPLE = 1
+    _RANGE_ARGUMENT_RANGE = 2
+
+
+cdef inline bint _range_has_lbound(uint8_t flags):
+    return not (flags & (RANGE_EMPTY | RANGE_LB_INF))
+
+
+cdef inline bint _range_has_ubound(uint8_t flags):
+    return not (flags & (RANGE_EMPTY | RANGE_UB_INF))
+
+
+cdef inline _RangeArgumentType _range_type(object obj):
+    if cpython.PyTuple_Check(obj) or cpython.PyList_Check(obj):
+        return _RANGE_ARGUMENT_TUPLE
+    elif isinstance(obj, apg_types.Range):
+        return _RANGE_ARGUMENT_RANGE
+    else:
+        return _RANGE_ARGUMENT_INVALID
+
+
+cdef range_encode(ConnectionSettings settings, WriteBuffer buf,
+                  object obj, uint32_t elem_oid,
+                  encode_func_ex encoder, const void *encoder_arg):
+    cdef:
+        ssize_t obj_len
+        uint8_t flags = 0
+        object lower = None
+        object upper = None
+        WriteBuffer bounds_data = WriteBuffer.new()
+        _RangeArgumentType arg_type = _range_type(obj)
+
+    if arg_type == _RANGE_ARGUMENT_INVALID:
+        raise TypeError(
+            'list, tuple or Range object expected (got type {})'.format(
+                type(obj)))
+
+    elif arg_type == _RANGE_ARGUMENT_TUPLE:
+        obj_len = len(obj)
+        if obj_len == 2:
+            lower = obj[0]
+            upper = obj[1]
+
+            if lower is None:
+                flags |= RANGE_LB_INF
+
+            if upper is None:
+                flags |= RANGE_UB_INF
+
+            flags |= RANGE_LB_INC | RANGE_UB_INC
+
+        elif obj_len == 1:
+            lower = obj[0]
+            flags |= RANGE_LB_INC | RANGE_UB_INF
+
+        elif obj_len == 0:
+            flags |= RANGE_EMPTY
+
+        else:
+            raise ValueError(
+                'expected 0, 1 or 2 elements in range (got {})'.format(
+                    obj_len))
+
+    else:
+        if obj.isempty:
+            flags |= RANGE_EMPTY
+        else:
+            lower = obj.lower
+            upper = obj.upper
+
+            if obj.lower_inc:
+                flags |= RANGE_LB_INC
+            elif lower is None:
+                flags |= RANGE_LB_INF
+
+            if obj.upper_inc:
+                flags |= RANGE_UB_INC
+            elif upper is None:
+                flags |= RANGE_UB_INF
+
+    if _range_has_lbound(flags):
+        encoder(settings, bounds_data, lower, encoder_arg)
+
+    if _range_has_ubound(flags):
+        encoder(settings, bounds_data, upper, encoder_arg)
+
+    buf.write_int32(1 + bounds_data.len())
+    buf.write_byte(<int8_t>flags)
+    buf.write_buffer(bounds_data)
+
+
+cdef range_decode(ConnectionSettings settings, FastReadBuffer buf,
+                  decode_func_ex decoder, const void *decoder_arg):
+    cdef:
+        uint8_t flags = <uint8_t>buf.read(1)[0]
+        int32_t bound_len
+        object lower = None
+        object upper = None
+        FastReadBuffer bound_buf = FastReadBuffer.new()
+
+    if _range_has_lbound(flags):
+        bound_len = hton.unpack_int32(buf.read(4))
+        if bound_len == -1:
+            lower = None
+        else:
+            bound_buf.slice_from(buf, bound_len)
+            lower = decoder(settings, bound_buf, decoder_arg)
+
+    if _range_has_ubound(flags):
+        bound_len = hton.unpack_int32(buf.read(4))
+        if bound_len == -1:
+            upper = None
+        else:
+            bound_buf.slice_from(buf, bound_len)
+            upper = decoder(settings, bound_buf, decoder_arg)
+
+    return apg_types.Range(lower=lower, upper=upper,
+                           lower_inc=(flags & RANGE_LB_INC) != 0,
+                           upper_inc=(flags & RANGE_UB_INC) != 0,
+                           empty=(flags & RANGE_EMPTY) != 0)
+
+
+cdef init_range_codecs():
+    register_core_codec(ANYRANGEOID,
+                        NULL,
+                        <decode_func>&text_decode,
+                        PG_FORMAT_TEXT)
+
+
+init_range_codecs()
diff --git a/asyncpg/protocol/codecs/record.pyx b/asyncpg/protocol/codecs/record.pyx
new file mode 100644 (file)
index 0000000..291a0b1
--- /dev/null
@@ -0,0 +1,57 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+cdef inline record_encode_frame(ConnectionSettings settings, WriteBuffer buf,
+                                WriteBuffer elem_data, int32_t elem_count):
+    buf.write_int32(4 + elem_data.len())
+    # attribute count
+    buf.write_int32(elem_count)
+    # encoded attribute data
+    buf.write_buffer(elem_data)
+
+
+cdef anonymous_record_decode(ConnectionSettings settings, FastReadBuffer buf):
+    cdef:
+        tuple result
+        uint32_t elem_count
+        int32_t elem_len
+        uint32_t elem_typ
+        uint32_t i
+        Codec elem_codec
+        FastReadBuffer elem_buf = FastReadBuffer.new()
+
+    elem_count = <uint32_t>hton.unpack_int32(buf.read(4))
+    result = cpython.PyTuple_New(elem_count)
+
+    for i in range(elem_count):
+        elem_typ = <uint32_t>hton.unpack_int32(buf.read(4))
+        elem_len = hton.unpack_int32(buf.read(4))
+
+        if elem_len == -1:
+            elem = None
+        else:
+            elem_codec = settings.get_data_codec(elem_typ)
+            if elem_codec is None or not elem_codec.has_decoder():
+                raise RuntimeError(
+                    'no decoder for composite type element in '
+                    'position {} of type OID {}'.format(i, elem_typ))
+            elem = elem_codec.decode(settings,
+                                     elem_buf.slice_from(buf, elem_len))
+
+        cpython.Py_INCREF(elem)
+        cpython.PyTuple_SET_ITEM(result, i, elem)
+
+    return result
+
+
+cdef init_record_codecs():
+    register_core_codec(RECORDOID,
+                        <encode_func>NULL,
+                        <decode_func>&anonymous_record_decode,
+                        PG_FORMAT_BINARY)
+
+init_record_codecs()
diff --git a/asyncpg/protocol/codecs/text.pyx b/asyncpg/protocol/codecs/text.pyx
new file mode 100644 (file)
index 0000000..b8397d9
--- /dev/null
@@ -0,0 +1,67 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+cdef inline as_pg_string_and_size(
+        ConnectionSettings settings, obj, char **cstr, ssize_t *size):
+
+    if not cpython.PyUnicode_Check(obj):
+        obj = str(obj)
+
+    if settings.is_encoding_utf8():
+        cstr[0] = PyUnicode_AsUTF8AndSize(obj, size)
+    else:
+        encoded = settings.get_text_codec().encode(obj)
+        cpython.PyBytes_AsStringAndSize(encoded, cstr, size)
+
+    if size[0] > 0x7fffffff:
+        raise ValueError('string too long')
+
+
+cdef text_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+    cdef:
+        char *str
+        ssize_t size
+
+    as_pg_string_and_size(settings, obj, &str, &size)
+
+    buf.write_int32(<int32_t>size)
+    buf.write_cstr(str, size)
+
+
+cdef inline decode_pg_string(ConnectionSettings settings, const char* data,
+                             ssize_t len):
+
+    if settings.is_encoding_utf8():
+        # decode UTF-8 in strict mode
+        return cpython.PyUnicode_DecodeUTF8(data, len, NULL)
+    else:
+        bytes = cpython.PyBytes_FromStringAndSize(data, len)
+        return settings.get_text_codec().decode(bytes)
+
+
+cdef text_decode(ConnectionSettings settings, FastReadBuffer buf):
+    cdef ssize_t buf_len = buf.len
+    return decode_pg_string(settings, buf.read_all(), buf_len)
+
+
+cdef init_text_codecs():
+    textoids = [
+        NAMEOID,
+        BPCHAROID,
+        VARCHAROID,
+        TEXTOID,
+        XMLOID
+    ]
+
+    for oid in textoids:
+        register_core_codec(oid,
+                            <encode_func>&text_encode,
+                            <decode_func>&text_decode,
+                            PG_FORMAT_BINARY)
+
+
+init_text_codecs()
diff --git a/asyncpg/protocol/codecs/textutils.pyx b/asyncpg/protocol/codecs/textutils.pyx
new file mode 100644 (file)
index 0000000..1a09c17
--- /dev/null
@@ -0,0 +1,72 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+
+cdef int apg_strcasecmp(const Py_UCS4 *s1, const Py_UCS4 *s2):
+    cdef:
+        uint32_t c1
+        uint32_t c2
+        int i = 0
+
+    while True:
+        c1 = s1[i]
+        c2 = s2[i]
+
+        if c1 != c2:
+            if c1 >= <uint32_t><Py_UCS4>'A' and c1 <= <uint32_t><Py_UCS4>'Z':
+                c1 += <uint32_t><Py_UCS4>'a' - <uint32_t><Py_UCS4>'A'
+            if c2 >= <uint32_t><Py_UCS4>'A' and c2 <= <uint32_t><Py_UCS4>'Z':
+                c2 += <uint32_t><Py_UCS4>'a' - <uint32_t><Py_UCS4>'A'
+
+            if c1 != c2:
+                return <int32_t>c1 - <int32_t>c2
+
+        if c1 == 0 or c2 == 0:
+            break
+
+        i += 1
+
+    return 0
+
+
+cdef inline bint apg_ascii_isspace(Py_UCS4 ch):
+    return (
+        ch == ' ' or
+        ch == '\n' or
+        ch == '\r' or
+        ch == '\t' or
+        ch == '\v' or
+        ch == '\f'
+    )
+
+
+cdef Py_UCS4 *apg_parse_int32(Py_UCS4 *buf, int32_t *num):
+    cdef:
+        Py_UCS4 *p
+        int32_t n = 0
+        int32_t neg = 0
+
+    if buf[0] == '-':
+        neg = 1
+        buf += 1
+    elif buf[0] == '+':
+        buf += 1
+
+    p = buf
+    while <int>p[0] >= <int><Py_UCS4>'0' and <int>p[0] <= <int><Py_UCS4>'9':
+        n = 10 * n - (<int>p[0] - <int32_t><Py_UCS4>'0')
+        p += 1
+
+    if p == buf:
+        return NULL
+
+    if not neg:
+        n = -n
+
+    num[0] = n
+
+    return p
diff --git a/asyncpg/protocol/codecs/tsearch.pyx b/asyncpg/protocol/codecs/tsearch.pyx
new file mode 100644 (file)
index 0000000..dd080d5
--- /dev/null
@@ -0,0 +1,26 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+cdef init_tsearch_codecs():
+    ts_oids = [
+        TSQUERYOID,
+        TSVECTOROID,
+    ]
+
+    for oid in ts_oids:
+        register_core_codec(oid,
+                            <encode_func>&text_encode,
+                            <decode_func>&text_decode,
+                            PG_FORMAT_TEXT)
+
+    register_core_codec(GTSVECTOROID,
+                        NULL,
+                        <decode_func>&text_decode,
+                        PG_FORMAT_TEXT)
+
+
+init_tsearch_codecs()
diff --git a/asyncpg/protocol/codecs/txid.pyx b/asyncpg/protocol/codecs/txid.pyx
new file mode 100644 (file)
index 0000000..5ea5e41
--- /dev/null
@@ -0,0 +1,71 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+cdef txid_snapshot_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+    cdef:
+        ssize_t nxip
+        int64_t xmin
+        int64_t xmax
+        int i
+        WriteBuffer xip_buf = WriteBuffer.new()
+
+    if not (cpython.PyTuple_Check(obj) or cpython.PyList_Check(obj)):
+        raise TypeError(
+            'list or tuple expected (got type {})'.format(type(obj)))
+
+    if len(obj) != 3:
+        raise ValueError(
+            'invalid number of elements in txid_snapshot tuple, expecting 4')
+
+    nxip = len(obj[2])
+    if nxip > _MAXINT32:
+        raise ValueError('txid_snapshot value is too long')
+
+    xmin = obj[0]
+    xmax = obj[1]
+
+    for i in range(nxip):
+        xip_buf.write_int64(obj[2][i])
+
+    buf.write_int32(20 + xip_buf.len())
+
+    buf.write_int32(<int32_t>nxip)
+    buf.write_int64(obj[0])
+    buf.write_int64(obj[1])
+    buf.write_buffer(xip_buf)
+
+
+cdef txid_snapshot_decode(ConnectionSettings settings, FastReadBuffer buf):
+    cdef:
+        int32_t nxip
+        int64_t xmin
+        int64_t xmax
+        tuple xip_tup
+        int32_t i
+        object xip
+
+    nxip = hton.unpack_int32(buf.read(4))
+    xmin = hton.unpack_int64(buf.read(8))
+    xmax = hton.unpack_int64(buf.read(8))
+
+    xip_tup = cpython.PyTuple_New(nxip)
+    for i in range(nxip):
+        xip = cpython.PyLong_FromLongLong(hton.unpack_int64(buf.read(8)))
+        cpython.Py_INCREF(xip)
+        cpython.PyTuple_SET_ITEM(xip_tup, i, xip)
+
+    return (xmin, xmax, xip_tup)
+
+
+cdef init_txid_codecs():
+    register_core_codec(TXID_SNAPSHOTOID,
+                        <encode_func>&txid_snapshot_encode,
+                        <decode_func>&txid_snapshot_decode,
+                        PG_FORMAT_BINARY)
+
+
+init_txid_codecs()
diff --git a/asyncpg/protocol/codecs/uuid.pyx b/asyncpg/protocol/codecs/uuid.pyx
new file mode 100644 (file)
index 0000000..a40ef3a
--- /dev/null
@@ -0,0 +1,31 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import uuid
+
+
+_UUID = uuid.UUID
+
+
+cdef uuid_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):
+    if cpython.PyUnicode_Check(obj):
+        obj = _UUID(obj)
+
+    bytea_encode(settings, wbuf, obj.bytes)
+
+
+cdef uuid_decode(ConnectionSettings settings, FastReadBuffer buf):
+    return _UUID(bytes=bytea_decode(settings, buf))
+
+
+cdef init_uuid_codecs():
+    register_core_codec(UUIDOID,
+                        <encode_func>&uuid_encode,
+                        <decode_func>&uuid_decode,
+                        PG_FORMAT_BINARY)
+
+init_uuid_codecs()
diff --git a/asyncpg/protocol/consts.pxi b/asyncpg/protocol/consts.pxi
new file mode 100644 (file)
index 0000000..cfa82e6
--- /dev/null
@@ -0,0 +1,13 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+DEF _BUFFER_INITIAL_SIZE = 1024
+DEF _BUFFER_MAX_GROW = 65536
+DEF _BUFFER_FREELIST_SIZE = 256
+DEF _RECORD_FREELIST_SIZE = 1024
+DEF _MEMORY_FREELIST_SIZE = 1024
+DEF _MAXINT32 = 2**31 - 1
diff --git a/asyncpg/protocol/coreproto.pxd b/asyncpg/protocol/coreproto.pxd
new file mode 100644 (file)
index 0000000..efe5d1b
--- /dev/null
@@ -0,0 +1,158 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+cdef enum ConnectionStatus:
+    CONNECTION_OK = 1
+    CONNECTION_BAD = 2
+    CONNECTION_STARTED = 3           # Waiting for connection to be made.
+
+
+cdef enum ProtocolState:
+    PROTOCOL_IDLE = 0
+
+    PROTOCOL_FAILED = 1
+
+    PROTOCOL_ERROR_CONSUME = 2
+
+    PROTOCOL_AUTH = 10
+    PROTOCOL_PREPARE = 11
+    PROTOCOL_BIND_EXECUTE = 12
+    PROTOCOL_BIND_EXECUTE_MANY = 13
+    PROTOCOL_CLOSE_STMT_PORTAL = 14
+    PROTOCOL_SIMPLE_QUERY = 15
+    PROTOCOL_EXECUTE = 16
+    PROTOCOL_BIND = 17
+
+
+cdef enum AuthenticationMessage:
+    AUTH_SUCCESSFUL = 0
+    AUTH_REQUIRED_KERBEROS = 2
+    AUTH_REQUIRED_PASSWORD = 3
+    AUTH_REQUIRED_PASSWORDMD5 = 5
+    AUTH_REQUIRED_SCMCRED = 6
+    AUTH_REQUIRED_GSS = 7
+    AUTH_REQUIRED_GSS_CONTINUE = 8
+    AUTH_REQUIRED_SSPI = 9
+
+
+AUTH_METHOD_NAME = {
+    AUTH_REQUIRED_KERBEROS: 'kerberosv5',
+    AUTH_REQUIRED_PASSWORD: 'password',
+    AUTH_REQUIRED_PASSWORDMD5: 'md5',
+    AUTH_REQUIRED_GSS: 'gss',
+    AUTH_REQUIRED_SSPI: 'sspi',
+}
+
+
+cdef enum ResultType:
+    RESULT_OK = 1
+    RESULT_FAILED = 2
+
+
+cdef enum TransactionStatus:
+    PQTRANS_IDLE = 0                 # connection idle
+    PQTRANS_ACTIVE = 1               # command in progress
+    PQTRANS_INTRANS = 2              # idle, within transaction block
+    PQTRANS_INERROR = 3              # idle, within failed transaction
+    PQTRANS_UNKNOWN = 4              # cannot determine status
+
+
+ctypedef object (*decode_row_method)(object, const char*, ssize_t)
+
+
+cdef class CoreProtocol:
+    cdef:
+        ReadBuffer buffer
+        bint _skip_discard
+        bint _discard_data
+
+        # executemany support data
+        object _execute_iter
+        str _execute_portal_name
+        str _execute_stmt_name
+
+        ConnectionStatus con_status
+        ProtocolState state
+        TransactionStatus xact_status
+
+        str encoding
+
+        object transport
+
+        # Dict with all connection arguments
+        dict con_args
+
+        readonly int32_t backend_pid
+        readonly int32_t backend_secret
+
+        ## Result
+        ResultType result_type
+        object result
+        bytes result_param_desc
+        bytes result_row_desc
+        bytes result_status_msg
+
+        # True - completed, False - suspended
+        bint result_execute_completed
+
+    cdef _process__auth(self, char mtype)
+    cdef _process__prepare(self, char mtype)
+    cdef _process__bind_execute(self, char mtype)
+    cdef _process__bind_execute_many(self, char mtype)
+    cdef _process__close_stmt_portal(self, char mtype)
+    cdef _process__simple_query(self, char mtype)
+    cdef _process__bind(self, char mtype)
+
+    cdef _parse_msg_authentication(self)
+    cdef _parse_msg_parameter_status(self)
+    cdef _parse_msg_notification(self)
+    cdef _parse_msg_backend_key_data(self)
+    cdef _parse_msg_ready_for_query(self)
+    cdef _parse_data_msgs(self)
+    cdef _parse_msg_error_response(self, is_error)
+    cdef _parse_msg_command_complete(self)
+
+    cdef _auth_password_message_cleartext(self)
+    cdef _auth_password_message_md5(self, bytes salt)
+
+    cdef _write(self, buf)
+    cdef inline _write_sync_message(self)
+
+    cdef _read_server_messages(self)
+
+    cdef _push_result(self)
+    cdef _reset_result(self)
+    cdef _set_state(self, ProtocolState new_state)
+
+    cdef _ensure_connected(self)
+
+    cdef WriteBuffer _build_bind_message(self, str portal_name,
+                                         str stmt_name,
+                                         WriteBuffer bind_data)
+
+
+    cdef _connect(self)
+    cdef _prepare(self, str stmt_name, str query)
+    cdef _send_bind_message(self, str portal_name, str stmt_name,
+                            WriteBuffer bind_data, int32_t limit)
+    cdef _bind_execute(self, str portal_name, str stmt_name,
+                       WriteBuffer bind_data, int32_t limit)
+    cdef _bind_execute_many(self, str portal_name, str stmt_name,
+                            object bind_data)
+    cdef _bind(self, str portal_name, str stmt_name,
+               WriteBuffer bind_data)
+    cdef _execute(self, str portal_name, int32_t limit)
+    cdef _close(self, str name, bint is_portal)
+    cdef _simple_query(self, str query)
+    cdef _terminate(self)
+
+    cdef _decode_row(self, const char* buf, ssize_t buf_len)
+
+    cdef _on_result(self)
+    cdef _on_notification(self, pid, channel, payload)
+    cdef _set_server_parameter(self, name, val)
+    cdef _on_connection_lost(self, exc)
diff --git a/asyncpg/protocol/coreproto.pyx b/asyncpg/protocol/coreproto.pyx
new file mode 100644 (file)
index 0000000..b72cdff
--- /dev/null
@@ -0,0 +1,756 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+from hashlib import md5 as hashlib_md5  # for MD5 authentication
+
+
+cdef class CoreProtocol:
+
+    def __init__(self, con_args):
+        self.buffer = ReadBuffer()
+        self.user = con_args.get('user')
+        self.password = con_args.get('password')
+        self.auth_msg = None
+        self.con_args = con_args
+        self.transport = None
+        self.con_status = CONNECTION_BAD
+        self.state = PROTOCOL_IDLE
+        self.xact_status = PQTRANS_IDLE
+        self.encoding = 'utf-8'
+
+        self._skip_discard = False
+
+        # executemany support data
+        self._execute_iter = None
+        self._execute_portal_name = None
+        self._execute_stmt_name = None
+
+        self._reset_result()
+
+    cdef _write(self, buf):
+        self.transport.write(memoryview(buf))
+
+    cdef inline _write_sync_message(self):
+        self.transport.write(SYNC_MESSAGE)
+
+    cdef _read_server_messages(self):
+        cdef:
+            char mtype
+            ProtocolState state
+
+        while self.buffer.has_message() == 1:
+            mtype = self.buffer.get_message_type()
+            state = self.state
+
+            try:
+                if mtype == b'S':
+                    # ParameterStatus
+                    self._parse_msg_parameter_status()
+                    continue
+                elif mtype == b'A':
+                    # NotificationResponse
+                    self._parse_msg_notification()
+                    continue
+
+                if state == PROTOCOL_AUTH:
+                    self._process__auth(mtype)
+
+                elif state == PROTOCOL_PREPARE:
+                    self._process__prepare(mtype)
+
+                elif state == PROTOCOL_BIND_EXECUTE:
+                    self._process__bind_execute(mtype)
+
+                elif state == PROTOCOL_BIND_EXECUTE_MANY:
+                    self._process__bind_execute_many(mtype)
+
+                elif state == PROTOCOL_EXECUTE:
+                    self._process__bind_execute(mtype)
+
+                elif state == PROTOCOL_BIND:
+                    self._process__bind(mtype)
+
+                elif state == PROTOCOL_CLOSE_STMT_PORTAL:
+                    self._process__close_stmt_portal(mtype)
+
+                elif state == PROTOCOL_SIMPLE_QUERY:
+                    self._process__simple_query(mtype)
+
+                elif state == PROTOCOL_ERROR_CONSUME:
+                    # Error in protocol (on asyncpg side);
+                    # discard all messages until sync message
+
+                    if mtype == b'Z':
+                        # Sync point, self to push the result
+                        if self.result_type != RESULT_FAILED:
+                            self.result_type = RESULT_FAILED
+                            self.result = RuntimeError(
+                                'unknown error in protocol implementation')
+
+                        self._push_result()
+
+                    else:
+                        self.buffer.consume_message()
+
+                else:
+                    raise RuntimeError(
+                        'protocol is in an unknown state {}'.format(state))
+
+            except Exception as ex:
+                self.result_type = RESULT_FAILED
+                self.result = ex
+
+                if mtype == b'Z':
+                    self._push_result()
+                else:
+                    self.state = PROTOCOL_ERROR_CONSUME
+
+            finally:
+                if self._skip_discard:
+                    self._skip_discard = False
+                else:
+                    self.buffer.discard_message()
+
+    cdef _process__auth(self, char mtype):
+        if mtype == b'R':
+            # Authentication...
+            self._parse_msg_authentication()
+            if self.result_type != RESULT_OK:
+                self.con_status = CONNECTION_BAD
+                self._push_result()
+                self.transport.close()
+
+            elif self.auth_msg is not None:
+                # Server wants us to send auth data, so do that.
+                self._write(self.auth_msg)
+                self.auth_msg = None
+
+        elif mtype == b'K':
+            # BackendKeyData
+            self._parse_msg_backend_key_data()
+
+        elif mtype == b'E':
+            # ErrorResponse
+            self.con_status = CONNECTION_BAD
+            self._parse_msg_error_response(True)
+            self._push_result()
+
+        elif mtype == b'Z':
+            # ReadyForQuery
+            self._parse_msg_ready_for_query()
+            self.con_status = CONNECTION_OK
+            self._push_result()
+
+    cdef _process__prepare(self, char mtype):
+        if mtype == b't':
+            # Parameters description
+            self.result_param_desc = self.buffer.consume_message().as_bytes()
+
+        elif mtype == b'1':
+            # ParseComplete
+            self.buffer.consume_message()
+
+        elif mtype == b'T':
+            # Row description
+            self.result_row_desc = self.buffer.consume_message().as_bytes()
+
+        elif mtype == b'E':
+            # ErrorResponse
+            self._parse_msg_error_response(True)
+
+        elif mtype == b'Z':
+            # ReadyForQuery
+            self._parse_msg_ready_for_query()
+            self._push_result()
+
+        elif mtype == b'n':
+            # NoData
+            self.buffer.consume_message()
+
+    cdef _process__bind_execute(self, char mtype):
+        if mtype == b'D':
+            # DataRow
+            self._parse_data_msgs()
+
+        elif mtype == b's':
+            # PortalSuspended
+            self.buffer.consume_message()
+
+        elif mtype == b'C':
+            # CommandComplete
+            self.result_execute_completed = True
+            self._parse_msg_command_complete()
+
+        elif mtype == b'E':
+            # ErrorResponse
+            self._parse_msg_error_response(True)
+
+        elif mtype == b'2':
+            # BindComplete
+            self.buffer.consume_message()
+
+        elif mtype == b'Z':
+            # ReadyForQuery
+            self._parse_msg_ready_for_query()
+            self._push_result()
+
+        elif mtype == b'I':
+            # EmptyQueryResponse
+            self.buffer.consume_message()
+
+    cdef _process__bind_execute_many(self, char mtype):
+        cdef WriteBuffer buf
+
+        if mtype == b'D':
+            # DataRow
+            self._parse_data_msgs()
+
+        elif mtype == b's':
+            # PortalSuspended
+            self.buffer.consume_message()
+
+        elif mtype == b'C':
+            # CommandComplete
+            self._parse_msg_command_complete()
+
+        elif mtype == b'E':
+            # ErrorResponse
+            self._parse_msg_error_response(True)
+
+        elif mtype == b'2':
+            # BindComplete
+            self.buffer.consume_message()
+
+        elif mtype == b'Z':
+            # ReadyForQuery
+            self._parse_msg_ready_for_query()
+            if self.result_type == RESULT_FAILED:
+                self._push_result()
+            else:
+                try:
+                    buf = <WriteBuffer>next(self._execute_iter)
+                except StopIteration:
+                    self._push_result()
+                else:
+                    # Next iteration over the executemany() arg sequence
+                    self._send_bind_message(
+                        self._execute_portal_name, self._execute_stmt_name,
+                        buf, 0)
+
+        elif mtype == b'I':
+            # EmptyQueryResponse
+            self.buffer.consume_message()
+
+    cdef _process__bind(self, char mtype):
+        if mtype == b'E':
+            # ErrorResponse
+            self._parse_msg_error_response(True)
+
+        elif mtype == b'2':
+            # BindComplete
+            self.buffer.consume_message()
+
+        elif mtype == b'Z':
+            # ReadyForQuery
+            self._parse_msg_ready_for_query()
+            self._push_result()
+
+    cdef _process__close_stmt_portal(self, char mtype):
+        if mtype == b'E':
+            # ErrorResponse
+            self._parse_msg_error_response(True)
+
+        elif mtype == b'3':
+            # CloseComplete
+            self.buffer.consume_message()
+
+        elif mtype == b'Z':
+            # ReadyForQuery
+            self._parse_msg_ready_for_query()
+            self._push_result()
+
+    cdef _process__simple_query(self, char mtype):
+        if mtype in {b'D', b'I', b'N', b'T'}:
+            # 'D' - DataRow
+            # 'I' - EmptyQueryResponse
+            # 'N' - NoticeResponse
+            # 'T' - RowDescription
+            self.buffer.consume_message()
+
+        elif mtype == b'E':
+            # ErrorResponse
+            self._parse_msg_error_response(True)
+
+        elif mtype == b'Z':
+            # ReadyForQuery
+            self._parse_msg_ready_for_query()
+            self._push_result()
+
+        elif mtype == b'C':
+            # CommandComplete
+            self._parse_msg_command_complete()
+
+        else:
+            # We don't really care about COPY IN etc
+            self.buffer.consume_message()
+
+    cdef _parse_msg_command_complete(self):
+        cdef:
+            char* cbuf
+            ssize_t cbuf_len
+
+        cbuf = self.buffer.try_consume_message(&cbuf_len)
+        if cbuf != NULL and cbuf_len > 0:
+            msg = cpython.PyBytes_FromStringAndSize(cbuf, cbuf_len - 1)
+        else:
+            msg = self.buffer.read_cstr()
+        self.result_status_msg = msg
+
+    cdef _parse_data_msgs(self):
+        cdef:
+            ReadBuffer buf = self.buffer
+            list rows
+            decode_row_method decoder = <decode_row_method>self._decode_row
+
+            char* cbuf
+            ssize_t cbuf_len
+            object row
+            Memory mem
+
+        if ASYNCPG_DEBUG:
+            if buf.get_message_type() != b'D':
+                raise RuntimeError(
+                    '_parse_data_msgs: first message is not "D"')
+
+        if self._discard_data:
+            while True:
+                buf.consume_message()
+                if not buf.has_message() or buf.get_message_type() != b'D':
+                    self._skip_discard = True
+                    return
+
+        if ASYNCPG_DEBUG:
+            if type(self.result) is not list:
+                raise RuntimeError(
+                    '_parse_data_msgs: result is not a list, but {!r}'.
+                    format(self.result))
+
+        rows = self.result
+        while True:
+            cbuf = buf.try_consume_message(&cbuf_len)
+            if cbuf != NULL:
+                row = decoder(self, cbuf, cbuf_len)
+            else:
+                mem = buf.consume_message()
+                row = decoder(self, mem.buf, mem.length)
+
+            cpython.PyList_Append(rows, row)
+
+            if not buf.has_message() or buf.get_message_type() != b'D':
+                self._skip_discard = True
+                return
+
+    cdef _parse_msg_backend_key_data(self):
+        self.backend_pid = self.buffer.read_int32()
+        self.backend_secret = self.buffer.read_int32()
+
+    cdef _parse_msg_parameter_status(self):
+        name = self.buffer.read_cstr()
+        name = name.decode(self.encoding)
+
+        val = self.buffer.read_cstr()
+        val = val.decode(self.encoding)
+
+        self._set_server_parameter(name, val)
+
+    cdef _parse_msg_notification(self):
+        pid = self.buffer.read_int32()
+        channel = self.buffer.read_cstr().decode(self.encoding)
+        payload = self.buffer.read_cstr().decode(self.encoding)
+        self._on_notification(pid, channel, payload)
+
+    cdef _parse_msg_authentication(self):
+        cdef:
+            int32_t status
+            bytes md5_salt
+
+        status = self.buffer.read_int32()
+
+        if status == AUTH_SUCCESSFUL:
+            # AuthenticationOk
+            self.result_type = RESULT_OK
+
+        elif status == AUTH_REQUIRED_PASSWORD:
+            # AuthenticationCleartextPassword
+            self.result_type = RESULT_OK
+            self.auth_msg = self._auth_password_message_cleartext()
+
+        elif status == AUTH_REQUIRED_PASSWORDMD5:
+            # AuthenticationMD5Password
+            # Note: MD5 salt is passed as a four-byte sequence
+            md5_salt = cpython.PyBytes_FromStringAndSize(
+                self.buffer.read_bytes(4), 4)
+            self.auth_msg = self._auth_password_message_md5(md5_salt)
+
+        elif status in (AUTH_REQUIRED_KERBEROS, AUTH_REQUIRED_SCMCRED,
+                        AUTH_REQUIRED_GSS, AUTH_REQUIRED_GSS_CONTINUE,
+                        AUTH_REQUIRED_SSPI):
+            self.result_type = RESULT_FAILED
+            self.result = apg_exc.InterfaceError(
+                'unsupported authentication method requested by the '
+                'server: {!r}'.format(AUTH_METHOD_NAME[status]))
+
+        else:
+            self.result_type = RESULT_FAILED
+            self.result = apg_exc.InterfaceError(
+                'unsupported authentication method requested by the '
+                'server: {}'.format(status))
+
+        self.buffer.consume_message()
+
+    cdef _auth_password_message_cleartext(self):
+        cdef:
+            WriteBuffer msg
+
+        msg = WriteBuffer.new_message(b'p')
+        msg.write_bytestring(self.password.encode('ascii'))
+        msg.end_message()
+
+        return msg
+
+    cdef _auth_password_message_md5(self, bytes salt):
+        cdef:
+            WriteBuffer msg
+
+        msg = WriteBuffer.new_message(b'p')
+
+        # 'md5' + md5(md5(password + username) + salt))
+        userpass = ((self.password or '') + (self.user or '')).encode('ascii')
+        hash = hashlib_md5(hashlib_md5(userpass).hexdigest().\
+                encode('ascii') + salt).hexdigest().encode('ascii')
+
+        msg.write_bytestring(b'md5' + hash)
+        msg.end_message()
+
+        return msg
+
+    cdef _parse_msg_ready_for_query(self):
+        cdef char status = self.buffer.read_byte()
+
+        if status == b'I':
+            self.xact_status = PQTRANS_IDLE
+        elif status == b'T':
+            self.xact_status = PQTRANS_INTRANS
+        elif status == b'E':
+            self.xact_status = PQTRANS_INERROR
+        else:
+            self.xact_status = PQTRANS_UNKNOWN
+
+    cdef _parse_msg_error_response(self, is_error):
+        cdef:
+            char code
+            bytes message
+            dict parsed = {}
+
+        while True:
+            code = self.buffer.read_byte()
+            if code == 0:
+                break
+
+            message = self.buffer.read_cstr()
+
+            parsed[chr(code)] = message.decode()
+
+        if is_error:
+            self.result_type = RESULT_FAILED
+            self.result = parsed
+
+    cdef _push_result(self):
+        try:
+            self._on_result()
+        finally:
+            self._set_state(PROTOCOL_IDLE)
+            self._reset_result()
+
+    cdef _reset_result(self):
+        self.result_type = RESULT_OK
+        self.result = None
+        self.result_param_desc = None
+        self.result_row_desc = None
+        self.result_status_msg = None
+        self.result_execute_completed = False
+        self._discard_data = False
+
+    cdef _set_state(self, ProtocolState new_state):
+        if new_state == PROTOCOL_IDLE:
+            if self.state == PROTOCOL_FAILED:
+                raise RuntimeError(
+                    'cannot switch to "idle" state; '
+                    'protocol is in the "failed" state')
+            elif self.state == PROTOCOL_IDLE:
+                raise RuntimeError(
+                    'protocol is already in the "idle" state')
+            else:
+                self.state = new_state
+
+        elif new_state == PROTOCOL_FAILED:
+            self.state = PROTOCOL_FAILED
+
+        else:
+            if self.state == PROTOCOL_IDLE:
+                self.state = new_state
+
+            elif self.state == PROTOCOL_FAILED:
+                raise RuntimeError(
+                    'cannot switch to state {}; '
+                    'protocol is in the "failed" state'.format(new_state))
+            else:
+                raise RuntimeError(
+                    'cannot switch to state {}; '
+                    'another operation ({}) is in progress'.format(
+                        new_state, self.state))
+
+    cdef _ensure_connected(self):
+        if self.con_status != CONNECTION_OK:
+            raise RuntimeError('not connected')
+
+    cdef WriteBuffer _build_bind_message(self, str portal_name,
+                                         str stmt_name,
+                                         WriteBuffer bind_data):
+        cdef WriteBuffer buf
+
+        buf = WriteBuffer.new_message(b'B')
+        buf.write_str(portal_name, self.encoding)
+        buf.write_str(stmt_name, self.encoding)
+
+        # Arguments
+        buf.write_buffer(bind_data)
+
+        buf.end_message()
+        return buf
+
+    # API for subclasses
+
+    cdef _connect(self):
+        cdef:
+            WriteBuffer buf
+            WriteBuffer outbuf
+
+        if self.con_status != CONNECTION_BAD:
+            raise RuntimeError('already connected')
+
+        self._set_state(PROTOCOL_AUTH)
+        self.con_status = CONNECTION_STARTED
+
+        # Assemble a startup message
+        buf = WriteBuffer()
+
+        # protocol version
+        buf.write_int16(3)
+        buf.write_int16(0)
+
+        buf.write_bytestring(b'client_encoding')
+        buf.write_bytestring("'{}'".format(self.encoding).encode('ascii'))
+
+        for param in self.con_args:
+            if param == 'password':
+                continue
+            buf.write_str(param, self.encoding)
+            buf.write_str(self.con_args[param], self.encoding)
+
+        buf.write_bytestring(b'')
+
+        # Send the buffer
+        outbuf = WriteBuffer()
+        outbuf.write_int32(buf.len() + 4)
+        outbuf.write_buffer(buf)
+        self._write(outbuf)
+
+    cdef _prepare(self, str stmt_name, str query):
+        cdef:
+            WriteBuffer packet
+            WriteBuffer buf
+
+        self._ensure_connected()
+        self._set_state(PROTOCOL_PREPARE)
+
+        packet = WriteBuffer.new()
+
+        buf = WriteBuffer.new_message(b'P')
+        buf.write_str(stmt_name, self.encoding)
+        buf.write_str(query, self.encoding)
+        buf.write_int16(0)
+        buf.end_message()
+        packet.write_buffer(buf)
+
+        buf = WriteBuffer.new_message(b'D')
+        buf.write_byte(b'S')
+        buf.write_str(stmt_name, self.encoding)
+        buf.end_message()
+        packet.write_buffer(buf)
+
+        packet.write_bytes(SYNC_MESSAGE)
+
+        self.transport.write(memoryview(packet))
+
+    cdef _send_bind_message(self, str portal_name, str stmt_name,
+                            WriteBuffer bind_data, int32_t limit):
+
+        cdef WriteBuffer buf
+
+        buf = self._build_bind_message(portal_name, stmt_name, bind_data)
+        self._write(buf)
+
+        buf = WriteBuffer.new_message(b'E')
+        buf.write_str(portal_name, self.encoding)  # name of the portal
+        buf.write_int32(limit)  # number of rows to return; 0 - all
+        buf.end_message()
+        self._write(buf)
+
+        self._write_sync_message()
+
+    cdef _bind_execute(self, str portal_name, str stmt_name,
+                       WriteBuffer bind_data, int32_t limit):
+
+        cdef WriteBuffer buf
+
+        self._ensure_connected()
+        self._set_state(PROTOCOL_BIND_EXECUTE)
+
+        self.result = []
+
+        self._send_bind_message(portal_name, stmt_name, bind_data, limit)
+
+    cdef _bind_execute_many(self, str portal_name, str stmt_name,
+                            object bind_data):
+
+        cdef WriteBuffer buf
+
+        self._ensure_connected()
+        self._set_state(PROTOCOL_BIND_EXECUTE_MANY)
+
+        self.result = None
+        self._discard_data = True
+        self._execute_iter = bind_data
+        self._execute_portal_name = portal_name
+        self._execute_stmt_name = stmt_name
+
+        try:
+            buf = <WriteBuffer>next(bind_data)
+        except StopIteration:
+            self._push_result()
+        else:
+            self._send_bind_message(portal_name, stmt_name, buf, 0)
+
+    cdef _execute(self, str portal_name, int32_t limit):
+        cdef WriteBuffer buf
+
+        self._ensure_connected()
+        self._set_state(PROTOCOL_EXECUTE)
+
+        self.result = []
+
+        buf = WriteBuffer.new_message(b'E')
+        buf.write_str(portal_name, self.encoding)  # name of the portal
+        buf.write_int32(limit)  # number of rows to return; 0 - all
+        buf.end_message()
+        self._write(buf)
+        self._write_sync_message()
+
+    cdef _bind(self, str portal_name, str stmt_name,
+               WriteBuffer bind_data):
+
+        cdef WriteBuffer buf
+
+        self._ensure_connected()
+        self._set_state(PROTOCOL_BIND)
+
+        buf = self._build_bind_message(portal_name, stmt_name, bind_data)
+        self._write(buf)
+        self._write_sync_message()
+
+    cdef _close(self, str name, bint is_portal):
+        cdef WriteBuffer buf
+
+        self._ensure_connected()
+        self._set_state(PROTOCOL_CLOSE_STMT_PORTAL)
+
+        buf = WriteBuffer.new_message(b'C')
+
+        if is_portal:
+            buf.write_byte(b'P')
+        else:
+            buf.write_byte(b'S')
+
+        buf.write_str(name, self.encoding)
+        buf.end_message()
+        self._write(buf)
+
+        self._write_sync_message()
+
+    cdef _simple_query(self, str query):
+        cdef WriteBuffer buf
+        self._ensure_connected()
+        self._set_state(PROTOCOL_SIMPLE_QUERY)
+        buf = WriteBuffer.new_message(b'Q')
+        buf.write_str(query, self.encoding)
+        buf.end_message()
+        self._write(buf)
+
+    cdef _terminate(self):
+        cdef WriteBuffer buf
+        self._ensure_connected()
+        buf = WriteBuffer.new_message(b'X')
+        buf.end_message()
+        self._write(buf)
+
+    cdef _decode_row(self, const char* buf, ssize_t buf_len):
+        pass
+
+    cdef _set_server_parameter(self, name, val):
+        pass
+
+    cdef _on_result(self):
+        pass
+
+    cdef _on_notification(self, pid, channel, payload):
+        pass
+
+    cdef _on_connection_lost(self, exc):
+        pass
+
+    # asyncio callbacks:
+
+    def data_received(self, data):
+        self.buffer.feed_data(data)
+        self._read_server_messages()
+
+    def connection_made(self, transport):
+        self.transport = transport
+
+        sock = transport.get_extra_info('socket')
+        if (sock is not None and
+              (not hasattr(socket, 'AF_UNIX')
+               or sock.family != socket.AF_UNIX)):
+            sock.setsockopt(socket.IPPROTO_TCP,
+                            socket.TCP_NODELAY, 1)
+
+        try:
+            self._connect()
+        except Exception as ex:
+            transport.abort()
+            self.con_status = CONNECTION_BAD
+            self._set_state(PROTOCOL_FAILED)
+            self._on_error(ex)
+
+    def connection_lost(self, exc):
+        self.con_status = CONNECTION_BAD
+        self._set_state(PROTOCOL_FAILED)
+        self._on_connection_lost(exc)
+
+
+cdef bytes SYNC_MESSAGE = bytes(WriteBuffer.new_message(b'S').end_message())
diff --git a/asyncpg/protocol/debug.h b/asyncpg/protocol/debug.h
new file mode 100644 (file)
index 0000000..31df2df
--- /dev/null
@@ -0,0 +1,3 @@
+#ifndef ASYNCPG_DEBUG
+#define ASYNCPG_DEBUG 0
+#endif
diff --git a/asyncpg/protocol/debug.pxd b/asyncpg/protocol/debug.pxd
new file mode 100644 (file)
index 0000000..ce3c61e
--- /dev/null
@@ -0,0 +1,3 @@
+cdef extern from "debug.h":
+
+       cdef int ASYNCPG_DEBUG
diff --git a/asyncpg/protocol/encodings.pyx b/asyncpg/protocol/encodings.pyx
new file mode 100644 (file)
index 0000000..baeba90
--- /dev/null
@@ -0,0 +1,63 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+'''Map PostgreSQL encoding names to Python encoding names
+
+https://www.postgresql.org/docs/current/static/multibyte.html#CHARSET-TABLE
+'''
+
+cdef dict ENCODINGS_MAP = {
+    'abc': 'cp1258',
+    'alt': 'cp866',
+    'euc_cn': 'euccn',
+    'euc_jp': 'eucjp',
+    'euc_kr': 'euckr',
+    'koi8r': 'koi8_r',
+    'koi8u': 'koi8_u',
+    'shift_jis_2004': 'euc_jis_2004',
+    'sjis': 'shift_jis',
+    'sql_ascii': 'ascii',
+    'vscii': 'cp1258',
+    'tcvn': 'cp1258',
+    'tcvn5712': 'cp1258',
+    'unicode': 'utf_8',
+    'win': 'cp1521',
+    'win1250': 'cp1250',
+    'win1251': 'cp1251',
+    'win1252': 'cp1252',
+    'win1253': 'cp1253',
+    'win1254': 'cp1254',
+    'win1255': 'cp1255',
+    'win1256': 'cp1256',
+    'win1257': 'cp1257',
+    'win1258': 'cp1258',
+    'win866': 'cp866',
+    'win874': 'cp874',
+    'win932': 'cp932',
+    'win936': 'cp936',
+    'win949': 'cp949',
+    'win950': 'cp950',
+    'windows1250': 'cp1250',
+    'windows1251': 'cp1251',
+    'windows1252': 'cp1252',
+    'windows1253': 'cp1253',
+    'windows1254': 'cp1254',
+    'windows1255': 'cp1255',
+    'windows1256': 'cp1256',
+    'windows1257': 'cp1257',
+    'windows1258': 'cp1258',
+    'windows866': 'cp866',
+    'windows874': 'cp874',
+    'windows932': 'cp932',
+    'windows936': 'cp936',
+    'windows949': 'cp949',
+    'windows950': 'cp950',
+}
+
+
+cdef get_python_encoding(pg_encoding):
+    return ENCODINGS_MAP.get(pg_encoding.lower(), pg_encoding.lower())
diff --git a/asyncpg/protocol/hton.pxd b/asyncpg/protocol/hton.pxd
new file mode 100644 (file)
index 0000000..402a289
--- /dev/null
@@ -0,0 +1,84 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+from libc.stdint cimport int16_t, int32_t, uint16_t, uint32_t, int64_t, uint64_t
+
+
+IF UNAME_SYSNAME == "Windows":
+    cdef extern from "winsock2.h":
+        uint32_t htonl(uint32_t hostlong)
+        uint16_t htons(uint16_t hostshort)
+        uint32_t ntohl(uint32_t netlong)
+        uint16_t ntohs(uint16_t netshort)
+ELSE:
+    cdef extern from "arpa/inet.h":
+        uint32_t htonl(uint32_t hostlong)
+        uint16_t htons(uint16_t hostshort)
+        uint32_t ntohl(uint32_t netlong)
+        uint16_t ntohs(uint16_t netshort)
+
+
+cdef inline void pack_int16(char* buf, int16_t x):
+    (<uint16_t*>buf)[0] = htons(<uint16_t>x)
+
+
+cdef inline int16_t unpack_int16(const char* buf):
+    return <int16_t>ntohs((<uint16_t*>buf)[0])
+
+
+cdef inline void pack_int32(char* buf, int32_t x):
+    (<uint32_t*>buf)[0] = htonl(<uint32_t>x)
+
+
+cdef inline int32_t unpack_int32(const char* buf):
+    return <int32_t>ntohl((<uint32_t*>buf)[0])
+
+
+cdef inline void pack_int64(char* buf, int64_t x):
+    (<uint32_t*>buf)[0] = htonl(<uint32_t>(<uint64_t>(x) >> 32))
+    (<uint32_t*>&buf[4])[0] = htonl(<uint32_t>(x))
+
+
+cdef inline int64_t unpack_int64(const char* buf):
+    cdef int64_t hh = unpack_int32(buf)
+    cdef uint32_t hl = <uint32_t>unpack_int32(&buf[4])
+
+    return (hh << 32) | hl
+
+
+cdef union _floatconv:
+    uint32_t i
+    float f
+
+
+cdef inline int32_t pack_float(char* buf, float f):
+    cdef _floatconv v
+    v.f = f
+    pack_int32(buf, <int32_t>v.i)
+
+
+cdef inline float unpack_float(const char* buf):
+    cdef _floatconv v
+    v.i = <uint32_t>unpack_int32(buf)
+    return v.f
+
+
+cdef union _doubleconv:
+    uint64_t i
+    double f
+
+
+cdef inline int64_t pack_double(char* buf, double f):
+    cdef _doubleconv v
+    v.f = f
+    pack_int64(buf, <int64_t>v.i)
+
+
+cdef inline double unpack_double(const char* buf):
+    cdef _doubleconv v
+    v.i = <uint64_t>unpack_int64(buf)
+    return v.f
diff --git a/asyncpg/protocol/pgtypes.pxi b/asyncpg/protocol/pgtypes.pxi
new file mode 100644 (file)
index 0000000..1798323
--- /dev/null
@@ -0,0 +1,182 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+# GENERATED FROM pg_catalog.pg_type
+# DO NOT MODIFY, use tools/generate_type_map.py to update
+
+DEF INVALIDOID = 0
+DEF MAXBUILTINOID = 9999
+DEF MAXSUPPORTEDOID = 4096
+
+DEF BOOLOID = 16
+DEF BYTEAOID = 17
+DEF CHAROID = 18
+DEF NAMEOID = 19
+DEF INT8OID = 20
+DEF INT2OID = 21
+DEF INT4OID = 23
+DEF REGPROCOID = 24
+DEF TEXTOID = 25
+DEF OIDOID = 26
+DEF TIDOID = 27
+DEF XIDOID = 28
+DEF CIDOID = 29
+DEF PG_DDL_COMMANDOID = 32
+DEF JSONOID = 114
+DEF XMLOID = 142
+DEF PG_NODE_TREEOID = 194
+DEF SMGROID = 210
+DEF POINTOID = 600
+DEF LSEGOID = 601
+DEF PATHOID = 602
+DEF BOXOID = 603
+DEF POLYGONOID = 604
+DEF LINEOID = 628
+DEF CIDROID = 650
+DEF FLOAT4OID = 700
+DEF FLOAT8OID = 701
+DEF ABSTIMEOID = 702
+DEF RELTIMEOID = 703
+DEF TINTERVALOID = 704
+DEF UNKNOWNOID = 705
+DEF CIRCLEOID = 718
+DEF MONEYOID = 790
+DEF MACADDROID = 829
+DEF INETOID = 869
+DEF _TEXTOID = 1009
+DEF _OIDOID = 1028
+DEF ACLITEMOID = 1033
+DEF BPCHAROID = 1042
+DEF VARCHAROID = 1043
+DEF DATEOID = 1082
+DEF TIMEOID = 1083
+DEF TIMESTAMPOID = 1114
+DEF TIMESTAMPTZOID = 1184
+DEF INTERVALOID = 1186
+DEF TIMETZOID = 1266
+DEF BITOID = 1560
+DEF VARBITOID = 1562
+DEF NUMERICOID = 1700
+DEF REFCURSOROID = 1790
+DEF REGPROCEDUREOID = 2202
+DEF REGOPEROID = 2203
+DEF REGOPERATOROID = 2204
+DEF REGCLASSOID = 2205
+DEF REGTYPEOID = 2206
+DEF RECORDOID = 2249
+DEF CSTRINGOID = 2275
+DEF ANYOID = 2276
+DEF ANYARRAYOID = 2277
+DEF VOIDOID = 2278
+DEF TRIGGEROID = 2279
+DEF LANGUAGE_HANDLEROID = 2280
+DEF INTERNALOID = 2281
+DEF OPAQUEOID = 2282
+DEF ANYELEMENTOID = 2283
+DEF ANYNONARRAYOID = 2776
+DEF UUIDOID = 2950
+DEF TXID_SNAPSHOTOID = 2970
+DEF FDW_HANDLEROID = 3115
+DEF PG_LSNOID = 3220
+DEF TSM_HANDLEROID = 3310
+DEF ANYENUMOID = 3500
+DEF TSVECTOROID = 3614
+DEF TSQUERYOID = 3615
+DEF GTSVECTOROID = 3642
+DEF REGCONFIGOID = 3734
+DEF REGDICTIONARYOID = 3769
+DEF JSONBOID = 3802
+DEF ANYRANGEOID = 3831
+DEF EVENT_TRIGGEROID = 3838
+DEF REGNAMESPACEOID = 4089
+DEF REGROLEOID = 4096
+
+cdef ARRAY_TYPES = (_TEXTOID, _OIDOID,)
+
+TYPEMAP = {
+    ABSTIMEOID: 'abstime',
+    ACLITEMOID: 'aclitem',
+    ANYARRAYOID: 'anyarray',
+    ANYELEMENTOID: 'anyelement',
+    ANYENUMOID: 'anyenum',
+    ANYNONARRAYOID: 'anynonarray',
+    ANYOID: 'any',
+    ANYRANGEOID: 'anyrange',
+    BITOID: 'bit',
+    BOOLOID: 'bool',
+    BOXOID: 'box',
+    BPCHAROID: 'bpchar',
+    BYTEAOID: 'bytea',
+    CHAROID: 'char',
+    CIDOID: 'cid',
+    CIDROID: 'cidr',
+    CIRCLEOID: 'circle',
+    CSTRINGOID: 'cstring',
+    DATEOID: 'date',
+    EVENT_TRIGGEROID: 'event_trigger',
+    FDW_HANDLEROID: 'fdw_handler',
+    FLOAT4OID: 'float4',
+    FLOAT8OID: 'float8',
+    GTSVECTOROID: 'gtsvector',
+    INETOID: 'inet',
+    INT2OID: 'int2',
+    INT4OID: 'int4',
+    INT8OID: 'int8',
+    INTERNALOID: 'internal',
+    INTERVALOID: 'interval',
+    JSONBOID: 'jsonb',
+    JSONOID: 'json',
+    LANGUAGE_HANDLEROID: 'language_handler',
+    LINEOID: 'line',
+    LSEGOID: 'lseg',
+    MACADDROID: 'macaddr',
+    MONEYOID: 'money',
+    NAMEOID: 'name',
+    NUMERICOID: 'numeric',
+    OIDOID: 'oid',
+    OPAQUEOID: 'opaque',
+    PATHOID: 'path',
+    PG_DDL_COMMANDOID: 'pg_ddl_command',
+    PG_LSNOID: 'pg_lsn',
+    PG_NODE_TREEOID: 'pg_node_tree',
+    POINTOID: 'point',
+    POLYGONOID: 'polygon',
+    RECORDOID: 'record',
+    REFCURSOROID: 'refcursor',
+    REGCLASSOID: 'regclass',
+    REGCONFIGOID: 'regconfig',
+    REGDICTIONARYOID: 'regdictionary',
+    REGNAMESPACEOID: 'regnamespace',
+    REGOPERATOROID: 'regoperator',
+    REGOPEROID: 'regoper',
+    REGPROCEDUREOID: 'regprocedure',
+    REGPROCOID: 'regproc',
+    REGROLEOID: 'regrole',
+    REGTYPEOID: 'regtype',
+    RELTIMEOID: 'reltime',
+    SMGROID: 'smgr',
+    TEXTOID: 'text',
+    TIDOID: 'tid',
+    TIMEOID: 'time',
+    TIMESTAMPOID: 'timestamp',
+    TIMESTAMPTZOID: 'timestamptz',
+    TIMETZOID: 'timetz',
+    TINTERVALOID: 'tinterval',
+    TRIGGEROID: 'trigger',
+    TSM_HANDLEROID: 'tsm_handler',
+    TSQUERYOID: 'tsquery',
+    TSVECTOROID: 'tsvector',
+    TXID_SNAPSHOTOID: 'txid_snapshot',
+    UNKNOWNOID: 'unknown',
+    UUIDOID: 'uuid',
+    VARBITOID: 'varbit',
+    VARCHAROID: 'varchar',
+    VOIDOID: 'void',
+    XIDOID: 'xid',
+    XMLOID: 'xml',
+    _OIDOID: 'oid[]',
+    _TEXTOID: 'text[]'}
diff --git a/asyncpg/protocol/prepared_stmt.pxd b/asyncpg/protocol/prepared_stmt.pxd
new file mode 100644 (file)
index 0000000..f71b599
--- /dev/null
@@ -0,0 +1,37 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+cdef class PreparedStatementState:
+    cdef:
+        readonly str name
+        readonly str query
+        readonly bint closed
+        readonly int refs
+
+        FastReadBuffer buffer
+
+        list         row_desc
+        list         parameters_desc
+
+        BaseProtocol protocol
+        ConnectionSettings settings
+
+        int16_t      args_num
+        bint         have_text_args
+        tuple        args_codecs
+
+        int16_t      cols_num
+        object       cols_desc
+        bint         have_text_cols
+        tuple        rows_codecs
+
+    cdef _encode_bind_msg(self, args)
+    cdef _ensure_rows_decoder(self)
+    cdef _ensure_args_encoder(self)
+    cdef _set_row_desc(self, object desc)
+    cdef _set_args_desc(self, object desc)
+    cdef _decode_row(self, const char* cbuf, ssize_t buf_len)
diff --git a/asyncpg/protocol/prepared_stmt.pyx b/asyncpg/protocol/prepared_stmt.pyx
new file mode 100644 (file)
index 0000000..0da8e50
--- /dev/null
@@ -0,0 +1,313 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+@cython.final
+cdef class PreparedStatementState:
+
+    def __cinit__(self, str name, str query, BaseProtocol protocol):
+        self.name = name
+        self.query = query
+        self.protocol = protocol
+        self.settings = protocol.settings
+        self.row_desc = self.parameters_desc = None
+        self.args_codecs = self.rows_codecs = None
+        self.args_num = self.cols_num = 0
+        self.cols_desc = None
+        self.closed = False
+        self.refs = 0
+        self.buffer = FastReadBuffer.new()
+
+    def _get_parameters(self):
+        cdef Codec codec
+
+        result = []
+        for oid in self.parameters_desc:
+            codec = self.settings.get_data_codec(oid)
+            if codec is None:
+                raise RuntimeError
+            result.append(apg_types.Type(
+                oid, codec.name, codec.kind, codec.schema))
+
+        return tuple(result)
+
+    def _get_attributes(self):
+        cdef Codec codec
+
+        result = []
+        for d in self.row_desc:
+            name = d[0]
+            oid = d[3]
+
+            codec = self.settings.get_data_codec(oid)
+            if codec is None:
+                raise RuntimeError
+
+            name = name.decode(self.settings._encoding)
+
+            result.append(
+                apg_types.Attribute(name,
+                    apg_types.Type(oid, codec.name, codec.kind, codec.schema)))
+
+        return tuple(result)
+
+    def _init_types(self):
+        cdef:
+            Codec codec
+            set result = set()
+
+        if self.parameters_desc:
+            for p_oid in self.parameters_desc:
+                codec = self.settings.get_data_codec(<uint32_t>p_oid)
+                if codec is None or not codec.has_encoder():
+                    result.add(p_oid)
+
+        if self.row_desc:
+            for rdesc in self.row_desc:
+                codec = self.settings.get_data_codec(<uint32_t>(rdesc[3]))
+                if codec is None or not codec.has_decoder():
+                    result.add(rdesc[3])
+
+        if len(result):
+            return result
+        else:
+            return True
+
+    def attach(self):
+        self.refs += 1
+
+    def detach(self):
+        self.refs -= 1
+
+    def mark_closed(self):
+        self.closed = True
+
+    cdef _encode_bind_msg(self, args):
+        cdef:
+            int idx
+            WriteBuffer writer
+            Codec codec
+
+        self._ensure_args_encoder()
+        self._ensure_rows_decoder()
+
+        writer = WriteBuffer.new()
+
+        if self.args_num != len(args):
+            raise ValueError(
+                'number of arguments ({}) does not match '
+                'number of parameters ({})'.format(
+                    len(args), self.args_num))
+
+        if self.have_text_args:
+            writer.write_int16(self.args_num)
+            for idx from 0 <= idx < self.args_num:
+                codec = <Codec>(self.args_codecs[idx])
+                writer.write_int16(codec.format)
+        else:
+            # All arguments are in binary format
+            writer.write_int32(0x00010001)
+
+        writer.write_int16(self.args_num)
+
+        for idx from 0 <= idx < self.args_num:
+            arg = args[idx]
+            if arg is None:
+                writer.write_int32(-1)
+            else:
+                codec = <Codec>(self.args_codecs[idx])
+                codec.encode(self.settings, writer, arg)
+
+        if self.have_text_cols:
+            writer.write_int16(self.cols_num)
+            for idx from 0 <= idx < self.cols_num:
+                codec = <Codec>(self.rows_codecs[idx])
+                writer.write_int16(codec.format)
+        else:
+            # All columns are in binary format
+            writer.write_int32(0x00010001)
+
+        return writer
+
+    cdef _ensure_rows_decoder(self):
+        cdef:
+            list cols_names
+            object cols_mapping
+            tuple row
+            int oid
+            Codec codec
+            list codecs
+
+        if self.cols_desc is not None:
+            return
+
+        if self.cols_num == 0:
+            self.cols_desc = record.ApgRecordDesc_New({}, ())
+            return
+
+        cols_mapping = collections.OrderedDict()
+        cols_names = []
+        codecs = []
+        for i from 0 <= i < self.cols_num:
+            row = self.row_desc[i]
+            col_name = row[0].decode(self.settings._encoding)
+            cols_mapping[col_name] = i
+            cols_names.append(col_name)
+            oid = row[3]
+            codec = self.settings.get_data_codec(<uint32_t>oid)
+            if codec is None or not codec.has_decoder():
+                raise RuntimeError('no decoder for OID {}'.format(oid))
+            if not codec.is_binary():
+                self.have_text_cols = True
+
+            codecs.append(codec)
+
+        self.cols_desc = record.ApgRecordDesc_New(
+            cols_mapping, tuple(cols_names))
+
+        self.rows_codecs = tuple(codecs)
+
+    cdef _ensure_args_encoder(self):
+        cdef:
+            int p_oid
+            Codec codec
+            list codecs = []
+
+        if self.args_num == 0 or self.args_codecs is not None:
+            return
+
+        for i from 0 <= i < self.args_num:
+            p_oid = self.parameters_desc[i]
+            codec = self.settings.get_data_codec(<uint32_t>p_oid)
+            if codec is None or not codec.has_encoder():
+                raise RuntimeError('no encoder for OID {}'.format(p_oid))
+            if codec.type not in {}:
+                self.have_text_args = True
+
+            codecs.append(codec)
+
+        self.args_codecs = tuple(codecs)
+
+    cdef _set_row_desc(self, object desc):
+        self.row_desc = _decode_row_desc(desc)
+        self.cols_num = <int16_t>(len(self.row_desc))
+
+    cdef _set_args_desc(self, object desc):
+        self.parameters_desc = _decode_parameters_desc(desc)
+        self.args_num = <int16_t>(len(self.parameters_desc))
+
+    cdef _decode_row(self, const char* cbuf, ssize_t buf_len):
+        cdef:
+            Codec codec
+            int16_t fnum
+            int32_t flen
+            object dec_row
+            tuple rows_codecs = self.rows_codecs
+            ConnectionSettings settings = self.settings
+            int32_t i
+            FastReadBuffer rbuf = self.buffer
+            ssize_t bl
+
+        rbuf.buf = cbuf
+        rbuf.len = buf_len
+
+        fnum = hton.unpack_int16(rbuf.read(2))
+
+        if fnum != self.cols_num:
+            raise RuntimeError(
+                'number of columns in result ({}) is '
+                'different from what was described ({})'.format(
+                    fnum, self.cols_num))
+
+        if rows_codecs is None or len(rows_codecs) < fnum:
+            if fnum > 0:
+                # It's OK to have no rows_codecs for empty records
+                raise RuntimeError('invalid rows_codecs')
+
+        dec_row = record.ApgRecord_New(self.cols_desc, fnum)
+        for i in range(fnum):
+            flen = hton.unpack_int32(rbuf.read(4))
+
+            if flen == -1:
+                val = None
+            else:
+                # Clamp buffer size to that of the reported field length
+                # to make sure that codecs can rely on read_all() working
+                # properly.
+                bl = rbuf.len
+                if flen > bl:
+                    # Check for overflow
+                    rbuf._raise_ins_err(flen, bl)
+                rbuf.len = flen
+                codec = <Codec>cpython.PyTuple_GET_ITEM(rows_codecs, i)
+                val = codec.decode(settings, rbuf)
+                if rbuf.len != 0:
+                    raise BufferError(
+                        'unexpected trailing {} bytes in buffer'.format(
+                            rbuf.len))
+                rbuf.len = bl - flen
+
+            cpython.Py_INCREF(val)
+            record.ApgRecord_SET_ITEM(dec_row, i, val)
+
+        if rbuf.len != 0:
+            raise BufferError('unexpected trailing {} bytes in buffer'.format(
+                rbuf.len))
+
+        return dec_row
+
+
+cdef _decode_parameters_desc(object desc):
+    cdef:
+        ReadBuffer reader
+        int16_t nparams
+        int32_t p_oid
+        list result = []
+
+    reader = ReadBuffer.new_message_parser(desc)
+    nparams = reader.read_int16()
+
+    for i from 0 <= i < nparams:
+        p_oid = reader.read_int32()
+        result.append(p_oid)
+
+    return result
+
+
+cdef _decode_row_desc(object desc):
+    cdef:
+        ReadBuffer reader
+
+        int16_t nfields
+
+        bytes f_name
+        int32_t f_table_oid
+        int16_t f_column_num
+        int32_t f_dt_oid
+        int16_t f_dt_size
+        int32_t f_dt_mod
+        int16_t f_format
+
+        list result
+
+    reader = ReadBuffer.new_message_parser(desc)
+    nfields = reader.read_int16()
+    result = []
+
+    for i from 0 <= i < nfields:
+        f_name = reader.read_cstr()
+        f_table_oid = reader.read_int32()
+        f_column_num = reader.read_int16()
+        f_dt_oid = reader.read_int32()
+        f_dt_size = reader.read_int16()
+        f_dt_mod = reader.read_int32()
+        f_format = reader.read_int16()
+
+        result.append(
+            (f_name, f_table_oid, f_column_num, f_dt_oid,
+             f_dt_size, f_dt_mod, f_format))
+
+    return result
diff --git a/asyncpg/protocol/protocol.c b/asyncpg/protocol/protocol.c
new file mode 100644 (file)
index 0000000..27aba80
--- /dev/null
@@ -0,0 +1,75615 @@
+/* Generated by Cython 0.25.2 */
+
+/* BEGIN: Cython Metadata
+{
+    "distutils": {
+        "depends": [
+            "asyncpg/protocol/debug.h"
+        ],
+        "extra_compile_args": [
+            "-O2",
+            "-Wall",
+            "-Wsign-compare",
+            "-Wconversion"
+        ]
+    },
+    "module_name": "asyncpg.protocol.protocol"
+}
+END: Cython Metadata */
+
+#define PY_SSIZE_T_CLEAN
+#include "Python.h"
+#ifndef Py_PYTHON_H
+    #error Python headers needed to compile C extensions, please install development version of Python.
+#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000)
+    #error Cython requires Python 2.6+ or Python 3.2+.
+#else
+#define CYTHON_ABI "0_25_2"
+#include <stddef.h>
+#ifndef offsetof
+  #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
+#endif
+#if !defined(WIN32) && !defined(MS_WINDOWS)
+  #ifndef __stdcall
+    #define __stdcall
+  #endif
+  #ifndef __cdecl
+    #define __cdecl
+  #endif
+  #ifndef __fastcall
+    #define __fastcall
+  #endif
+#endif
+#ifndef DL_IMPORT
+  #define DL_IMPORT(t) t
+#endif
+#ifndef DL_EXPORT
+  #define DL_EXPORT(t) t
+#endif
+#ifndef HAVE_LONG_LONG
+  #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000)
+    #define HAVE_LONG_LONG
+  #endif
+#endif
+#ifndef PY_LONG_LONG
+  #define PY_LONG_LONG LONG_LONG
+#endif
+#ifndef Py_HUGE_VAL
+  #define Py_HUGE_VAL HUGE_VAL
+#endif
+#ifdef PYPY_VERSION
+  #define CYTHON_COMPILING_IN_PYPY 1
+  #define CYTHON_COMPILING_IN_PYSTON 0
+  #define CYTHON_COMPILING_IN_CPYTHON 0
+  #undef CYTHON_USE_TYPE_SLOTS
+  #define CYTHON_USE_TYPE_SLOTS 0
+  #undef CYTHON_USE_ASYNC_SLOTS
+  #define CYTHON_USE_ASYNC_SLOTS 0
+  #undef CYTHON_USE_PYLIST_INTERNALS
+  #define CYTHON_USE_PYLIST_INTERNALS 0
+  #undef CYTHON_USE_UNICODE_INTERNALS
+  #define CYTHON_USE_UNICODE_INTERNALS 0
+  #undef CYTHON_USE_UNICODE_WRITER
+  #define CYTHON_USE_UNICODE_WRITER 0
+  #undef CYTHON_USE_PYLONG_INTERNALS
+  #define CYTHON_USE_PYLONG_INTERNALS 0
+  #undef CYTHON_AVOID_BORROWED_REFS
+  #define CYTHON_AVOID_BORROWED_REFS 1
+  #undef CYTHON_ASSUME_SAFE_MACROS
+  #define CYTHON_ASSUME_SAFE_MACROS 0
+  #undef CYTHON_UNPACK_METHODS
+  #define CYTHON_UNPACK_METHODS 0
+  #undef CYTHON_FAST_THREAD_STATE
+  #define CYTHON_FAST_THREAD_STATE 0
+  #undef CYTHON_FAST_PYCALL
+  #define CYTHON_FAST_PYCALL 0
+#elif defined(PYSTON_VERSION)
+  #define CYTHON_COMPILING_IN_PYPY 0
+  #define CYTHON_COMPILING_IN_PYSTON 1
+  #define CYTHON_COMPILING_IN_CPYTHON 0
+  #ifndef CYTHON_USE_TYPE_SLOTS
+    #define CYTHON_USE_TYPE_SLOTS 1
+  #endif
+  #undef CYTHON_USE_ASYNC_SLOTS
+  #define CYTHON_USE_ASYNC_SLOTS 0
+  #undef CYTHON_USE_PYLIST_INTERNALS
+  #define CYTHON_USE_PYLIST_INTERNALS 0
+  #ifndef CYTHON_USE_UNICODE_INTERNALS
+    #define CYTHON_USE_UNICODE_INTERNALS 1
+  #endif
+  #undef CYTHON_USE_UNICODE_WRITER
+  #define CYTHON_USE_UNICODE_WRITER 0
+  #undef CYTHON_USE_PYLONG_INTERNALS
+  #define CYTHON_USE_PYLONG_INTERNALS 0
+  #ifndef CYTHON_AVOID_BORROWED_REFS
+    #define CYTHON_AVOID_BORROWED_REFS 0
+  #endif
+  #ifndef CYTHON_ASSUME_SAFE_MACROS
+    #define CYTHON_ASSUME_SAFE_MACROS 1
+  #endif
+  #ifndef CYTHON_UNPACK_METHODS
+    #define CYTHON_UNPACK_METHODS 1
+  #endif
+  #undef CYTHON_FAST_THREAD_STATE
+  #define CYTHON_FAST_THREAD_STATE 0
+  #undef CYTHON_FAST_PYCALL
+  #define CYTHON_FAST_PYCALL 0
+#else
+  #define CYTHON_COMPILING_IN_PYPY 0
+  #define CYTHON_COMPILING_IN_PYSTON 0
+  #define CYTHON_COMPILING_IN_CPYTHON 1
+  #ifndef CYTHON_USE_TYPE_SLOTS
+    #define CYTHON_USE_TYPE_SLOTS 1
+  #endif
+  #if PY_MAJOR_VERSION < 3
+    #undef CYTHON_USE_ASYNC_SLOTS
+    #define CYTHON_USE_ASYNC_SLOTS 0
+  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
+    #define CYTHON_USE_ASYNC_SLOTS 1
+  #endif
+  #if PY_VERSION_HEX < 0x02070000
+    #undef CYTHON_USE_PYLONG_INTERNALS
+    #define CYTHON_USE_PYLONG_INTERNALS 0
+  #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
+    #define CYTHON_USE_PYLONG_INTERNALS 1
+  #endif
+  #ifndef CYTHON_USE_PYLIST_INTERNALS
+    #define CYTHON_USE_PYLIST_INTERNALS 1
+  #endif
+  #ifndef CYTHON_USE_UNICODE_INTERNALS
+    #define CYTHON_USE_UNICODE_INTERNALS 1
+  #endif
+  #if PY_VERSION_HEX < 0x030300F0
+    #undef CYTHON_USE_UNICODE_WRITER
+    #define CYTHON_USE_UNICODE_WRITER 0
+  #elif !defined(CYTHON_USE_UNICODE_WRITER)
+    #define CYTHON_USE_UNICODE_WRITER 1
+  #endif
+  #ifndef CYTHON_AVOID_BORROWED_REFS
+    #define CYTHON_AVOID_BORROWED_REFS 0
+  #endif
+  #ifndef CYTHON_ASSUME_SAFE_MACROS
+    #define CYTHON_ASSUME_SAFE_MACROS 1
+  #endif
+  #ifndef CYTHON_UNPACK_METHODS
+    #define CYTHON_UNPACK_METHODS 1
+  #endif
+  #ifndef CYTHON_FAST_THREAD_STATE
+    #define CYTHON_FAST_THREAD_STATE 1
+  #endif
+  #ifndef CYTHON_FAST_PYCALL
+    #define CYTHON_FAST_PYCALL 1
+  #endif
+#endif
+#if !defined(CYTHON_FAST_PYCCALL)
+#define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
+#endif
+#if CYTHON_USE_PYLONG_INTERNALS
+  #include "longintrepr.h"
+  #undef SHIFT
+  #undef BASE
+  #undef MASK
+#endif
+#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
+  #define Py_OptimizeFlag 0
+#endif
+#define __PYX_BUILD_PY_SSIZE_T "n"
+#define CYTHON_FORMAT_SSIZE_T "z"
+#if PY_MAJOR_VERSION < 3
+  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
+  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
+          PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
+  #define __Pyx_DefaultClassType PyClass_Type
+#else
+  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
+  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
+          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
+  #define __Pyx_DefaultClassType PyType_Type
+#endif
+#ifndef Py_TPFLAGS_CHECKTYPES
+  #define Py_TPFLAGS_CHECKTYPES 0
+#endif
+#ifndef Py_TPFLAGS_HAVE_INDEX
+  #define Py_TPFLAGS_HAVE_INDEX 0
+#endif
+#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
+  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
+#endif
+#ifndef Py_TPFLAGS_HAVE_FINALIZE
+  #define Py_TPFLAGS_HAVE_FINALIZE 0
+#endif
+#ifndef METH_FASTCALL
+  #define METH_FASTCALL 0x80
+  typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args,
+                                              Py_ssize_t nargs, PyObject *kwnames);
+#else
+  #define __Pyx_PyCFunctionFast _PyCFunctionFast
+#endif
+#if CYTHON_FAST_PYCCALL
+#define __Pyx_PyFastCFunction_Check(func)\
+    ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)))))
+#else
+#define __Pyx_PyFastCFunction_Check(func) 0
+#endif
+#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
+  #define CYTHON_PEP393_ENABLED 1
+  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
+                                              0 : _PyUnicode_Ready((PyObject *)(op)))
+  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
+  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
+  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
+  #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
+  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
+  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
+  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
+  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
+#else
+  #define CYTHON_PEP393_ENABLED 0
+  #define PyUnicode_1BYTE_KIND  1
+  #define PyUnicode_2BYTE_KIND  2
+  #define PyUnicode_4BYTE_KIND  4
+  #define __Pyx_PyUnicode_READY(op)       (0)
+  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
+  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
+  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
+  #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
+  #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
+  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
+  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
+  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
+#endif
+#if CYTHON_COMPILING_IN_PYPY
+  #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
+  #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
+#else
+  #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
+  #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
+      PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
+#endif
+#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
+  #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
+#endif
+#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
+  #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
+#endif
+#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
+  #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
+#endif
+#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
+  #define PyObject_Malloc(s)   PyMem_Malloc(s)
+  #define PyObject_Free(p)     PyMem_Free(p)
+  #define PyObject_Realloc(p)  PyMem_Realloc(p)
+#endif
+#if CYTHON_COMPILING_IN_PYSTON
+  #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
+  #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
+#else
+  #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
+  #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
+#endif
+#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
+#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
+#if PY_MAJOR_VERSION >= 3
+  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
+#else
+  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
+#endif
+#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
+  #define PyObject_ASCII(o)            PyObject_Repr(o)
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define PyBaseString_Type            PyUnicode_Type
+  #define PyStringObject               PyUnicodeObject
+  #define PyString_Type                PyUnicode_Type
+  #define PyString_Check               PyUnicode_Check
+  #define PyString_CheckExact          PyUnicode_CheckExact
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
+  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
+#else
+  #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
+  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
+#endif
+#ifndef PySet_CheckExact
+  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
+#endif
+#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
+#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
+#if PY_MAJOR_VERSION >= 3
+  #define PyIntObject                  PyLongObject
+  #define PyInt_Type                   PyLong_Type
+  #define PyInt_Check(op)              PyLong_Check(op)
+  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
+  #define PyInt_FromString             PyLong_FromString
+  #define PyInt_FromUnicode            PyLong_FromUnicode
+  #define PyInt_FromLong               PyLong_FromLong
+  #define PyInt_FromSize_t             PyLong_FromSize_t
+  #define PyInt_FromSsize_t            PyLong_FromSsize_t
+  #define PyInt_AsLong                 PyLong_AsLong
+  #define PyInt_AS_LONG                PyLong_AS_LONG
+  #define PyInt_AsSsize_t              PyLong_AsSsize_t
+  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
+  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
+  #define PyNumber_Int                 PyNumber_Long
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define PyBoolObject                 PyLongObject
+#endif
+#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
+  #ifndef PyUnicode_InternFromString
+    #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
+  #endif
+#endif
+#if PY_VERSION_HEX < 0x030200A4
+  typedef long Py_hash_t;
+  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
+  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
+#else
+  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
+  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
+#else
+  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
+#endif
+#if CYTHON_USE_ASYNC_SLOTS
+  #if PY_VERSION_HEX >= 0x030500B1
+    #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
+    #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
+  #else
+    typedef struct {
+        unaryfunc am_await;
+        unaryfunc am_aiter;
+        unaryfunc am_anext;
+    } __Pyx_PyAsyncMethodsStruct;
+    #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
+  #endif
+#else
+  #define __Pyx_PyType_AsAsync(obj) NULL
+#endif
+#ifndef CYTHON_RESTRICT
+  #if defined(__GNUC__)
+    #define CYTHON_RESTRICT __restrict__
+  #elif defined(_MSC_VER) && _MSC_VER >= 1400
+    #define CYTHON_RESTRICT __restrict
+  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+    #define CYTHON_RESTRICT restrict
+  #else
+    #define CYTHON_RESTRICT
+  #endif
+#endif
+#ifndef CYTHON_UNUSED
+# if defined(__GNUC__)
+#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
+#     define CYTHON_UNUSED __attribute__ ((__unused__))
+#   else
+#     define CYTHON_UNUSED
+#   endif
+# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
+#   define CYTHON_UNUSED __attribute__ ((__unused__))
+# else
+#   define CYTHON_UNUSED
+# endif
+#endif
+#ifndef CYTHON_MAYBE_UNUSED_VAR
+#  if defined(__cplusplus)
+     template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
+#  else
+#    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
+#  endif
+#endif
+#ifndef CYTHON_NCP_UNUSED
+# if CYTHON_COMPILING_IN_CPYTHON
+#  define CYTHON_NCP_UNUSED
+# else
+#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
+# endif
+#endif
+#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
+
+#ifndef CYTHON_INLINE
+  #if defined(__clang__)
+    #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
+  #elif defined(__GNUC__)
+    #define CYTHON_INLINE __inline__
+  #elif defined(_MSC_VER)
+    #define CYTHON_INLINE __inline
+  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+    #define CYTHON_INLINE inline
+  #else
+    #define CYTHON_INLINE
+  #endif
+#endif
+
+#if defined(WIN32) || defined(MS_WINDOWS)
+  #define _USE_MATH_DEFINES
+#endif
+#include <math.h>
+#ifdef NAN
+#define __PYX_NAN() ((float) NAN)
+#else
+static CYTHON_INLINE float __PYX_NAN() {
+  float value;
+  memset(&value, 0xFF, sizeof(value));
+  return value;
+}
+#endif
+#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
+#define __Pyx_truncl trunc
+#else
+#define __Pyx_truncl truncl
+#endif
+
+
+#define __PYX_ERR(f_index, lineno, Ln_error) \
+{ \
+  __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
+}
+
+#if PY_MAJOR_VERSION >= 3
+  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
+  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
+#else
+  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
+  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
+#endif
+
+#ifndef __PYX_EXTERN_C
+  #ifdef __cplusplus
+    #define __PYX_EXTERN_C extern "C"
+  #else
+    #define __PYX_EXTERN_C extern
+  #endif
+#endif
+
+#define __PYX_HAVE__asyncpg__protocol__protocol
+#define __PYX_HAVE_API__asyncpg__protocol__protocol
+#include <stdint.h>
+#include "debug.h"
+#include <string.h>
+#include <stdio.h>
+#include "pythread.h"
+#include "record/recordobj.h"
+#include "arpa/inet.h"
+#include <math.h>
+#ifdef _OPENMP
+#include <omp.h>
+#endif /* _OPENMP */
+
+#ifdef PYREX_WITHOUT_ASSERTIONS
+#define CYTHON_WITHOUT_ASSERTIONS
+#endif
+
+typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
+                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
+
+#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
+#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
+#define __PYX_DEFAULT_STRING_ENCODING ""
+#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
+#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
+#define __Pyx_uchar_cast(c) ((unsigned char)c)
+#define __Pyx_long_cast(x) ((long)x)
+#define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
+    (sizeof(type) < sizeof(Py_ssize_t))  ||\
+    (sizeof(type) > sizeof(Py_ssize_t) &&\
+          likely(v < (type)PY_SSIZE_T_MAX ||\
+                 v == (type)PY_SSIZE_T_MAX)  &&\
+          (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
+                                v == (type)PY_SSIZE_T_MIN)))  ||\
+    (sizeof(type) == sizeof(Py_ssize_t) &&\
+          (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
+                               v == (type)PY_SSIZE_T_MAX)))  )
+#if defined (__cplusplus) && __cplusplus >= 201103L
+    #include <cstdlib>
+    #define __Pyx_sst_abs(value) std::abs(value)
+#elif SIZEOF_INT >= SIZEOF_SIZE_T
+    #define __Pyx_sst_abs(value) abs(value)
+#elif SIZEOF_LONG >= SIZEOF_SIZE_T
+    #define __Pyx_sst_abs(value) labs(value)
+#elif defined (_MSC_VER) && defined (_M_X64)
+    #define __Pyx_sst_abs(value) _abs64(value)
+#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+    #define __Pyx_sst_abs(value) llabs(value)
+#elif defined (__GNUC__)
+    #define __Pyx_sst_abs(value) __builtin_llabs(value)
+#else
+    #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
+#endif
+static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
+static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
+#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
+#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
+#define __Pyx_PyBytes_FromString        PyBytes_FromString
+#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
+static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
+#if PY_MAJOR_VERSION < 3
+    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
+    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
+#else
+    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
+    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
+#endif
+#define __Pyx_PyObject_AsSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
+#define __Pyx_PyObject_AsUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
+#define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
+#define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
+#define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
+#define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
+#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
+#if PY_MAJOR_VERSION < 3
+static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
+{
+    const Py_UNICODE *u_end = u;
+    while (*u_end++) ;
+    return (size_t)(u_end - u - 1);
+}
+#else
+#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
+#endif
+#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
+#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
+#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
+#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
+#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
+#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False))
+static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
+static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
+static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
+static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
+#if CYTHON_ASSUME_SAFE_MACROS
+#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
+#else
+#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
+#endif
+#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
+#if PY_MAJOR_VERSION >= 3
+#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
+#else
+#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
+#endif
+#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
+#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
+static int __Pyx_sys_getdefaultencoding_not_ascii;
+static int __Pyx_init_sys_getdefaultencoding_params(void) {
+    PyObject* sys;
+    PyObject* default_encoding = NULL;
+    PyObject* ascii_chars_u = NULL;
+    PyObject* ascii_chars_b = NULL;
+    const char* default_encoding_c;
+    sys = PyImport_ImportModule("sys");
+    if (!sys) goto bad;
+    default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
+    Py_DECREF(sys);
+    if (!default_encoding) goto bad;
+    default_encoding_c = PyBytes_AsString(default_encoding);
+    if (!default_encoding_c) goto bad;
+    if (strcmp(default_encoding_c, "ascii") == 0) {
+        __Pyx_sys_getdefaultencoding_not_ascii = 0;
+    } else {
+        char ascii_chars[128];
+        int c;
+        for (c = 0; c < 128; c++) {
+            ascii_chars[c] = c;
+        }
+        __Pyx_sys_getdefaultencoding_not_ascii = 1;
+        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
+        if (!ascii_chars_u) goto bad;
+        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
+        if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
+            PyErr_Format(
+                PyExc_ValueError,
+                "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
+                default_encoding_c);
+            goto bad;
+        }
+        Py_DECREF(ascii_chars_u);
+        Py_DECREF(ascii_chars_b);
+    }
+    Py_DECREF(default_encoding);
+    return 0;
+bad:
+    Py_XDECREF(default_encoding);
+    Py_XDECREF(ascii_chars_u);
+    Py_XDECREF(ascii_chars_b);
+    return -1;
+}
+#endif
+#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
+#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
+#else
+#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
+#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
+static char* __PYX_DEFAULT_STRING_ENCODING;
+static int __Pyx_init_sys_getdefaultencoding_params(void) {
+    PyObject* sys;
+    PyObject* default_encoding = NULL;
+    char* default_encoding_c;
+    sys = PyImport_ImportModule("sys");
+    if (!sys) goto bad;
+    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
+    Py_DECREF(sys);
+    if (!default_encoding) goto bad;
+    default_encoding_c = PyBytes_AsString(default_encoding);
+    if (!default_encoding_c) goto bad;
+    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
+    if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
+    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
+    Py_DECREF(default_encoding);
+    return 0;
+bad:
+    Py_XDECREF(default_encoding);
+    return -1;
+}
+#endif
+#endif
+
+
+/* Test for GCC > 2.95 */
+#if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
+  #define likely(x)   __builtin_expect(!!(x), 1)
+  #define unlikely(x) __builtin_expect(!!(x), 0)
+#else /* !__GNUC__ or GCC < 2.95 */
+  #define likely(x)   (x)
+  #define unlikely(x) (x)
+#endif /* __GNUC__ */
+
+static PyObject *__pyx_m;
+static PyObject *__pyx_d;
+static PyObject *__pyx_b;
+static PyObject *__pyx_empty_tuple;
+static PyObject *__pyx_empty_bytes;
+static PyObject *__pyx_empty_unicode;
+static int __pyx_lineno;
+static int __pyx_clineno = 0;
+static const char * __pyx_cfilenm= __FILE__;
+static const char *__pyx_filename;
+
+
+static const char *__pyx_f[] = {
+  "asyncpg/protocol/settings.pyx",
+  "asyncpg/protocol/buffer.pyx",
+  "asyncpg/protocol/codecs/base.pyx",
+  "asyncpg/protocol/codecs/int.pyx",
+  "asyncpg/protocol/coreproto.pyx",
+  "asyncpg/protocol/encodings.pyx",
+  "asyncpg/protocol/codecs/bytea.pyx",
+  "asyncpg/protocol/codecs/text.pyx",
+  "asyncpg/protocol/codecs/bits.pyx",
+  "asyncpg/protocol/codecs/datetime.pyx",
+  "asyncpg/protocol/codecs/float.pyx",
+  "asyncpg/protocol/codecs/geometry.pyx",
+  "asyncpg/protocol/codecs/json.pyx",
+  "asyncpg/protocol/codecs/money.pyx",
+  "asyncpg/protocol/codecs/network.pyx",
+  "asyncpg/protocol/codecs/numeric.pyx",
+  "asyncpg/protocol/codecs/tsearch.pyx",
+  "asyncpg/protocol/codecs/txid.pyx",
+  "asyncpg/protocol/codecs/uuid.pyx",
+  "asyncpg/protocol/codecs/misc.pyx",
+  "asyncpg/protocol/codecs/array.pyx",
+  "asyncpg/protocol/codecs/range.pyx",
+  "asyncpg/protocol/codecs/record.pyx",
+  "asyncpg/protocol/codecs/hstore.pyx",
+  "asyncpg/protocol/coreproto.pxd",
+  "asyncpg/protocol/prepared_stmt.pyx",
+  "asyncpg/protocol/prepared_stmt.pxd",
+  "asyncpg/protocol/protocol.pyx",
+  "asyncpg/protocol/protocol.pxd",
+  "type.pxd",
+  "bool.pxd",
+  "complex.pxd",
+  "asyncpg/protocol/pgtypes.pxi",
+};
+
+/*--- Type declarations ---*/
+struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory;
+struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer;
+struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer;
+struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer;
+struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec;
+struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig;
+struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings;
+struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol;
+struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState;
+struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol;
+struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare;
+struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute;
+struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many;
+struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr;
+struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind;
+struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute;
+struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query;
+struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement;
+struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close;
+union __pyx_t_7asyncpg_8protocol_4hton__floatconv;
+union __pyx_t_7asyncpg_8protocol_4hton__doubleconv;
+
+/* "hton.pxd":53
+ * 
+ * 
+ * cdef union _floatconv:             # <<<<<<<<<<<<<<
+ *     uint32_t i
+ *     float f
+ */
+union __pyx_t_7asyncpg_8protocol_4hton__floatconv {
+  uint32_t i;
+  float f;
+};
+
+/* "hton.pxd":70
+ * 
+ * 
+ * cdef union _doubleconv:             # <<<<<<<<<<<<<<
+ *     uint64_t i
+ *     double f
+ */
+union __pyx_t_7asyncpg_8protocol_4hton__doubleconv {
+  uint64_t i;
+  double f;
+};
+struct __pyx_opt_args_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_data_codec;
+
+/* "asyncpg/protocol/codecs/base.pxd":25
+ * 
+ * 
+ * cdef enum CodecType:             # <<<<<<<<<<<<<<
+ *     CODEC_UNDEFINED = 0
+ *     CODEC_C         = 1
+ */
+enum __pyx_t_7asyncpg_8protocol_8protocol_CodecType {
+  __pyx_e_7asyncpg_8protocol_8protocol_CODEC_UNDEFINED = 0,
+  __pyx_e_7asyncpg_8protocol_8protocol_CODEC_C = 1,
+  __pyx_e_7asyncpg_8protocol_8protocol_CODEC_PY = 2,
+  __pyx_e_7asyncpg_8protocol_8protocol_CODEC_ARRAY = 3,
+  __pyx_e_7asyncpg_8protocol_8protocol_CODEC_COMPOSITE = 4,
+  __pyx_e_7asyncpg_8protocol_8protocol_CODEC_RANGE = 5
+};
+
+/* "asyncpg/protocol/codecs/base.pxd":34
+ * 
+ * 
+ * cdef enum CodecFormat:             # <<<<<<<<<<<<<<
+ *     PG_FORMAT_ANY = -1
+ *     PG_FORMAT_TEXT = 0
+ */
+enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat {
+  __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_ANY = -1L,
+  __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT = 0,
+  __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY = 1
+};
+
+/* "asyncpg/protocol/coreproto.pxd":8
+ * 
+ * 
+ * cdef enum ConnectionStatus:             # <<<<<<<<<<<<<<
+ *     CONNECTION_OK = 1
+ *     CONNECTION_BAD = 2
+ */
+enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus {
+  __pyx_e_7asyncpg_8protocol_8protocol_CONNECTION_OK = 1,
+  __pyx_e_7asyncpg_8protocol_8protocol_CONNECTION_BAD = 2,
+  __pyx_e_7asyncpg_8protocol_8protocol_CONNECTION_STARTED = 3
+};
+
+/* "asyncpg/protocol/coreproto.pxd":14
+ * 
+ * 
+ * cdef enum ProtocolState:             # <<<<<<<<<<<<<<
+ *     PROTOCOL_IDLE = 0
+ * 
+ */
+enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState {
+  __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_IDLE = 0,
+  __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_FAILED = 1,
+  __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_ERROR_CONSUME = 2,
+  __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_AUTH = 10,
+  __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_PREPARE = 11,
+  __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_BIND_EXECUTE = 12,
+  __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_BIND_EXECUTE_MANY = 13,
+  __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_CLOSE_STMT_PORTAL = 14,
+  __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_SIMPLE_QUERY = 15,
+  __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_EXECUTE = 16,
+  __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_BIND = 17
+};
+
+/* "asyncpg/protocol/coreproto.pxd":31
+ * 
+ * 
+ * cdef enum AuthenticationMessage:             # <<<<<<<<<<<<<<
+ *     AUTH_SUCCESSFUL = 0
+ *     AUTH_REQUIRED_KERBEROS = 2
+ */
+enum __pyx_t_7asyncpg_8protocol_8protocol_AuthenticationMessage {
+  __pyx_e_7asyncpg_8protocol_8protocol_AUTH_SUCCESSFUL = 0,
+  __pyx_e_7asyncpg_8protocol_8protocol_AUTH_REQUIRED_KERBEROS = 2,
+  __pyx_e_7asyncpg_8protocol_8protocol_AUTH_REQUIRED_PASSWORD = 3,
+  __pyx_e_7asyncpg_8protocol_8protocol_AUTH_REQUIRED_PASSWORDMD5 = 5,
+  __pyx_e_7asyncpg_8protocol_8protocol_AUTH_REQUIRED_SCMCRED = 6,
+  __pyx_e_7asyncpg_8protocol_8protocol_AUTH_REQUIRED_GSS = 7,
+  __pyx_e_7asyncpg_8protocol_8protocol_AUTH_REQUIRED_GSS_CONTINUE = 8,
+  __pyx_e_7asyncpg_8protocol_8protocol_AUTH_REQUIRED_SSPI = 9
+};
+
+/* "asyncpg/protocol/coreproto.pxd":51
+ * 
+ * 
+ * cdef enum ResultType:             # <<<<<<<<<<<<<<
+ *     RESULT_OK = 1
+ *     RESULT_FAILED = 2
+ */
+enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType {
+  __pyx_e_7asyncpg_8protocol_8protocol_RESULT_OK = 1,
+  __pyx_e_7asyncpg_8protocol_8protocol_RESULT_FAILED = 2
+};
+
+/* "asyncpg/protocol/coreproto.pxd":56
+ * 
+ * 
+ * cdef enum TransactionStatus:             # <<<<<<<<<<<<<<
+ *     PQTRANS_IDLE = 0                 # connection idle
+ *     PQTRANS_ACTIVE = 1               # command in progress
+ */
+enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus {
+  __pyx_e_7asyncpg_8protocol_8protocol_PQTRANS_IDLE = 0,
+  __pyx_e_7asyncpg_8protocol_8protocol_PQTRANS_ACTIVE = 1,
+  __pyx_e_7asyncpg_8protocol_8protocol_PQTRANS_INTRANS = 2,
+  __pyx_e_7asyncpg_8protocol_8protocol_PQTRANS_INERROR = 3,
+  __pyx_e_7asyncpg_8protocol_8protocol_PQTRANS_UNKNOWN = 4
+};
+
+/* "asyncpg/protocol/codecs/base.pxd":8
+ * 
+ * 
+ * ctypedef object (*encode_func)(ConnectionSettings settings,             # <<<<<<<<<<<<<<
+ *                                WriteBuffer buf,
+ *                                object obj)
+ */
+typedef PyObject *(*__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *);
+
+/* "asyncpg/protocol/codecs/base.pxd":12
+ *                                object obj)
+ * 
+ * ctypedef object (*decode_func)(ConnectionSettings settings,             # <<<<<<<<<<<<<<
+ *                                FastReadBuffer buf)
+ * 
+ */
+typedef PyObject *(*__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *);
+
+/* "asyncpg/protocol/codecs/base.pxd":15
+ *                                FastReadBuffer buf)
+ * 
+ * ctypedef object (*codec_encode_func)(Codec codec,             # <<<<<<<<<<<<<<
+ *                                      ConnectionSettings settings,
+ *                                      WriteBuffer buf,
+ */
+typedef PyObject *(*__pyx_t_7asyncpg_8protocol_8protocol_codec_encode_func)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *);
+
+/* "asyncpg/protocol/codecs/base.pxd":20
+ *                                      object obj)
+ * 
+ * ctypedef object (*codec_decode_func)(Codec codec,             # <<<<<<<<<<<<<<
+ *                                      ConnectionSettings settings,
+ *                                      FastReadBuffer buf)
+ */
+typedef PyObject *(*__pyx_t_7asyncpg_8protocol_8protocol_codec_decode_func)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *);
+
+/* "asyncpg/protocol/settings.pxd":25
+ *     cpdef inline set_builtin_type_codec(
+ *         self, typeoid, typename, typeschema, typekind, alias_to)
+ *     cpdef inline Codec get_data_codec(self, uint32_t oid, CodecFormat format=*)             # <<<<<<<<<<<<<<
+ */
+struct __pyx_opt_args_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_data_codec {
+  int __pyx_n;
+  enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat format;
+};
+
+/* "asyncpg/protocol/coreproto.pxd":64
+ * 
+ * 
+ * ctypedef object (*decode_row_method)(object, const char*, ssize_t)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+typedef PyObject *(*__pyx_t_7asyncpg_8protocol_8protocol_decode_row_method)(PyObject *, char const *, Py_ssize_t);
+
+/* "asyncpg/protocol/codecs/array.pyx":574
+ * 
+ * 
+ * cdef enum _ArrayParseState:             # <<<<<<<<<<<<<<
+ *     APS_START = 1
+ *     APS_STRIDE_STARTED = 2
+ */
+enum __pyx_t_7asyncpg_8protocol_8protocol__ArrayParseState {
+  __pyx_e_7asyncpg_8protocol_8protocol_APS_START = 1,
+  __pyx_e_7asyncpg_8protocol_8protocol_APS_STRIDE_STARTED = 2,
+  __pyx_e_7asyncpg_8protocol_8protocol_APS_STRIDE_DONE = 3,
+  __pyx_e_7asyncpg_8protocol_8protocol_APS_STRIDE_DELIMITED = 4,
+  __pyx_e_7asyncpg_8protocol_8protocol_APS_ELEM_STARTED = 5,
+  __pyx_e_7asyncpg_8protocol_8protocol_APS_ELEM_DELIMITED = 6
+};
+
+/* "asyncpg/protocol/codecs/range.pyx":18
+ * 
+ * 
+ * cdef enum _RangeArgumentType:             # <<<<<<<<<<<<<<
+ *     _RANGE_ARGUMENT_INVALID = 0
+ *     _RANGE_ARGUMENT_TUPLE = 1
+ */
+enum __pyx_t_7asyncpg_8protocol_8protocol__RangeArgumentType {
+  __pyx_e_7asyncpg_8protocol_8protocol__RANGE_ARGUMENT_INVALID = 0,
+  __pyx_e_7asyncpg_8protocol_8protocol__RANGE_ARGUMENT_TUPLE = 1,
+  __pyx_e_7asyncpg_8protocol_8protocol__RANGE_ARGUMENT_RANGE = 2
+};
+
+/* "asyncpg/protocol/codecs/array.pyx":17
+ * 
+ * 
+ * ctypedef object (*encode_func_ex)(ConnectionSettings settings,             # <<<<<<<<<<<<<<
+ *                                   WriteBuffer buf,
+ *                                   object obj,
+ */
+typedef PyObject *(*__pyx_t_7asyncpg_8protocol_8protocol_encode_func_ex)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *, void const *);
+
+/* "asyncpg/protocol/codecs/array.pyx":23
+ * 
+ * 
+ * ctypedef object (*decode_func_ex)(ConnectionSettings settings,             # <<<<<<<<<<<<<<
+ *                                   FastReadBuffer buf,
+ *                                   const void *arg)
+ */
+typedef PyObject *(*__pyx_t_7asyncpg_8protocol_8protocol_decode_func_ex)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *, void const *);
+
+/* "asyncpg/protocol/buffer.pxd":8
+ * 
+ * 
+ * cdef class Memory:             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         char* buf
+ */
+struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory {
+  PyObject_HEAD
+  struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_Memory *__pyx_vtab;
+  char *buf;
+  PyObject *owner;
+  Py_ssize_t length;
+};
+
+
+/* "asyncpg/protocol/buffer.pxd":20
+ * 
+ * 
+ * cdef class WriteBuffer:             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         # Preallocated small buffer
+ */
+struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer {
+  PyObject_HEAD
+  struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_vtab;
+  int _smallbuf_inuse;
+  char _smallbuf[0x400];
+  char *_buf;
+  Py_ssize_t _size;
+  Py_ssize_t _length;
+  int _view_count;
+  int _message_mode;
+};
+
+
+/* "asyncpg/protocol/buffer.pxd":65
+ * 
+ * 
+ * cdef class ReadBuffer:             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         # A deque of buffers (bytes objects)
+ */
+struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer {
+  PyObject_HEAD
+  struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_vtab;
+  PyObject *_bufs;
+  PyObject *_bufs_append;
+  PyObject *_bufs_popleft;
+  PyObject *_buf0;
+  PyObject *_buf0_prev;
+  int32_t _bufs_len;
+  Py_ssize_t _pos0;
+  Py_ssize_t _len0;
+  Py_ssize_t _length;
+  char _current_message_type;
+  int _current_message_len;
+  Py_ssize_t _current_message_len_unread;
+  int _current_message_ready;
+};
+
+
+/* "asyncpg/protocol/buffer.pxd":119
+ * 
+ * 
+ * cdef class FastReadBuffer:             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         const char* buf
+ */
+struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer {
+  PyObject_HEAD
+  struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_vtab;
+  char const *buf;
+  Py_ssize_t len;
+};
+
+
+/* "asyncpg/protocol/codecs/base.pxd":40
+ * 
+ * 
+ * cdef class Codec:             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         uint32_t        oid
+ */
+struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec {
+  PyObject_HEAD
+  struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_Codec *__pyx_vtab;
+  uint32_t oid;
+  PyObject *name;
+  PyObject *schema;
+  PyObject *kind;
+  enum __pyx_t_7asyncpg_8protocol_8protocol_CodecType type;
+  enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat format;
+  __pyx_t_7asyncpg_8protocol_8protocol_encode_func c_encoder;
+  __pyx_t_7asyncpg_8protocol_8protocol_decode_func c_decoder;
+  PyObject *py_encoder;
+  PyObject *py_decoder;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *element_codec;
+  Py_UCS4 element_delimiter;
+  PyObject *element_type_oids;
+  PyObject *element_names;
+  PyObject *element_codecs;
+  __pyx_t_7asyncpg_8protocol_8protocol_codec_encode_func encoder;
+  __pyx_t_7asyncpg_8protocol_8protocol_codec_decode_func decoder;
+};
+
+
+/* "asyncpg/protocol/codecs/base.pxd":154
+ * 
+ * 
+ * cdef class DataCodecConfig:             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         dict _type_codecs_cache
+ */
+struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig {
+  PyObject_HEAD
+  struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_DataCodecConfig *__pyx_vtab;
+  PyObject *_type_codecs_cache;
+  PyObject *_local_type_codecs;
+};
+
+
+/* "asyncpg/protocol/settings.pxd":8
+ * 
+ * 
+ * cdef class ConnectionSettings:             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         str _encoding
+ */
+struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings {
+  PyObject_HEAD
+  struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_vtab;
+  PyObject *_encoding;
+  PyObject *_codec;
+  PyObject *_settings;
+  int _is_utf8;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *_data_codecs;
+};
+
+
+/* "asyncpg/protocol/coreproto.pxd":67
+ * 
+ * 
+ * cdef class CoreProtocol:             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         ReadBuffer buffer
+ */
+struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol {
+  PyObject_HEAD
+  struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_vtab;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *buffer;
+  int _skip_discard;
+  int _discard_data;
+  PyObject *_execute_iter;
+  PyObject *_execute_portal_name;
+  PyObject *_execute_stmt_name;
+  enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus con_status;
+  enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState state;
+  enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus xact_status;
+  PyObject *encoding;
+  PyObject *transport;
+  PyObject *con_args;
+  int32_t backend_pid;
+  int32_t backend_secret;
+  enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType result_type;
+  PyObject *result;
+  PyObject *result_param_desc;
+  PyObject *result_row_desc;
+  PyObject *result_status_msg;
+  int result_execute_completed;
+};
+
+
+/* "asyncpg/protocol/prepared_stmt.pxd":8
+ * 
+ * 
+ * cdef class PreparedStatementState:             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         readonly str name
+ */
+struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState {
+  PyObject_HEAD
+  struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_vtab;
+  PyObject *name;
+  PyObject *query;
+  int closed;
+  int refs;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *buffer;
+  PyObject *row_desc;
+  PyObject *parameters_desc;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *protocol;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *settings;
+  int16_t args_num;
+  int have_text_args;
+  PyObject *args_codecs;
+  int16_t cols_num;
+  PyObject *cols_desc;
+  int have_text_cols;
+  PyObject *rows_codecs;
+};
+
+
+/* "asyncpg/protocol/protocol.pxd":25
+ * 
+ * 
+ * cdef class BaseProtocol(CoreProtocol):             # <<<<<<<<<<<<<<
+ * 
+ *     cdef:
+ */
+struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol __pyx_base;
+  PyObject *loop;
+  PyObject *address;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *settings;
+  PyObject *cancel_sent_waiter;
+  PyObject *cancel_waiter;
+  PyObject *waiter;
+  int return_extra;
+  PyObject *create_future;
+  PyObject *timeout_handle;
+  PyObject *timeout_callback;
+  PyObject *completed_callback;
+  PyObject *connection;
+  PyObject *last_query;
+  int uid_counter;
+  int closing;
+  uint64_t queries_count;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *statement;
+};
+
+
+/* "asyncpg/protocol/protocol.pyx":123
+ *         return self.settings
+ * 
+ *     async def prepare(self, stmt_name, query, timeout):             # <<<<<<<<<<<<<<
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ */
+struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare {
+  PyObject_HEAD
+  PyObject *__pyx_v_query;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self;
+  PyObject *__pyx_v_stmt_name;
+  PyObject *__pyx_v_timeout;
+};
+
+
+/* "asyncpg/protocol/protocol.pyx":142
+ *         return await self._new_waiter(timeout)
+ * 
+ *     async def bind_execute(self, PreparedStatementState state, args,             # <<<<<<<<<<<<<<
+ *                            str portal_name, int limit, return_extra,
+ *                            timeout):
+ */
+struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute {
+  PyObject_HEAD
+  PyObject *__pyx_v_args;
+  int __pyx_v_limit;
+  PyObject *__pyx_v_portal_name;
+  PyObject *__pyx_v_return_extra;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_state;
+  PyObject *__pyx_v_timeout;
+};
+
+
+/* "asyncpg/protocol/protocol.pyx":167
+ *         return await self._new_waiter(timeout)
+ * 
+ *     async def bind_execute_many(self, PreparedStatementState state, args,             # <<<<<<<<<<<<<<
+ *                                 str portal_name, timeout):
+ * 
+ */
+struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many {
+  PyObject_HEAD
+  PyObject *__pyx_v_arg_bufs;
+  PyObject *__pyx_v_args;
+  PyObject *__pyx_v_data_gen;
+  PyObject *__pyx_v_genexpr;
+  PyObject *__pyx_v_portal_name;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_state;
+  PyObject *__pyx_v_timeout;
+  PyObject *__pyx_v_waiter;
+};
+
+
+/* "asyncpg/protocol/protocol.pyx":181
+ *         # this generator expression to keep the memory pressure under
+ *         # control.
+ *         data_gen = (state._encode_bind_msg(b) for b in args)             # <<<<<<<<<<<<<<
+ *         arg_bufs = iter(data_gen)
+ * 
+ */
+struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr {
+  PyObject_HEAD
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many *__pyx_outer_scope;
+  PyObject *__pyx_v_b;
+  PyObject *__pyx_t_0;
+  Py_ssize_t __pyx_t_1;
+  PyObject *(*__pyx_t_2)(PyObject *);
+};
+
+
+/* "asyncpg/protocol/protocol.pyx":198
+ *         return await waiter
+ * 
+ *     async def bind(self, PreparedStatementState state, args,             # <<<<<<<<<<<<<<
+ *                    str portal_name, timeout):
+ * 
+ */
+struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind {
+  PyObject_HEAD
+  PyObject *__pyx_v_args;
+  PyObject *__pyx_v_portal_name;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_state;
+  PyObject *__pyx_v_timeout;
+};
+
+
+/* "asyncpg/protocol/protocol.pyx":219
+ *         return await self._new_waiter(timeout)
+ * 
+ *     async def execute(self, PreparedStatementState state,             # <<<<<<<<<<<<<<
+ *                       str portal_name, int limit, return_extra,
+ *                       timeout):
+ */
+struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute {
+  PyObject_HEAD
+  int __pyx_v_limit;
+  PyObject *__pyx_v_portal_name;
+  PyObject *__pyx_v_return_extra;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_state;
+  PyObject *__pyx_v_timeout;
+};
+
+
+/* "asyncpg/protocol/protocol.pyx":242
+ *         return await self._new_waiter(timeout)
+ * 
+ *     async def query(self, query, timeout):             # <<<<<<<<<<<<<<
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ */
+struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query {
+  PyObject_HEAD
+  PyObject *__pyx_v_query;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self;
+  PyObject *__pyx_v_timeout;
+};
+
+
+/* "asyncpg/protocol/protocol.pyx":257
+ *         return await self._new_waiter(timeout)
+ * 
+ *     async def close_statement(self, PreparedStatementState state, timeout):             # <<<<<<<<<<<<<<
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ */
+struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement {
+  PyObject_HEAD
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_state;
+  PyObject *__pyx_v_timeout;
+};
+
+
+/* "asyncpg/protocol/protocol.pyx":289
+ *         self.transport.abort()
+ * 
+ *     async def close(self):             # <<<<<<<<<<<<<<
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ */
+struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close {
+  PyObject_HEAD
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self;
+};
+
+
+
+/* "asyncpg/protocol/buffer.pyx":18
+ * @cython.final
+ * @cython.freelist(_MEMORY_FREELIST_SIZE)
+ * cdef class Memory:             # <<<<<<<<<<<<<<
+ * 
+ *     cdef as_bytes(self):
+ */
+
+struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_Memory {
+  PyObject *(*as_bytes)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *);
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *(*new)(char *, PyObject *, Py_ssize_t);
+};
+static struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_Memory *__pyx_vtabptr_7asyncpg_8protocol_8protocol_Memory;
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_6Memory_as_bytes(struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *);
+static CYTHON_INLINE struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *__pyx_f_7asyncpg_8protocol_8protocol_6Memory_new(char *, PyObject *, Py_ssize_t);
+
+
+/* "asyncpg/protocol/buffer.pyx":36
+ * @cython.final
+ * @cython.freelist(_BUFFER_FREELIST_SIZE)
+ * cdef class WriteBuffer:             # <<<<<<<<<<<<<<
+ * 
+ *     def __cinit__(self):
+ */
+
+struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_WriteBuffer {
+  PyObject *(*_check_readonly)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *);
+  PyObject *(*len)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *);
+  PyObject *(*_ensure_alloced)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, Py_ssize_t);
+  PyObject *(*_reallocate)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, Py_ssize_t);
+  PyObject *(*start_message)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, char);
+  PyObject *(*end_message)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *);
+  PyObject *(*write_buffer)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *);
+  PyObject *(*write_byte)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, char);
+  PyObject *(*write_bytes)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *);
+  PyObject *(*write_bytestring)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *);
+  PyObject *(*write_str)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *, PyObject *);
+  PyObject *(*write_cstr)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, char *, Py_ssize_t);
+  PyObject *(*write_int16)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, int16_t);
+  PyObject *(*write_int32)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, int32_t);
+  PyObject *(*write_int64)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, int64_t);
+  PyObject *(*write_float)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, float);
+  PyObject *(*write_double)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, double);
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *(*new_message)(char);
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *(*new)(void);
+};
+static struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_vtabptr_7asyncpg_8protocol_8protocol_WriteBuffer;
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__check_readonly(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *);
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_len(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *);
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__ensure_alloced(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, Py_ssize_t);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__reallocate(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, Py_ssize_t);
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_start_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, char);
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_end_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_buffer(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, char);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_bytes(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_bytestring(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_str(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *, PyObject *);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_cstr(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, char *, Py_ssize_t);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int16(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, int16_t);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, int32_t);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int64(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, int64_t);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_float(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, float);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_double(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, double);
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new_message(char);
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new(void);
+
+
+/* "asyncpg/protocol/buffer.pyx":231
+ * @cython.final
+ * @cython.freelist(_BUFFER_FREELIST_SIZE)
+ * cdef class ReadBuffer:             # <<<<<<<<<<<<<<
+ * 
+ *     def __cinit__(self):
+ */
+
+struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_ReadBuffer {
+  PyObject *(*feed_data)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *, PyObject *);
+  PyObject *(*_ensure_first_buf)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *);
+  PyObject *(*_switch_to_next_buf)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *);
+  PyObject *(*read_byte)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *);
+  char *(*_try_read_bytes)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *, Py_ssize_t);
+  PyObject *(*read)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *, Py_ssize_t);
+  PyObject *(*read_bytes)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *, Py_ssize_t);
+  PyObject *(*read_int32)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *);
+  PyObject *(*read_int16)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *);
+  PyObject *(*read_cstr)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *);
+  int32_t (*has_message)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *);
+  char *(*try_consume_message)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *, Py_ssize_t *);
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *(*consume_message)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *);
+  PyObject *(*discard_message)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *);
+  PyObject *(*_discard_message)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *);
+  char (*get_message_type)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *);
+  int32_t (*get_message_length)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *);
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *(*new_message_parser)(PyObject *);
+};
+static struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_vtabptr_7asyncpg_8protocol_8protocol_ReadBuffer;
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_feed_data(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *, PyObject *);
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__ensure_first_buf(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__switch_to_next_buf(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *);
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_byte(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *);
+static CYTHON_INLINE char *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__try_read_bytes(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *, Py_ssize_t);
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *, Py_ssize_t);
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_bytes(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *, Py_ssize_t);
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_int32(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *);
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_int16(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *);
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_cstr(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *);
+static int32_t __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_has_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *);
+static CYTHON_INLINE char *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_try_consume_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *, Py_ssize_t *);
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_discard_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *);
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__discard_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *);
+static CYTHON_INLINE char __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_get_message_type(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *);
+static CYTHON_INLINE int32_t __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_get_message_length(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *);
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_new_message_parser(PyObject *);
+
+
+/* "asyncpg/protocol/buffer.pyx":582
+ * @cython.final
+ * @cython.freelist(_BUFFER_FREELIST_SIZE)
+ * cdef class FastReadBuffer:             # <<<<<<<<<<<<<<
+ * 
+ *     cdef inline const char* read(self, ssize_t n) except NULL:
+ */
+
+struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_FastReadBuffer {
+  char const *(*read)(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *, Py_ssize_t);
+  char const *(*read_all)(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *);
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *(*slice_from)(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *, Py_ssize_t);
+  PyObject *(*_raise_ins_err)(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *, Py_ssize_t, Py_ssize_t);
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *(*new)(void);
+};
+static struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_vtabptr_7asyncpg_8protocol_8protocol_FastReadBuffer;
+static CYTHON_INLINE char const *__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *, Py_ssize_t);
+static CYTHON_INLINE char const *__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read_all(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *);
+static CYTHON_INLINE struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_slice_from(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *, Py_ssize_t);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer__raise_ins_err(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *, Py_ssize_t, Py_ssize_t);
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_new(void);
+
+
+/* "asyncpg/protocol/codecs/base.pyx":15
+ * 
+ * @cython.final
+ * cdef class Codec:             # <<<<<<<<<<<<<<
+ * 
+ *     def __cinit__(self, uint32_t oid):
+ */
+
+struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_Codec {
+  PyObject *(*init)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, PyObject *, PyObject *, PyObject *, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecType, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat, __pyx_t_7asyncpg_8protocol_8protocol_encode_func, __pyx_t_7asyncpg_8protocol_8protocol_decode_func, PyObject *, PyObject *, struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, PyObject *, PyObject *, PyObject *, Py_UCS4);
+  PyObject *(*encode_scalar)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *);
+  PyObject *(*encode_array)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *);
+  PyObject *(*encode_range)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *);
+  PyObject *(*encode_composite)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *);
+  PyObject *(*encode_in_python)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *);
+  PyObject *(*decode_scalar)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *);
+  PyObject *(*decode_array)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *);
+  PyObject *(*decode_array_text)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *);
+  PyObject *(*decode_range)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *);
+  PyObject *(*decode_composite)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *);
+  PyObject *(*decode_in_python)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *);
+  PyObject *(*encode)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *);
+  PyObject *(*decode)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *);
+  PyObject *(*has_encoder)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *);
+  PyObject *(*has_decoder)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *);
+  PyObject *(*is_binary)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *);
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *(*copy)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *);
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *(*new_array_codec)(uint32_t, PyObject *, PyObject *, struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, Py_UCS4);
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *(*new_range_codec)(uint32_t, PyObject *, PyObject *, struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *);
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *(*new_composite_codec)(uint32_t, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *);
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *(*new_python_codec)(uint32_t, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat);
+};
+static struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_Codec *__pyx_vtabptr_7asyncpg_8protocol_8protocol_Codec;
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_init(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, PyObject *, PyObject *, PyObject *, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecType, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat, __pyx_t_7asyncpg_8protocol_8protocol_encode_func, __pyx_t_7asyncpg_8protocol_8protocol_decode_func, PyObject *, PyObject *, struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, PyObject *, PyObject *, PyObject *, Py_UCS4);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_scalar(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_array(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_range(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_composite(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_in_python(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_scalar(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_array(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_array_text(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_range(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_composite(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_in_python(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *);
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *);
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_has_encoder(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_has_decoder(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_is_binary(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *);
+static CYTHON_INLINE struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_copy(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *);
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_new_array_codec(uint32_t, PyObject *, PyObject *, struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, Py_UCS4);
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_new_range_codec(uint32_t, PyObject *, PyObject *, struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *);
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_new_composite_codec(uint32_t, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *);
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_new_python_codec(uint32_t, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat);
+
+
+/* "asyncpg/protocol/codecs/base.pyx":318
+ * 
+ * 
+ * cdef class DataCodecConfig:             # <<<<<<<<<<<<<<
+ *     def __init__(self, cache_key):
+ *         try:
+ */
+
+struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_DataCodecConfig {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *(*get_codec)(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *, uint32_t, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat);
+};
+static struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_DataCodecConfig *__pyx_vtabptr_7asyncpg_8protocol_8protocol_DataCodecConfig;
+static CYTHON_INLINE struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_15DataCodecConfig_get_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *, uint32_t, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat);
+
+
+/* "asyncpg/protocol/settings.pyx":9
+ * 
+ * @cython.final
+ * cdef class ConnectionSettings:             # <<<<<<<<<<<<<<
+ * 
+ *     def __cinit__(self, conn_key):
+ */
+
+struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_ConnectionSettings {
+  PyObject *(*add_setting)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, PyObject *, PyObject *);
+  PyObject *(*is_encoding_utf8)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *);
+  PyObject *(*get_text_codec)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, int __pyx_skip_dispatch);
+  PyObject *(*register_data_types)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, PyObject *, int __pyx_skip_dispatch);
+  PyObject *(*add_python_codec)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch);
+  PyObject *(*set_builtin_type_codec)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch);
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *(*get_data_codec)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, uint32_t, int __pyx_skip_dispatch, struct __pyx_opt_args_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_data_codec *__pyx_optional_args);
+};
+static struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_vtabptr_7asyncpg_8protocol_8protocol_ConnectionSettings;
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_add_setting(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, PyObject *, PyObject *);
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_is_encoding_utf8(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *);
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_text_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, int __pyx_skip_dispatch);
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_register_data_types(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, PyObject *, int __pyx_skip_dispatch);
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_add_python_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch);
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_set_builtin_type_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch);
+static CYTHON_INLINE struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_data_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, uint32_t, int __pyx_skip_dispatch, struct __pyx_opt_args_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_data_codec *__pyx_optional_args);
+
+
+/* "asyncpg/protocol/coreproto.pyx":11
+ * 
+ * 
+ * cdef class CoreProtocol:             # <<<<<<<<<<<<<<
+ * 
+ *     def __init__(self, con_args):
+ */
+
+struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol {
+  PyObject *(*_process__auth)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, char);
+  PyObject *(*_process__prepare)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, char);
+  PyObject *(*_process__bind_execute)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, char);
+  PyObject *(*_process__bind_execute_many)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, char);
+  PyObject *(*_process__close_stmt_portal)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, char);
+  PyObject *(*_process__simple_query)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, char);
+  PyObject *(*_process__bind)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, char);
+  PyObject *(*_parse_msg_authentication)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *);
+  PyObject *(*_parse_msg_parameter_status)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *);
+  PyObject *(*_parse_msg_notification)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *);
+  PyObject *(*_parse_msg_backend_key_data)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *);
+  PyObject *(*_parse_msg_ready_for_query)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *);
+  PyObject *(*_parse_data_msgs)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *);
+  PyObject *(*_parse_msg_error_response)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *);
+  PyObject *(*_parse_msg_command_complete)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *);
+  PyObject *(*_auth_password_message_cleartext)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *);
+  PyObject *(*_auth_password_message_md5)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *);
+  PyObject *(*_write)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *);
+  PyObject *(*_write_sync_message)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *);
+  PyObject *(*_read_server_messages)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *);
+  PyObject *(*_push_result)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *);
+  PyObject *(*_reset_result)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *);
+  PyObject *(*_set_state)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState);
+  PyObject *(*_ensure_connected)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *);
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *(*_build_bind_message)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *, PyObject *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *);
+  PyObject *(*_connect)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *);
+  PyObject *(*_prepare)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *, PyObject *);
+  PyObject *(*_send_bind_message)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *, PyObject *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, int32_t);
+  PyObject *(*_bind_execute)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *, PyObject *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, int32_t);
+  PyObject *(*_bind_execute_many)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *, PyObject *, PyObject *);
+  PyObject *(*_bind)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *, PyObject *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *);
+  PyObject *(*_execute)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *, int32_t);
+  PyObject *(*_close)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *, int);
+  PyObject *(*_simple_query)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *);
+  PyObject *(*_terminate)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *);
+  PyObject *(*_decode_row)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, char const *, Py_ssize_t);
+  PyObject *(*_on_result)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *);
+  PyObject *(*_on_notification)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *, PyObject *, PyObject *);
+  PyObject *(*_set_server_parameter)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *, PyObject *);
+  PyObject *(*_on_connection_lost)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *);
+};
+static struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_vtabptr_7asyncpg_8protocol_8protocol_CoreProtocol;
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__write_sync_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *);
+
+
+/* "asyncpg/protocol/prepared_stmt.pyx":9
+ * 
+ * @cython.final
+ * cdef class PreparedStatementState:             # <<<<<<<<<<<<<<
+ * 
+ *     def __cinit__(self, str name, str query, BaseProtocol protocol):
+ */
+
+struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_PreparedStatementState {
+  PyObject *(*_encode_bind_msg)(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *, PyObject *);
+  PyObject *(*_ensure_rows_decoder)(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *);
+  PyObject *(*_ensure_args_encoder)(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *);
+  PyObject *(*_set_row_desc)(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *, PyObject *);
+  PyObject *(*_set_args_desc)(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *, PyObject *);
+  PyObject *(*_decode_row)(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *, char const *, Py_ssize_t);
+};
+static struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_vtabptr_7asyncpg_8protocol_8protocol_PreparedStatementState;
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__encode_bind_msg(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *, PyObject *);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__ensure_rows_decoder(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__ensure_args_encoder(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__set_row_desc(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *, PyObject *);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__set_args_desc(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *, PyObject *);
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__decode_row(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *, char const *, Py_ssize_t);
+
+
+/* "asyncpg/protocol/protocol.pyx":82
+ * 
+ * 
+ * cdef class BaseProtocol(CoreProtocol):             # <<<<<<<<<<<<<<
+ *     def __init__(self, addr, connected_fut, con_args, loop):
+ *         CoreProtocol.__init__(self, con_args)
+ */
+
+struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol {
+  struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol __pyx_base;
+  PyObject *(*_ensure_clear_state)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *);
+  PyObject *(*_new_waiter)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *, PyObject *);
+  PyObject *(*_on_result__connect)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *, PyObject *);
+  PyObject *(*_on_result__prepare)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *, PyObject *);
+  PyObject *(*_on_result__bind_and_exec)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *, PyObject *);
+  PyObject *(*_on_result__close_stmt_or_portal)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *, PyObject *);
+  PyObject *(*_on_result__simple_query)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *, PyObject *);
+  PyObject *(*_on_result__bind)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *, PyObject *);
+  PyObject *(*_handle_waiter_on_connection_lost)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *, PyObject *);
+  PyObject *(*_dispatch_result)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *);
+};
+static struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_vtabptr_7asyncpg_8protocol_8protocol_BaseProtocol;
+
+/* --- Runtime support code (head) --- */
+/* Refnanny.proto */
+#ifndef CYTHON_REFNANNY
+  #define CYTHON_REFNANNY 0
+#endif
+#if CYTHON_REFNANNY
+  typedef struct {
+    void (*INCREF)(void*, PyObject*, int);
+    void (*DECREF)(void*, PyObject*, int);
+    void (*GOTREF)(void*, PyObject*, int);
+    void (*GIVEREF)(void*, PyObject*, int);
+    void* (*SetupContext)(const char*, int, const char*);
+    void (*FinishContext)(void**);
+  } __Pyx_RefNannyAPIStruct;
+  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
+  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
+  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
+#ifdef WITH_THREAD
+  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
+          if (acquire_gil) {\
+              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
+              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
+              PyGILState_Release(__pyx_gilstate_save);\
+          } else {\
+              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
+          }
+#else
+  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
+          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
+#endif
+  #define __Pyx_RefNannyFinishContext()\
+          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
+  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
+  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
+  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
+  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
+#else
+  #define __Pyx_RefNannyDeclarations
+  #define __Pyx_RefNannySetupContext(name, acquire_gil)
+  #define __Pyx_RefNannyFinishContext()
+  #define __Pyx_INCREF(r) Py_INCREF(r)
+  #define __Pyx_DECREF(r) Py_DECREF(r)
+  #define __Pyx_GOTREF(r)
+  #define __Pyx_GIVEREF(r)
+  #define __Pyx_XINCREF(r) Py_XINCREF(r)
+  #define __Pyx_XDECREF(r) Py_XDECREF(r)
+  #define __Pyx_XGOTREF(r)
+  #define __Pyx_XGIVEREF(r)
+#endif
+#define __Pyx_XDECREF_SET(r, v) do {\
+        PyObject *tmp = (PyObject *) r;\
+        r = v; __Pyx_XDECREF(tmp);\
+    } while (0)
+#define __Pyx_DECREF_SET(r, v) do {\
+        PyObject *tmp = (PyObject *) r;\
+        r = v; __Pyx_DECREF(tmp);\
+    } while (0)
+#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
+#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
+
+/* PyObjectGetAttrStr.proto */
+#if CYTHON_USE_TYPE_SLOTS
+static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
+    PyTypeObject* tp = Py_TYPE(obj);
+    if (likely(tp->tp_getattro))
+        return tp->tp_getattro(obj, attr_name);
+#if PY_MAJOR_VERSION < 3
+    if (likely(tp->tp_getattr))
+        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
+#endif
+    return PyObject_GetAttr(obj, attr_name);
+}
+#else
+#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
+#endif
+
+/* GetBuiltinName.proto */
+static PyObject *__Pyx_GetBuiltinName(PyObject *name);
+
+/* dict_getitem_default.proto */
+static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value);
+
+/* PyCFunctionFastCall.proto */
+#if CYTHON_FAST_PYCCALL
+static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
+#else
+#define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
+#endif
+
+/* PyFunctionFastCall.proto */
+#if CYTHON_FAST_PYCALL
+#define __Pyx_PyFunction_FastCall(func, args, nargs)\
+    __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
+#if 1 || PY_VERSION_HEX < 0x030600B1
+static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
+#else
+#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
+#endif
+#endif
+
+/* PyObjectCall.proto */
+#if CYTHON_COMPILING_IN_CPYTHON
+static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
+#else
+#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
+#endif
+
+/* PyObjectCallMethO.proto */
+#if CYTHON_COMPILING_IN_CPYTHON
+static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
+#endif
+
+/* PyObjectCallOneArg.proto */
+static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
+
+/* PyObjectCallNoArg.proto */
+#if CYTHON_COMPILING_IN_CPYTHON
+static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
+#else
+#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
+#endif
+
+/* RaiseDoubleKeywords.proto */
+static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
+
+/* ParseKeywords.proto */
+static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
+    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
+    const char* function_name);
+
+/* RaiseArgTupleInvalid.proto */
+static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
+    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
+
+/* GetModuleGlobalName.proto */
+static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
+
+/* IncludeStringH.proto */
+#include <string.h>
+
+/* BytesEquals.proto */
+static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
+
+/* UnicodeEquals.proto */
+static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
+
+/* DictGetItem.proto */
+#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
+static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
+    PyObject *value;
+    value = PyDict_GetItemWithError(d, key);
+    if (unlikely(!value)) {
+        if (!PyErr_Occurred()) {
+            PyObject* args = PyTuple_Pack(1, key);
+            if (likely(args))
+                PyErr_SetObject(PyExc_KeyError, args);
+            Py_XDECREF(args);
+        }
+        return NULL;
+    }
+    Py_INCREF(value);
+    return value;
+}
+#else
+    #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
+#endif
+
+/* PyThreadStateGet.proto */
+#if CYTHON_FAST_THREAD_STATE
+#define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
+#define __Pyx_PyThreadState_assign  __pyx_tstate = PyThreadState_GET();
+#else
+#define __Pyx_PyThreadState_declare
+#define __Pyx_PyThreadState_assign
+#endif
+
+/* SaveResetException.proto */
+#if CYTHON_FAST_THREAD_STATE
+#define __Pyx_ExceptionSave(type, value, tb)  __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
+static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
+#define __Pyx_ExceptionReset(type, value, tb)  __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
+static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
+#else
+#define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
+#define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
+#endif
+
+/* PyErrExceptionMatches.proto */
+#if CYTHON_FAST_THREAD_STATE
+#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
+static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
+#else
+#define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
+#endif
+
+/* GetException.proto */
+#if CYTHON_FAST_THREAD_STATE
+#define __Pyx_GetException(type, value, tb)  __Pyx__GetException(__pyx_tstate, type, value, tb)
+static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
+#else
+static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
+#endif
+
+/* PyErrFetchRestore.proto */
+#if CYTHON_FAST_THREAD_STATE
+#define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
+#define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
+#define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
+#define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
+static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
+static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
+#else
+#define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
+#define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
+#define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
+#define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
+#endif
+
+/* RaiseException.proto */
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
+
+/* ExtTypeTest.proto */
+static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
+
+/* KeywordStringCheck.proto */
+static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed);
+
+/* WriteUnraisableException.proto */
+static void __Pyx_WriteUnraisable(const char *name, int clineno,
+                                  int lineno, const char *filename,
+                                  int full_traceback, int nogil);
+
+/* GetItemInt.proto */
+#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
+    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
+    __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
+    (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
+               __Pyx_GetItemInt_Generic(o, to_py_func(i))))
+#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
+    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
+    __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
+    (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
+                                                              int wraparound, int boundscheck);
+#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
+    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
+    __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
+    (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
+                                                              int wraparound, int boundscheck);
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
+                                                     int is_list, int wraparound, int boundscheck);
+
+/* None.proto */
+static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);
+
+/* SliceObject.proto */
+static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
+        PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
+        PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
+        int has_cstart, int has_cstop, int wraparound);
+
+/* ListAppend.proto */
+#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
+static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
+    PyListObject* L = (PyListObject*) list;
+    Py_ssize_t len = Py_SIZE(list);
+    if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
+        Py_INCREF(x);
+        PyList_SET_ITEM(list, len, x);
+        Py_SIZE(list) = len+1;
+        return 0;
+    }
+    return PyList_Append(list, x);
+}
+#else
+#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
+#endif
+
+/* PyIntBinop.proto */
+#if !CYTHON_COMPILING_IN_PYPY
+static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
+#else
+#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace)\
+    (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
+#endif
+
+/* PyDictContains.proto */
+static CYTHON_INLINE int __Pyx_PyDict_ContainsTF(PyObject* item, PyObject* dict, int eq) {
+    int result = PyDict_Contains(dict, item);
+    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
+}
+
+/* py_dict_clear.proto */
+#define __Pyx_PyDict_Clear(d) (PyDict_Clear(d), 0)
+
+/* PySequenceContains.proto */
+static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) {
+    int result = PySequence_Contains(seq, item);
+    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
+}
+
+/* SwapException.proto */
+#if CYTHON_FAST_THREAD_STATE
+#define __Pyx_ExceptionSwap(type, value, tb)  __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
+static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
+#else
+static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
+#endif
+
+/* None.proto */
+static CYTHON_INLINE int64_t __Pyx_mod_int64_t(int64_t, int64_t);
+
+/* PyIntBinop.proto */
+#if !CYTHON_COMPILING_IN_PYPY
+static PyObject* __Pyx_PyInt_AddCObj(PyObject *op1, PyObject *op2, long intval, int inplace);
+#else
+#define __Pyx_PyInt_AddCObj(op1, op2, intval, inplace)\
+    (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
+#endif
+
+/* RaiseTooManyValuesToUnpack.proto */
+static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
+
+/* RaiseNeedMoreValuesToUnpack.proto */
+static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
+
+/* IterFinish.proto */
+static CYTHON_INLINE int __Pyx_IterFinish(void);
+
+/* UnpackItemEndCheck.proto */
+static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
+
+/* PyObjectSetAttrStr.proto */
+#if CYTHON_USE_TYPE_SLOTS
+#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o,n,NULL)
+static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
+    PyTypeObject* tp = Py_TYPE(obj);
+    if (likely(tp->tp_setattro))
+        return tp->tp_setattro(obj, attr_name, value);
+#if PY_MAJOR_VERSION < 3
+    if (likely(tp->tp_setattr))
+        return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
+#endif
+    return PyObject_SetAttr(obj, attr_name, value);
+}
+#else
+#define __Pyx_PyObject_DelAttrStr(o,n)   PyObject_DelAttr(o,n)
+#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
+#endif
+
+/* IterNext.proto */
+#define __Pyx_PyIter_Next(obj) __Pyx_PyIter_Next2(obj, NULL)
+static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject *, PyObject *);
+
+/* decode_c_bytes.proto */
+static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes(
+         const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop,
+         const char* encoding, const char* errors,
+         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));
+
+/* decode_bytes.proto */
+static CYTHON_INLINE PyObject* __Pyx_decode_bytes(
+         PyObject* string, Py_ssize_t start, Py_ssize_t stop,
+         const char* encoding, const char* errors,
+         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
+    return __Pyx_decode_c_bytes(
+        PyBytes_AS_STRING(string), PyBytes_GET_SIZE(string),
+        start, stop, encoding, errors, decode_func);
+}
+
+/* PyObjectCallMethod0.proto */
+static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);
+
+/* RaiseNoneIterError.proto */
+static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
+
+/* UnpackTupleError.proto */
+static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index);
+
+/* UnpackTuple2.proto */
+static CYTHON_INLINE int __Pyx_unpack_tuple2(PyObject* tuple, PyObject** value1, PyObject** value2,
+                                             int is_tuple, int has_known_size, int decref_tuple);
+
+/* dict_iter.proto */
+static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* dict, int is_dict, PyObject* method_name,
+                                                   Py_ssize_t* p_orig_length, int* p_is_dict);
+static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* dict_or_iter, Py_ssize_t orig_length, Py_ssize_t* ppos,
+                                              PyObject** pkey, PyObject** pvalue, PyObject** pitem, int is_dict);
+
+/* ArgTypeTest.proto */
+static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
+    const char *name, int exact);
+
+/* FetchCommonType.proto */
+static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
+
+/* PyObjectCallMethod1.proto */
+static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);
+
+/* CoroutineBase.proto */
+typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyObject *);
+typedef struct {
+    PyObject_HEAD
+    __pyx_coroutine_body_t body;
+    PyObject *closure;
+    PyObject *exc_type;
+    PyObject *exc_value;
+    PyObject *exc_traceback;
+    PyObject *gi_weakreflist;
+    PyObject *classobj;
+    PyObject *yieldfrom;
+    PyObject *gi_name;
+    PyObject *gi_qualname;
+    PyObject *gi_modulename;
+    int resume_label;
+    char is_running;
+} __pyx_CoroutineObject;
+static __pyx_CoroutineObject *__Pyx__Coroutine_New(
+    PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *closure,
+    PyObject *name, PyObject *qualname, PyObject *module_name);
+static int __Pyx_Coroutine_clear(PyObject *self);
+#if 1 || PY_VERSION_HEX < 0x030300B0
+static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue);
+#else
+#define __Pyx_PyGen_FetchStopIterationValue(pvalue) PyGen_FetchStopIterationValue(pvalue)
+#endif
+
+/* PatchModuleWithCoroutine.proto */
+static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code);
+
+/* PatchGeneratorABC.proto */
+static int __Pyx_patch_abc(void);
+
+/* Coroutine.proto */
+#define __Pyx_Coroutine_USED
+static PyTypeObject *__pyx_CoroutineType = 0;
+static PyTypeObject *__pyx_CoroutineAwaitType = 0;
+#define __Pyx_Coroutine_CheckExact(obj) (Py_TYPE(obj) == __pyx_CoroutineType)
+#define __Pyx_Coroutine_New(body, closure, name, qualname, module_name)\
+    __Pyx__Coroutine_New(__pyx_CoroutineType, body, closure, name, qualname, module_name)
+static int __pyx_Coroutine_init(void);
+static PyObject *__Pyx__Coroutine_await(PyObject *coroutine);
+
+/* GetAwaitIter.proto */
+static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAwaitableIter(PyObject *o);
+static PyObject *__Pyx__Coroutine_GetAwaitableIter(PyObject *o);
+
+/* CoroutineYieldFrom.proto */
+#define __Pyx_Coroutine_Yield_From(gen, source) __Pyx__Coroutine_Yield_From(gen, source, 0)
+static CYTHON_INLINE PyObject* __Pyx__Coroutine_Yield_From(__pyx_CoroutineObject *gen, PyObject *source, int warn);
+
+/* ReturnWithStopIteration.proto */
+#define __Pyx_ReturnWithStopIteration(value)\
+    if (value == Py_None) PyErr_SetNone(PyExc_StopIteration); else __Pyx__ReturnWithStopIteration(value)
+static void __Pyx__ReturnWithStopIteration(PyObject* value);
+
+/* None.proto */
+static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname);
+
+/* SetVTable.proto */
+static int __Pyx_SetVtable(PyObject *dict, void *vtable);
+
+/* Import.proto */
+static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
+
+/* PatchInspect.proto */
+static PyObject* __Pyx_patch_inspect(PyObject* module);
+
+/* PatchAsyncIO.proto */
+static PyObject* __Pyx_patch_asyncio(PyObject* module);
+
+/* ImportFrom.proto */
+static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
+
+/* CalculateMetaclass.proto */
+static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);
+
+/* Py3ClassCreate.proto */
+static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
+                                           PyObject *mkw, PyObject *modname, PyObject *doc);
+static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
+                                      PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass);
+
+/* CodeObjectCache.proto */
+typedef struct {
+    PyCodeObject* code_object;
+    int code_line;
+} __Pyx_CodeObjectCacheEntry;
+struct __Pyx_CodeObjectCache {
+    int count;
+    int max_count;
+    __Pyx_CodeObjectCacheEntry* entries;
+};
+static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
+static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
+static PyCodeObject *__pyx_find_code_object(int code_line);
+static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
+
+/* AddTraceback.proto */
+static void __Pyx_AddTraceback(const char *funcname, int c_line,
+                               int py_line, const char *filename);
+
+/* CIntToPy.proto */
+static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_AuthenticationMessage(enum __pyx_t_7asyncpg_8protocol_8protocol_AuthenticationMessage value);
+
+/* CIntToPy.proto */
+static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
+
+/* CIntToPy.proto */
+static CYTHON_INLINE PyObject* __Pyx_PyInt_From_char(char value);
+
+/* CIntToPy.proto */
+static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int32_t(int32_t value);
+
+/* CIntToPy.proto */
+static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int16_t(int16_t value);
+
+/* CIntToPy.proto */
+static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_CodecType(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecType value);
+
+/* CIntToPy.proto */
+static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint32_t(uint32_t value);
+
+/* CIntToPy.proto */
+static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
+
+/* UnicodeAsUCS4.proto */
+static CYTHON_INLINE Py_UCS4 __Pyx_PyUnicode_AsPy_UCS4(PyObject*);
+
+/* CIntToPy.proto */
+static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_CodecFormat(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat value);
+
+/* CIntToPy.proto */
+static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int64_t(int64_t value);
+
+/* CIntToPy.proto */
+static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint8_t(uint8_t value);
+
+/* CIntToPy.proto */
+static CYTHON_INLINE PyObject* __Pyx_PyInt_From_ptrdiff_t(ptrdiff_t value);
+
+/* CIntToPy.proto */
+static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ProtocolState(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState value);
+
+/* CIntToPy.proto */
+static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint64_t(uint64_t value);
+
+/* CIntFromPy.proto */
+static CYTHON_INLINE uint32_t __Pyx_PyInt_As_uint32_t(PyObject *);
+
+/* CIntFromPy.proto */
+static CYTHON_INLINE enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat __Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_CodecFormat(PyObject *);
+
+/* CIntFromPy.proto */
+static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
+
+/* CIntFromPy.proto */
+static CYTHON_INLINE int64_t __Pyx_PyInt_As_int64_t(PyObject *);
+
+/* CIntFromPy.proto */
+static CYTHON_INLINE int32_t __Pyx_PyInt_As_int32_t(PyObject *);
+
+/* CIntFromPy.proto */
+static CYTHON_INLINE int8_t __Pyx_PyInt_As_int8_t(PyObject *);
+
+/* CIntFromPy.proto */
+static CYTHON_INLINE uint8_t __Pyx_PyInt_As_uint8_t(PyObject *);
+
+/* CIntFromPy.proto */
+static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *);
+
+/* CIntFromPy.proto */
+static CYTHON_INLINE int16_t __Pyx_PyInt_As_int16_t(PyObject *);
+
+/* ObjectAsUCS4.proto */
+#define __Pyx_PyObject_AsPy_UCS4(x)\
+    (likely(PyUnicode_Check(x)) ? __Pyx_PyUnicode_AsPy_UCS4(x) : __Pyx__PyObject_AsPy_UCS4(x))
+static Py_UCS4 __Pyx__PyObject_AsPy_UCS4(PyObject*);
+
+/* CIntFromPy.proto */
+static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
+
+/* Generator.proto */
+#define __Pyx_Generator_USED
+static PyTypeObject *__pyx_GeneratorType = 0;
+#define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType)
+#define __Pyx_Generator_New(body, closure, name, qualname, module_name)\
+    __Pyx__Coroutine_New(__pyx_GeneratorType, body, closure, name, qualname, module_name)
+static PyObject *__Pyx_Generator_Next(PyObject *self);
+static int __pyx_Generator_init(void);
+
+/* CheckBinaryVersion.proto */
+static int __Pyx_check_binary_version(void);
+
+/* VoidPtrExport.proto */
+static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig);
+
+/* PyIdentifierFromString.proto */
+#if !defined(__Pyx_PyIdentifier_FromString)
+#if PY_MAJOR_VERSION < 3
+  #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
+#else
+  #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
+#endif
+#endif
+
+/* ModuleImport.proto */
+static PyObject *__Pyx_ImportModule(const char *name);
+
+/* TypeImport.proto */
+static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);
+
+/* InitStrings.proto */
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_add_setting(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_val); /* proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_is_encoding_utf8(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self); /* proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_text_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, CYTHON_UNUSED int __pyx_skip_dispatch); /* proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_register_data_types(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, PyObject *__pyx_v_types, CYTHON_UNUSED int __pyx_skip_dispatch); /* proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_add_python_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, PyObject *__pyx_v_typeoid, PyObject *__pyx_v_typename, PyObject *__pyx_v_typeschema, PyObject *__pyx_v_typekind, PyObject *__pyx_v_encoder, PyObject *__pyx_v_decoder, PyObject *__pyx_v_binary, CYTHON_UNUSED int __pyx_skip_dispatch); /* proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_set_builtin_type_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, PyObject *__pyx_v_typeoid, PyObject *__pyx_v_typename, PyObject *__pyx_v_typeschema, PyObject *__pyx_v_typekind, PyObject *__pyx_v_alias_to, CYTHON_UNUSED int __pyx_skip_dispatch); /* proto*/
+static CYTHON_INLINE struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_data_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, uint32_t __pyx_v_oid, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_data_codec *__pyx_optional_args); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_6Memory_as_bytes(struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *__pyx_v_self); /* proto*/
+static CYTHON_INLINE struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *__pyx_f_7asyncpg_8protocol_8protocol_6Memory_new(char *__pyx_v_buf, PyObject *__pyx_v_owner, Py_ssize_t __pyx_v_length); /* proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__check_readonly(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self); /* proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_len(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self); /* proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__ensure_alloced(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, Py_ssize_t __pyx_v_extra_length); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__reallocate(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, Py_ssize_t __pyx_v_new_size); /* proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_start_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, char __pyx_v_type); /* proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_end_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_buffer(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, char __pyx_v_b); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_bytes(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, PyObject *__pyx_v_data); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_bytestring(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, PyObject *__pyx_v_string); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_str(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, PyObject *__pyx_v_string, PyObject *__pyx_v_encoding); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_cstr(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, char *__pyx_v_data, Py_ssize_t __pyx_v_len); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int16(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, int16_t __pyx_v_i); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, int32_t __pyx_v_i); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int64(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, int64_t __pyx_v_i); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_float(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, float __pyx_v_f); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_double(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, double __pyx_v_d); /* proto*/
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new_message(char __pyx_v_type); /* proto*/
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new(void); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_feed_data(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self, PyObject *__pyx_v_data); /* proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__ensure_first_buf(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__switch_to_next_buf(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self); /* proto*/
+static CYTHON_INLINE char *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__try_read_bytes(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self, Py_ssize_t __pyx_v_nbytes); /* proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self, Py_ssize_t __pyx_v_nbytes); /* proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_byte(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self); /* proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_bytes(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self, Py_ssize_t __pyx_v_n); /* proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_int32(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self); /* proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_int16(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self); /* proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_cstr(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self); /* proto*/
+static int32_t __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_has_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self); /* proto*/
+static CYTHON_INLINE char *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_try_consume_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self, Py_ssize_t *__pyx_v_len); /* proto*/
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_discard_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self); /* proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__discard_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self); /* proto*/
+static CYTHON_INLINE char __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_get_message_type(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self); /* proto*/
+static CYTHON_INLINE int32_t __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_get_message_length(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self); /* proto*/
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_new_message_parser(PyObject *__pyx_v_data); /* proto*/
+static CYTHON_INLINE char const *__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_self, Py_ssize_t __pyx_v_n); /* proto*/
+static CYTHON_INLINE char const *__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read_all(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_self); /* proto*/
+static CYTHON_INLINE struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_slice_from(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_source, Py_ssize_t __pyx_v_len); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer__raise_ins_err(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_self, Py_ssize_t __pyx_v_n, CYTHON_UNUSED Py_ssize_t __pyx_v_len); /* proto*/
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_new(void); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_init(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_schema, PyObject *__pyx_v_kind, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecType __pyx_v_type, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat __pyx_v_format, __pyx_t_7asyncpg_8protocol_8protocol_encode_func __pyx_v_c_encoder, __pyx_t_7asyncpg_8protocol_8protocol_decode_func __pyx_v_c_decoder, PyObject *__pyx_v_py_encoder, PyObject *__pyx_v_py_decoder, struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_element_codec, PyObject *__pyx_v_element_type_oids, PyObject *__pyx_v_element_names, PyObject *__pyx_v_element_codecs, Py_UCS4 __pyx_v_element_delimiter); /* proto*/
+static CYTHON_INLINE struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_copy(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_scalar(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_array(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_range(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_composite(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_in_python(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj); /* proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_scalar(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_array(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_array_text(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_range(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_composite(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_in_python(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf); /* proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_has_encoder(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_has_decoder(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_is_binary(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self); /* proto*/
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_new_array_codec(uint32_t __pyx_v_oid, PyObject *__pyx_v_name, PyObject *__pyx_v_schema, struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_element_codec, Py_UCS4 __pyx_v_element_delimiter); /* proto*/
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_new_range_codec(uint32_t __pyx_v_oid, PyObject *__pyx_v_name, PyObject *__pyx_v_schema, struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_element_codec); /* proto*/
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_new_composite_codec(uint32_t __pyx_v_oid, PyObject *__pyx_v_name, PyObject *__pyx_v_schema, PyObject *__pyx_v_element_codecs, PyObject *__pyx_v_element_type_oids, PyObject *__pyx_v_element_names); /* proto*/
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_new_python_codec(uint32_t __pyx_v_oid, PyObject *__pyx_v_name, PyObject *__pyx_v_schema, PyObject *__pyx_v_kind, PyObject *__pyx_v_encoder, PyObject *__pyx_v_decoder, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat __pyx_v_format); /* proto*/
+static CYTHON_INLINE struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_15DataCodecConfig_get_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *__pyx_v_self, uint32_t __pyx_v_oid, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat __pyx_v_format); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__write(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_buf); /* proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__write_sync_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__read_server_messages(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__auth(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, char __pyx_v_mtype); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__prepare(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, char __pyx_v_mtype); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__bind_execute(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, char __pyx_v_mtype); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__bind_execute_many(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, char __pyx_v_mtype); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__bind(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, char __pyx_v_mtype); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__close_stmt_portal(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, char __pyx_v_mtype); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__simple_query(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, char __pyx_v_mtype); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__parse_msg_command_complete(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__parse_data_msgs(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__parse_msg_backend_key_data(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__parse_msg_parameter_status(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__parse_msg_notification(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__parse_msg_authentication(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__auth_password_message_cleartext(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__auth_password_message_md5(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_salt); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__parse_msg_ready_for_query(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__parse_msg_error_response(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_is_error); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__push_result(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__reset_result(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__set_state(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState __pyx_v_new_state); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__ensure_connected(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self); /* proto*/
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__build_bind_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_portal_name, PyObject *__pyx_v_stmt_name, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_bind_data); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__connect(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__prepare(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_stmt_name, PyObject *__pyx_v_query); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__send_bind_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_portal_name, PyObject *__pyx_v_stmt_name, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_bind_data, int32_t __pyx_v_limit); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__bind_execute(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_portal_name, PyObject *__pyx_v_stmt_name, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_bind_data, int32_t __pyx_v_limit); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__bind_execute_many(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_portal_name, PyObject *__pyx_v_stmt_name, PyObject *__pyx_v_bind_data); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__execute(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_portal_name, int32_t __pyx_v_limit); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__bind(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_portal_name, PyObject *__pyx_v_stmt_name, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_bind_data); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__close(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_name, int __pyx_v_is_portal); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__simple_query(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_query); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__terminate(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__decode_row(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, CYTHON_UNUSED char const *__pyx_v_buf, CYTHON_UNUSED Py_ssize_t __pyx_v_buf_len); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__set_server_parameter(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_name, CYTHON_UNUSED PyObject *__pyx_v_val); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__on_result(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__on_notification(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_pid, CYTHON_UNUSED PyObject *__pyx_v_channel, CYTHON_UNUSED PyObject *__pyx_v_payload); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__on_connection_lost(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_exc); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__encode_bind_msg(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self, PyObject *__pyx_v_args); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__ensure_rows_decoder(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__ensure_args_encoder(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__set_row_desc(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self, PyObject *__pyx_v_desc); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__set_args_desc(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self, PyObject *__pyx_v_desc); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__decode_row(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self, char const *__pyx_v_cbuf, Py_ssize_t __pyx_v_buf_len); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__handle_waiter_on_connection_lost(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_cause); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__set_server_parameter(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_val); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__ensure_clear_state(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__new_waiter(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_timeout); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_result__connect(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_waiter); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_result__prepare(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_waiter); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_result__bind_and_exec(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_waiter); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_result__bind(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_waiter); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_result__close_stmt_or_portal(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_waiter); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_result__simple_query(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_waiter); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__decode_row(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, char const *__pyx_v_buf, Py_ssize_t __pyx_v_buf_len); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__dispatch_result(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_result(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_notification(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_pid, PyObject *__pyx_v_channel, PyObject *__pyx_v_payload); /* proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_connection_lost(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_exc); /* proto*/
+
+/* Module declarations from 'libc.stdint' */
+
+/* Module declarations from 'asyncpg.protocol.debug' */
+
+/* Module declarations from 'cython' */
+
+/* Module declarations from 'cpython.version' */
+
+/* Module declarations from '__builtin__' */
+
+/* Module declarations from 'cpython.type' */
+static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
+
+/* Module declarations from 'libc.string' */
+
+/* Module declarations from 'libc.stdio' */
+
+/* Module declarations from 'cpython.object' */
+
+/* Module declarations from 'cpython.ref' */
+
+/* Module declarations from 'cpython.exc' */
+
+/* Module declarations from 'cpython.module' */
+
+/* Module declarations from 'cpython.mem' */
+
+/* Module declarations from 'cpython.tuple' */
+
+/* Module declarations from 'cpython.list' */
+
+/* Module declarations from 'cpython.sequence' */
+
+/* Module declarations from 'cpython.mapping' */
+
+/* Module declarations from 'cpython.iterator' */
+
+/* Module declarations from 'cpython.number' */
+
+/* Module declarations from 'cpython.int' */
+
+/* Module declarations from '__builtin__' */
+
+/* Module declarations from 'cpython.bool' */
+static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;
+
+/* Module declarations from 'cpython.long' */
+
+/* Module declarations from 'cpython.float' */
+
+/* Module declarations from '__builtin__' */
+
+/* Module declarations from 'cpython.complex' */
+static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;
+
+/* Module declarations from 'cpython.string' */
+
+/* Module declarations from 'cpython.unicode' */
+
+/* Module declarations from 'cpython.dict' */
+
+/* Module declarations from 'cpython.instance' */
+
+/* Module declarations from 'cpython.function' */
+
+/* Module declarations from 'cpython.method' */
+
+/* Module declarations from 'cpython.weakref' */
+
+/* Module declarations from 'cpython.getargs' */
+
+/* Module declarations from 'cpython.pythread' */
+
+/* Module declarations from 'cpython.pystate' */
+
+/* Module declarations from 'cpython.cobject' */
+
+/* Module declarations from 'cpython.oldbuffer' */
+
+/* Module declarations from 'cpython.set' */
+
+/* Module declarations from 'cpython.buffer' */
+
+/* Module declarations from 'cpython.bytes' */
+
+/* Module declarations from 'cpython.pycapsule' */
+
+/* Module declarations from 'cpython' */
+
+/* Module declarations from 'asyncpg.protocol' */
+
+/* Module declarations from 'asyncpg.protocol.record' */
+
+/* Module declarations from 'asyncpg.protocol.python' */
+
+/* Module declarations from 'asyncpg.protocol.hton' */
+static CYTHON_INLINE void __pyx_f_7asyncpg_8protocol_4hton_pack_int16(char *, int16_t); /*proto*/
+static CYTHON_INLINE int16_t __pyx_f_7asyncpg_8protocol_4hton_unpack_int16(char const *); /*proto*/
+static CYTHON_INLINE void __pyx_f_7asyncpg_8protocol_4hton_pack_int32(char *, int32_t); /*proto*/
+static CYTHON_INLINE int32_t __pyx_f_7asyncpg_8protocol_4hton_unpack_int32(char const *); /*proto*/
+static CYTHON_INLINE void __pyx_f_7asyncpg_8protocol_4hton_pack_int64(char *, int64_t); /*proto*/
+static CYTHON_INLINE int64_t __pyx_f_7asyncpg_8protocol_4hton_unpack_int64(char const *); /*proto*/
+static CYTHON_INLINE int32_t __pyx_f_7asyncpg_8protocol_4hton_pack_float(char *, float); /*proto*/
+static CYTHON_INLINE float __pyx_f_7asyncpg_8protocol_4hton_unpack_float(char const *); /*proto*/
+static CYTHON_INLINE int64_t __pyx_f_7asyncpg_8protocol_4hton_pack_double(char *, double); /*proto*/
+static CYTHON_INLINE double __pyx_f_7asyncpg_8protocol_4hton_unpack_double(char const *); /*proto*/
+
+/* Module declarations from 'libc' */
+
+/* Module declarations from 'libc.math' */
+
+/* Module declarations from 'asyncpg.protocol.protocol' */
+static PyTypeObject *__pyx_ptype_7asyncpg_8protocol_8protocol_Memory = 0;
+static PyTypeObject *__pyx_ptype_7asyncpg_8protocol_8protocol_WriteBuffer = 0;
+static PyTypeObject *__pyx_ptype_7asyncpg_8protocol_8protocol_ReadBuffer = 0;
+static PyTypeObject *__pyx_ptype_7asyncpg_8protocol_8protocol_FastReadBuffer = 0;
+static PyTypeObject *__pyx_ptype_7asyncpg_8protocol_8protocol_Codec = 0;
+static PyTypeObject *__pyx_ptype_7asyncpg_8protocol_8protocol_DataCodecConfig = 0;
+static PyTypeObject *__pyx_ptype_7asyncpg_8protocol_8protocol_ConnectionSettings = 0;
+static PyTypeObject *__pyx_ptype_7asyncpg_8protocol_8protocol_CoreProtocol = 0;
+static PyTypeObject *__pyx_ptype_7asyncpg_8protocol_8protocol_PreparedStatementState = 0;
+static PyTypeObject *__pyx_ptype_7asyncpg_8protocol_8protocol_BaseProtocol = 0;
+static PyTypeObject *__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare = 0;
+static PyTypeObject *__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute = 0;
+static PyTypeObject *__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many = 0;
+static PyTypeObject *__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr = 0;
+static PyTypeObject *__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind = 0;
+static PyTypeObject *__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute = 0;
+static PyTypeObject *__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query = 0;
+static PyTypeObject *__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement = 0;
+static PyTypeObject *__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close = 0;
+static PyObject *__pyx_v_7asyncpg_8protocol_8protocol_ARRAY_TYPES = 0;
+static PyObject *__pyx_v_7asyncpg_8protocol_8protocol_ENCODINGS_MAP = 0;
+static void *__pyx_v_7asyncpg_8protocol_8protocol_binary_codec_map[(0x1000 + 1)];
+static void *__pyx_v_7asyncpg_8protocol_8protocol_text_codec_map[(0x1000 + 1)];
+static PyObject *__pyx_v_7asyncpg_8protocol_8protocol_TYPE_CODECS_CACHE = 0;
+static PyObject *__pyx_v_7asyncpg_8protocol_8protocol_EXTRA_CODECS = 0;
+static int32_t __pyx_v_7asyncpg_8protocol_8protocol_pg_epoch_datetime_ts;
+static int32_t __pyx_v_7asyncpg_8protocol_8protocol_pg_epoch_datetime_utc_ts;
+static int32_t __pyx_v_7asyncpg_8protocol_8protocol_pg_date_offset_ord;
+static int64_t __pyx_v_7asyncpg_8protocol_8protocol_pg_time64_infinity;
+static int64_t __pyx_v_7asyncpg_8protocol_8protocol_pg_time64_negative_infinity;
+static int32_t __pyx_v_7asyncpg_8protocol_8protocol_pg_date_infinity;
+static int32_t __pyx_v_7asyncpg_8protocol_8protocol_pg_date_negative_infinity;
+static int32_t __pyx_v_7asyncpg_8protocol_8protocol_infinity_datetime_ord;
+static int64_t __pyx_v_7asyncpg_8protocol_8protocol_infinity_datetime_ts;
+static int32_t __pyx_v_7asyncpg_8protocol_8protocol_negative_infinity_datetime_ord;
+static int64_t __pyx_v_7asyncpg_8protocol_8protocol_negative_infinity_datetime_ts;
+static int32_t __pyx_v_7asyncpg_8protocol_8protocol_infinity_date_ord;
+static int32_t __pyx_v_7asyncpg_8protocol_8protocol_negative_infinity_date_ord;
+static Py_UCS4 *__pyx_v_7asyncpg_8protocol_8protocol_APG_NULL;
+static PyObject *__pyx_v_7asyncpg_8protocol_8protocol_SYNC_MESSAGE = 0;
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_get_python_encoding(PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_codec_encode_func_ex(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *, void const *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_codec_decode_func_ex(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *, void const *); /*proto*/
+static CYTHON_INLINE struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_get_core_codec(uint32_t, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat); /*proto*/
+static CYTHON_INLINE int __pyx_f_7asyncpg_8protocol_8protocol_has_core_codec(uint32_t); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(uint32_t, __pyx_t_7asyncpg_8protocol_8protocol_encode_func, __pyx_t_7asyncpg_8protocol_8protocol_decode_func, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_register_extra_codec(PyObject *, __pyx_t_7asyncpg_8protocol_8protocol_encode_func, __pyx_t_7asyncpg_8protocol_8protocol_decode_func, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat); /*proto*/
+static CYTHON_INLINE struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_get_extra_codec(PyObject *, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat); /*proto*/
+static int __pyx_f_7asyncpg_8protocol_8protocol_apg_strcasecmp(Py_UCS4 const *, Py_UCS4 const *); /*proto*/
+static CYTHON_INLINE int __pyx_f_7asyncpg_8protocol_8protocol_apg_ascii_isspace(Py_UCS4); /*proto*/
+static Py_UCS4 *__pyx_f_7asyncpg_8protocol_8protocol_apg_parse_int32(Py_UCS4 *, int32_t *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_bytea_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_bytea_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_bytea_codecs(void); /*proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_as_pg_string_and_size(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, PyObject *, char **, Py_ssize_t *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_text_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_decode_pg_string(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, char const *, Py_ssize_t); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_text_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_text_codecs(void); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_bits_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_bits_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_bits_codecs(void); /*proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol__encode_time(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, int64_t, int32_t); /*proto*/
+static CYTHON_INLINE int32_t __pyx_f_7asyncpg_8protocol_8protocol__decode_time(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *, int64_t *, uint32_t *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_date_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_date_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_timestamp_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_timestamp_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_timestamptz_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_timestamptz_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_time_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_time_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_timetz_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_timetz_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_interval_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_interval_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_datetime_codecs(void); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_float4_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_float4_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_float8_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_float8_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_float_codecs(void); /*proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol__encode_points(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol__decode_points(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_box_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_box_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_line_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_line_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_lseg_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_lseg_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_point_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_point_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_path_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_path_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_poly_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_poly_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_circle_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_circle_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_geometry_codecs(void); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_bool_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_bool_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_int2_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_int2_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_int4_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_int4_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_int8_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_int8_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_int_codecs(void); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_jsonb_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_jsonb_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_json_codecs(void); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_monetary_codecs(void); /*proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol__net_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, int32_t, uint8_t, int8_t, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_net_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_cidr_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_inet_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_network_codecs(void); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_numeric_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_numeric_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_numeric_codecs(void); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_tsearch_codecs(void); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_txid_snapshot_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_txid_snapshot_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_txid_codecs(void); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_uuid_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_uuid_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_uuid_codecs(void); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_void_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_void_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_pseudo_codecs(void); /*proto*/
+static CYTHON_INLINE int __pyx_f_7asyncpg_8protocol_8protocol__is_trivial_container(PyObject *); /*proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol__is_container(PyObject *); /*proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol__is_sub_array(PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol__get_array_shape(PyObject *, int32_t *, int32_t *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol__write_array_data(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, PyObject *, int32_t, int32_t, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, __pyx_t_7asyncpg_8protocol_8protocol_encode_func_ex, void const *); /*proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_array_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *, uint32_t, __pyx_t_7asyncpg_8protocol_8protocol_encode_func_ex, void const *); /*proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_array_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *, __pyx_t_7asyncpg_8protocol_8protocol_decode_func_ex, void const *); /*proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol__nested_array_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *, __pyx_t_7asyncpg_8protocol_8protocol_decode_func_ex, void const *, int32_t, int32_t *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_textarray_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *, __pyx_t_7asyncpg_8protocol_8protocol_decode_func_ex, void const *, Py_UCS4); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol__textarray_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, Py_UCS4 *, __pyx_t_7asyncpg_8protocol_8protocol_decode_func_ex, void const *, Py_UCS4); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol__UnexpectedCharacter(Py_UCS4 const *, Py_UCS4 const *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol__infer_array_dims(Py_UCS4 const *, Py_UCS4, int32_t *, int32_t *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_int4_encode_ex(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *, void const *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_int4_decode_ex(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *, void const *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_arrayoid_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_arrayoid_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_text_encode_ex(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *, void const *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_text_decode_ex(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *, void const *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_arraytext_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_arraytext_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_anyarray_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_array_codecs(void); /*proto*/
+static CYTHON_INLINE int __pyx_f_7asyncpg_8protocol_8protocol__range_has_lbound(uint8_t); /*proto*/
+static CYTHON_INLINE int __pyx_f_7asyncpg_8protocol_8protocol__range_has_ubound(uint8_t); /*proto*/
+static CYTHON_INLINE enum __pyx_t_7asyncpg_8protocol_8protocol__RangeArgumentType __pyx_f_7asyncpg_8protocol_8protocol__range_type(PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_range_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *, uint32_t, __pyx_t_7asyncpg_8protocol_8protocol_encode_func_ex, void const *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_range_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *, __pyx_t_7asyncpg_8protocol_8protocol_decode_func_ex, void const *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_range_codecs(void); /*proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_record_encode_frame(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, int32_t); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_anonymous_record_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_record_codecs(void); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_hstore_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_hstore_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_hstore_codecs(void); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol__decode_parameters_desc(PyObject *); /*proto*/
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol__decode_row_desc(PyObject *); /*proto*/
+#define __Pyx_MODULE_NAME "asyncpg.protocol.protocol"
+int __pyx_module_is_main_asyncpg__protocol__protocol = 0;
+
+/* Implementation of 'asyncpg.protocol.protocol' */
+static PyObject *__pyx_builtin_KeyError;
+static PyObject *__pyx_builtin_AttributeError;
+static PyObject *__pyx_builtin_object;
+static PyObject *__pyx_builtin_RuntimeError;
+static PyObject *__pyx_builtin_MemoryError;
+static PyObject *__pyx_builtin_chr;
+static PyObject *__pyx_builtin_print;
+static PyObject *__pyx_builtin_ValueError;
+static PyObject *__pyx_builtin_range;
+static PyObject *__pyx_builtin_enumerate;
+static PyObject *__pyx_builtin_NotImplementedError;
+static PyObject *__pyx_builtin_TypeError;
+static PyObject *__pyx_builtin_memoryview;
+static PyObject *__pyx_builtin_StopIteration;
+static const char __pyx_k_c[] = "c";
+static const char __pyx_k_d[] = "d";
+static const char __pyx_k_i[] = "i";
+static const char __pyx_k_r[] = "r";
+static const char __pyx_k_NA[] = "NA";
+static const char __pyx_k__3[] = "_";
+static const char __pyx_k_ns[] = "ns";
+static const char __pyx_k_Box[] = "Box";
+static const char __pyx_k_Dec[] = "_Dec";
+static const char __pyx_k__18[] = "";
+static const char __pyx_k__19[] = "\000";
+static const char __pyx_k__28[] = "{}[]";
+static const char __pyx_k__66[] = "'{}'";
+static const char __pyx_k_abc[] = "abc";
+static const char __pyx_k_add[] = "__add__";
+static const char __pyx_k_alt[] = "alt";
+static const char __pyx_k_any[] = "any";
+static const char __pyx_k_bit[] = "bit";
+static const char __pyx_k_box[] = "box";
+static const char __pyx_k_chr[] = "chr";
+static const char __pyx_k_cid[] = "cid";
+static const char __pyx_k_doc[] = "__doc__";
+static const char __pyx_k_get[] = "get";
+static const char __pyx_k_len[] = "__len__";
+static const char __pyx_k_md5[] = "md5";
+static const char __pyx_k_new[] = "new";
+static const char __pyx_k_oid[] = "oid";
+static const char __pyx_k_rec[] = "rec";
+static const char __pyx_k_tid[] = "tid";
+static const char __pyx_k_utc[] = "utc";
+static const char __pyx_k_win[] = "win";
+static const char __pyx_k_xid[] = "xid";
+static const char __pyx_k_xml[] = "xml";
+static const char __pyx_k_Line[] = "Line";
+static const char __pyx_k_Path[] = "Path";
+static const char __pyx_k_Type[] = "Type";
+static const char __pyx_k_UUID[] = "_UUID";
+static const char __pyx_k_addr[] = "addr";
+static const char __pyx_k_args[] = "args";
+static const char __pyx_k_base[] = "_base";
+static const char __pyx_k_bind[] = "bind";
+static const char __pyx_k_bool[] = "bool";
+static const char __pyx_k_char[] = "char";
+static const char __pyx_k_cidr[] = "cidr";
+static const char __pyx_k_date[] = "date";
+static const char __pyx_k_days[] = "days";
+static const char __pyx_k_desc[] = "desc";
+static const char __pyx_k_done[] = "done";
+static const char __pyx_k_elem[] = "elem";
+static const char __pyx_k_find[] = "find";
+static const char __pyx_k_hour[] = "hour";
+static const char __pyx_k_inet[] = "inet";
+static const char __pyx_k_init[] = "__init__";
+static const char __pyx_k_int2[] = "int2";
+static const char __pyx_k_int4[] = "int4";
+static const char __pyx_k_int8[] = "int8";
+static const char __pyx_k_json[] = "json";
+static const char __pyx_k_kind[] = "kind";
+static const char __pyx_k_line[] = "line";
+static const char __pyx_k_loop[] = "loop";
+static const char __pyx_k_lseg[] = "lseg";
+static const char __pyx_k_main[] = "__main__";
+static const char __pyx_k_name[] = "name";
+static const char __pyx_k_path[] = "path";
+static const char __pyx_k_send[] = "send";
+static const char __pyx_k_sjis[] = "sjis";
+static const char __pyx_k_smgr[] = "smgr";
+static const char __pyx_k_stmt[] = "stmt_{}";
+static const char __pyx_k_tcvn[] = "tcvn";
+static const char __pyx_k_test[] = "__test__";
+static const char __pyx_k_text[] = "text";
+static const char __pyx_k_time[] = "time";
+static const char __pyx_k_user[] = "user";
+static const char __pyx_k_uuid[] = "uuid";
+static const char __pyx_k_void[] = "void";
+static const char __pyx_k_Point[] = "Point";
+static const char __pyx_k_Range[] = "Range";
+static const char __pyx_k_abort[] = "abort";
+static const char __pyx_k_array[] = "array";
+static const char __pyx_k_ascii[] = "ascii";
+static const char __pyx_k_await[] = "__await__";
+static const char __pyx_k_bytea[] = "bytea";
+static const char __pyx_k_bytes[] = "bytes";
+static const char __pyx_k_cause[] = "__cause__";
+static const char __pyx_k_close[] = "close";
+static const char __pyx_k_cp866[] = "cp866";
+static const char __pyx_k_cp874[] = "cp874";
+static const char __pyx_k_cp932[] = "cp932";
+static const char __pyx_k_cp936[] = "cp936";
+static const char __pyx_k_cp949[] = "cp949";
+static const char __pyx_k_cp950[] = "cp950";
+static const char __pyx_k_deque[] = "deque";
+static const char __pyx_k_elems[] = "elems";
+static const char __pyx_k_empty[] = "empty";
+static const char __pyx_k_euccn[] = "euccn";
+static const char __pyx_k_eucjp[] = "eucjp";
+static const char __pyx_k_euckr[] = "euckr";
+static const char __pyx_k_ipnet[] = "_ipnet";
+static const char __pyx_k_items[] = "items";
+static const char __pyx_k_jsonb[] = "jsonb";
+static const char __pyx_k_koi8r[] = "koi8r";
+static const char __pyx_k_koi8u[] = "koi8u";
+static const char __pyx_k_limit[] = "limit";
+static const char __pyx_k_lower[] = "lower";
+static const char __pyx_k_money[] = "money";
+static const char __pyx_k_oid_2[] = "oid[]";
+static const char __pyx_k_point[] = "point";
+static const char __pyx_k_print[] = "print";
+static const char __pyx_k_query[] = "query";
+static const char __pyx_k_range[] = "range";
+static const char __pyx_k_state[] = "state";
+static const char __pyx_k_throw[] = "throw";
+static const char __pyx_k_types[] = "types";
+static const char __pyx_k_upper[] = "upper";
+static const char __pyx_k_utf_8[] = "utf-8";
+static const char __pyx_k_vscii[] = "vscii";
+static const char __pyx_k_write[] = "write";
+static const char __pyx_k_Circle[] = "Circle";
+static const char __pyx_k_Future[] = "Future";
+static const char __pyx_k_UUID_2[] = "UUID";
+static const char __pyx_k_append[] = "append";
+static const char __pyx_k_binary[] = "binary";
+static const char __pyx_k_bpchar[] = "bpchar";
+static const char __pyx_k_cancel[] = "cancel";
+static const char __pyx_k_circle[] = "circle";
+static const char __pyx_k_codecs[] = "codecs";
+static const char __pyx_k_cp1250[] = "cp1250";
+static const char __pyx_k_cp1251[] = "cp1251";
+static const char __pyx_k_cp1252[] = "cp1252";
+static const char __pyx_k_cp1253[] = "cp1253";
+static const char __pyx_k_cp1254[] = "cp1254";
+static const char __pyx_k_cp1255[] = "cp1255";
+static const char __pyx_k_cp1256[] = "cp1256";
+static const char __pyx_k_cp1257[] = "cp1257";
+static const char __pyx_k_cp1258[] = "cp1258";
+static const char __pyx_k_cp1521[] = "cp1521";
+static const char __pyx_k_decode[] = "decode";
+static const char __pyx_k_encode[] = "encode";
+static const char __pyx_k_euc_cn[] = "euc_cn";
+static const char __pyx_k_euc_jp[] = "euc_jp";
+static const char __pyx_k_euc_kr[] = "euc_kr";
+static const char __pyx_k_extend[] = "extend";
+static const char __pyx_k_family[] = "family";
+static const char __pyx_k_float4[] = "float4";
+static const char __pyx_k_float8[] = "float8";
+static const char __pyx_k_format[] = "format";
+static const char __pyx_k_import[] = "__import__";
+static const char __pyx_k_ipaddr[] = "_ipaddr";
+static const char __pyx_k_koi8_r[] = "koi8_r";
+static const char __pyx_k_koi8_u[] = "koi8_u";
+static const char __pyx_k_lookup[] = "lookup";
+static const char __pyx_k_loop_2[] = "_loop";
+static const char __pyx_k_minute[] = "minute";
+static const char __pyx_k_module[] = "__module__";
+static const char __pyx_k_name_2[] = "__name__";
+static const char __pyx_k_notify[] = "_notify";
+static const char __pyx_k_object[] = "object";
+static const char __pyx_k_opaque[] = "opaque";
+static const char __pyx_k_packed[] = "packed";
+static const char __pyx_k_pg_lsn[] = "pg_lsn";
+static const char __pyx_k_record[] = "record";
+static const char __pyx_k_scalar[] = "scalar";
+static const char __pyx_k_second[] = "second";
+static const char __pyx_k_socket[] = "socket";
+static const char __pyx_k_text_2[] = "text[]";
+static const char __pyx_k_timetz[] = "timetz";
+static const char __pyx_k_tzinfo[] = "tzinfo";
+static const char __pyx_k_varbit[] = "varbit";
+static const char __pyx_k_win866[] = "win866";
+static const char __pyx_k_win874[] = "win874";
+static const char __pyx_k_win932[] = "win932";
+static const char __pyx_k_win936[] = "win936";
+static const char __pyx_k_win949[] = "win949";
+static const char __pyx_k_win950[] = "win950";
+static const char __pyx_k_AF_UNIX[] = "AF_UNIX";
+static const char __pyx_k_Decimal[] = "Decimal";
+static const char __pyx_k_MAXYEAR[] = "MAXYEAR";
+static const char __pyx_k_MINYEAR[] = "MINYEAR";
+static const char __pyx_k_Polygon[] = "Polygon";
+static const char __pyx_k_TYPEMAP[] = "TYPEMAP";
+static const char __pyx_k_abstime[] = "abstime";
+static const char __pyx_k_aclitem[] = "aclitem";
+static const char __pyx_k_anyenum[] = "anyenum";
+static const char __pyx_k_apg_exc[] = "apg_exc";
+static const char __pyx_k_asyncio[] = "asyncio";
+static const char __pyx_k_asyncpg[] = "asyncpg";
+static const char __pyx_k_cstring[] = "cstring";
+static const char __pyx_k_decimal[] = "decimal";
+static const char __pyx_k_decoder[] = "decoder";
+static const char __pyx_k_encoder[] = "encoder";
+static const char __pyx_k_execute[] = "execute";
+static const char __pyx_k_genexpr[] = "genexpr";
+static const char __pyx_k_getattr[] = "__getattr__";
+static const char __pyx_k_hashlib[] = "hashlib";
+static const char __pyx_k_inspect[] = "inspect";
+static const char __pyx_k_isempty[] = "isempty";
+static const char __pyx_k_macaddr[] = "macaddr";
+static const char __pyx_k_mapping[] = "mapping";
+static const char __pyx_k_minutes[] = "minutes";
+static const char __pyx_k_numeric[] = "numeric";
+static const char __pyx_k_polygon[] = "polygon";
+static const char __pyx_k_popleft[] = "popleft";
+static const char __pyx_k_prepare[] = "prepare";
+static const char __pyx_k_regoper[] = "regoper";
+static const char __pyx_k_regproc[] = "regproc";
+static const char __pyx_k_regrole[] = "regrole";
+static const char __pyx_k_regtype[] = "regtype";
+static const char __pyx_k_reltime[] = "reltime";
+static const char __pyx_k_replace[] = "replace";
+static const char __pyx_k_seconds[] = "seconds";
+static const char __pyx_k_timeout[] = "timeout";
+static const char __pyx_k_trigger[] = "trigger";
+static const char __pyx_k_tsquery[] = "tsquery";
+static const char __pyx_k_typeoid[] = "typeoid";
+static const char __pyx_k_unicode[] = "unicode";
+static const char __pyx_k_unknown[] = "unknown";
+static const char __pyx_k_utf_8_2[] = "utf_8";
+static const char __pyx_k_varchar[] = "varchar";
+static const char __pyx_k_version[] = "version";
+static const char __pyx_k_win1250[] = "win1250";
+static const char __pyx_k_win1251[] = "win1251";
+static const char __pyx_k_win1252[] = "win1252";
+static const char __pyx_k_win1253[] = "win1253";
+static const char __pyx_k_win1254[] = "win1254";
+static const char __pyx_k_win1255[] = "win1255";
+static const char __pyx_k_win1256[] = "win1256";
+static const char __pyx_k_win1257[] = "win1257";
+static const char __pyx_k_win1258[] = "win1258";
+static const char __pyx_k_KeyError[] = "KeyError";
+static const char __pyx_k_Protocol[] = "Protocol";
+static const char __pyx_k_alias_to[] = "alias_to";
+static const char __pyx_k_anyarray[] = "anyarray";
+static const char __pyx_k_anyrange[] = "anyrange";
+static const char __pyx_k_auth_msg[] = "auth_msg";
+static const char __pyx_k_basetype[] = "basetype";
+static const char __pyx_k_con_args[] = "con_args";
+static const char __pyx_k_conn_key[] = "conn_key";
+static const char __pyx_k_database[] = "database";
+static const char __pyx_k_datetime[] = "datetime";
+static const char __pyx_k_elemtype[] = "elemtype";
+static const char __pyx_k_internal[] = "internal";
+static const char __pyx_k_interval[] = "interval";
+static const char __pyx_k_on_error[] = "_on_error";
+static const char __pyx_k_password[] = "password";
+static const char __pyx_k_protocol[] = "protocol";
+static const char __pyx_k_pyx_capi[] = "__pyx_capi__";
+static const char __pyx_k_qualname[] = "__qualname__";
+static const char __pyx_k_regclass[] = "regclass";
+static const char __pyx_k_supernet[] = "supernet";
+static const char __pyx_k_tcvn5712[] = "tcvn5712";
+static const char __pyx_k_timezone[] = "timezone";
+static const char __pyx_k_tsvector[] = "tsvector";
+static const char __pyx_k_typekind[] = "typekind";
+static const char __pyx_k_typename[] = "typename";
+static const char __pyx_k_Attribute[] = "Attribute";
+static const char __pyx_k_BitString[] = "BitString";
+static const char __pyx_k_Container[] = "Container";
+static const char __pyx_k_TypeError[] = "TypeError";
+static const char __pyx_k_add_types[] = "add_types";
+static const char __pyx_k_apg_types[] = "apg_types";
+static const char __pyx_k_attrnames[] = "attrnames";
+static const char __pyx_k_cache_key[] = "cache_key";
+static const char __pyx_k_cancelled[] = "cancelled";
+static const char __pyx_k_composite[] = "composite";
+static const char __pyx_k_elemdelim[] = "elemdelim";
+static const char __pyx_k_enumerate[] = "enumerate";
+static const char __pyx_k_frombytes[] = "frombytes";
+static const char __pyx_k_gtsvector[] = "gtsvector";
+static const char __pyx_k_hexdigest[] = "hexdigest";
+static const char __pyx_k_ipaddress[] = "ipaddress";
+static const char __pyx_k_is_closed[] = "is_closed";
+static const char __pyx_k_lower_inc[] = "lower_inc";
+static const char __pyx_k_metaclass[] = "__metaclass__";
+static const char __pyx_k_prefixlen[] = "prefixlen";
+static const char __pyx_k_prepare_2[] = "__prepare__";
+static const char __pyx_k_refcursor[] = "refcursor";
+static const char __pyx_k_regconfig[] = "regconfig";
+static const char __pyx_k_shift_jis[] = "shift_jis";
+static const char __pyx_k_sql_ascii[] = "sql_ascii";
+static const char __pyx_k_stmt_name[] = "stmt_name";
+static const char __pyx_k_timedelta[] = "timedelta";
+static const char __pyx_k_timestamp[] = "timestamp";
+static const char __pyx_k_tinterval[] = "tinterval";
+static const char __pyx_k_toordinal[] = "toordinal";
+static const char __pyx_k_upper_inc[] = "upper_inc";
+static const char __pyx_k_utcoffset[] = "utcoffset";
+static const char __pyx_k_ValueError[] = "ValueError";
+static const char __pyx_k_anyelement[] = "anyelement";
+static const char __pyx_k_astimezone[] = "astimezone";
+static const char __pyx_k_call_later[] = "call_later";
+static const char __pyx_k_exceptions[] = "exceptions";
+static const char __pyx_k_has_bin_io[] = "has_bin_io";
+static const char __pyx_k_ip_address[] = "ip_address";
+static const char __pyx_k_ip_network[] = "ip_network";
+static const char __pyx_k_memoryview[] = "memoryview";
+static const char __pyx_k_new_prefix[] = "new_prefix";
+static const char __pyx_k_on_timeout[] = "_on_timeout";
+static const char __pyx_k_pg_catalog[] = "pg_catalog";
+static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
+static const char __pyx_k_set_result[] = "set_result";
+static const char __pyx_k_setsockopt[] = "setsockopt";
+static const char __pyx_k_startswith[] = "startswith";
+static const char __pyx_k_typeschema[] = "typeschema";
+static const char __pyx_k_windows866[] = "windows866";
+static const char __pyx_k_windows874[] = "windows874";
+static const char __pyx_k_windows932[] = "windows932";
+static const char __pyx_k_windows936[] = "windows936";
+static const char __pyx_k_windows949[] = "windows949";
+static const char __pyx_k_windows950[] = "windows950";
+static const char __pyx_k_ARRAY_TYPES[] = "ARRAY_TYPES";
+static const char __pyx_k_BufferError[] = "BufferError";
+static const char __pyx_k_IPPROTO_TCP[] = "IPPROTO_TCP";
+static const char __pyx_k_LineSegment[] = "LineSegment";
+static const char __pyx_k_MemoryError[] = "MemoryError";
+static const char __pyx_k_OrderedDict[] = "OrderedDict";
+static const char __pyx_k_TCP_NODELAY[] = "TCP_NODELAY";
+static const char __pyx_k_anynonarray[] = "anynonarray";
+static const char __pyx_k_attrtypoids[] = "attrtypoids";
+static const char __pyx_k_collections[] = "collections";
+static const char __pyx_k_fdw_handler[] = "fdw_handler";
+static const char __pyx_k_fromordinal[] = "fromordinal";
+static const char __pyx_k_hashlib_md5[] = "hashlib_md5";
+static const char __pyx_k_microsecond[] = "microsecond";
+static const char __pyx_k_portal_name[] = "portal_name";
+static const char __pyx_k_regoperator[] = "regoperator";
+static const char __pyx_k_timestamptz[] = "timestamptz";
+static const char __pyx_k_tsm_handler[] = "tsm_handler";
+static const char __pyx_k_windows1250[] = "windows1250";
+static const char __pyx_k_windows1251[] = "windows1251";
+static const char __pyx_k_windows1252[] = "windows1252";
+static const char __pyx_k_windows1253[] = "windows1253";
+static const char __pyx_k_windows1254[] = "windows1254";
+static const char __pyx_k_windows1255[] = "windows1255";
+static const char __pyx_k_windows1256[] = "windows1256";
+static const char __pyx_k_windows1257[] = "windows1257";
+static const char __pyx_k_windows1258[] = "windows1258";
+static const char __pyx_k_ContainerABC[] = "ContainerABC";
+static const char __pyx_k_RuntimeError[] = "RuntimeError";
+static const char __pyx_k_TimeoutError[] = "TimeoutError";
+static const char __pyx_k_apg_exc_base[] = "apg_exc_base";
+static const char __pyx_k_bind_execute[] = "bind_execute";
+static const char __pyx_k_euc_jis_2004[] = "euc_jis_2004";
+static const char __pyx_k_microseconds[] = "microseconds";
+static const char __pyx_k_pg_node_tree[] = "pg_node_tree";
+static const char __pyx_k_regnamespace[] = "regnamespace";
+static const char __pyx_k_regprocedure[] = "regprocedure";
+static const char __pyx_k_return_extra[] = "return_extra";
+static const char __pyx_k_StopIteration[] = "StopIteration";
+static const char __pyx_k_asyncio_tasks[] = "asyncio.tasks";
+static const char __pyx_k_asyncpg_types[] = "asyncpg.types";
+static const char __pyx_k_connected_fut[] = "connected_fut";
+static const char __pyx_k_create_future[] = "create_future";
+static const char __pyx_k_create_record[] = "_create_record";
+static const char __pyx_k_event_trigger[] = "event_trigger";
+static const char __pyx_k_infinity_date[] = "infinity_date";
+static const char __pyx_k_not_connected[] = "not connected";
+static const char __pyx_k_pg_epoch_date[] = "pg_epoch_date";
+static const char __pyx_k_range_subtype[] = "range_subtype";
+static const char __pyx_k_regdictionary[] = "regdictionary";
+static const char __pyx_k_set_exception[] = "set_exception";
+static const char __pyx_k_txid_snapshot[] = "txid_snapshot";
+static const char __pyx_k_AttributeError[] = "AttributeError";
+static const char __pyx_k_InterfaceError[] = "InterfaceError";
+static const char __pyx_k_get_extra_info[] = "get_extra_info";
+static const char __pyx_k_pg_ddl_command[] = "pg_ddl_command";
+static const char __pyx_k_request_cancel[] = "_request_cancel";
+static const char __pyx_k_shift_jis_2004[] = "shift_jis_2004";
+static const char __pyx_k_PostgresMessage[] = "PostgresMessage";
+static const char __pyx_k_buffer_overread[] = "buffer overread";
+static const char __pyx_k_client_encoding[] = "client_encoding";
+static const char __pyx_k_close_statement[] = "close_statement";
+static const char __pyx_k_collections_abc[] = "collections.abc";
+static const char __pyx_k_command_timeout[] = "_command_timeout";
+static const char __pyx_k_elem_has_bin_io[] = "elem_has_bin_io";
+static const char __pyx_k_network_address[] = "network_address";
+static const char __pyx_k_string_too_long[] = "string too long";
+static const char __pyx_k_AUTH_METHOD_NAME[] = "AUTH_METHOD_NAME";
+static const char __pyx_k_add_python_codec[] = "add_python_codec";
+static const char __pyx_k_language_handler[] = "language_handler";
+static const char __pyx_k_BaseProtocol_bind[] = "BaseProtocol.bind";
+static const char __pyx_k_add_done_callback[] = "add_done_callback";
+static const char __pyx_k_already_connected[] = "already connected";
+static const char __pyx_k_bind_execute_many[] = "bind_execute_many";
+static const char __pyx_k_date_from_ordinal[] = "date_from_ordinal";
+static const char __pyx_k_infinity_datetime[] = "infinity_datetime";
+static const char __pyx_k_pg_contrib_hstore[] = "pg_contrib.hstore";
+static const char __pyx_k_pg_epoch_datetime[] = "pg_epoch_datetime";
+static const char __pyx_k_BaseProtocol_close[] = "BaseProtocol.close";
+static const char __pyx_k_BaseProtocol_query[] = "BaseProtocol.query";
+static const char __pyx_k_asyncio_coroutines[] = "asyncio.coroutines";
+static const char __pyx_k_asyncpg_exceptions[] = "asyncpg.exceptions";
+static const char __pyx_k_bit_value_too_long[] = "bit value too long";
+static const char __pyx_k_empty_first_buffer[] = "empty first buffer";
+static const char __pyx_k_no_decoder_for_OID[] = "no decoder for OID {}";
+static const char __pyx_k_no_encoder_for_OID[] = "no encoder for OID {}";
+static const char __pyx_k_NotImplementedError[] = "NotImplementedError";
+static const char __pyx_k_invalid_rows_codecs[] = "invalid rows_codecs";
+static const char __pyx_k_on_waiter_completed[] = "_on_waiter_completed";
+static const char __pyx_k_path_value_too_long[] = "path value too long";
+static const char __pyx_k_BaseProtocol_execute[] = "BaseProtocol.execute";
+static const char __pyx_k_BaseProtocol_prepare[] = "BaseProtocol.prepare";
+static const char __pyx_k_unknown_alias_target[] = "unknown alias target: {}";
+static const char __pyx_k_invalid_array_element[] = "invalid array element: {}";
+static const char __pyx_k_invalid_bits_in_value[] = "invalid bits in \"{}\" value";
+static const char __pyx_k_no_message_to_consume[] = "no message to consume";
+static const char __pyx_k_no_message_to_discard[] = "no message to discard";
+static const char __pyx_k_non_homogeneous_array[] = "non-homogeneous array";
+static const char __pyx_k_pg_epoch_datetime_utc[] = "pg_epoch_datetime_utc";
+static const char __pyx_k_unexpected_codec_type[] = "unexpected codec type: {}";
+static const char __pyx_k_cancel_current_command[] = "_cancel_current_command";
+static const char __pyx_k_create_future_fallback[] = "_create_future_fallback";
+static const char __pyx_k_negative_infinity_date[] = "negative_infinity_date";
+static const char __pyx_k_polygon_value_too_long[] = "polygon value too long";
+static const char __pyx_k_set_builtin_type_codec[] = "set_builtin_type_codec";
+static const char __pyx_k_Codec_oid_elem_oid_core[] = "<Codec oid={} elem_oid={} core={}>";
+static const char __pyx_k_invalid_length_in_value[] = "invalid length in \"{}\" value";
+static const char __pyx_k_no_decoder_for_type_OID[] = "no decoder for type OID {}";
+static const char __pyx_k_unexpected_JSONB_format[] = "unexpected JSONB format: {}";
+static const char __pyx_k_on_result_waiter_is_None[] = "_on_result: waiter is None";
+static const char __pyx_k_on_result_waiter_is_done[] = "_on_result: waiter is done";
+static const char __pyx_k_unexpected_end_of_string[] = "unexpected end of string";
+static const char __pyx_k_BaseProtocol_bind_execute[] = "BaseProtocol.bind_execute";
+static const char __pyx_k_asyncpg_protocol_protocol[] = "asyncpg.protocol.protocol";
+static const char __pyx_k_hstore_value_is_too_large[] = "hstore value is too large";
+static const char __pyx_k_malformed_array_literal_r[] = "malformed array literal {!r}: {}";
+static const char __pyx_k_read_cstr_buffer_overread[] = "read_cstr: buffer overread";
+static const char __pyx_k_negative_infinity_datetime[] = "negative_infinity_datetime";
+static const char __pyx_k_ConnectionDoesNotExistError[] = "ConnectionDoesNotExistError";
+static const char __pyx_k_BaseProtocol_close_statement[] = "BaseProtocol.close_statement";
+static const char __pyx_k_decode_row_statement_is_None[] = "_decode_row: statement is None";
+static const char __pyx_k_missing_array_dimension_value[] = "missing array dimension value";
+static const char __pyx_k_no_codec_for_domain_base_type[] = "no codec for domain base type {}";
+static const char __pyx_k_not_enough_data_to_read_bytes[] = "not enough data to read {} bytes";
+static const char __pyx_k_BaseProtocol_bind_execute_many[] = "BaseProtocol.bind_execute_many";
+static const char __pyx_k_a_boolean_is_required_got_type[] = "a boolean is required (got type {})";
+static const char __pyx_k_cannot_override_codec_for_type[] = "cannot override codec for type {}";
+static const char __pyx_k_invalid_array_element_at_index[] = "invalid array element at index {}: {}";
+static const char __pyx_k_missing_after_array_dimensions[] = "missing ']' after array dimensions";
+static const char __pyx_k_a_non_trivial_iterable_expected[] = "a non-trivial iterable expected (got type {!r})";
+static const char __pyx_k_cannot_close_prepared_statement[] = "cannot close prepared statement; refs == {} != 0";
+static const char __pyx_k_cannot_switch_to_state_protocol[] = "cannot switch to state {}; protocol is in the \"failed\" state";
+static const char __pyx_k_discarding_message_r_unread_dat[] = "!!! discarding message {!r} unread data: {!r}";
+static const char __pyx_k_end_message_buffer_is_too_small[] = "end_message: buffer is too small";
+static const char __pyx_k_feed_data_bytes_object_expected[] = "feed_data: bytes object expected";
+static const char __pyx_k_got_result_for_unknown_protocol[] = "got result for unknown protocol state {}";
+static const char __pyx_k_home_travis_build_MagicStack_as[] = "/home/travis/build/MagicStack/asyncpg/asyncpg/protocol/protocol.pyx";
+static const char __pyx_k_integer_too_large_to_be_encoded[] = "integer too large to be encoded as INT2: {!r}";
+static const char __pyx_k_invalid_address_family_in_value[] = "invalid address family in \"{}\" value";
+static const char __pyx_k_list_or_tuple_expected_got_type[] = "list or tuple expected (got type {})";
+static const char __pyx_k_no_codec_for_array_element_type[] = "no codec for array element type {}";
+static const char __pyx_k_no_codec_for_range_element_type[] = "no codec for range element type {}";
+static const char __pyx_k_on_result__prepare_statement_is[] = "_on_result__prepare: statement is None";
+static const char __pyx_k_parse_data_msgs_first_message_i[] = "_parse_data_msgs: first message is not \"D\"";
+static const char __pyx_k_parse_data_msgs_result_is_not_a[] = "_parse_data_msgs: result is not a list, but {!r}";
+static const char __pyx_k_protocol_is_already_in_the_idle[] = "protocol is already in the \"idle\" state";
+static const char __pyx_k_protocol_is_in_an_unknown_state[] = "protocol is in an unknown state {}";
+static const char __pyx_k_the_buffer_is_in_read_only_mode[] = "the buffer is in read-only mode";
+static const char __pyx_k_txid_snapshot_value_is_too_long[] = "txid_snapshot value is too long";
+static const char __pyx_k_type_record_missing_field_types[] = "type record missing field types for composite {}";
+static const char __pyx_k_Deallocating_buffer_with_attache[] = "Deallocating buffer with attached memoryviews";
+static const char __pyx_k_bind_execute_many_locals_genexpr[] = "bind_execute_many.<locals>.genexpr";
+static const char __pyx_k_cannot_perform_operation_another[] = "cannot perform operation: another operation is cancelling";
+static const char __pyx_k_cannot_perform_operation_connect[] = "cannot perform operation: connection is closed";
+static const char __pyx_k_cannot_register_core_codec_for_O[] = "cannot register core codec for OID {}: it is greater than MAXSUPPORTEDOID ({})";
+static const char __pyx_k_cannot_start_message_for_a_non_e[] = "cannot start_message for a non-empty buffer";
+static const char __pyx_k_cannot_switch_to_idle_state_prot[] = "cannot switch to \"idle\" state; protocol is in the \"failed\" state";
+static const char __pyx_k_cannot_switch_to_state_another_o[] = "cannot switch to state {}; another operation ({}) is in progress";
+static const char __pyx_k_connection_was_closed_in_the_mid[] = "connection was closed in the middle of operation";
+static const char __pyx_k_debug_first_buffer_of_ReadBuffer[] = "debug: first buffer of ReadBuffer is empty";
+static const char __pyx_k_debug_second_buffer_of_ReadBuffe[] = "debug: second buffer of ReadBuffer is empty";
+static const char __pyx_k_end_message_can_only_be_called_w[] = "end_message can only be called with start_message";
+static const char __pyx_k_end_message_message_is_too_large[] = "end_message: message is too large";
+static const char __pyx_k_expected_0_1_or_2_elements_in_ra[] = "expected 0, 1 or 2 elements in range (got {})";
+static const char __pyx_k_failed_to_read_one_byte_on_a_non[] = "failed to read one byte on a non-empty buffer";
+static const char __pyx_k_float_value_too_large_to_be_enco[] = "float value too large to be encoded as FLOAT4";
+static const char __pyx_k_inconsistent_sub_array_dimension[] = "inconsistent sub-array dimensions at position {}";
+static const char __pyx_k_insufficient_data_in_buffer_requ[] = "insufficient data in buffer: requested {}, remaining {}";
+static const char __pyx_k_invalid_number_of_elements_in_tx[] = "invalid number of elements in txid_snapshot tuple, expecting 4";
+static const char __pyx_k_invalid_state_after_cancellation[] = "invalid state after cancellation";
+static const char __pyx_k_list_tuple_or_Range_object_expec[] = "list, tuple or Range object expected (got type {})";
+static const char __pyx_k_missing_after_array_dimensions_2[] = "missing '=' after array dimensions";
+static const char __pyx_k_no_codec_for_composite_attribute[] = "no codec for composite attribute type {}";
+static const char __pyx_k_no_decoder_for_composite_type_el[] = "no decoder for composite type element in position {} of type OID {}";
+static const char __pyx_k_not_enough_data_to_read_one_byte[] = "not enough data to read one byte";
+static const char __pyx_k_null_value_not_allowed_in_hstore[] = "null value not allowed in hstore key";
+static const char __pyx_k_number_of_arguments_does_not_mat[] = "number of arguments ({}) does not match number of parameters ({})";
+static const char __pyx_k_number_of_array_dimensions_excee[] = "number of array dimensions ({}) exceed the maximum expected ({})";
+static const char __pyx_k_number_of_columns_in_result_is_d[] = "number of columns in result ({}) is different from what was described ({})";
+static const char __pyx_k_read_cstr_only_works_when_the_me[] = "read_cstr only works when the message guaranteed to be in the buffer";
+static const char __pyx_k_specified_array_dimensions_do_no[] = "specified array dimensions do not match array content";
+static const char __pyx_k_too_many_elements_in_array_value[] = "too many elements in array value";
+static const char __pyx_k_too_many_elements_in_composite_t[] = "too many elements in composite type record";
+static const char __pyx_k_type_record_missing_base_type_fo[] = "type record missing base type for domain {}";
+static const char __pyx_k_unexpected_character_r_at_positi[] = "unexpected character {!r} at position {}";
+static const char __pyx_k_unexpected_data_type_of_composit[] = "unexpected data type of composite type attribute {}: {!r}, expected {!r}";
+static const char __pyx_k_unexpected_trailing_bytes_in_buf[] = "unexpected trailing {} bytes in buffer";
+static const char __pyx_k_unhandled_standard_data_type_r_O[] = "unhandled standard data type {!r} (OID {})";
+static const char __pyx_k_unknown_error_in_protocol_implem[] = "unknown error in protocol implementation";
+static const char __pyx_k_unsupported_authentication_metho[] = "unsupported authentication method requested by the server: {!r}";
+static const char __pyx_k_cannot_perform_operation_another_2[] = "cannot perform operation: another operation is in progress";
+static const char __pyx_k_type_record_missing_base_type_fo_2[] = "type record missing base type for range {}";
+static const char __pyx_k_unsupported_authentication_metho_2[] = "unsupported authentication method requested by the server: {}";
+static PyObject *__pyx_n_s_AF_UNIX;
+static PyObject *__pyx_n_u_AF_UNIX;
+static PyObject *__pyx_n_s_ARRAY_TYPES;
+static PyObject *__pyx_n_s_AUTH_METHOD_NAME;
+static PyObject *__pyx_n_s_Attribute;
+static PyObject *__pyx_n_s_AttributeError;
+static PyObject *__pyx_n_s_BaseProtocol_bind;
+static PyObject *__pyx_n_s_BaseProtocol_bind_execute;
+static PyObject *__pyx_n_s_BaseProtocol_bind_execute_many;
+static PyObject *__pyx_n_s_BaseProtocol_close;
+static PyObject *__pyx_n_s_BaseProtocol_close_statement;
+static PyObject *__pyx_n_s_BaseProtocol_execute;
+static PyObject *__pyx_n_s_BaseProtocol_prepare;
+static PyObject *__pyx_n_s_BaseProtocol_query;
+static PyObject *__pyx_n_s_BitString;
+static PyObject *__pyx_n_s_Box;
+static PyObject *__pyx_n_s_BufferError;
+static PyObject *__pyx_n_s_Circle;
+static PyObject *__pyx_kp_u_Codec_oid_elem_oid_core;
+static PyObject *__pyx_n_s_ConnectionDoesNotExistError;
+static PyObject *__pyx_n_s_Container;
+static PyObject *__pyx_n_s_ContainerABC;
+static PyObject *__pyx_kp_u_Deallocating_buffer_with_attache;
+static PyObject *__pyx_n_s_Dec;
+static PyObject *__pyx_n_s_Decimal;
+static PyObject *__pyx_n_s_Future;
+static PyObject *__pyx_n_s_IPPROTO_TCP;
+static PyObject *__pyx_n_s_InterfaceError;
+static PyObject *__pyx_n_s_KeyError;
+static PyObject *__pyx_n_s_Line;
+static PyObject *__pyx_n_s_LineSegment;
+static PyObject *__pyx_n_s_MAXYEAR;
+static PyObject *__pyx_n_s_MINYEAR;
+static PyObject *__pyx_n_s_MemoryError;
+static PyObject *__pyx_n_u_NA;
+static PyObject *__pyx_n_s_NotImplementedError;
+static PyObject *__pyx_n_s_OrderedDict;
+static PyObject *__pyx_n_s_Path;
+static PyObject *__pyx_n_s_Point;
+static PyObject *__pyx_n_s_Polygon;
+static PyObject *__pyx_n_s_PostgresMessage;
+static PyObject *__pyx_n_s_Protocol;
+static PyObject *__pyx_n_s_Range;
+static PyObject *__pyx_n_s_RuntimeError;
+static PyObject *__pyx_n_s_StopIteration;
+static PyObject *__pyx_n_s_TCP_NODELAY;
+static PyObject *__pyx_n_s_TYPEMAP;
+static PyObject *__pyx_n_s_TimeoutError;
+static PyObject *__pyx_n_s_Type;
+static PyObject *__pyx_n_s_TypeError;
+static PyObject *__pyx_n_s_UUID;
+static PyObject *__pyx_n_s_UUID_2;
+static PyObject *__pyx_n_s_ValueError;
+static PyObject *__pyx_kp_b__18;
+static PyObject *__pyx_kp_u__18;
+static PyObject *__pyx_kp_b__19;
+static PyObject *__pyx_kp_u__28;
+static PyObject *__pyx_n_u__3;
+static PyObject *__pyx_kp_u__66;
+static PyObject *__pyx_kp_u_a_boolean_is_required_got_type;
+static PyObject *__pyx_kp_u_a_non_trivial_iterable_expected;
+static PyObject *__pyx_n_u_abc;
+static PyObject *__pyx_n_s_abort;
+static PyObject *__pyx_n_u_abstime;
+static PyObject *__pyx_n_u_aclitem;
+static PyObject *__pyx_n_s_add;
+static PyObject *__pyx_n_s_add_done_callback;
+static PyObject *__pyx_n_s_add_python_codec;
+static PyObject *__pyx_n_s_add_types;
+static PyObject *__pyx_n_s_addr;
+static PyObject *__pyx_n_s_alias_to;
+static PyObject *__pyx_kp_u_already_connected;
+static PyObject *__pyx_n_u_alt;
+static PyObject *__pyx_n_u_any;
+static PyObject *__pyx_n_u_anyarray;
+static PyObject *__pyx_n_u_anyelement;
+static PyObject *__pyx_n_u_anyenum;
+static PyObject *__pyx_n_u_anynonarray;
+static PyObject *__pyx_n_u_anyrange;
+static PyObject *__pyx_n_s_apg_exc;
+static PyObject *__pyx_n_s_apg_exc_base;
+static PyObject *__pyx_n_s_apg_types;
+static PyObject *__pyx_n_s_append;
+static PyObject *__pyx_n_s_args;
+static PyObject *__pyx_n_u_array;
+static PyObject *__pyx_n_u_ascii;
+static PyObject *__pyx_n_s_astimezone;
+static PyObject *__pyx_n_s_asyncio;
+static PyObject *__pyx_n_s_asyncio_coroutines;
+static PyObject *__pyx_n_s_asyncio_tasks;
+static PyObject *__pyx_n_s_asyncpg;
+static PyObject *__pyx_n_s_asyncpg_exceptions;
+static PyObject *__pyx_n_s_asyncpg_protocol_protocol;
+static PyObject *__pyx_n_s_asyncpg_types;
+static PyObject *__pyx_n_u_attrnames;
+static PyObject *__pyx_n_u_attrtypoids;
+static PyObject *__pyx_n_s_auth_msg;
+static PyObject *__pyx_n_s_await;
+static PyObject *__pyx_n_s_base;
+static PyObject *__pyx_n_u_basetype;
+static PyObject *__pyx_n_s_binary;
+static PyObject *__pyx_n_s_bind;
+static PyObject *__pyx_n_s_bind_execute;
+static PyObject *__pyx_n_s_bind_execute_many;
+static PyObject *__pyx_n_s_bind_execute_many_locals_genexpr;
+static PyObject *__pyx_n_u_bit;
+static PyObject *__pyx_kp_u_bit_value_too_long;
+static PyObject *__pyx_n_u_bool;
+static PyObject *__pyx_n_u_box;
+static PyObject *__pyx_n_u_bpchar;
+static PyObject *__pyx_kp_u_buffer_overread;
+static PyObject *__pyx_n_u_bytea;
+static PyObject *__pyx_n_s_bytes;
+static PyObject *__pyx_n_b_c;
+static PyObject *__pyx_n_s_cache_key;
+static PyObject *__pyx_n_s_call_later;
+static PyObject *__pyx_n_s_cancel;
+static PyObject *__pyx_n_s_cancel_current_command;
+static PyObject *__pyx_n_s_cancelled;
+static PyObject *__pyx_kp_u_cannot_close_prepared_statement;
+static PyObject *__pyx_kp_u_cannot_override_codec_for_type;
+static PyObject *__pyx_kp_u_cannot_perform_operation_another;
+static PyObject *__pyx_kp_u_cannot_perform_operation_another_2;
+static PyObject *__pyx_kp_u_cannot_perform_operation_connect;
+static PyObject *__pyx_kp_u_cannot_register_core_codec_for_O;
+static PyObject *__pyx_kp_u_cannot_start_message_for_a_non_e;
+static PyObject *__pyx_kp_u_cannot_switch_to_idle_state_prot;
+static PyObject *__pyx_kp_u_cannot_switch_to_state_another_o;
+static PyObject *__pyx_kp_u_cannot_switch_to_state_protocol;
+static PyObject *__pyx_n_s_cause;
+static PyObject *__pyx_n_u_char;
+static PyObject *__pyx_n_s_chr;
+static PyObject *__pyx_n_u_cid;
+static PyObject *__pyx_n_u_cidr;
+static PyObject *__pyx_n_u_circle;
+static PyObject *__pyx_n_b_client_encoding;
+static PyObject *__pyx_n_u_client_encoding;
+static PyObject *__pyx_n_s_close;
+static PyObject *__pyx_n_s_close_statement;
+static PyObject *__pyx_n_s_codecs;
+static PyObject *__pyx_n_s_collections;
+static PyObject *__pyx_n_s_collections_abc;
+static PyObject *__pyx_n_s_command_timeout;
+static PyObject *__pyx_n_u_composite;
+static PyObject *__pyx_n_s_con_args;
+static PyObject *__pyx_n_s_conn_key;
+static PyObject *__pyx_n_s_connected_fut;
+static PyObject *__pyx_kp_u_connection_was_closed_in_the_mid;
+static PyObject *__pyx_n_u_cp1250;
+static PyObject *__pyx_n_u_cp1251;
+static PyObject *__pyx_n_u_cp1252;
+static PyObject *__pyx_n_u_cp1253;
+static PyObject *__pyx_n_u_cp1254;
+static PyObject *__pyx_n_u_cp1255;
+static PyObject *__pyx_n_u_cp1256;
+static PyObject *__pyx_n_u_cp1257;
+static PyObject *__pyx_n_u_cp1258;
+static PyObject *__pyx_n_u_cp1521;
+static PyObject *__pyx_n_u_cp866;
+static PyObject *__pyx_n_u_cp874;
+static PyObject *__pyx_n_u_cp932;
+static PyObject *__pyx_n_u_cp936;
+static PyObject *__pyx_n_u_cp949;
+static PyObject *__pyx_n_u_cp950;
+static PyObject *__pyx_n_s_create_future;
+static PyObject *__pyx_n_s_create_future_fallback;
+static PyObject *__pyx_n_s_create_record;
+static PyObject *__pyx_n_u_cstring;
+static PyObject *__pyx_n_b_d;
+static PyObject *__pyx_n_u_database;
+static PyObject *__pyx_n_s_date;
+static PyObject *__pyx_n_u_date;
+static PyObject *__pyx_n_s_date_from_ordinal;
+static PyObject *__pyx_n_s_datetime;
+static PyObject *__pyx_n_s_days;
+static PyObject *__pyx_kp_u_debug_first_buffer_of_ReadBuffer;
+static PyObject *__pyx_kp_u_debug_second_buffer_of_ReadBuffe;
+static PyObject *__pyx_n_s_decimal;
+static PyObject *__pyx_n_s_decode;
+static PyObject *__pyx_kp_u_decode_row_statement_is_None;
+static PyObject *__pyx_n_s_decoder;
+static PyObject *__pyx_n_s_deque;
+static PyObject *__pyx_n_s_desc;
+static PyObject *__pyx_kp_u_discarding_message_r_unread_dat;
+static PyObject *__pyx_n_s_doc;
+static PyObject *__pyx_n_s_done;
+static PyObject *__pyx_n_s_elem;
+static PyObject *__pyx_n_u_elem_has_bin_io;
+static PyObject *__pyx_n_u_elemdelim;
+static PyObject *__pyx_n_s_elems;
+static PyObject *__pyx_n_u_elemtype;
+static PyObject *__pyx_n_s_empty;
+static PyObject *__pyx_kp_u_empty_first_buffer;
+static PyObject *__pyx_n_s_encode;
+static PyObject *__pyx_n_s_encoder;
+static PyObject *__pyx_kp_u_end_message_buffer_is_too_small;
+static PyObject *__pyx_kp_u_end_message_can_only_be_called_w;
+static PyObject *__pyx_kp_u_end_message_message_is_too_large;
+static PyObject *__pyx_n_s_enumerate;
+static PyObject *__pyx_n_u_euc_cn;
+static PyObject *__pyx_n_u_euc_jis_2004;
+static PyObject *__pyx_n_u_euc_jp;
+static PyObject *__pyx_n_u_euc_kr;
+static PyObject *__pyx_n_u_euccn;
+static PyObject *__pyx_n_u_eucjp;
+static PyObject *__pyx_n_u_euckr;
+static PyObject *__pyx_n_u_event_trigger;
+static PyObject *__pyx_n_s_exceptions;
+static PyObject *__pyx_n_s_execute;
+static PyObject *__pyx_kp_u_expected_0_1_or_2_elements_in_ra;
+static PyObject *__pyx_n_s_extend;
+static PyObject *__pyx_kp_u_failed_to_read_one_byte_on_a_non;
+static PyObject *__pyx_n_s_family;
+static PyObject *__pyx_n_u_fdw_handler;
+static PyObject *__pyx_kp_u_feed_data_bytes_object_expected;
+static PyObject *__pyx_n_s_find;
+static PyObject *__pyx_n_u_float4;
+static PyObject *__pyx_n_u_float8;
+static PyObject *__pyx_kp_u_float_value_too_large_to_be_enco;
+static PyObject *__pyx_n_s_format;
+static PyObject *__pyx_n_s_frombytes;
+static PyObject *__pyx_n_s_fromordinal;
+static PyObject *__pyx_n_s_genexpr;
+static PyObject *__pyx_n_s_get;
+static PyObject *__pyx_n_s_get_extra_info;
+static PyObject *__pyx_n_s_getattr;
+static PyObject *__pyx_kp_u_got_result_for_unknown_protocol;
+static PyObject *__pyx_n_u_gtsvector;
+static PyObject *__pyx_n_u_has_bin_io;
+static PyObject *__pyx_n_s_hashlib;
+static PyObject *__pyx_n_s_hashlib_md5;
+static PyObject *__pyx_n_s_hexdigest;
+static PyObject *__pyx_kp_s_home_travis_build_MagicStack_as;
+static PyObject *__pyx_n_s_hour;
+static PyObject *__pyx_kp_u_hstore_value_is_too_large;
+static PyObject *__pyx_n_s_i;
+static PyObject *__pyx_n_s_import;
+static PyObject *__pyx_kp_u_inconsistent_sub_array_dimension;
+static PyObject *__pyx_n_u_inet;
+static PyObject *__pyx_n_s_infinity_date;
+static PyObject *__pyx_n_s_infinity_datetime;
+static PyObject *__pyx_n_s_init;
+static PyObject *__pyx_n_s_inspect;
+static PyObject *__pyx_kp_u_insufficient_data_in_buffer_requ;
+static PyObject *__pyx_n_u_int2;
+static PyObject *__pyx_n_u_int4;
+static PyObject *__pyx_n_u_int8;
+static PyObject *__pyx_kp_u_integer_too_large_to_be_encoded;
+static PyObject *__pyx_n_u_internal;
+static PyObject *__pyx_n_u_interval;
+static PyObject *__pyx_kp_u_invalid_address_family_in_value;
+static PyObject *__pyx_kp_u_invalid_array_element;
+static PyObject *__pyx_kp_u_invalid_array_element_at_index;
+static PyObject *__pyx_kp_u_invalid_bits_in_value;
+static PyObject *__pyx_kp_u_invalid_length_in_value;
+static PyObject *__pyx_kp_u_invalid_number_of_elements_in_tx;
+static PyObject *__pyx_kp_u_invalid_rows_codecs;
+static PyObject *__pyx_kp_u_invalid_state_after_cancellation;
+static PyObject *__pyx_n_s_ip_address;
+static PyObject *__pyx_n_s_ip_network;
+static PyObject *__pyx_n_s_ipaddr;
+static PyObject *__pyx_n_s_ipaddress;
+static PyObject *__pyx_n_s_ipnet;
+static PyObject *__pyx_n_s_is_closed;
+static PyObject *__pyx_n_s_isempty;
+static PyObject *__pyx_n_s_items;
+static PyObject *__pyx_n_u_items;
+static PyObject *__pyx_n_u_json;
+static PyObject *__pyx_n_u_jsonb;
+static PyObject *__pyx_n_u_kind;
+static PyObject *__pyx_n_u_koi8_r;
+static PyObject *__pyx_n_u_koi8_u;
+static PyObject *__pyx_n_u_koi8r;
+static PyObject *__pyx_n_u_koi8u;
+static PyObject *__pyx_n_u_language_handler;
+static PyObject *__pyx_n_s_len;
+static PyObject *__pyx_n_s_limit;
+static PyObject *__pyx_n_u_line;
+static PyObject *__pyx_kp_u_list_or_tuple_expected_got_type;
+static PyObject *__pyx_kp_u_list_tuple_or_Range_object_expec;
+static PyObject *__pyx_n_s_lookup;
+static PyObject *__pyx_n_s_loop;
+static PyObject *__pyx_n_s_loop_2;
+static PyObject *__pyx_n_s_lower;
+static PyObject *__pyx_n_s_lower_inc;
+static PyObject *__pyx_n_u_lseg;
+static PyObject *__pyx_n_u_macaddr;
+static PyObject *__pyx_n_s_main;
+static PyObject *__pyx_kp_u_malformed_array_literal_r;
+static PyObject *__pyx_n_s_mapping;
+static PyObject *__pyx_n_b_md5;
+static PyObject *__pyx_n_s_md5;
+static PyObject *__pyx_n_s_memoryview;
+static PyObject *__pyx_n_s_metaclass;
+static PyObject *__pyx_n_s_microsecond;
+static PyObject *__pyx_n_s_microseconds;
+static PyObject *__pyx_n_s_minute;
+static PyObject *__pyx_n_s_minutes;
+static PyObject *__pyx_kp_u_missing_after_array_dimensions;
+static PyObject *__pyx_kp_u_missing_after_array_dimensions_2;
+static PyObject *__pyx_kp_u_missing_array_dimension_value;
+static PyObject *__pyx_n_s_module;
+static PyObject *__pyx_n_u_money;
+static PyObject *__pyx_n_s_name;
+static PyObject *__pyx_n_u_name;
+static PyObject *__pyx_n_s_name_2;
+static PyObject *__pyx_n_s_negative_infinity_date;
+static PyObject *__pyx_n_s_negative_infinity_datetime;
+static PyObject *__pyx_n_s_network_address;
+static PyObject *__pyx_n_s_new;
+static PyObject *__pyx_n_s_new_prefix;
+static PyObject *__pyx_kp_u_no_codec_for_array_element_type;
+static PyObject *__pyx_kp_u_no_codec_for_composite_attribute;
+static PyObject *__pyx_kp_u_no_codec_for_domain_base_type;
+static PyObject *__pyx_kp_u_no_codec_for_range_element_type;
+static PyObject *__pyx_kp_u_no_decoder_for_OID;
+static PyObject *__pyx_kp_u_no_decoder_for_composite_type_el;
+static PyObject *__pyx_kp_u_no_decoder_for_type_OID;
+static PyObject *__pyx_kp_u_no_encoder_for_OID;
+static PyObject *__pyx_kp_u_no_message_to_consume;
+static PyObject *__pyx_kp_u_no_message_to_discard;
+static PyObject *__pyx_kp_u_non_homogeneous_array;
+static PyObject *__pyx_kp_u_not_connected;
+static PyObject *__pyx_kp_u_not_enough_data_to_read_bytes;
+static PyObject *__pyx_kp_u_not_enough_data_to_read_one_byte;
+static PyObject *__pyx_n_s_notify;
+static PyObject *__pyx_n_u_ns;
+static PyObject *__pyx_kp_u_null_value_not_allowed_in_hstore;
+static PyObject *__pyx_kp_u_number_of_arguments_does_not_mat;
+static PyObject *__pyx_kp_u_number_of_array_dimensions_excee;
+static PyObject *__pyx_kp_u_number_of_columns_in_result_is_d;
+static PyObject *__pyx_n_u_numeric;
+static PyObject *__pyx_n_s_object;
+static PyObject *__pyx_n_s_oid;
+static PyObject *__pyx_n_u_oid;
+static PyObject *__pyx_kp_u_oid_2;
+static PyObject *__pyx_n_s_on_error;
+static PyObject *__pyx_kp_u_on_result__prepare_statement_is;
+static PyObject *__pyx_kp_u_on_result_waiter_is_None;
+static PyObject *__pyx_kp_u_on_result_waiter_is_done;
+static PyObject *__pyx_n_s_on_timeout;
+static PyObject *__pyx_n_s_on_waiter_completed;
+static PyObject *__pyx_n_u_opaque;
+static PyObject *__pyx_n_s_packed;
+static PyObject *__pyx_kp_u_parse_data_msgs_first_message_i;
+static PyObject *__pyx_kp_u_parse_data_msgs_result_is_not_a;
+static PyObject *__pyx_n_s_password;
+static PyObject *__pyx_n_u_password;
+static PyObject *__pyx_n_u_path;
+static PyObject *__pyx_kp_u_path_value_too_long;
+static PyObject *__pyx_n_u_pg_catalog;
+static PyObject *__pyx_kp_u_pg_contrib_hstore;
+static PyObject *__pyx_n_u_pg_ddl_command;
+static PyObject *__pyx_n_s_pg_epoch_date;
+static PyObject *__pyx_n_s_pg_epoch_datetime;
+static PyObject *__pyx_n_s_pg_epoch_datetime_utc;
+static PyObject *__pyx_n_u_pg_lsn;
+static PyObject *__pyx_n_u_pg_node_tree;
+static PyObject *__pyx_n_u_point;
+static PyObject *__pyx_n_u_polygon;
+static PyObject *__pyx_kp_u_polygon_value_too_long;
+static PyObject *__pyx_n_s_popleft;
+static PyObject *__pyx_n_s_portal_name;
+static PyObject *__pyx_n_s_prefixlen;
+static PyObject *__pyx_n_s_prepare;
+static PyObject *__pyx_n_s_prepare_2;
+static PyObject *__pyx_n_s_print;
+static PyObject *__pyx_n_s_protocol;
+static PyObject *__pyx_kp_u_protocol_is_already_in_the_idle;
+static PyObject *__pyx_kp_u_protocol_is_in_an_unknown_state;
+static PyObject *__pyx_n_s_pyx_capi;
+static PyObject *__pyx_n_s_pyx_vtable;
+static PyObject *__pyx_n_s_qualname;
+static PyObject *__pyx_n_s_query;
+static PyObject *__pyx_n_b_r;
+static PyObject *__pyx_n_s_range;
+static PyObject *__pyx_n_u_range;
+static PyObject *__pyx_n_u_range_subtype;
+static PyObject *__pyx_kp_u_read_cstr_buffer_overread;
+static PyObject *__pyx_kp_u_read_cstr_only_works_when_the_me;
+static PyObject *__pyx_n_s_rec;
+static PyObject *__pyx_n_u_record;
+static PyObject *__pyx_n_u_refcursor;
+static PyObject *__pyx_n_u_regclass;
+static PyObject *__pyx_n_u_regconfig;
+static PyObject *__pyx_n_u_regdictionary;
+static PyObject *__pyx_n_u_regnamespace;
+static PyObject *__pyx_n_u_regoper;
+static PyObject *__pyx_n_u_regoperator;
+static PyObject *__pyx_n_u_regproc;
+static PyObject *__pyx_n_u_regprocedure;
+static PyObject *__pyx_n_u_regrole;
+static PyObject *__pyx_n_u_regtype;
+static PyObject *__pyx_n_u_reltime;
+static PyObject *__pyx_n_s_replace;
+static PyObject *__pyx_n_s_request_cancel;
+static PyObject *__pyx_n_s_return_extra;
+static PyObject *__pyx_n_u_scalar;
+static PyObject *__pyx_n_s_second;
+static PyObject *__pyx_n_s_seconds;
+static PyObject *__pyx_n_s_send;
+static PyObject *__pyx_n_s_set_builtin_type_codec;
+static PyObject *__pyx_n_s_set_exception;
+static PyObject *__pyx_n_s_set_result;
+static PyObject *__pyx_n_s_setsockopt;
+static PyObject *__pyx_n_u_shift_jis;
+static PyObject *__pyx_n_u_shift_jis_2004;
+static PyObject *__pyx_n_u_sjis;
+static PyObject *__pyx_n_u_smgr;
+static PyObject *__pyx_n_s_socket;
+static PyObject *__pyx_n_u_socket;
+static PyObject *__pyx_kp_u_specified_array_dimensions_do_no;
+static PyObject *__pyx_n_u_sql_ascii;
+static PyObject *__pyx_n_s_startswith;
+static PyObject *__pyx_n_s_state;
+static PyObject *__pyx_kp_u_stmt;
+static PyObject *__pyx_n_s_stmt_name;
+static PyObject *__pyx_kp_u_string_too_long;
+static PyObject *__pyx_n_s_supernet;
+static PyObject *__pyx_n_u_tcvn;
+static PyObject *__pyx_n_u_tcvn5712;
+static PyObject *__pyx_n_s_test;
+static PyObject *__pyx_n_u_text;
+static PyObject *__pyx_kp_u_text_2;
+static PyObject *__pyx_kp_u_the_buffer_is_in_read_only_mode;
+static PyObject *__pyx_n_s_throw;
+static PyObject *__pyx_n_u_tid;
+static PyObject *__pyx_n_s_time;
+static PyObject *__pyx_n_u_time;
+static PyObject *__pyx_n_s_timedelta;
+static PyObject *__pyx_n_s_timeout;
+static PyObject *__pyx_n_s_timestamp;
+static PyObject *__pyx_n_u_timestamp;
+static PyObject *__pyx_n_u_timestamptz;
+static PyObject *__pyx_n_u_timetz;
+static PyObject *__pyx_n_s_timezone;
+static PyObject *__pyx_n_u_tinterval;
+static PyObject *__pyx_kp_u_too_many_elements_in_array_value;
+static PyObject *__pyx_kp_u_too_many_elements_in_composite_t;
+static PyObject *__pyx_n_s_toordinal;
+static PyObject *__pyx_n_u_trigger;
+static PyObject *__pyx_n_u_tsm_handler;
+static PyObject *__pyx_n_u_tsquery;
+static PyObject *__pyx_n_u_tsvector;
+static PyObject *__pyx_n_u_txid_snapshot;
+static PyObject *__pyx_kp_u_txid_snapshot_value_is_too_long;
+static PyObject *__pyx_kp_u_type_record_missing_base_type_fo;
+static PyObject *__pyx_kp_u_type_record_missing_base_type_fo_2;
+static PyObject *__pyx_kp_u_type_record_missing_field_types;
+static PyObject *__pyx_n_s_typekind;
+static PyObject *__pyx_n_s_typename;
+static PyObject *__pyx_n_s_typeoid;
+static PyObject *__pyx_n_s_types;
+static PyObject *__pyx_n_s_typeschema;
+static PyObject *__pyx_n_s_tzinfo;
+static PyObject *__pyx_kp_u_unexpected_JSONB_format;
+static PyObject *__pyx_kp_u_unexpected_character_r_at_positi;
+static PyObject *__pyx_kp_u_unexpected_codec_type;
+static PyObject *__pyx_kp_u_unexpected_data_type_of_composit;
+static PyObject *__pyx_kp_u_unexpected_end_of_string;
+static PyObject *__pyx_kp_u_unexpected_trailing_bytes_in_buf;
+static PyObject *__pyx_kp_u_unhandled_standard_data_type_r_O;
+static PyObject *__pyx_n_u_unicode;
+static PyObject *__pyx_n_u_unknown;
+static PyObject *__pyx_kp_u_unknown_alias_target;
+static PyObject *__pyx_kp_u_unknown_error_in_protocol_implem;
+static PyObject *__pyx_kp_u_unsupported_authentication_metho;
+static PyObject *__pyx_kp_u_unsupported_authentication_metho_2;
+static PyObject *__pyx_n_s_upper;
+static PyObject *__pyx_n_s_upper_inc;
+static PyObject *__pyx_n_s_user;
+static PyObject *__pyx_n_u_user;
+static PyObject *__pyx_n_s_utc;
+static PyObject *__pyx_n_s_utcoffset;
+static PyObject *__pyx_kp_u_utf_8;
+static PyObject *__pyx_n_u_utf_8_2;
+static PyObject *__pyx_n_s_uuid;
+static PyObject *__pyx_n_u_uuid;
+static PyObject *__pyx_n_u_varbit;
+static PyObject *__pyx_n_u_varchar;
+static PyObject *__pyx_n_s_version;
+static PyObject *__pyx_n_u_void;
+static PyObject *__pyx_n_u_vscii;
+static PyObject *__pyx_n_u_win;
+static PyObject *__pyx_n_u_win1250;
+static PyObject *__pyx_n_u_win1251;
+static PyObject *__pyx_n_u_win1252;
+static PyObject *__pyx_n_u_win1253;
+static PyObject *__pyx_n_u_win1254;
+static PyObject *__pyx_n_u_win1255;
+static PyObject *__pyx_n_u_win1256;
+static PyObject *__pyx_n_u_win1257;
+static PyObject *__pyx_n_u_win1258;
+static PyObject *__pyx_n_u_win866;
+static PyObject *__pyx_n_u_win874;
+static PyObject *__pyx_n_u_win932;
+static PyObject *__pyx_n_u_win936;
+static PyObject *__pyx_n_u_win949;
+static PyObject *__pyx_n_u_win950;
+static PyObject *__pyx_n_u_windows1250;
+static PyObject *__pyx_n_u_windows1251;
+static PyObject *__pyx_n_u_windows1252;
+static PyObject *__pyx_n_u_windows1253;
+static PyObject *__pyx_n_u_windows1254;
+static PyObject *__pyx_n_u_windows1255;
+static PyObject *__pyx_n_u_windows1256;
+static PyObject *__pyx_n_u_windows1257;
+static PyObject *__pyx_n_u_windows1258;
+static PyObject *__pyx_n_u_windows866;
+static PyObject *__pyx_n_u_windows874;
+static PyObject *__pyx_n_u_windows932;
+static PyObject *__pyx_n_u_windows936;
+static PyObject *__pyx_n_u_windows949;
+static PyObject *__pyx_n_u_windows950;
+static PyObject *__pyx_n_s_write;
+static PyObject *__pyx_n_u_xid;
+static PyObject *__pyx_n_u_xml;
+static int __pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings___cinit__(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, PyObject *__pyx_v_conn_key); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_2get_text_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_4register_data_types(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, PyObject *__pyx_v_types); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_6add_python_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, PyObject *__pyx_v_typeoid, PyObject *__pyx_v_typename, PyObject *__pyx_v_typeschema, PyObject *__pyx_v_typekind, PyObject *__pyx_v_encoder, PyObject *__pyx_v_decoder, PyObject *__pyx_v_binary); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_8set_builtin_type_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, PyObject *__pyx_v_typeoid, PyObject *__pyx_v_typename, PyObject *__pyx_v_typeschema, PyObject *__pyx_v_typekind, PyObject *__pyx_v_alias_to); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_10get_data_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, uint32_t __pyx_v_oid, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat __pyx_v_format); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_12__getattr__(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, PyObject *__pyx_v_name); /* proto */
+static int __pyx_pf_7asyncpg_8protocol_8protocol_11WriteBuffer___cinit__(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self); /* proto */
+static void __pyx_pf_7asyncpg_8protocol_8protocol_11WriteBuffer_2__dealloc__(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self); /* proto */
+static int __pyx_pf_7asyncpg_8protocol_8protocol_11WriteBuffer_4__getbuffer__(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, Py_buffer *__pyx_v_buffer, int __pyx_v_flags); /* proto */
+static void __pyx_pf_7asyncpg_8protocol_8protocol_11WriteBuffer_6__releasebuffer__(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, CYTHON_UNUSED Py_buffer *__pyx_v_buffer); /* proto */
+static int __pyx_pf_7asyncpg_8protocol_8protocol_10ReadBuffer___cinit__(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self); /* proto */
+static int __pyx_pf_7asyncpg_8protocol_8protocol_5Codec___cinit__(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, uint32_t __pyx_v_oid); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_5Codec_2__repr__(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self); /* proto */
+static int __pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig___init__(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *__pyx_v_self, PyObject *__pyx_v_cache_key); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig_2add_types(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *__pyx_v_self, PyObject *__pyx_v_types); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig_4add_python_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *__pyx_v_self, PyObject *__pyx_v_typeoid, PyObject *__pyx_v_typename, PyObject *__pyx_v_typeschema, PyObject *__pyx_v_typekind, PyObject *__pyx_v_encoder, PyObject *__pyx_v_decoder, PyObject *__pyx_v_binary); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig_6set_builtin_type_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *__pyx_v_self, PyObject *__pyx_v_typeoid, PyObject *__pyx_v_typename, PyObject *__pyx_v_typeschema, PyObject *__pyx_v_typekind, PyObject *__pyx_v_alias_to); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig_8clear_type_cache(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *__pyx_v_self); /* proto */
+static int __pyx_pf_7asyncpg_8protocol_8protocol_12CoreProtocol___init__(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_con_args); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12CoreProtocol_2data_received(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_data); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12CoreProtocol_4connection_made(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_transport); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12CoreProtocol_6connection_lost(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_exc); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12CoreProtocol_11backend_pid___get__(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12CoreProtocol_14backend_secret___get__(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self); /* proto */
+static int __pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState___cinit__(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_query, struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_protocol); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_2_get_parameters(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_4_get_attributes(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_6_init_types(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_8attach(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_10detach(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_12mark_closed(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_4name___get__(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_5query___get__(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_6closed___get__(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_4refs___get__(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self); /* proto */
+static int __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol___init__(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_addr, PyObject *__pyx_v_connected_fut, PyObject *__pyx_v_con_args, PyObject *__pyx_v_loop); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_2set_connection(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_connection); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_4get_server_pid(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_6get_settings(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_8prepare(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_stmt_name, PyObject *__pyx_v_query, PyObject *__pyx_v_timeout); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_11bind_execute(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_state, PyObject *__pyx_v_args, PyObject *__pyx_v_portal_name, int __pyx_v_limit, PyObject *__pyx_v_return_extra, PyObject *__pyx_v_timeout); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_17bind_execute_many_genexpr(PyObject *__pyx_self); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_14bind_execute_many(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_state, PyObject *__pyx_v_args, PyObject *__pyx_v_portal_name, PyObject *__pyx_v_timeout); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_17bind(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_state, PyObject *__pyx_v_args, PyObject *__pyx_v_portal_name, PyObject *__pyx_v_timeout); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_20execute(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_state, PyObject *__pyx_v_portal_name, int __pyx_v_limit, PyObject *__pyx_v_return_extra, PyObject *__pyx_v_timeout); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_23query(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_query, PyObject *__pyx_v_timeout); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_26close_statement(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_state, PyObject *__pyx_v_timeout); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_29is_closed(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_31is_connected(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_33abort(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_35close(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_38_request_cancel(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_40_on_timeout(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_fut); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_42_on_waiter_completed(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_fut); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_44_create_future_fallback(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_13queries_count___get__(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol__create_record(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_mapping, PyObject *__pyx_v_elems); /* proto */
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol_Memory(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol_WriteBuffer(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol_ReadBuffer(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol_FastReadBuffer(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol_Codec(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol_DataCodecConfig(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol_ConnectionSettings(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol_CoreProtocol(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol_PreparedStatementState(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol_BaseProtocol(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
+static PyObject *__pyx_int_0;
+static PyObject *__pyx_int_1;
+static PyObject *__pyx_int_4;
+static PyObject *__pyx_int_6;
+static PyObject *__pyx_int_12;
+static PyObject *__pyx_int_16;
+static PyObject *__pyx_int_17;
+static PyObject *__pyx_int_18;
+static PyObject *__pyx_int_19;
+static PyObject *__pyx_int_20;
+static PyObject *__pyx_int_21;
+static PyObject *__pyx_int_23;
+static PyObject *__pyx_int_24;
+static PyObject *__pyx_int_25;
+static PyObject *__pyx_int_26;
+static PyObject *__pyx_int_27;
+static PyObject *__pyx_int_28;
+static PyObject *__pyx_int_29;
+static PyObject *__pyx_int_31;
+static PyObject *__pyx_int_32;
+static PyObject *__pyx_int_59;
+static PyObject *__pyx_int_114;
+static PyObject *__pyx_int_142;
+static PyObject *__pyx_int_194;
+static PyObject *__pyx_int_210;
+static PyObject *__pyx_int_600;
+static PyObject *__pyx_int_601;
+static PyObject *__pyx_int_602;
+static PyObject *__pyx_int_603;
+static PyObject *__pyx_int_604;
+static PyObject *__pyx_int_628;
+static PyObject *__pyx_int_650;
+static PyObject *__pyx_int_700;
+static PyObject *__pyx_int_701;
+static PyObject *__pyx_int_702;
+static PyObject *__pyx_int_703;
+static PyObject *__pyx_int_704;
+static PyObject *__pyx_int_705;
+static PyObject *__pyx_int_718;
+static PyObject *__pyx_int_790;
+static PyObject *__pyx_int_829;
+static PyObject *__pyx_int_869;
+static PyObject *__pyx_int_1009;
+static PyObject *__pyx_int_1028;
+static PyObject *__pyx_int_1033;
+static PyObject *__pyx_int_1042;
+static PyObject *__pyx_int_1043;
+static PyObject *__pyx_int_1082;
+static PyObject *__pyx_int_1083;
+static PyObject *__pyx_int_1114;
+static PyObject *__pyx_int_1184;
+static PyObject *__pyx_int_1186;
+static PyObject *__pyx_int_1266;
+static PyObject *__pyx_int_1560;
+static PyObject *__pyx_int_1562;
+static PyObject *__pyx_int_1700;
+static PyObject *__pyx_int_1790;
+static PyObject *__pyx_int_2000;
+static PyObject *__pyx_int_2202;
+static PyObject *__pyx_int_2203;
+static PyObject *__pyx_int_2204;
+static PyObject *__pyx_int_2205;
+static PyObject *__pyx_int_2206;
+static PyObject *__pyx_int_2249;
+static PyObject *__pyx_int_2275;
+static PyObject *__pyx_int_2276;
+static PyObject *__pyx_int_2277;
+static PyObject *__pyx_int_2278;
+static PyObject *__pyx_int_2279;
+static PyObject *__pyx_int_2280;
+static PyObject *__pyx_int_2281;
+static PyObject *__pyx_int_2282;
+static PyObject *__pyx_int_2283;
+static PyObject *__pyx_int_2776;
+static PyObject *__pyx_int_2950;
+static PyObject *__pyx_int_2970;
+static PyObject *__pyx_int_3115;
+static PyObject *__pyx_int_3220;
+static PyObject *__pyx_int_3310;
+static PyObject *__pyx_int_3500;
+static PyObject *__pyx_int_3614;
+static PyObject *__pyx_int_3615;
+static PyObject *__pyx_int_3642;
+static PyObject *__pyx_int_3734;
+static PyObject *__pyx_int_3769;
+static PyObject *__pyx_int_3802;
+static PyObject *__pyx_int_3831;
+static PyObject *__pyx_int_3838;
+static PyObject *__pyx_int_4089;
+static PyObject *__pyx_int_4096;
+static PyObject *__pyx_int_9999;
+static PyObject *__pyx_int_999999;
+static enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat __pyx_k__2;
+static PyObject *__pyx_tuple_;
+static PyObject *__pyx_tuple__4;
+static PyObject *__pyx_tuple__5;
+static PyObject *__pyx_tuple__6;
+static PyObject *__pyx_tuple__7;
+static PyObject *__pyx_tuple__8;
+static PyObject *__pyx_tuple__9;
+static PyObject *__pyx_slice__27;
+static PyObject *__pyx_tuple__10;
+static PyObject *__pyx_tuple__11;
+static PyObject *__pyx_tuple__12;
+static PyObject *__pyx_tuple__13;
+static PyObject *__pyx_tuple__14;
+static PyObject *__pyx_tuple__15;
+static PyObject *__pyx_tuple__16;
+static PyObject *__pyx_tuple__17;
+static PyObject *__pyx_tuple__20;
+static PyObject *__pyx_tuple__21;
+static PyObject *__pyx_tuple__22;
+static PyObject *__pyx_tuple__23;
+static PyObject *__pyx_tuple__24;
+static PyObject *__pyx_tuple__25;
+static PyObject *__pyx_tuple__26;
+static PyObject *__pyx_tuple__29;
+static PyObject *__pyx_tuple__30;
+static PyObject *__pyx_tuple__31;
+static PyObject *__pyx_tuple__32;
+static PyObject *__pyx_tuple__33;
+static PyObject *__pyx_tuple__34;
+static PyObject *__pyx_tuple__35;
+static PyObject *__pyx_tuple__36;
+static PyObject *__pyx_tuple__37;
+static PyObject *__pyx_tuple__38;
+static PyObject *__pyx_tuple__39;
+static PyObject *__pyx_tuple__40;
+static PyObject *__pyx_tuple__41;
+static PyObject *__pyx_tuple__42;
+static PyObject *__pyx_tuple__43;
+static PyObject *__pyx_tuple__44;
+static PyObject *__pyx_tuple__45;
+static PyObject *__pyx_tuple__46;
+static PyObject *__pyx_tuple__47;
+static PyObject *__pyx_tuple__48;
+static PyObject *__pyx_tuple__49;
+static PyObject *__pyx_tuple__50;
+static PyObject *__pyx_tuple__51;
+static PyObject *__pyx_tuple__52;
+static PyObject *__pyx_tuple__53;
+static PyObject *__pyx_tuple__54;
+static PyObject *__pyx_tuple__55;
+static PyObject *__pyx_tuple__56;
+static PyObject *__pyx_tuple__57;
+static PyObject *__pyx_tuple__58;
+static PyObject *__pyx_tuple__59;
+static PyObject *__pyx_tuple__60;
+static PyObject *__pyx_tuple__61;
+static PyObject *__pyx_tuple__62;
+static PyObject *__pyx_tuple__63;
+static PyObject *__pyx_tuple__64;
+static PyObject *__pyx_tuple__65;
+static PyObject *__pyx_tuple__67;
+static PyObject *__pyx_tuple__68;
+static PyObject *__pyx_tuple__69;
+static PyObject *__pyx_tuple__70;
+static PyObject *__pyx_tuple__71;
+static PyObject *__pyx_tuple__72;
+static PyObject *__pyx_tuple__73;
+static PyObject *__pyx_tuple__74;
+static PyObject *__pyx_tuple__75;
+static PyObject *__pyx_tuple__76;
+static PyObject *__pyx_tuple__77;
+static PyObject *__pyx_tuple__78;
+static PyObject *__pyx_tuple__79;
+static PyObject *__pyx_tuple__80;
+static PyObject *__pyx_tuple__81;
+static PyObject *__pyx_tuple__82;
+static PyObject *__pyx_tuple__83;
+static PyObject *__pyx_tuple__84;
+static PyObject *__pyx_tuple__85;
+static PyObject *__pyx_tuple__86;
+static PyObject *__pyx_tuple__87;
+static PyObject *__pyx_codeobj__88;
+
+/* "asyncpg/protocol/encodings.pyx":62
+ * 
+ * 
+ * cdef get_python_encoding(pg_encoding):             # <<<<<<<<<<<<<<
+ *     return ENCODINGS_MAP.get(pg_encoding.lower(), pg_encoding.lower())
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_get_python_encoding(PyObject *__pyx_v_pg_encoding) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  __Pyx_RefNannySetupContext("get_python_encoding", 0);
+
+  /* "asyncpg/protocol/encodings.pyx":63
+ * 
+ * cdef get_python_encoding(pg_encoding):
+ *     return ENCODINGS_MAP.get(pg_encoding.lower(), pg_encoding.lower())             # <<<<<<<<<<<<<<
+ */
+  __Pyx_XDECREF(__pyx_r);
+  if (unlikely(__pyx_v_7asyncpg_8protocol_8protocol_ENCODINGS_MAP == Py_None)) {
+    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
+    __PYX_ERR(5, 63, __pyx_L1_error)
+  }
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_pg_encoding, __pyx_n_s_lower); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 63, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (__pyx_t_3) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 63, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  } else {
+    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 63, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_pg_encoding, __pyx_n_s_lower); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 63, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
+    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
+    if (likely(__pyx_t_4)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+      __Pyx_INCREF(__pyx_t_4);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_3, function);
+    }
+  }
+  if (__pyx_t_4) {
+    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 63, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  } else {
+    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 63, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = __Pyx_PyDict_GetItemDefault(__pyx_v_7asyncpg_8protocol_8protocol_ENCODINGS_MAP, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 63, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_r = __pyx_t_3;
+  __pyx_t_3 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/encodings.pyx":62
+ * 
+ * 
+ * cdef get_python_encoding(pg_encoding):             # <<<<<<<<<<<<<<
+ *     return ENCODINGS_MAP.get(pg_encoding.lower(), pg_encoding.lower())
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.get_python_encoding", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/settings.pyx":11
+ * cdef class ConnectionSettings:
+ * 
+ *     def __cinit__(self, conn_key):             # <<<<<<<<<<<<<<
+ *         self._encoding = 'utf-8'
+ *         self._is_utf8 = True
+ */
+
+/* Python wrapper */
+static int __pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_conn_key = 0;
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_conn_key,0};
+    PyObject* values[1] = {0};
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_conn_key)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+      }
+      if (unlikely(kw_args > 0)) {
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 11, __pyx_L3_error)
+      }
+    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
+      goto __pyx_L5_argtuple_error;
+    } else {
+      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+    }
+    __pyx_v_conn_key = values[0];
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 11, __pyx_L3_error)
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ConnectionSettings.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return -1;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings___cinit__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *)__pyx_v_self), __pyx_v_conn_key);
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static int __pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings___cinit__(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, PyObject *__pyx_v_conn_key) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("__cinit__", 0);
+
+  /* "asyncpg/protocol/settings.pyx":12
+ * 
+ *     def __cinit__(self, conn_key):
+ *         self._encoding = 'utf-8'             # <<<<<<<<<<<<<<
+ *         self._is_utf8 = True
+ *         self._settings = {}
+ */
+  __Pyx_INCREF(__pyx_kp_u_utf_8);
+  __Pyx_GIVEREF(__pyx_kp_u_utf_8);
+  __Pyx_GOTREF(__pyx_v_self->_encoding);
+  __Pyx_DECREF(__pyx_v_self->_encoding);
+  __pyx_v_self->_encoding = __pyx_kp_u_utf_8;
+
+  /* "asyncpg/protocol/settings.pyx":13
+ *     def __cinit__(self, conn_key):
+ *         self._encoding = 'utf-8'
+ *         self._is_utf8 = True             # <<<<<<<<<<<<<<
+ *         self._settings = {}
+ *         self._codec = codecs.lookup('utf-8')
+ */
+  __pyx_v_self->_is_utf8 = 1;
+
+  /* "asyncpg/protocol/settings.pyx":14
+ *         self._encoding = 'utf-8'
+ *         self._is_utf8 = True
+ *         self._settings = {}             # <<<<<<<<<<<<<<
+ *         self._codec = codecs.lookup('utf-8')
+ *         self._data_codecs = DataCodecConfig(conn_key)
+ */
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  __Pyx_GOTREF(__pyx_v_self->_settings);
+  __Pyx_DECREF(__pyx_v_self->_settings);
+  __pyx_v_self->_settings = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/settings.pyx":15
+ *         self._is_utf8 = True
+ *         self._settings = {}
+ *         self._codec = codecs.lookup('utf-8')             # <<<<<<<<<<<<<<
+ *         self._data_codecs = DataCodecConfig(conn_key)
+ * 
+ */
+  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_codecs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_lookup); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_GIVEREF(__pyx_t_1);
+  __Pyx_GOTREF(__pyx_v_self->_codec);
+  __Pyx_DECREF(__pyx_v_self->_codec);
+  __pyx_v_self->_codec = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/settings.pyx":16
+ *         self._settings = {}
+ *         self._codec = codecs.lookup('utf-8')
+ *         self._data_codecs = DataCodecConfig(conn_key)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef add_setting(self, str name, str val):
+ */
+  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(__pyx_v_conn_key);
+  __Pyx_GIVEREF(__pyx_v_conn_key);
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_conn_key);
+  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_DataCodecConfig), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_GIVEREF(__pyx_t_2);
+  __Pyx_GOTREF(__pyx_v_self->_data_codecs);
+  __Pyx_DECREF(((PyObject *)__pyx_v_self->_data_codecs));
+  __pyx_v_self->_data_codecs = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *)__pyx_t_2);
+  __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/settings.pyx":11
+ * cdef class ConnectionSettings:
+ * 
+ *     def __cinit__(self, conn_key):             # <<<<<<<<<<<<<<
+ *         self._encoding = 'utf-8'
+ *         self._is_utf8 = True
+ */
+
+  /* function exit code */
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ConnectionSettings.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/settings.pyx":18
+ *         self._data_codecs = DataCodecConfig(conn_key)
+ * 
+ *     cdef add_setting(self, str name, str val):             # <<<<<<<<<<<<<<
+ *         self._settings[name] = val
+ *         if name == 'client_encoding':
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_add_setting(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_val) {
+  PyObject *__pyx_v_py_enc = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  __Pyx_RefNannySetupContext("add_setting", 0);
+
+  /* "asyncpg/protocol/settings.pyx":19
+ * 
+ *     cdef add_setting(self, str name, str val):
+ *         self._settings[name] = val             # <<<<<<<<<<<<<<
+ *         if name == 'client_encoding':
+ *             py_enc = get_python_encoding(val)
+ */
+  if (unlikely(__pyx_v_self->_settings == Py_None)) {
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+    __PYX_ERR(0, 19, __pyx_L1_error)
+  }
+  if (unlikely(PyDict_SetItem(__pyx_v_self->_settings, __pyx_v_name, __pyx_v_val) < 0)) __PYX_ERR(0, 19, __pyx_L1_error)
+
+  /* "asyncpg/protocol/settings.pyx":20
+ *     cdef add_setting(self, str name, str val):
+ *         self._settings[name] = val
+ *         if name == 'client_encoding':             # <<<<<<<<<<<<<<
+ *             py_enc = get_python_encoding(val)
+ *             self._codec = codecs.lookup(py_enc)
+ */
+  __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_name, __pyx_n_u_client_encoding, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 20, __pyx_L1_error)
+  __pyx_t_2 = (__pyx_t_1 != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/settings.pyx":21
+ *         self._settings[name] = val
+ *         if name == 'client_encoding':
+ *             py_enc = get_python_encoding(val)             # <<<<<<<<<<<<<<
+ *             self._codec = codecs.lookup(py_enc)
+ *             self._encoding = self._codec.name
+ */
+    __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_get_python_encoding(__pyx_v_val); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 21, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_v_py_enc = __pyx_t_3;
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/settings.pyx":22
+ *         if name == 'client_encoding':
+ *             py_enc = get_python_encoding(val)
+ *             self._codec = codecs.lookup(py_enc)             # <<<<<<<<<<<<<<
+ *             self._encoding = self._codec.name
+ *             self._is_utf8 = self._encoding == 'utf-8'
+ */
+    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_codecs); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 22, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_lookup); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 22, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_4 = NULL;
+    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
+      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
+      if (likely(__pyx_t_4)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+        __Pyx_INCREF(__pyx_t_4);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_5, function);
+      }
+    }
+    if (!__pyx_t_4) {
+      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_py_enc); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 22, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_5)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_py_enc};
+        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 22, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_py_enc};
+        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 22, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+      } else
+      #endif
+      {
+        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 22, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_6);
+        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
+        __Pyx_INCREF(__pyx_v_py_enc);
+        __Pyx_GIVEREF(__pyx_v_py_enc);
+        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_py_enc);
+        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 22, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_GIVEREF(__pyx_t_3);
+    __Pyx_GOTREF(__pyx_v_self->_codec);
+    __Pyx_DECREF(__pyx_v_self->_codec);
+    __pyx_v_self->_codec = __pyx_t_3;
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/settings.pyx":23
+ *             py_enc = get_python_encoding(val)
+ *             self._codec = codecs.lookup(py_enc)
+ *             self._encoding = self._codec.name             # <<<<<<<<<<<<<<
+ *             self._is_utf8 = self._encoding == 'utf-8'
+ * 
+ */
+    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_codec, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 23, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    if (!(likely(PyUnicode_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 23, __pyx_L1_error)
+    __Pyx_GIVEREF(__pyx_t_3);
+    __Pyx_GOTREF(__pyx_v_self->_encoding);
+    __Pyx_DECREF(__pyx_v_self->_encoding);
+    __pyx_v_self->_encoding = ((PyObject*)__pyx_t_3);
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/settings.pyx":24
+ *             self._codec = codecs.lookup(py_enc)
+ *             self._encoding = self._codec.name
+ *             self._is_utf8 = self._encoding == 'utf-8'             # <<<<<<<<<<<<<<
+ * 
+ *     cdef inline is_encoding_utf8(self):
+ */
+    __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_self->_encoding, __pyx_kp_u_utf_8, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 24, __pyx_L1_error)
+    __pyx_v_self->_is_utf8 = __pyx_t_2;
+
+    /* "asyncpg/protocol/settings.pyx":20
+ *     cdef add_setting(self, str name, str val):
+ *         self._settings[name] = val
+ *         if name == 'client_encoding':             # <<<<<<<<<<<<<<
+ *             py_enc = get_python_encoding(val)
+ *             self._codec = codecs.lookup(py_enc)
+ */
+  }
+
+  /* "asyncpg/protocol/settings.pyx":18
+ *         self._data_codecs = DataCodecConfig(conn_key)
+ * 
+ *     cdef add_setting(self, str name, str val):             # <<<<<<<<<<<<<<
+ *         self._settings[name] = val
+ *         if name == 'client_encoding':
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ConnectionSettings.add_setting", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_py_enc);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/settings.pyx":26
+ *             self._is_utf8 = self._encoding == 'utf-8'
+ * 
+ *     cdef inline is_encoding_utf8(self):             # <<<<<<<<<<<<<<
+ *         return self._is_utf8
+ * 
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_is_encoding_utf8(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("is_encoding_utf8", 0);
+
+  /* "asyncpg/protocol/settings.pyx":27
+ * 
+ *     cdef inline is_encoding_utf8(self):
+ *         return self._is_utf8             # <<<<<<<<<<<<<<
+ * 
+ *     cpdef inline get_text_codec(self):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_is_utf8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 27, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/settings.pyx":26
+ *             self._is_utf8 = self._encoding == 'utf-8'
+ * 
+ *     cdef inline is_encoding_utf8(self):             # <<<<<<<<<<<<<<
+ *         return self._is_utf8
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ConnectionSettings.is_encoding_utf8", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/settings.pyx":29
+ *         return self._is_utf8
+ * 
+ *     cpdef inline get_text_codec(self):             # <<<<<<<<<<<<<<
+ *         return self._codec
+ * 
+ */
+
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_3get_text_codec(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_text_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, CYTHON_UNUSED int __pyx_skip_dispatch) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("get_text_codec", 0);
+
+  /* "asyncpg/protocol/settings.pyx":30
+ * 
+ *     cpdef inline get_text_codec(self):
+ *         return self._codec             # <<<<<<<<<<<<<<
+ * 
+ *     cpdef inline register_data_types(self, types):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_self->_codec);
+  __pyx_r = __pyx_v_self->_codec;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/settings.pyx":29
+ *         return self._is_utf8
+ * 
+ *     cpdef inline get_text_codec(self):             # <<<<<<<<<<<<<<
+ *         return self._codec
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_3get_text_codec(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_3get_text_codec(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("get_text_codec (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_2get_text_codec(((struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_2get_text_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("get_text_codec", 0);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_text_codec(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ConnectionSettings.get_text_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/settings.pyx":32
+ *         return self._codec
+ * 
+ *     cpdef inline register_data_types(self, types):             # <<<<<<<<<<<<<<
+ *         self._data_codecs.add_types(types)
+ * 
+ */
+
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_5register_data_types(PyObject *__pyx_v_self, PyObject *__pyx_v_types); /*proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_register_data_types(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, PyObject *__pyx_v_types, CYTHON_UNUSED int __pyx_skip_dispatch) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  __Pyx_RefNannySetupContext("register_data_types", 0);
+
+  /* "asyncpg/protocol/settings.pyx":33
+ * 
+ *     cpdef inline register_data_types(self, types):
+ *         self._data_codecs.add_types(types)             # <<<<<<<<<<<<<<
+ * 
+ *     cpdef inline add_python_codec(self, typeoid, typename, typeschema,
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->_data_codecs), __pyx_n_s_add_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (!__pyx_t_3) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_types); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_types};
+      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_types};
+      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else
+    #endif
+    {
+      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 33, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
+      __Pyx_INCREF(__pyx_v_types);
+      __Pyx_GIVEREF(__pyx_v_types);
+      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_types);
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/settings.pyx":32
+ *         return self._codec
+ * 
+ *     cpdef inline register_data_types(self, types):             # <<<<<<<<<<<<<<
+ *         self._data_codecs.add_types(types)
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ConnectionSettings.register_data_types", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_5register_data_types(PyObject *__pyx_v_self, PyObject *__pyx_v_types); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_5register_data_types(PyObject *__pyx_v_self, PyObject *__pyx_v_types) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("register_data_types (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_4register_data_types(((struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *)__pyx_v_self), ((PyObject *)__pyx_v_types));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_4register_data_types(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, PyObject *__pyx_v_types) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("register_data_types", 0);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_register_data_types(__pyx_v_self, __pyx_v_types, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ConnectionSettings.register_data_types", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/settings.pyx":35
+ *         self._data_codecs.add_types(types)
+ * 
+ *     cpdef inline add_python_codec(self, typeoid, typename, typeschema,             # <<<<<<<<<<<<<<
+ *                                   typekind, encoder, decoder, binary):
+ *         self._data_codecs.add_python_codec(typeoid, typename, typeschema,
+ */
+
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_7add_python_codec(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_add_python_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, PyObject *__pyx_v_typeoid, PyObject *__pyx_v_typename, PyObject *__pyx_v_typeschema, PyObject *__pyx_v_typekind, PyObject *__pyx_v_encoder, PyObject *__pyx_v_decoder, PyObject *__pyx_v_binary, CYTHON_UNUSED int __pyx_skip_dispatch) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  __Pyx_RefNannySetupContext("add_python_codec", 0);
+
+  /* "asyncpg/protocol/settings.pyx":37
+ *     cpdef inline add_python_codec(self, typeoid, typename, typeschema,
+ *                                   typekind, encoder, decoder, binary):
+ *         self._data_codecs.add_python_codec(typeoid, typename, typeschema,             # <<<<<<<<<<<<<<
+ *                                            typekind, encoder, decoder, binary)
+ * 
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->_data_codecs), __pyx_n_s_add_python_codec); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 37, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+
+  /* "asyncpg/protocol/settings.pyx":38
+ *                                   typekind, encoder, decoder, binary):
+ *         self._data_codecs.add_python_codec(typeoid, typename, typeschema,
+ *                                            typekind, encoder, decoder, binary)             # <<<<<<<<<<<<<<
+ * 
+ *     cpdef inline set_builtin_type_codec(self, typeoid, typename, typeschema,
+ */
+  __pyx_t_3 = NULL;
+  __pyx_t_4 = 0;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+      __pyx_t_4 = 1;
+    }
+  }
+  #if CYTHON_FAST_PYCALL
+  if (PyFunction_Check(__pyx_t_2)) {
+    PyObject *__pyx_temp[8] = {__pyx_t_3, __pyx_v_typeoid, __pyx_v_typename, __pyx_v_typeschema, __pyx_v_typekind, __pyx_v_encoder, __pyx_v_decoder, __pyx_v_binary};
+    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 7+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+  } else
+  #endif
+  #if CYTHON_FAST_PYCCALL
+  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+    PyObject *__pyx_temp[8] = {__pyx_t_3, __pyx_v_typeoid, __pyx_v_typename, __pyx_v_typeschema, __pyx_v_typekind, __pyx_v_encoder, __pyx_v_decoder, __pyx_v_binary};
+    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 7+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+  } else
+  #endif
+  {
+    __pyx_t_5 = PyTuple_New(7+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 37, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    if (__pyx_t_3) {
+      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
+    }
+    __Pyx_INCREF(__pyx_v_typeoid);
+    __Pyx_GIVEREF(__pyx_v_typeoid);
+    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_typeoid);
+    __Pyx_INCREF(__pyx_v_typename);
+    __Pyx_GIVEREF(__pyx_v_typename);
+    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_typename);
+    __Pyx_INCREF(__pyx_v_typeschema);
+    __Pyx_GIVEREF(__pyx_v_typeschema);
+    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_typeschema);
+    __Pyx_INCREF(__pyx_v_typekind);
+    __Pyx_GIVEREF(__pyx_v_typekind);
+    PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_4, __pyx_v_typekind);
+    __Pyx_INCREF(__pyx_v_encoder);
+    __Pyx_GIVEREF(__pyx_v_encoder);
+    PyTuple_SET_ITEM(__pyx_t_5, 4+__pyx_t_4, __pyx_v_encoder);
+    __Pyx_INCREF(__pyx_v_decoder);
+    __Pyx_GIVEREF(__pyx_v_decoder);
+    PyTuple_SET_ITEM(__pyx_t_5, 5+__pyx_t_4, __pyx_v_decoder);
+    __Pyx_INCREF(__pyx_v_binary);
+    __Pyx_GIVEREF(__pyx_v_binary);
+    PyTuple_SET_ITEM(__pyx_t_5, 6+__pyx_t_4, __pyx_v_binary);
+    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/settings.pyx":35
+ *         self._data_codecs.add_types(types)
+ * 
+ *     cpdef inline add_python_codec(self, typeoid, typename, typeschema,             # <<<<<<<<<<<<<<
+ *                                   typekind, encoder, decoder, binary):
+ *         self._data_codecs.add_python_codec(typeoid, typename, typeschema,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ConnectionSettings.add_python_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_7add_python_codec(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_7add_python_codec(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_typeoid = 0;
+  PyObject *__pyx_v_typename = 0;
+  PyObject *__pyx_v_typeschema = 0;
+  PyObject *__pyx_v_typekind = 0;
+  PyObject *__pyx_v_encoder = 0;
+  PyObject *__pyx_v_decoder = 0;
+  PyObject *__pyx_v_binary = 0;
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("add_python_codec (wrapper)", 0);
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_typeoid,&__pyx_n_s_typename,&__pyx_n_s_typeschema,&__pyx_n_s_typekind,&__pyx_n_s_encoder,&__pyx_n_s_decoder,&__pyx_n_s_binary,0};
+    PyObject* values[7] = {0,0,0,0,0,0,0};
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
+        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
+        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typeoid)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+        case  1:
+        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typename)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("add_python_codec", 1, 7, 7, 1); __PYX_ERR(0, 35, __pyx_L3_error)
+        }
+        case  2:
+        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typeschema)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("add_python_codec", 1, 7, 7, 2); __PYX_ERR(0, 35, __pyx_L3_error)
+        }
+        case  3:
+        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typekind)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("add_python_codec", 1, 7, 7, 3); __PYX_ERR(0, 35, __pyx_L3_error)
+        }
+        case  4:
+        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_encoder)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("add_python_codec", 1, 7, 7, 4); __PYX_ERR(0, 35, __pyx_L3_error)
+        }
+        case  5:
+        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_decoder)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("add_python_codec", 1, 7, 7, 5); __PYX_ERR(0, 35, __pyx_L3_error)
+        }
+        case  6:
+        if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_binary)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("add_python_codec", 1, 7, 7, 6); __PYX_ERR(0, 35, __pyx_L3_error)
+        }
+      }
+      if (unlikely(kw_args > 0)) {
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_python_codec") < 0)) __PYX_ERR(0, 35, __pyx_L3_error)
+      }
+    } else if (PyTuple_GET_SIZE(__pyx_args) != 7) {
+      goto __pyx_L5_argtuple_error;
+    } else {
+      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
+      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
+    }
+    __pyx_v_typeoid = values[0];
+    __pyx_v_typename = values[1];
+    __pyx_v_typeschema = values[2];
+    __pyx_v_typekind = values[3];
+    __pyx_v_encoder = values[4];
+    __pyx_v_decoder = values[5];
+    __pyx_v_binary = values[6];
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("add_python_codec", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 35, __pyx_L3_error)
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ConnectionSettings.add_python_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_6add_python_codec(((struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *)__pyx_v_self), __pyx_v_typeoid, __pyx_v_typename, __pyx_v_typeschema, __pyx_v_typekind, __pyx_v_encoder, __pyx_v_decoder, __pyx_v_binary);
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_6add_python_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, PyObject *__pyx_v_typeoid, PyObject *__pyx_v_typename, PyObject *__pyx_v_typeschema, PyObject *__pyx_v_typekind, PyObject *__pyx_v_encoder, PyObject *__pyx_v_decoder, PyObject *__pyx_v_binary) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("add_python_codec", 0);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_add_python_codec(__pyx_v_self, __pyx_v_typeoid, __pyx_v_typename, __pyx_v_typeschema, __pyx_v_typekind, __pyx_v_encoder, __pyx_v_decoder, __pyx_v_binary, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 35, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ConnectionSettings.add_python_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/settings.pyx":40
+ *                                            typekind, encoder, decoder, binary)
+ * 
+ *     cpdef inline set_builtin_type_codec(self, typeoid, typename, typeschema,             # <<<<<<<<<<<<<<
+ *                                         typekind, alias_to):
+ *         self._data_codecs.set_builtin_type_codec(typeoid, typename, typeschema,
+ */
+
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_9set_builtin_type_codec(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_set_builtin_type_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, PyObject *__pyx_v_typeoid, PyObject *__pyx_v_typename, PyObject *__pyx_v_typeschema, PyObject *__pyx_v_typekind, PyObject *__pyx_v_alias_to, CYTHON_UNUSED int __pyx_skip_dispatch) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  __Pyx_RefNannySetupContext("set_builtin_type_codec", 0);
+
+  /* "asyncpg/protocol/settings.pyx":42
+ *     cpdef inline set_builtin_type_codec(self, typeoid, typename, typeschema,
+ *                                         typekind, alias_to):
+ *         self._data_codecs.set_builtin_type_codec(typeoid, typename, typeschema,             # <<<<<<<<<<<<<<
+ *                                           typekind, alias_to)
+ * 
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->_data_codecs), __pyx_n_s_set_builtin_type_codec); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 42, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+
+  /* "asyncpg/protocol/settings.pyx":43
+ *                                         typekind, alias_to):
+ *         self._data_codecs.set_builtin_type_codec(typeoid, typename, typeschema,
+ *                                           typekind, alias_to)             # <<<<<<<<<<<<<<
+ * 
+ *     cpdef inline Codec get_data_codec(self, uint32_t oid,
+ */
+  __pyx_t_3 = NULL;
+  __pyx_t_4 = 0;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+      __pyx_t_4 = 1;
+    }
+  }
+  #if CYTHON_FAST_PYCALL
+  if (PyFunction_Check(__pyx_t_2)) {
+    PyObject *__pyx_temp[6] = {__pyx_t_3, __pyx_v_typeoid, __pyx_v_typename, __pyx_v_typeschema, __pyx_v_typekind, __pyx_v_alias_to};
+    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 5+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+  } else
+  #endif
+  #if CYTHON_FAST_PYCCALL
+  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+    PyObject *__pyx_temp[6] = {__pyx_t_3, __pyx_v_typeoid, __pyx_v_typename, __pyx_v_typeschema, __pyx_v_typekind, __pyx_v_alias_to};
+    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 5+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+  } else
+  #endif
+  {
+    __pyx_t_5 = PyTuple_New(5+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 42, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    if (__pyx_t_3) {
+      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
+    }
+    __Pyx_INCREF(__pyx_v_typeoid);
+    __Pyx_GIVEREF(__pyx_v_typeoid);
+    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_typeoid);
+    __Pyx_INCREF(__pyx_v_typename);
+    __Pyx_GIVEREF(__pyx_v_typename);
+    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_typename);
+    __Pyx_INCREF(__pyx_v_typeschema);
+    __Pyx_GIVEREF(__pyx_v_typeschema);
+    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_typeschema);
+    __Pyx_INCREF(__pyx_v_typekind);
+    __Pyx_GIVEREF(__pyx_v_typekind);
+    PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_4, __pyx_v_typekind);
+    __Pyx_INCREF(__pyx_v_alias_to);
+    __Pyx_GIVEREF(__pyx_v_alias_to);
+    PyTuple_SET_ITEM(__pyx_t_5, 4+__pyx_t_4, __pyx_v_alias_to);
+    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/settings.pyx":40
+ *                                            typekind, encoder, decoder, binary)
+ * 
+ *     cpdef inline set_builtin_type_codec(self, typeoid, typename, typeschema,             # <<<<<<<<<<<<<<
+ *                                         typekind, alias_to):
+ *         self._data_codecs.set_builtin_type_codec(typeoid, typename, typeschema,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ConnectionSettings.set_builtin_type_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_9set_builtin_type_codec(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_9set_builtin_type_codec(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_typeoid = 0;
+  PyObject *__pyx_v_typename = 0;
+  PyObject *__pyx_v_typeschema = 0;
+  PyObject *__pyx_v_typekind = 0;
+  PyObject *__pyx_v_alias_to = 0;
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("set_builtin_type_codec (wrapper)", 0);
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_typeoid,&__pyx_n_s_typename,&__pyx_n_s_typeschema,&__pyx_n_s_typekind,&__pyx_n_s_alias_to,0};
+    PyObject* values[5] = {0,0,0,0,0};
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typeoid)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+        case  1:
+        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typename)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("set_builtin_type_codec", 1, 5, 5, 1); __PYX_ERR(0, 40, __pyx_L3_error)
+        }
+        case  2:
+        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typeschema)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("set_builtin_type_codec", 1, 5, 5, 2); __PYX_ERR(0, 40, __pyx_L3_error)
+        }
+        case  3:
+        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typekind)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("set_builtin_type_codec", 1, 5, 5, 3); __PYX_ERR(0, 40, __pyx_L3_error)
+        }
+        case  4:
+        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_alias_to)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("set_builtin_type_codec", 1, 5, 5, 4); __PYX_ERR(0, 40, __pyx_L3_error)
+        }
+      }
+      if (unlikely(kw_args > 0)) {
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_builtin_type_codec") < 0)) __PYX_ERR(0, 40, __pyx_L3_error)
+      }
+    } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
+      goto __pyx_L5_argtuple_error;
+    } else {
+      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+    }
+    __pyx_v_typeoid = values[0];
+    __pyx_v_typename = values[1];
+    __pyx_v_typeschema = values[2];
+    __pyx_v_typekind = values[3];
+    __pyx_v_alias_to = values[4];
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("set_builtin_type_codec", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 40, __pyx_L3_error)
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ConnectionSettings.set_builtin_type_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_8set_builtin_type_codec(((struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *)__pyx_v_self), __pyx_v_typeoid, __pyx_v_typename, __pyx_v_typeschema, __pyx_v_typekind, __pyx_v_alias_to);
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_8set_builtin_type_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, PyObject *__pyx_v_typeoid, PyObject *__pyx_v_typename, PyObject *__pyx_v_typeschema, PyObject *__pyx_v_typekind, PyObject *__pyx_v_alias_to) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("set_builtin_type_codec", 0);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_set_builtin_type_codec(__pyx_v_self, __pyx_v_typeoid, __pyx_v_typename, __pyx_v_typeschema, __pyx_v_typekind, __pyx_v_alias_to, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ConnectionSettings.set_builtin_type_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/settings.pyx":45
+ *                                           typekind, alias_to)
+ * 
+ *     cpdef inline Codec get_data_codec(self, uint32_t oid,             # <<<<<<<<<<<<<<
+ *                                       CodecFormat format=PG_FORMAT_ANY):
+ *         if format == PG_FORMAT_ANY:
+ */
+
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_11get_data_codec(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static CYTHON_INLINE struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_data_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, uint32_t __pyx_v_oid, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_data_codec *__pyx_optional_args) {
+  enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat __pyx_v_format = __pyx_k__2;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_codec = NULL;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_3;
+  __Pyx_RefNannySetupContext("get_data_codec", 0);
+  if (__pyx_optional_args) {
+    if (__pyx_optional_args->__pyx_n > 0) {
+      __pyx_v_format = __pyx_optional_args->format;
+    }
+  }
+
+  /* "asyncpg/protocol/settings.pyx":47
+ *     cpdef inline Codec get_data_codec(self, uint32_t oid,
+ *                                       CodecFormat format=PG_FORMAT_ANY):
+ *         if format == PG_FORMAT_ANY:             # <<<<<<<<<<<<<<
+ *             codec = self._data_codecs.get_codec(oid, PG_FORMAT_BINARY)
+ *             if codec is None:
+ */
+  __pyx_t_1 = ((__pyx_v_format == __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_ANY) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/settings.pyx":48
+ *                                       CodecFormat format=PG_FORMAT_ANY):
+ *         if format == PG_FORMAT_ANY:
+ *             codec = self._data_codecs.get_codec(oid, PG_FORMAT_BINARY)             # <<<<<<<<<<<<<<
+ *             if codec is None:
+ *                 codec = self._data_codecs.get_codec(oid, PG_FORMAT_TEXT)
+ */
+    __pyx_t_2 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_15DataCodecConfig_get_codec(__pyx_v_self->_data_codecs, __pyx_v_oid, __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 48, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_v_codec = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_2);
+    __pyx_t_2 = 0;
+
+    /* "asyncpg/protocol/settings.pyx":49
+ *         if format == PG_FORMAT_ANY:
+ *             codec = self._data_codecs.get_codec(oid, PG_FORMAT_BINARY)
+ *             if codec is None:             # <<<<<<<<<<<<<<
+ *                 codec = self._data_codecs.get_codec(oid, PG_FORMAT_TEXT)
+ *             return codec
+ */
+    __pyx_t_1 = (((PyObject *)__pyx_v_codec) == Py_None);
+    __pyx_t_3 = (__pyx_t_1 != 0);
+    if (__pyx_t_3) {
+
+      /* "asyncpg/protocol/settings.pyx":50
+ *             codec = self._data_codecs.get_codec(oid, PG_FORMAT_BINARY)
+ *             if codec is None:
+ *                 codec = self._data_codecs.get_codec(oid, PG_FORMAT_TEXT)             # <<<<<<<<<<<<<<
+ *             return codec
+ *         else:
+ */
+      __pyx_t_2 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_15DataCodecConfig_get_codec(__pyx_v_self->_data_codecs, __pyx_v_oid, __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF_SET(__pyx_v_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_2));
+      __pyx_t_2 = 0;
+
+      /* "asyncpg/protocol/settings.pyx":49
+ *         if format == PG_FORMAT_ANY:
+ *             codec = self._data_codecs.get_codec(oid, PG_FORMAT_BINARY)
+ *             if codec is None:             # <<<<<<<<<<<<<<
+ *                 codec = self._data_codecs.get_codec(oid, PG_FORMAT_TEXT)
+ *             return codec
+ */
+    }
+
+    /* "asyncpg/protocol/settings.pyx":51
+ *             if codec is None:
+ *                 codec = self._data_codecs.get_codec(oid, PG_FORMAT_TEXT)
+ *             return codec             # <<<<<<<<<<<<<<
+ *         else:
+ *             return self._data_codecs.get_codec(oid, format)
+ */
+    __Pyx_XDECREF(((PyObject *)__pyx_r));
+    __Pyx_INCREF(((PyObject *)__pyx_v_codec));
+    __pyx_r = __pyx_v_codec;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/settings.pyx":47
+ *     cpdef inline Codec get_data_codec(self, uint32_t oid,
+ *                                       CodecFormat format=PG_FORMAT_ANY):
+ *         if format == PG_FORMAT_ANY:             # <<<<<<<<<<<<<<
+ *             codec = self._data_codecs.get_codec(oid, PG_FORMAT_BINARY)
+ *             if codec is None:
+ */
+  }
+
+  /* "asyncpg/protocol/settings.pyx":53
+ *             return codec
+ *         else:
+ *             return self._data_codecs.get_codec(oid, format)             # <<<<<<<<<<<<<<
+ * 
+ *     def __getattr__(self, name):
+ */
+  /*else*/ {
+    __Pyx_XDECREF(((PyObject *)__pyx_r));
+    __pyx_t_2 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_15DataCodecConfig_get_codec(__pyx_v_self->_data_codecs, __pyx_v_oid, __pyx_v_format)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 53, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_r = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_2);
+    __pyx_t_2 = 0;
+    goto __pyx_L0;
+  }
+
+  /* "asyncpg/protocol/settings.pyx":45
+ *                                           typekind, alias_to)
+ * 
+ *     cpdef inline Codec get_data_codec(self, uint32_t oid,             # <<<<<<<<<<<<<<
+ *                                       CodecFormat format=PG_FORMAT_ANY):
+ *         if format == PG_FORMAT_ANY:
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ConnectionSettings.get_data_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
+  __Pyx_XGIVEREF((PyObject *)__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_11get_data_codec(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_11get_data_codec(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  uint32_t __pyx_v_oid;
+  enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat __pyx_v_format;
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("get_data_codec (wrapper)", 0);
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_oid,&__pyx_n_s_format,0};
+    PyObject* values[2] = {0,0};
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_oid)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+        case  1:
+        if (kw_args > 0) {
+          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_format);
+          if (value) { values[1] = value; kw_args--; }
+        }
+      }
+      if (unlikely(kw_args > 0)) {
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_data_codec") < 0)) __PYX_ERR(0, 45, __pyx_L3_error)
+      }
+    } else {
+      switch (PyTuple_GET_SIZE(__pyx_args)) {
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+    }
+    __pyx_v_oid = __Pyx_PyInt_As_uint32_t(values[0]); if (unlikely((__pyx_v_oid == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 45, __pyx_L3_error)
+    if (values[1]) {
+      __pyx_v_format = ((enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)__Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_CodecFormat(values[1])); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 46, __pyx_L3_error)
+    } else {
+      __pyx_v_format = __pyx_k__2;
+    }
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("get_data_codec", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 45, __pyx_L3_error)
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ConnectionSettings.get_data_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_10get_data_codec(((struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *)__pyx_v_self), __pyx_v_oid, __pyx_v_format);
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_10get_data_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, uint32_t __pyx_v_oid, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat __pyx_v_format) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  struct __pyx_opt_args_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_data_codec __pyx_t_2;
+  __Pyx_RefNannySetupContext("get_data_codec", 0);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_2.__pyx_n = 1;
+  __pyx_t_2.format = __pyx_v_format;
+  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_7asyncpg_8protocol_8protocol_ConnectionSettings->get_data_codec(__pyx_v_self, __pyx_v_oid, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ConnectionSettings.get_data_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/settings.pyx":55
+ *             return self._data_codecs.get_codec(oid, format)
+ * 
+ *     def __getattr__(self, name):             # <<<<<<<<<<<<<<
+ *         if not name.startswith('_'):
+ *             try:
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_13__getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_name); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_13__getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_name) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__getattr__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_12__getattr__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *)__pyx_v_self), ((PyObject *)__pyx_v_name));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_12__getattr__(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, PyObject *__pyx_v_name) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_3;
+  int __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  int __pyx_t_8;
+  PyObject *__pyx_t_9 = NULL;
+  PyObject *__pyx_t_10 = NULL;
+  PyObject *__pyx_t_11 = NULL;
+  __Pyx_RefNannySetupContext("__getattr__", 0);
+
+  /* "asyncpg/protocol/settings.pyx":56
+ * 
+ *     def __getattr__(self, name):
+ *         if not name.startswith('_'):             # <<<<<<<<<<<<<<
+ *             try:
+ *                 return self._settings[name]
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_name, __pyx_n_s_startswith); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 56, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_4 = ((!__pyx_t_3) != 0);
+  if (__pyx_t_4) {
+
+    /* "asyncpg/protocol/settings.pyx":57
+ *     def __getattr__(self, name):
+ *         if not name.startswith('_'):
+ *             try:             # <<<<<<<<<<<<<<
+ *                 return self._settings[name]
+ *             except KeyError:
+ */
+    {
+      __Pyx_PyThreadState_declare
+      __Pyx_PyThreadState_assign
+      __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
+      __Pyx_XGOTREF(__pyx_t_5);
+      __Pyx_XGOTREF(__pyx_t_6);
+      __Pyx_XGOTREF(__pyx_t_7);
+      /*try:*/ {
+
+        /* "asyncpg/protocol/settings.pyx":58
+ *         if not name.startswith('_'):
+ *             try:
+ *                 return self._settings[name]             # <<<<<<<<<<<<<<
+ *             except KeyError:
+ *                 raise AttributeError(name) from None
+ */
+        __Pyx_XDECREF(__pyx_r);
+        if (unlikely(__pyx_v_self->_settings == Py_None)) {
+          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+          __PYX_ERR(0, 58, __pyx_L4_error)
+        }
+        __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_self->_settings, __pyx_v_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L4_error)
+        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_r = __pyx_t_2;
+        __pyx_t_2 = 0;
+        goto __pyx_L8_try_return;
+
+        /* "asyncpg/protocol/settings.pyx":57
+ *     def __getattr__(self, name):
+ *         if not name.startswith('_'):
+ *             try:             # <<<<<<<<<<<<<<
+ *                 return self._settings[name]
+ *             except KeyError:
+ */
+      }
+      __pyx_L4_error:;
+      __Pyx_PyThreadState_assign
+      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+      /* "asyncpg/protocol/settings.pyx":59
+ *             try:
+ *                 return self._settings[name]
+ *             except KeyError:             # <<<<<<<<<<<<<<
+ *                 raise AttributeError(name) from None
+ * 
+ */
+      __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
+      if (__pyx_t_8) {
+        __Pyx_AddTraceback("asyncpg.protocol.protocol.ConnectionSettings.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+        if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_9) < 0) __PYX_ERR(0, 59, __pyx_L6_except_error)
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_GOTREF(__pyx_t_9);
+
+        /* "asyncpg/protocol/settings.pyx":60
+ *                 return self._settings[name]
+ *             except KeyError:
+ *                 raise AttributeError(name) from None             # <<<<<<<<<<<<<<
+ * 
+ *         return object.__getattr__(self, name)
+ */
+        __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 60, __pyx_L6_except_error)
+        __Pyx_GOTREF(__pyx_t_10);
+        __Pyx_INCREF(__pyx_v_name);
+        __Pyx_GIVEREF(__pyx_v_name);
+        PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_name);
+        __pyx_t_11 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_t_10, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 60, __pyx_L6_except_error)
+        __Pyx_GOTREF(__pyx_t_11);
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        __Pyx_Raise(__pyx_t_11, 0, 0, Py_None);
+        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+        __PYX_ERR(0, 60, __pyx_L6_except_error)
+      }
+      goto __pyx_L6_except_error;
+      __pyx_L6_except_error:;
+
+      /* "asyncpg/protocol/settings.pyx":57
+ *     def __getattr__(self, name):
+ *         if not name.startswith('_'):
+ *             try:             # <<<<<<<<<<<<<<
+ *                 return self._settings[name]
+ *             except KeyError:
+ */
+      __Pyx_PyThreadState_assign
+      __Pyx_XGIVEREF(__pyx_t_5);
+      __Pyx_XGIVEREF(__pyx_t_6);
+      __Pyx_XGIVEREF(__pyx_t_7);
+      __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
+      goto __pyx_L1_error;
+      __pyx_L8_try_return:;
+      __Pyx_PyThreadState_assign
+      __Pyx_XGIVEREF(__pyx_t_5);
+      __Pyx_XGIVEREF(__pyx_t_6);
+      __Pyx_XGIVEREF(__pyx_t_7);
+      __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
+      goto __pyx_L0;
+    }
+
+    /* "asyncpg/protocol/settings.pyx":56
+ * 
+ *     def __getattr__(self, name):
+ *         if not name.startswith('_'):             # <<<<<<<<<<<<<<
+ *             try:
+ *                 return self._settings[name]
+ */
+  }
+
+  /* "asyncpg/protocol/settings.pyx":62
+ *                 raise AttributeError(name) from None
+ * 
+ *         return object.__getattr__(self, name)             # <<<<<<<<<<<<<<
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_builtin_object, __pyx_n_s_getattr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = NULL;
+  __pyx_t_8 = 0;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
+    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
+    if (likely(__pyx_t_2)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
+      __Pyx_INCREF(__pyx_t_2);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_1, function);
+      __pyx_t_8 = 1;
+    }
+  }
+  #if CYTHON_FAST_PYCALL
+  if (PyFunction_Check(__pyx_t_1)) {
+    PyObject *__pyx_temp[3] = {__pyx_t_2, ((PyObject *)__pyx_v_self), __pyx_v_name};
+    __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 62, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_GOTREF(__pyx_t_9);
+  } else
+  #endif
+  #if CYTHON_FAST_PYCCALL
+  if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
+    PyObject *__pyx_temp[3] = {__pyx_t_2, ((PyObject *)__pyx_v_self), __pyx_v_name};
+    __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 62, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_GOTREF(__pyx_t_9);
+  } else
+  #endif
+  {
+    __pyx_t_11 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 62, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_11);
+    if (__pyx_t_2) {
+      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_2); __pyx_t_2 = NULL;
+    }
+    __Pyx_INCREF(((PyObject *)__pyx_v_self));
+    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
+    PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_8, ((PyObject *)__pyx_v_self));
+    __Pyx_INCREF(__pyx_v_name);
+    __Pyx_GIVEREF(__pyx_v_name);
+    PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_8, __pyx_v_name);
+    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 62, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_9);
+    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_r = __pyx_t_9;
+  __pyx_t_9 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/settings.pyx":55
+ *             return self._data_codecs.get_codec(oid, format)
+ * 
+ *     def __getattr__(self, name):             # <<<<<<<<<<<<<<
+ *         if not name.startswith('_'):
+ *             try:
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_XDECREF(__pyx_t_11);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ConnectionSettings.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":20
+ * cdef class Memory:
+ * 
+ *     cdef as_bytes(self):             # <<<<<<<<<<<<<<
+ *         return cpython.PyBytes_FromStringAndSize(self.buf, self.length)
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_6Memory_as_bytes(struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("as_bytes", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":21
+ * 
+ *     cdef as_bytes(self):
+ *         return cpython.PyBytes_FromStringAndSize(self.buf, self.length)             # <<<<<<<<<<<<<<
+ * 
+ *     @staticmethod
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyBytes_FromStringAndSize(__pyx_v_self->buf, __pyx_v_self->length); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 21, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/buffer.pyx":20
+ * cdef class Memory:
+ * 
+ *     cdef as_bytes(self):             # <<<<<<<<<<<<<<
+ *         return cpython.PyBytes_FromStringAndSize(self.buf, self.length)
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.Memory.as_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":24
+ * 
+ *     @staticmethod
+ *     cdef inline Memory new(char* buf, object owner, ssize_t length):             # <<<<<<<<<<<<<<
+ *         cdef Memory mem
+ *         mem = Memory.__new__(Memory)
+ */
+
+static CYTHON_INLINE struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *__pyx_f_7asyncpg_8protocol_8protocol_6Memory_new(char *__pyx_v_buf, PyObject *__pyx_v_owner, Py_ssize_t __pyx_v_length) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *__pyx_v_mem = 0;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("new", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":26
+ *     cdef inline Memory new(char* buf, object owner, ssize_t length):
+ *         cdef Memory mem
+ *         mem = Memory.__new__(Memory)             # <<<<<<<<<<<<<<
+ *         mem.buf = buf
+ *         mem.owner = owner
+ */
+  __pyx_t_1 = __pyx_tp_new_7asyncpg_8protocol_8protocol_Memory(((PyTypeObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_Memory), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 26, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7asyncpg_8protocol_8protocol_Memory)))) __PYX_ERR(1, 26, __pyx_L1_error)
+  __pyx_v_mem = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":27
+ *         cdef Memory mem
+ *         mem = Memory.__new__(Memory)
+ *         mem.buf = buf             # <<<<<<<<<<<<<<
+ *         mem.owner = owner
+ *         mem.length = length
+ */
+  __pyx_v_mem->buf = __pyx_v_buf;
+
+  /* "asyncpg/protocol/buffer.pyx":28
+ *         mem = Memory.__new__(Memory)
+ *         mem.buf = buf
+ *         mem.owner = owner             # <<<<<<<<<<<<<<
+ *         mem.length = length
+ *         return mem
+ */
+  __Pyx_INCREF(__pyx_v_owner);
+  __Pyx_GIVEREF(__pyx_v_owner);
+  __Pyx_GOTREF(__pyx_v_mem->owner);
+  __Pyx_DECREF(__pyx_v_mem->owner);
+  __pyx_v_mem->owner = __pyx_v_owner;
+
+  /* "asyncpg/protocol/buffer.pyx":29
+ *         mem.buf = buf
+ *         mem.owner = owner
+ *         mem.length = length             # <<<<<<<<<<<<<<
+ *         return mem
+ * 
+ */
+  __pyx_v_mem->length = __pyx_v_length;
+
+  /* "asyncpg/protocol/buffer.pyx":30
+ *         mem.owner = owner
+ *         mem.length = length
+ *         return mem             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(((PyObject *)__pyx_r));
+  __Pyx_INCREF(((PyObject *)__pyx_v_mem));
+  __pyx_r = __pyx_v_mem;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/buffer.pyx":24
+ * 
+ *     @staticmethod
+ *     cdef inline Memory new(char* buf, object owner, ssize_t length):             # <<<<<<<<<<<<<<
+ *         cdef Memory mem
+ *         mem = Memory.__new__(Memory)
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.Memory.new", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_mem);
+  __Pyx_XGIVEREF((PyObject *)__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":38
+ * cdef class WriteBuffer:
+ * 
+ *     def __cinit__(self):             # <<<<<<<<<<<<<<
+ *         self._smallbuf_inuse = True
+ *         self._buf = self._smallbuf
+ */
+
+/* Python wrapper */
+static int __pyx_pw_7asyncpg_8protocol_8protocol_11WriteBuffer_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pw_7asyncpg_8protocol_8protocol_11WriteBuffer_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
+  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
+    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
+  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_11WriteBuffer___cinit__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static int __pyx_pf_7asyncpg_8protocol_8protocol_11WriteBuffer___cinit__(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  char *__pyx_t_1;
+  __Pyx_RefNannySetupContext("__cinit__", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":39
+ * 
+ *     def __cinit__(self):
+ *         self._smallbuf_inuse = True             # <<<<<<<<<<<<<<
+ *         self._buf = self._smallbuf
+ *         self._size = _BUFFER_INITIAL_SIZE
+ */
+  __pyx_v_self->_smallbuf_inuse = 1;
+
+  /* "asyncpg/protocol/buffer.pyx":40
+ *     def __cinit__(self):
+ *         self._smallbuf_inuse = True
+ *         self._buf = self._smallbuf             # <<<<<<<<<<<<<<
+ *         self._size = _BUFFER_INITIAL_SIZE
+ *         self._length = 0
+ */
+  __pyx_t_1 = __pyx_v_self->_smallbuf;
+  __pyx_v_self->_buf = __pyx_t_1;
+
+  /* "asyncpg/protocol/buffer.pyx":41
+ *         self._smallbuf_inuse = True
+ *         self._buf = self._smallbuf
+ *         self._size = _BUFFER_INITIAL_SIZE             # <<<<<<<<<<<<<<
+ *         self._length = 0
+ *         self._message_mode = 0
+ */
+  __pyx_v_self->_size = 0x400;
+
+  /* "asyncpg/protocol/buffer.pyx":42
+ *         self._buf = self._smallbuf
+ *         self._size = _BUFFER_INITIAL_SIZE
+ *         self._length = 0             # <<<<<<<<<<<<<<
+ *         self._message_mode = 0
+ * 
+ */
+  __pyx_v_self->_length = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":43
+ *         self._size = _BUFFER_INITIAL_SIZE
+ *         self._length = 0
+ *         self._message_mode = 0             # <<<<<<<<<<<<<<
+ * 
+ *     def __dealloc__(self):
+ */
+  __pyx_v_self->_message_mode = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":38
+ * cdef class WriteBuffer:
+ * 
+ *     def __cinit__(self):             # <<<<<<<<<<<<<<
+ *         self._smallbuf_inuse = True
+ *         self._buf = self._smallbuf
+ */
+
+  /* function exit code */
+  __pyx_r = 0;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":45
+ *         self._message_mode = 0
+ * 
+ *     def __dealloc__(self):             # <<<<<<<<<<<<<<
+ *         if self._buf is not NULL and not self._smallbuf_inuse:
+ *             PyMem_Free(self._buf)
+ */
+
+/* Python wrapper */
+static void __pyx_pw_7asyncpg_8protocol_8protocol_11WriteBuffer_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pw_7asyncpg_8protocol_8protocol_11WriteBuffer_3__dealloc__(PyObject *__pyx_v_self) {
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
+  __pyx_pf_7asyncpg_8protocol_8protocol_11WriteBuffer_2__dealloc__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+}
+
+static void __pyx_pf_7asyncpg_8protocol_8protocol_11WriteBuffer_2__dealloc__(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self) {
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("__dealloc__", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":46
+ * 
+ *     def __dealloc__(self):
+ *         if self._buf is not NULL and not self._smallbuf_inuse:             # <<<<<<<<<<<<<<
+ *             PyMem_Free(self._buf)
+ *             self._buf = NULL
+ */
+  __pyx_t_2 = ((__pyx_v_self->_buf != NULL) != 0);
+  if (__pyx_t_2) {
+  } else {
+    __pyx_t_1 = __pyx_t_2;
+    goto __pyx_L4_bool_binop_done;
+  }
+  __pyx_t_2 = ((!(__pyx_v_self->_smallbuf_inuse != 0)) != 0);
+  __pyx_t_1 = __pyx_t_2;
+  __pyx_L4_bool_binop_done:;
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":47
+ *     def __dealloc__(self):
+ *         if self._buf is not NULL and not self._smallbuf_inuse:
+ *             PyMem_Free(self._buf)             # <<<<<<<<<<<<<<
+ *             self._buf = NULL
+ *             self._size = 0
+ */
+    PyMem_Free(__pyx_v_self->_buf);
+
+    /* "asyncpg/protocol/buffer.pyx":48
+ *         if self._buf is not NULL and not self._smallbuf_inuse:
+ *             PyMem_Free(self._buf)
+ *             self._buf = NULL             # <<<<<<<<<<<<<<
+ *             self._size = 0
+ * 
+ */
+    __pyx_v_self->_buf = NULL;
+
+    /* "asyncpg/protocol/buffer.pyx":49
+ *             PyMem_Free(self._buf)
+ *             self._buf = NULL
+ *             self._size = 0             # <<<<<<<<<<<<<<
+ * 
+ *         if self._view_count:
+ */
+    __pyx_v_self->_size = 0;
+
+    /* "asyncpg/protocol/buffer.pyx":46
+ * 
+ *     def __dealloc__(self):
+ *         if self._buf is not NULL and not self._smallbuf_inuse:             # <<<<<<<<<<<<<<
+ *             PyMem_Free(self._buf)
+ *             self._buf = NULL
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":51
+ *             self._size = 0
+ * 
+ *         if self._view_count:             # <<<<<<<<<<<<<<
+ *             raise RuntimeError(
+ *                 'Deallocating buffer with attached memoryviews')
+ */
+  __pyx_t_1 = (__pyx_v_self->_view_count != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":52
+ * 
+ *         if self._view_count:
+ *             raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                 'Deallocating buffer with attached memoryviews')
+ * 
+ */
+    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 52, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __PYX_ERR(1, 52, __pyx_L1_error)
+
+    /* "asyncpg/protocol/buffer.pyx":51
+ *             self._size = 0
+ * 
+ *         if self._view_count:             # <<<<<<<<<<<<<<
+ *             raise RuntimeError(
+ *                 'Deallocating buffer with attached memoryviews')
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":45
+ *         self._message_mode = 0
+ * 
+ *     def __dealloc__(self):             # <<<<<<<<<<<<<<
+ *         if self._buf is not NULL and not self._smallbuf_inuse:
+ *             PyMem_Free(self._buf)
+ */
+
+  /* function exit code */
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_WriteUnraisable("asyncpg.protocol.protocol.WriteBuffer.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+}
+
+/* "asyncpg/protocol/buffer.pyx":55
+ *                 'Deallocating buffer with attached memoryviews')
+ * 
+ *     def __getbuffer__(self, Py_buffer *buffer, int flags):             # <<<<<<<<<<<<<<
+ *         self._view_count += 1
+ * 
+ */
+
+/* Python wrapper */
+static CYTHON_UNUSED int __pyx_pw_7asyncpg_8protocol_8protocol_11WriteBuffer_5__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_buffer, int __pyx_v_flags); /*proto*/
+static CYTHON_UNUSED int __pyx_pw_7asyncpg_8protocol_8protocol_11WriteBuffer_5__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_buffer, int __pyx_v_flags) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_11WriteBuffer_4__getbuffer__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_v_self), ((Py_buffer *)__pyx_v_buffer), ((int)__pyx_v_flags));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static int __pyx_pf_7asyncpg_8protocol_8protocol_11WriteBuffer_4__getbuffer__(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, Py_buffer *__pyx_v_buffer, int __pyx_v_flags) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  __Pyx_RefNannySetupContext("__getbuffer__", 0);
+  if (__pyx_v_buffer != NULL) {
+    __pyx_v_buffer->obj = Py_None; __Pyx_INCREF(Py_None);
+    __Pyx_GIVEREF(__pyx_v_buffer->obj);
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":56
+ * 
+ *     def __getbuffer__(self, Py_buffer *buffer, int flags):
+ *         self._view_count += 1             # <<<<<<<<<<<<<<
+ * 
+ *         PyBuffer_FillInfo(
+ */
+  __pyx_v_self->_view_count = (__pyx_v_self->_view_count + 1);
+
+  /* "asyncpg/protocol/buffer.pyx":58
+ *         self._view_count += 1
+ * 
+ *         PyBuffer_FillInfo(             # <<<<<<<<<<<<<<
+ *             buffer, self, self._buf, self._length,
+ *             1,  # read-only
+ */
+  __pyx_t_1 = PyBuffer_FillInfo(__pyx_v_buffer, ((PyObject *)__pyx_v_self), __pyx_v_self->_buf, __pyx_v_self->_length, 1, __pyx_v_flags); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(1, 58, __pyx_L1_error)
+
+  /* "asyncpg/protocol/buffer.pyx":55
+ *                 'Deallocating buffer with attached memoryviews')
+ * 
+ *     def __getbuffer__(self, Py_buffer *buffer, int flags):             # <<<<<<<<<<<<<<
+ *         self._view_count += 1
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.WriteBuffer.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = -1;
+  if (__pyx_v_buffer != NULL && __pyx_v_buffer->obj != NULL) {
+    __Pyx_GOTREF(__pyx_v_buffer->obj);
+    __Pyx_DECREF(__pyx_v_buffer->obj); __pyx_v_buffer->obj = NULL;
+  }
+  goto __pyx_L2;
+  __pyx_L0:;
+  if (__pyx_v_buffer != NULL && __pyx_v_buffer->obj == Py_None) {
+    __Pyx_GOTREF(Py_None);
+    __Pyx_DECREF(Py_None); __pyx_v_buffer->obj = NULL;
+  }
+  __pyx_L2:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":63
+ *             flags)
+ * 
+ *     def __releasebuffer__(self, Py_buffer *buffer):             # <<<<<<<<<<<<<<
+ *         self._view_count -= 1
+ * 
+ */
+
+/* Python wrapper */
+static CYTHON_UNUSED void __pyx_pw_7asyncpg_8protocol_8protocol_11WriteBuffer_7__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_buffer); /*proto*/
+static CYTHON_UNUSED void __pyx_pw_7asyncpg_8protocol_8protocol_11WriteBuffer_7__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_buffer) {
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0);
+  __pyx_pf_7asyncpg_8protocol_8protocol_11WriteBuffer_6__releasebuffer__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_v_self), ((Py_buffer *)__pyx_v_buffer));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+}
+
+static void __pyx_pf_7asyncpg_8protocol_8protocol_11WriteBuffer_6__releasebuffer__(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, CYTHON_UNUSED Py_buffer *__pyx_v_buffer) {
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__releasebuffer__", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":64
+ * 
+ *     def __releasebuffer__(self, Py_buffer *buffer):
+ *         self._view_count -= 1             # <<<<<<<<<<<<<<
+ * 
+ *     cdef inline _check_readonly(self):
+ */
+  __pyx_v_self->_view_count = (__pyx_v_self->_view_count - 1);
+
+  /* "asyncpg/protocol/buffer.pyx":63
+ *             flags)
+ * 
+ *     def __releasebuffer__(self, Py_buffer *buffer):             # <<<<<<<<<<<<<<
+ *         self._view_count -= 1
+ * 
+ */
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+}
+
+/* "asyncpg/protocol/buffer.pyx":66
+ *         self._view_count -= 1
+ * 
+ *     cdef inline _check_readonly(self):             # <<<<<<<<<<<<<<
+ *         if self._view_count:
+ *             raise BufferError('the buffer is in read-only mode')
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__check_readonly(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("_check_readonly", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":67
+ * 
+ *     cdef inline _check_readonly(self):
+ *         if self._view_count:             # <<<<<<<<<<<<<<
+ *             raise BufferError('the buffer is in read-only mode')
+ * 
+ */
+  __pyx_t_1 = (__pyx_v_self->_view_count != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":68
+ *     cdef inline _check_readonly(self):
+ *         if self._view_count:
+ *             raise BufferError('the buffer is in read-only mode')             # <<<<<<<<<<<<<<
+ * 
+ *     cdef inline len(self):
+ */
+    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_BufferError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 68, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 68, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __PYX_ERR(1, 68, __pyx_L1_error)
+
+    /* "asyncpg/protocol/buffer.pyx":67
+ * 
+ *     cdef inline _check_readonly(self):
+ *         if self._view_count:             # <<<<<<<<<<<<<<
+ *             raise BufferError('the buffer is in read-only mode')
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":66
+ *         self._view_count -= 1
+ * 
+ *     cdef inline _check_readonly(self):             # <<<<<<<<<<<<<<
+ *         if self._view_count:
+ *             raise BufferError('the buffer is in read-only mode')
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.WriteBuffer._check_readonly", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":70
+ *             raise BufferError('the buffer is in read-only mode')
+ * 
+ *     cdef inline len(self):             # <<<<<<<<<<<<<<
+ *         return self._length
+ * 
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_len(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("len", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":71
+ * 
+ *     cdef inline len(self):
+ *         return self._length             # <<<<<<<<<<<<<<
+ * 
+ *     cdef inline _ensure_alloced(self, ssize_t extra_length):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->_length); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 71, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/buffer.pyx":70
+ *             raise BufferError('the buffer is in read-only mode')
+ * 
+ *     cdef inline len(self):             # <<<<<<<<<<<<<<
+ *         return self._length
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.WriteBuffer.len", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":73
+ *         return self._length
+ * 
+ *     cdef inline _ensure_alloced(self, ssize_t extra_length):             # <<<<<<<<<<<<<<
+ *         cdef ssize_t new_size = extra_length + self._length
+ * 
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__ensure_alloced(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, Py_ssize_t __pyx_v_extra_length) {
+  Py_ssize_t __pyx_v_new_size;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("_ensure_alloced", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":74
+ * 
+ *     cdef inline _ensure_alloced(self, ssize_t extra_length):
+ *         cdef ssize_t new_size = extra_length + self._length             # <<<<<<<<<<<<<<
+ * 
+ *         if new_size > self._size:
+ */
+  __pyx_v_new_size = (__pyx_v_extra_length + __pyx_v_self->_length);
+
+  /* "asyncpg/protocol/buffer.pyx":76
+ *         cdef ssize_t new_size = extra_length + self._length
+ * 
+ *         if new_size > self._size:             # <<<<<<<<<<<<<<
+ *             self._reallocate(new_size)
+ * 
+ */
+  __pyx_t_1 = ((__pyx_v_new_size > __pyx_v_self->_size) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":77
+ * 
+ *         if new_size > self._size:
+ *             self._reallocate(new_size)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _reallocate(self, ssize_t new_size):
+ */
+    __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__reallocate(__pyx_v_self, __pyx_v_new_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 77, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "asyncpg/protocol/buffer.pyx":76
+ *         cdef ssize_t new_size = extra_length + self._length
+ * 
+ *         if new_size > self._size:             # <<<<<<<<<<<<<<
+ *             self._reallocate(new_size)
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":73
+ *         return self._length
+ * 
+ *     cdef inline _ensure_alloced(self, ssize_t extra_length):             # <<<<<<<<<<<<<<
+ *         cdef ssize_t new_size = extra_length + self._length
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.WriteBuffer._ensure_alloced", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":79
+ *             self._reallocate(new_size)
+ * 
+ *     cdef _reallocate(self, ssize_t new_size):             # <<<<<<<<<<<<<<
+ *         cdef char *new_buf
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__reallocate(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, Py_ssize_t __pyx_v_new_size) {
+  char *__pyx_v_new_buf;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  __Pyx_RefNannySetupContext("_reallocate", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":82
+ *         cdef char *new_buf
+ * 
+ *         if new_size < _BUFFER_MAX_GROW:             # <<<<<<<<<<<<<<
+ *             new_size = _BUFFER_MAX_GROW
+ *         else:
+ */
+  __pyx_t_1 = ((__pyx_v_new_size < 0x10000) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":83
+ * 
+ *         if new_size < _BUFFER_MAX_GROW:
+ *             new_size = _BUFFER_MAX_GROW             # <<<<<<<<<<<<<<
+ *         else:
+ *             # Add a little extra
+ */
+    __pyx_v_new_size = 0x10000;
+
+    /* "asyncpg/protocol/buffer.pyx":82
+ *         cdef char *new_buf
+ * 
+ *         if new_size < _BUFFER_MAX_GROW:             # <<<<<<<<<<<<<<
+ *             new_size = _BUFFER_MAX_GROW
+ *         else:
+ */
+    goto __pyx_L3;
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":86
+ *         else:
+ *             # Add a little extra
+ *             new_size += _BUFFER_INITIAL_SIZE             # <<<<<<<<<<<<<<
+ * 
+ *         if self._smallbuf_inuse:
+ */
+  /*else*/ {
+    __pyx_v_new_size = (__pyx_v_new_size + 0x400);
+  }
+  __pyx_L3:;
+
+  /* "asyncpg/protocol/buffer.pyx":88
+ *             new_size += _BUFFER_INITIAL_SIZE
+ * 
+ *         if self._smallbuf_inuse:             # <<<<<<<<<<<<<<
+ *             new_buf = <char*>PyMem_Malloc(sizeof(char) * <size_t>new_size)
+ *             if new_buf is NULL:
+ */
+  __pyx_t_1 = (__pyx_v_self->_smallbuf_inuse != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":89
+ * 
+ *         if self._smallbuf_inuse:
+ *             new_buf = <char*>PyMem_Malloc(sizeof(char) * <size_t>new_size)             # <<<<<<<<<<<<<<
+ *             if new_buf is NULL:
+ *                 self._buf = NULL
+ */
+    __pyx_v_new_buf = ((char *)PyMem_Malloc(((sizeof(char)) * ((size_t)__pyx_v_new_size))));
+
+    /* "asyncpg/protocol/buffer.pyx":90
+ *         if self._smallbuf_inuse:
+ *             new_buf = <char*>PyMem_Malloc(sizeof(char) * <size_t>new_size)
+ *             if new_buf is NULL:             # <<<<<<<<<<<<<<
+ *                 self._buf = NULL
+ *                 self._size = 0
+ */
+    __pyx_t_1 = ((__pyx_v_new_buf == NULL) != 0);
+    if (__pyx_t_1) {
+
+      /* "asyncpg/protocol/buffer.pyx":91
+ *             new_buf = <char*>PyMem_Malloc(sizeof(char) * <size_t>new_size)
+ *             if new_buf is NULL:
+ *                 self._buf = NULL             # <<<<<<<<<<<<<<
+ *                 self._size = 0
+ *                 self._length = 0
+ */
+      __pyx_v_self->_buf = NULL;
+
+      /* "asyncpg/protocol/buffer.pyx":92
+ *             if new_buf is NULL:
+ *                 self._buf = NULL
+ *                 self._size = 0             # <<<<<<<<<<<<<<
+ *                 self._length = 0
+ *                 raise MemoryError
+ */
+      __pyx_v_self->_size = 0;
+
+      /* "asyncpg/protocol/buffer.pyx":93
+ *                 self._buf = NULL
+ *                 self._size = 0
+ *                 self._length = 0             # <<<<<<<<<<<<<<
+ *                 raise MemoryError
+ *             memcpy(new_buf, self._buf, <size_t>self._size)
+ */
+      __pyx_v_self->_length = 0;
+
+      /* "asyncpg/protocol/buffer.pyx":94
+ *                 self._size = 0
+ *                 self._length = 0
+ *                 raise MemoryError             # <<<<<<<<<<<<<<
+ *             memcpy(new_buf, self._buf, <size_t>self._size)
+ *             self._size = new_size
+ */
+      PyErr_NoMemory(); __PYX_ERR(1, 94, __pyx_L1_error)
+
+      /* "asyncpg/protocol/buffer.pyx":90
+ *         if self._smallbuf_inuse:
+ *             new_buf = <char*>PyMem_Malloc(sizeof(char) * <size_t>new_size)
+ *             if new_buf is NULL:             # <<<<<<<<<<<<<<
+ *                 self._buf = NULL
+ *                 self._size = 0
+ */
+    }
+
+    /* "asyncpg/protocol/buffer.pyx":95
+ *                 self._length = 0
+ *                 raise MemoryError
+ *             memcpy(new_buf, self._buf, <size_t>self._size)             # <<<<<<<<<<<<<<
+ *             self._size = new_size
+ *             self._buf = new_buf
+ */
+    memcpy(__pyx_v_new_buf, __pyx_v_self->_buf, ((size_t)__pyx_v_self->_size));
+
+    /* "asyncpg/protocol/buffer.pyx":96
+ *                 raise MemoryError
+ *             memcpy(new_buf, self._buf, <size_t>self._size)
+ *             self._size = new_size             # <<<<<<<<<<<<<<
+ *             self._buf = new_buf
+ *             self._smallbuf_inuse = False
+ */
+    __pyx_v_self->_size = __pyx_v_new_size;
+
+    /* "asyncpg/protocol/buffer.pyx":97
+ *             memcpy(new_buf, self._buf, <size_t>self._size)
+ *             self._size = new_size
+ *             self._buf = new_buf             # <<<<<<<<<<<<<<
+ *             self._smallbuf_inuse = False
+ *         else:
+ */
+    __pyx_v_self->_buf = __pyx_v_new_buf;
+
+    /* "asyncpg/protocol/buffer.pyx":98
+ *             self._size = new_size
+ *             self._buf = new_buf
+ *             self._smallbuf_inuse = False             # <<<<<<<<<<<<<<
+ *         else:
+ *             new_buf = <char*>PyMem_Realloc(<void*>self._buf, <size_t>new_size)
+ */
+    __pyx_v_self->_smallbuf_inuse = 0;
+
+    /* "asyncpg/protocol/buffer.pyx":88
+ *             new_size += _BUFFER_INITIAL_SIZE
+ * 
+ *         if self._smallbuf_inuse:             # <<<<<<<<<<<<<<
+ *             new_buf = <char*>PyMem_Malloc(sizeof(char) * <size_t>new_size)
+ *             if new_buf is NULL:
+ */
+    goto __pyx_L4;
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":100
+ *             self._smallbuf_inuse = False
+ *         else:
+ *             new_buf = <char*>PyMem_Realloc(<void*>self._buf, <size_t>new_size)             # <<<<<<<<<<<<<<
+ *             if new_buf is NULL:
+ *                 PyMem_Free(self._buf)
+ */
+  /*else*/ {
+    __pyx_v_new_buf = ((char *)PyMem_Realloc(((void *)__pyx_v_self->_buf), ((size_t)__pyx_v_new_size)));
+
+    /* "asyncpg/protocol/buffer.pyx":101
+ *         else:
+ *             new_buf = <char*>PyMem_Realloc(<void*>self._buf, <size_t>new_size)
+ *             if new_buf is NULL:             # <<<<<<<<<<<<<<
+ *                 PyMem_Free(self._buf)
+ *                 self._buf = NULL
+ */
+    __pyx_t_1 = ((__pyx_v_new_buf == NULL) != 0);
+    if (__pyx_t_1) {
+
+      /* "asyncpg/protocol/buffer.pyx":102
+ *             new_buf = <char*>PyMem_Realloc(<void*>self._buf, <size_t>new_size)
+ *             if new_buf is NULL:
+ *                 PyMem_Free(self._buf)             # <<<<<<<<<<<<<<
+ *                 self._buf = NULL
+ *                 self._size = 0
+ */
+      PyMem_Free(__pyx_v_self->_buf);
+
+      /* "asyncpg/protocol/buffer.pyx":103
+ *             if new_buf is NULL:
+ *                 PyMem_Free(self._buf)
+ *                 self._buf = NULL             # <<<<<<<<<<<<<<
+ *                 self._size = 0
+ *                 self._length = 0
+ */
+      __pyx_v_self->_buf = NULL;
+
+      /* "asyncpg/protocol/buffer.pyx":104
+ *                 PyMem_Free(self._buf)
+ *                 self._buf = NULL
+ *                 self._size = 0             # <<<<<<<<<<<<<<
+ *                 self._length = 0
+ *                 raise MemoryError
+ */
+      __pyx_v_self->_size = 0;
+
+      /* "asyncpg/protocol/buffer.pyx":105
+ *                 self._buf = NULL
+ *                 self._size = 0
+ *                 self._length = 0             # <<<<<<<<<<<<<<
+ *                 raise MemoryError
+ *             self._buf = new_buf
+ */
+      __pyx_v_self->_length = 0;
+
+      /* "asyncpg/protocol/buffer.pyx":106
+ *                 self._size = 0
+ *                 self._length = 0
+ *                 raise MemoryError             # <<<<<<<<<<<<<<
+ *             self._buf = new_buf
+ *             self._size = new_size
+ */
+      PyErr_NoMemory(); __PYX_ERR(1, 106, __pyx_L1_error)
+
+      /* "asyncpg/protocol/buffer.pyx":101
+ *         else:
+ *             new_buf = <char*>PyMem_Realloc(<void*>self._buf, <size_t>new_size)
+ *             if new_buf is NULL:             # <<<<<<<<<<<<<<
+ *                 PyMem_Free(self._buf)
+ *                 self._buf = NULL
+ */
+    }
+
+    /* "asyncpg/protocol/buffer.pyx":107
+ *                 self._length = 0
+ *                 raise MemoryError
+ *             self._buf = new_buf             # <<<<<<<<<<<<<<
+ *             self._size = new_size
+ * 
+ */
+    __pyx_v_self->_buf = __pyx_v_new_buf;
+
+    /* "asyncpg/protocol/buffer.pyx":108
+ *                 raise MemoryError
+ *             self._buf = new_buf
+ *             self._size = new_size             # <<<<<<<<<<<<<<
+ * 
+ *     cdef inline start_message(self, char type):
+ */
+    __pyx_v_self->_size = __pyx_v_new_size;
+  }
+  __pyx_L4:;
+
+  /* "asyncpg/protocol/buffer.pyx":79
+ *             self._reallocate(new_size)
+ * 
+ *     cdef _reallocate(self, ssize_t new_size):             # <<<<<<<<<<<<<<
+ *         cdef char *new_buf
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.WriteBuffer._reallocate", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":110
+ *             self._size = new_size
+ * 
+ *     cdef inline start_message(self, char type):             # <<<<<<<<<<<<<<
+ *         if self._length != 0:
+ *             raise BufferError('cannot start_message for a non-empty buffer')
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_start_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, char __pyx_v_type) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("start_message", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":111
+ * 
+ *     cdef inline start_message(self, char type):
+ *         if self._length != 0:             # <<<<<<<<<<<<<<
+ *             raise BufferError('cannot start_message for a non-empty buffer')
+ *         self._ensure_alloced(5)
+ */
+  __pyx_t_1 = ((__pyx_v_self->_length != 0) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":112
+ *     cdef inline start_message(self, char type):
+ *         if self._length != 0:
+ *             raise BufferError('cannot start_message for a non-empty buffer')             # <<<<<<<<<<<<<<
+ *         self._ensure_alloced(5)
+ *         self._message_mode = 1
+ */
+    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_BufferError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 112, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 112, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __PYX_ERR(1, 112, __pyx_L1_error)
+
+    /* "asyncpg/protocol/buffer.pyx":111
+ * 
+ *     cdef inline start_message(self, char type):
+ *         if self._length != 0:             # <<<<<<<<<<<<<<
+ *             raise BufferError('cannot start_message for a non-empty buffer')
+ *         self._ensure_alloced(5)
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":113
+ *         if self._length != 0:
+ *             raise BufferError('cannot start_message for a non-empty buffer')
+ *         self._ensure_alloced(5)             # <<<<<<<<<<<<<<
+ *         self._message_mode = 1
+ *         self._buf[0] = type
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__ensure_alloced(__pyx_v_self, 5); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 113, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":114
+ *             raise BufferError('cannot start_message for a non-empty buffer')
+ *         self._ensure_alloced(5)
+ *         self._message_mode = 1             # <<<<<<<<<<<<<<
+ *         self._buf[0] = type
+ *         self._length = 5
+ */
+  __pyx_v_self->_message_mode = 1;
+
+  /* "asyncpg/protocol/buffer.pyx":115
+ *         self._ensure_alloced(5)
+ *         self._message_mode = 1
+ *         self._buf[0] = type             # <<<<<<<<<<<<<<
+ *         self._length = 5
+ * 
+ */
+  (__pyx_v_self->_buf[0]) = __pyx_v_type;
+
+  /* "asyncpg/protocol/buffer.pyx":116
+ *         self._message_mode = 1
+ *         self._buf[0] = type
+ *         self._length = 5             # <<<<<<<<<<<<<<
+ * 
+ *     cdef inline end_message(self):
+ */
+  __pyx_v_self->_length = 5;
+
+  /* "asyncpg/protocol/buffer.pyx":110
+ *             self._size = new_size
+ * 
+ *     cdef inline start_message(self, char type):             # <<<<<<<<<<<<<<
+ *         if self._length != 0:
+ *             raise BufferError('cannot start_message for a non-empty buffer')
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.WriteBuffer.start_message", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":118
+ *         self._length = 5
+ * 
+ *     cdef inline end_message(self):             # <<<<<<<<<<<<<<
+ *         # "length-1" to exclude the message type byte
+ *         cdef ssize_t mlen = self._length - 1
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_end_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self) {
+  Py_ssize_t __pyx_v_mlen;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("end_message", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":120
+ *     cdef inline end_message(self):
+ *         # "length-1" to exclude the message type byte
+ *         cdef ssize_t mlen = self._length - 1             # <<<<<<<<<<<<<<
+ * 
+ *         self._check_readonly()
+ */
+  __pyx_v_mlen = (__pyx_v_self->_length - 1);
+
+  /* "asyncpg/protocol/buffer.pyx":122
+ *         cdef ssize_t mlen = self._length - 1
+ * 
+ *         self._check_readonly()             # <<<<<<<<<<<<<<
+ *         if not self._message_mode:
+ *             raise BufferError(
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__check_readonly(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 122, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":123
+ * 
+ *         self._check_readonly()
+ *         if not self._message_mode:             # <<<<<<<<<<<<<<
+ *             raise BufferError(
+ *                 'end_message can only be called with start_message')
+ */
+  __pyx_t_2 = ((!(__pyx_v_self->_message_mode != 0)) != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/buffer.pyx":124
+ *         self._check_readonly()
+ *         if not self._message_mode:
+ *             raise BufferError(             # <<<<<<<<<<<<<<
+ *                 'end_message can only be called with start_message')
+ *         if self._length < 5:
+ */
+    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_BufferError); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 124, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 124, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __PYX_ERR(1, 124, __pyx_L1_error)
+
+    /* "asyncpg/protocol/buffer.pyx":123
+ * 
+ *         self._check_readonly()
+ *         if not self._message_mode:             # <<<<<<<<<<<<<<
+ *             raise BufferError(
+ *                 'end_message can only be called with start_message')
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":126
+ *             raise BufferError(
+ *                 'end_message can only be called with start_message')
+ *         if self._length < 5:             # <<<<<<<<<<<<<<
+ *             raise BufferError('end_message: buffer is too small')
+ *         if mlen > _MAXINT32:
+ */
+  __pyx_t_2 = ((__pyx_v_self->_length < 5) != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/buffer.pyx":127
+ *                 'end_message can only be called with start_message')
+ *         if self._length < 5:
+ *             raise BufferError('end_message: buffer is too small')             # <<<<<<<<<<<<<<
+ *         if mlen > _MAXINT32:
+ *             raise BufferError('end_message: message is too large')
+ */
+    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_BufferError); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 127, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 127, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __PYX_ERR(1, 127, __pyx_L1_error)
+
+    /* "asyncpg/protocol/buffer.pyx":126
+ *             raise BufferError(
+ *                 'end_message can only be called with start_message')
+ *         if self._length < 5:             # <<<<<<<<<<<<<<
+ *             raise BufferError('end_message: buffer is too small')
+ *         if mlen > _MAXINT32:
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":128
+ *         if self._length < 5:
+ *             raise BufferError('end_message: buffer is too small')
+ *         if mlen > _MAXINT32:             # <<<<<<<<<<<<<<
+ *             raise BufferError('end_message: message is too large')
+ * 
+ */
+  __pyx_t_2 = ((__pyx_v_mlen > 0x7FFFFFFF) != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/buffer.pyx":129
+ *             raise BufferError('end_message: buffer is too small')
+ *         if mlen > _MAXINT32:
+ *             raise BufferError('end_message: message is too large')             # <<<<<<<<<<<<<<
+ * 
+ *         hton.pack_int32(&self._buf[1], <int32_t>mlen)
+ */
+    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_BufferError); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 129, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 129, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __PYX_ERR(1, 129, __pyx_L1_error)
+
+    /* "asyncpg/protocol/buffer.pyx":128
+ *         if self._length < 5:
+ *             raise BufferError('end_message: buffer is too small')
+ *         if mlen > _MAXINT32:             # <<<<<<<<<<<<<<
+ *             raise BufferError('end_message: message is too large')
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":131
+ *             raise BufferError('end_message: message is too large')
+ * 
+ *         hton.pack_int32(&self._buf[1], <int32_t>mlen)             # <<<<<<<<<<<<<<
+ *         return self
+ * 
+ */
+  __pyx_f_7asyncpg_8protocol_4hton_pack_int32((&(__pyx_v_self->_buf[1])), ((int32_t)__pyx_v_mlen));
+
+  /* "asyncpg/protocol/buffer.pyx":132
+ * 
+ *         hton.pack_int32(&self._buf[1], <int32_t>mlen)
+ *         return self             # <<<<<<<<<<<<<<
+ * 
+ *     cdef write_buffer(self, WriteBuffer buf):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(((PyObject *)__pyx_v_self));
+  __pyx_r = ((PyObject *)__pyx_v_self);
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/buffer.pyx":118
+ *         self._length = 5
+ * 
+ *     cdef inline end_message(self):             # <<<<<<<<<<<<<<
+ *         # "length-1" to exclude the message type byte
+ *         cdef ssize_t mlen = self._length - 1
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.WriteBuffer.end_message", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":134
+ *         return self
+ * 
+ *     cdef write_buffer(self, WriteBuffer buf):             # <<<<<<<<<<<<<<
+ *         self._check_readonly()
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_buffer(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  __Pyx_RefNannySetupContext("write_buffer", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":135
+ * 
+ *     cdef write_buffer(self, WriteBuffer buf):
+ *         self._check_readonly()             # <<<<<<<<<<<<<<
+ * 
+ *         if not buf._length:
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__check_readonly(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 135, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":137
+ *         self._check_readonly()
+ * 
+ *         if not buf._length:             # <<<<<<<<<<<<<<
+ *             return
+ * 
+ */
+  __pyx_t_2 = ((!(__pyx_v_buf->_length != 0)) != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/buffer.pyx":138
+ * 
+ *         if not buf._length:
+ *             return             # <<<<<<<<<<<<<<
+ * 
+ *         self._ensure_alloced(buf._length)
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/buffer.pyx":137
+ *         self._check_readonly()
+ * 
+ *         if not buf._length:             # <<<<<<<<<<<<<<
+ *             return
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":140
+ *             return
+ * 
+ *         self._ensure_alloced(buf._length)             # <<<<<<<<<<<<<<
+ *         memcpy(self._buf + self._length,
+ *                <void*>buf._buf,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__ensure_alloced(__pyx_v_self, __pyx_v_buf->_length); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 140, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":141
+ * 
+ *         self._ensure_alloced(buf._length)
+ *         memcpy(self._buf + self._length,             # <<<<<<<<<<<<<<
+ *                <void*>buf._buf,
+ *                <size_t>buf._length)
+ */
+  memcpy((__pyx_v_self->_buf + __pyx_v_self->_length), ((void *)__pyx_v_buf->_buf), ((size_t)__pyx_v_buf->_length));
+
+  /* "asyncpg/protocol/buffer.pyx":144
+ *                <void*>buf._buf,
+ *                <size_t>buf._length)
+ *         self._length += buf._length             # <<<<<<<<<<<<<<
+ * 
+ *     cdef write_byte(self, char b):
+ */
+  __pyx_v_self->_length = (__pyx_v_self->_length + __pyx_v_buf->_length);
+
+  /* "asyncpg/protocol/buffer.pyx":134
+ *         return self
+ * 
+ *     cdef write_buffer(self, WriteBuffer buf):             # <<<<<<<<<<<<<<
+ *         self._check_readonly()
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.WriteBuffer.write_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":146
+ *         self._length += buf._length
+ * 
+ *     cdef write_byte(self, char b):             # <<<<<<<<<<<<<<
+ *         self._check_readonly()
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, char __pyx_v_b) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("write_byte", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":147
+ * 
+ *     cdef write_byte(self, char b):
+ *         self._check_readonly()             # <<<<<<<<<<<<<<
+ * 
+ *         self._ensure_alloced(1)
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__check_readonly(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 147, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":149
+ *         self._check_readonly()
+ * 
+ *         self._ensure_alloced(1)             # <<<<<<<<<<<<<<
+ *         self._buf[self._length] = b
+ *         self._length += 1
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__ensure_alloced(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 149, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":150
+ * 
+ *         self._ensure_alloced(1)
+ *         self._buf[self._length] = b             # <<<<<<<<<<<<<<
+ *         self._length += 1
+ * 
+ */
+  (__pyx_v_self->_buf[__pyx_v_self->_length]) = __pyx_v_b;
+
+  /* "asyncpg/protocol/buffer.pyx":151
+ *         self._ensure_alloced(1)
+ *         self._buf[self._length] = b
+ *         self._length += 1             # <<<<<<<<<<<<<<
+ * 
+ *     cdef write_bytes(self, bytes data):
+ */
+  __pyx_v_self->_length = (__pyx_v_self->_length + 1);
+
+  /* "asyncpg/protocol/buffer.pyx":146
+ *         self._length += buf._length
+ * 
+ *     cdef write_byte(self, char b):             # <<<<<<<<<<<<<<
+ *         self._check_readonly()
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.WriteBuffer.write_byte", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":153
+ *         self._length += 1
+ * 
+ *     cdef write_bytes(self, bytes data):             # <<<<<<<<<<<<<<
+ *         cdef char* buf
+ *         cdef ssize_t len
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_bytes(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, PyObject *__pyx_v_data) {
+  char *__pyx_v_buf;
+  Py_ssize_t __pyx_v_len;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("write_bytes", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":157
+ *         cdef ssize_t len
+ * 
+ *         cpython.PyBytes_AsStringAndSize(data, &buf, &len)             # <<<<<<<<<<<<<<
+ *         self.write_cstr(buf, len)
+ * 
+ */
+  __pyx_t_1 = PyBytes_AsStringAndSize(__pyx_v_data, (&__pyx_v_buf), ((Py_ssize_t *)(&__pyx_v_len))); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(1, 157, __pyx_L1_error)
+
+  /* "asyncpg/protocol/buffer.pyx":158
+ * 
+ *         cpython.PyBytes_AsStringAndSize(data, &buf, &len)
+ *         self.write_cstr(buf, len)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef write_bytestring(self, bytes string):
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_cstr(__pyx_v_self, __pyx_v_buf, __pyx_v_len); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 158, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":153
+ *         self._length += 1
+ * 
+ *     cdef write_bytes(self, bytes data):             # <<<<<<<<<<<<<<
+ *         cdef char* buf
+ *         cdef ssize_t len
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.WriteBuffer.write_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":160
+ *         self.write_cstr(buf, len)
+ * 
+ *     cdef write_bytestring(self, bytes string):             # <<<<<<<<<<<<<<
+ *         cdef char* buf
+ *         cdef ssize_t len
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_bytestring(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, PyObject *__pyx_v_string) {
+  char *__pyx_v_buf;
+  Py_ssize_t __pyx_v_len;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("write_bytestring", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":164
+ *         cdef ssize_t len
+ * 
+ *         cpython.PyBytes_AsStringAndSize(string, &buf, &len)             # <<<<<<<<<<<<<<
+ *         # PyBytes_AsStringAndSize returns a null-terminated buffer,
+ *         # but the null byte is not counted in len. hence the + 1
+ */
+  __pyx_t_1 = PyBytes_AsStringAndSize(__pyx_v_string, (&__pyx_v_buf), ((Py_ssize_t *)(&__pyx_v_len))); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(1, 164, __pyx_L1_error)
+
+  /* "asyncpg/protocol/buffer.pyx":167
+ *         # PyBytes_AsStringAndSize returns a null-terminated buffer,
+ *         # but the null byte is not counted in len. hence the + 1
+ *         self.write_cstr(buf, len + 1)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef write_str(self, str string, str encoding):
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_cstr(__pyx_v_self, __pyx_v_buf, (__pyx_v_len + 1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 167, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":160
+ *         self.write_cstr(buf, len)
+ * 
+ *     cdef write_bytestring(self, bytes string):             # <<<<<<<<<<<<<<
+ *         cdef char* buf
+ *         cdef ssize_t len
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.WriteBuffer.write_bytestring", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":169
+ *         self.write_cstr(buf, len + 1)
+ * 
+ *     cdef write_str(self, str string, str encoding):             # <<<<<<<<<<<<<<
+ *         self.write_bytestring(string.encode(encoding))
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_str(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, PyObject *__pyx_v_string, PyObject *__pyx_v_encoding) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  __Pyx_RefNannySetupContext("write_str", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":170
+ * 
+ *     cdef write_str(self, str string, str encoding):
+ *         self.write_bytestring(string.encode(encoding))             # <<<<<<<<<<<<<<
+ * 
+ *     cdef write_cstr(self, char *data, ssize_t len):
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_string, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 170, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (!__pyx_t_3) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_encoding); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 170, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_encoding};
+      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 170, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_encoding};
+      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 170, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else
+    #endif
+    {
+      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 170, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
+      __Pyx_INCREF(__pyx_v_encoding);
+      __Pyx_GIVEREF(__pyx_v_encoding);
+      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_encoding);
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 170, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 170, __pyx_L1_error)
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_bytestring(__pyx_v_self, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 170, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":169
+ *         self.write_cstr(buf, len + 1)
+ * 
+ *     cdef write_str(self, str string, str encoding):             # <<<<<<<<<<<<<<
+ *         self.write_bytestring(string.encode(encoding))
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.WriteBuffer.write_str", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":172
+ *         self.write_bytestring(string.encode(encoding))
+ * 
+ *     cdef write_cstr(self, char *data, ssize_t len):             # <<<<<<<<<<<<<<
+ *         self._check_readonly()
+ *         self._ensure_alloced(len)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_cstr(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, char *__pyx_v_data, Py_ssize_t __pyx_v_len) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("write_cstr", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":173
+ * 
+ *     cdef write_cstr(self, char *data, ssize_t len):
+ *         self._check_readonly()             # <<<<<<<<<<<<<<
+ *         self._ensure_alloced(len)
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__check_readonly(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 173, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":174
+ *     cdef write_cstr(self, char *data, ssize_t len):
+ *         self._check_readonly()
+ *         self._ensure_alloced(len)             # <<<<<<<<<<<<<<
+ * 
+ *         memcpy(self._buf + self._length, <void*>data, <size_t>len)
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__ensure_alloced(__pyx_v_self, __pyx_v_len); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 174, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":176
+ *         self._ensure_alloced(len)
+ * 
+ *         memcpy(self._buf + self._length, <void*>data, <size_t>len)             # <<<<<<<<<<<<<<
+ *         self._length += len
+ * 
+ */
+  memcpy((__pyx_v_self->_buf + __pyx_v_self->_length), ((void *)__pyx_v_data), ((size_t)__pyx_v_len));
+
+  /* "asyncpg/protocol/buffer.pyx":177
+ * 
+ *         memcpy(self._buf + self._length, <void*>data, <size_t>len)
+ *         self._length += len             # <<<<<<<<<<<<<<
+ * 
+ *     cdef write_int16(self, int16_t i):
+ */
+  __pyx_v_self->_length = (__pyx_v_self->_length + __pyx_v_len);
+
+  /* "asyncpg/protocol/buffer.pyx":172
+ *         self.write_bytestring(string.encode(encoding))
+ * 
+ *     cdef write_cstr(self, char *data, ssize_t len):             # <<<<<<<<<<<<<<
+ *         self._check_readonly()
+ *         self._ensure_alloced(len)
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.WriteBuffer.write_cstr", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":179
+ *         self._length += len
+ * 
+ *     cdef write_int16(self, int16_t i):             # <<<<<<<<<<<<<<
+ *         self._check_readonly()
+ *         self._ensure_alloced(2)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int16(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, int16_t __pyx_v_i) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("write_int16", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":180
+ * 
+ *     cdef write_int16(self, int16_t i):
+ *         self._check_readonly()             # <<<<<<<<<<<<<<
+ *         self._ensure_alloced(2)
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__check_readonly(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 180, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":181
+ *     cdef write_int16(self, int16_t i):
+ *         self._check_readonly()
+ *         self._ensure_alloced(2)             # <<<<<<<<<<<<<<
+ * 
+ *         hton.pack_int16(&self._buf[self._length], i)
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__ensure_alloced(__pyx_v_self, 2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 181, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":183
+ *         self._ensure_alloced(2)
+ * 
+ *         hton.pack_int16(&self._buf[self._length], i)             # <<<<<<<<<<<<<<
+ *         self._length += 2
+ * 
+ */
+  __pyx_f_7asyncpg_8protocol_4hton_pack_int16((&(__pyx_v_self->_buf[__pyx_v_self->_length])), __pyx_v_i);
+
+  /* "asyncpg/protocol/buffer.pyx":184
+ * 
+ *         hton.pack_int16(&self._buf[self._length], i)
+ *         self._length += 2             # <<<<<<<<<<<<<<
+ * 
+ *     cdef write_int32(self, int32_t i):
+ */
+  __pyx_v_self->_length = (__pyx_v_self->_length + 2);
+
+  /* "asyncpg/protocol/buffer.pyx":179
+ *         self._length += len
+ * 
+ *     cdef write_int16(self, int16_t i):             # <<<<<<<<<<<<<<
+ *         self._check_readonly()
+ *         self._ensure_alloced(2)
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.WriteBuffer.write_int16", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":186
+ *         self._length += 2
+ * 
+ *     cdef write_int32(self, int32_t i):             # <<<<<<<<<<<<<<
+ *         self._check_readonly()
+ *         self._ensure_alloced(4)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, int32_t __pyx_v_i) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("write_int32", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":187
+ * 
+ *     cdef write_int32(self, int32_t i):
+ *         self._check_readonly()             # <<<<<<<<<<<<<<
+ *         self._ensure_alloced(4)
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__check_readonly(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 187, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":188
+ *     cdef write_int32(self, int32_t i):
+ *         self._check_readonly()
+ *         self._ensure_alloced(4)             # <<<<<<<<<<<<<<
+ * 
+ *         hton.pack_int32(&self._buf[self._length], i)
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__ensure_alloced(__pyx_v_self, 4); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 188, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":190
+ *         self._ensure_alloced(4)
+ * 
+ *         hton.pack_int32(&self._buf[self._length], i)             # <<<<<<<<<<<<<<
+ *         self._length += 4
+ * 
+ */
+  __pyx_f_7asyncpg_8protocol_4hton_pack_int32((&(__pyx_v_self->_buf[__pyx_v_self->_length])), __pyx_v_i);
+
+  /* "asyncpg/protocol/buffer.pyx":191
+ * 
+ *         hton.pack_int32(&self._buf[self._length], i)
+ *         self._length += 4             # <<<<<<<<<<<<<<
+ * 
+ *     cdef write_int64(self, int64_t i):
+ */
+  __pyx_v_self->_length = (__pyx_v_self->_length + 4);
+
+  /* "asyncpg/protocol/buffer.pyx":186
+ *         self._length += 2
+ * 
+ *     cdef write_int32(self, int32_t i):             # <<<<<<<<<<<<<<
+ *         self._check_readonly()
+ *         self._ensure_alloced(4)
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.WriteBuffer.write_int32", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":193
+ *         self._length += 4
+ * 
+ *     cdef write_int64(self, int64_t i):             # <<<<<<<<<<<<<<
+ *         self._check_readonly()
+ *         self._ensure_alloced(8)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int64(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, int64_t __pyx_v_i) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("write_int64", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":194
+ * 
+ *     cdef write_int64(self, int64_t i):
+ *         self._check_readonly()             # <<<<<<<<<<<<<<
+ *         self._ensure_alloced(8)
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__check_readonly(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 194, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":195
+ *     cdef write_int64(self, int64_t i):
+ *         self._check_readonly()
+ *         self._ensure_alloced(8)             # <<<<<<<<<<<<<<
+ * 
+ *         hton.pack_int64(&self._buf[self._length], i)
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__ensure_alloced(__pyx_v_self, 8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 195, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":197
+ *         self._ensure_alloced(8)
+ * 
+ *         hton.pack_int64(&self._buf[self._length], i)             # <<<<<<<<<<<<<<
+ *         self._length += 8
+ * 
+ */
+  __pyx_f_7asyncpg_8protocol_4hton_pack_int64((&(__pyx_v_self->_buf[__pyx_v_self->_length])), __pyx_v_i);
+
+  /* "asyncpg/protocol/buffer.pyx":198
+ * 
+ *         hton.pack_int64(&self._buf[self._length], i)
+ *         self._length += 8             # <<<<<<<<<<<<<<
+ * 
+ *     cdef write_float(self, float f):
+ */
+  __pyx_v_self->_length = (__pyx_v_self->_length + 8);
+
+  /* "asyncpg/protocol/buffer.pyx":193
+ *         self._length += 4
+ * 
+ *     cdef write_int64(self, int64_t i):             # <<<<<<<<<<<<<<
+ *         self._check_readonly()
+ *         self._ensure_alloced(8)
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.WriteBuffer.write_int64", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":200
+ *         self._length += 8
+ * 
+ *     cdef write_float(self, float f):             # <<<<<<<<<<<<<<
+ *         self._check_readonly()
+ *         self._ensure_alloced(4)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_float(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, float __pyx_v_f) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("write_float", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":201
+ * 
+ *     cdef write_float(self, float f):
+ *         self._check_readonly()             # <<<<<<<<<<<<<<
+ *         self._ensure_alloced(4)
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__check_readonly(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 201, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":202
+ *     cdef write_float(self, float f):
+ *         self._check_readonly()
+ *         self._ensure_alloced(4)             # <<<<<<<<<<<<<<
+ * 
+ *         hton.pack_float(&self._buf[self._length], f)
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__ensure_alloced(__pyx_v_self, 4); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 202, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":204
+ *         self._ensure_alloced(4)
+ * 
+ *         hton.pack_float(&self._buf[self._length], f)             # <<<<<<<<<<<<<<
+ *         self._length += 4
+ * 
+ */
+  __pyx_f_7asyncpg_8protocol_4hton_pack_float((&(__pyx_v_self->_buf[__pyx_v_self->_length])), __pyx_v_f);
+
+  /* "asyncpg/protocol/buffer.pyx":205
+ * 
+ *         hton.pack_float(&self._buf[self._length], f)
+ *         self._length += 4             # <<<<<<<<<<<<<<
+ * 
+ *     cdef write_double(self, double d):
+ */
+  __pyx_v_self->_length = (__pyx_v_self->_length + 4);
+
+  /* "asyncpg/protocol/buffer.pyx":200
+ *         self._length += 8
+ * 
+ *     cdef write_float(self, float f):             # <<<<<<<<<<<<<<
+ *         self._check_readonly()
+ *         self._ensure_alloced(4)
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.WriteBuffer.write_float", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":207
+ *         self._length += 4
+ * 
+ *     cdef write_double(self, double d):             # <<<<<<<<<<<<<<
+ *         self._check_readonly()
+ *         self._ensure_alloced(8)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_double(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, double __pyx_v_d) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("write_double", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":208
+ * 
+ *     cdef write_double(self, double d):
+ *         self._check_readonly()             # <<<<<<<<<<<<<<
+ *         self._ensure_alloced(8)
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__check_readonly(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 208, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":209
+ *     cdef write_double(self, double d):
+ *         self._check_readonly()
+ *         self._ensure_alloced(8)             # <<<<<<<<<<<<<<
+ * 
+ *         hton.pack_double(&self._buf[self._length], d)
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__ensure_alloced(__pyx_v_self, 8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 209, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":211
+ *         self._ensure_alloced(8)
+ * 
+ *         hton.pack_double(&self._buf[self._length], d)             # <<<<<<<<<<<<<<
+ *         self._length += 8
+ * 
+ */
+  __pyx_f_7asyncpg_8protocol_4hton_pack_double((&(__pyx_v_self->_buf[__pyx_v_self->_length])), __pyx_v_d);
+
+  /* "asyncpg/protocol/buffer.pyx":212
+ * 
+ *         hton.pack_double(&self._buf[self._length], d)
+ *         self._length += 8             # <<<<<<<<<<<<<<
+ * 
+ *     @staticmethod
+ */
+  __pyx_v_self->_length = (__pyx_v_self->_length + 8);
+
+  /* "asyncpg/protocol/buffer.pyx":207
+ *         self._length += 4
+ * 
+ *     cdef write_double(self, double d):             # <<<<<<<<<<<<<<
+ *         self._check_readonly()
+ *         self._ensure_alloced(8)
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.WriteBuffer.write_double", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":215
+ * 
+ *     @staticmethod
+ *     cdef WriteBuffer new_message(char type):             # <<<<<<<<<<<<<<
+ *         cdef WriteBuffer buf
+ *         buf = WriteBuffer.__new__(WriteBuffer)
+ */
+
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new_message(char __pyx_v_type) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf = 0;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("new_message", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":217
+ *     cdef WriteBuffer new_message(char type):
+ *         cdef WriteBuffer buf
+ *         buf = WriteBuffer.__new__(WriteBuffer)             # <<<<<<<<<<<<<<
+ *         buf.start_message(type)
+ *         return buf
+ */
+  __pyx_t_1 = __pyx_tp_new_7asyncpg_8protocol_8protocol_WriteBuffer(((PyTypeObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_WriteBuffer), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 217, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7asyncpg_8protocol_8protocol_WriteBuffer)))) __PYX_ERR(1, 217, __pyx_L1_error)
+  __pyx_v_buf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":218
+ *         cdef WriteBuffer buf
+ *         buf = WriteBuffer.__new__(WriteBuffer)
+ *         buf.start_message(type)             # <<<<<<<<<<<<<<
+ *         return buf
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_start_message(__pyx_v_buf, __pyx_v_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 218, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":219
+ *         buf = WriteBuffer.__new__(WriteBuffer)
+ *         buf.start_message(type)
+ *         return buf             # <<<<<<<<<<<<<<
+ * 
+ *     @staticmethod
+ */
+  __Pyx_XDECREF(((PyObject *)__pyx_r));
+  __Pyx_INCREF(((PyObject *)__pyx_v_buf));
+  __pyx_r = __pyx_v_buf;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/buffer.pyx":215
+ * 
+ *     @staticmethod
+ *     cdef WriteBuffer new_message(char type):             # <<<<<<<<<<<<<<
+ *         cdef WriteBuffer buf
+ *         buf = WriteBuffer.__new__(WriteBuffer)
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.WriteBuffer.new_message", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_buf);
+  __Pyx_XGIVEREF((PyObject *)__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":222
+ * 
+ *     @staticmethod
+ *     cdef WriteBuffer new():             # <<<<<<<<<<<<<<
+ *         cdef WriteBuffer buf
+ *         buf = WriteBuffer.__new__(WriteBuffer)
+ */
+
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new(void) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf = 0;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("new", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":224
+ *     cdef WriteBuffer new():
+ *         cdef WriteBuffer buf
+ *         buf = WriteBuffer.__new__(WriteBuffer)             # <<<<<<<<<<<<<<
+ *         return buf
+ * 
+ */
+  __pyx_t_1 = __pyx_tp_new_7asyncpg_8protocol_8protocol_WriteBuffer(((PyTypeObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_WriteBuffer), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 224, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7asyncpg_8protocol_8protocol_WriteBuffer)))) __PYX_ERR(1, 224, __pyx_L1_error)
+  __pyx_v_buf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":225
+ *         cdef WriteBuffer buf
+ *         buf = WriteBuffer.__new__(WriteBuffer)
+ *         return buf             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(((PyObject *)__pyx_r));
+  __Pyx_INCREF(((PyObject *)__pyx_v_buf));
+  __pyx_r = __pyx_v_buf;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/buffer.pyx":222
+ * 
+ *     @staticmethod
+ *     cdef WriteBuffer new():             # <<<<<<<<<<<<<<
+ *         cdef WriteBuffer buf
+ *         buf = WriteBuffer.__new__(WriteBuffer)
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.WriteBuffer.new", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_buf);
+  __Pyx_XGIVEREF((PyObject *)__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":233
+ * cdef class ReadBuffer:
+ * 
+ *     def __cinit__(self):             # <<<<<<<<<<<<<<
+ *         self._bufs = collections.deque()
+ *         self._bufs_append = self._bufs.append
+ */
+
+/* Python wrapper */
+static int __pyx_pw_7asyncpg_8protocol_8protocol_10ReadBuffer_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pw_7asyncpg_8protocol_8protocol_10ReadBuffer_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
+  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
+    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
+  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_10ReadBuffer___cinit__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static int __pyx_pf_7asyncpg_8protocol_8protocol_10ReadBuffer___cinit__(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("__cinit__", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":234
+ * 
+ *     def __cinit__(self):
+ *         self._bufs = collections.deque()             # <<<<<<<<<<<<<<
+ *         self._bufs_append = self._bufs.append
+ *         self._bufs_popleft = self._bufs.popleft
+ */
+  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_collections); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 234, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_deque); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 234, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = NULL;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
+    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
+    if (likely(__pyx_t_2)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+      __Pyx_INCREF(__pyx_t_2);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_3, function);
+    }
+  }
+  if (__pyx_t_2) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 234, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  } else {
+    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 234, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_GIVEREF(__pyx_t_1);
+  __Pyx_GOTREF(__pyx_v_self->_bufs);
+  __Pyx_DECREF(__pyx_v_self->_bufs);
+  __pyx_v_self->_bufs = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":235
+ *     def __cinit__(self):
+ *         self._bufs = collections.deque()
+ *         self._bufs_append = self._bufs.append             # <<<<<<<<<<<<<<
+ *         self._bufs_popleft = self._bufs.popleft
+ *         self._bufs_len = 0
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_bufs, __pyx_n_s_append); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 235, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  __Pyx_GOTREF(__pyx_v_self->_bufs_append);
+  __Pyx_DECREF(__pyx_v_self->_bufs_append);
+  __pyx_v_self->_bufs_append = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":236
+ *         self._bufs = collections.deque()
+ *         self._bufs_append = self._bufs.append
+ *         self._bufs_popleft = self._bufs.popleft             # <<<<<<<<<<<<<<
+ *         self._bufs_len = 0
+ *         self._buf0 = None
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_bufs, __pyx_n_s_popleft); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 236, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  __Pyx_GOTREF(__pyx_v_self->_bufs_popleft);
+  __Pyx_DECREF(__pyx_v_self->_bufs_popleft);
+  __pyx_v_self->_bufs_popleft = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":237
+ *         self._bufs_append = self._bufs.append
+ *         self._bufs_popleft = self._bufs.popleft
+ *         self._bufs_len = 0             # <<<<<<<<<<<<<<
+ *         self._buf0 = None
+ *         self._buf0_prev = None
+ */
+  __pyx_v_self->_bufs_len = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":238
+ *         self._bufs_popleft = self._bufs.popleft
+ *         self._bufs_len = 0
+ *         self._buf0 = None             # <<<<<<<<<<<<<<
+ *         self._buf0_prev = None
+ *         self._pos0 = 0
+ */
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->_buf0);
+  __Pyx_DECREF(__pyx_v_self->_buf0);
+  __pyx_v_self->_buf0 = ((PyObject*)Py_None);
+
+  /* "asyncpg/protocol/buffer.pyx":239
+ *         self._bufs_len = 0
+ *         self._buf0 = None
+ *         self._buf0_prev = None             # <<<<<<<<<<<<<<
+ *         self._pos0 = 0
+ *         self._len0 = 0
+ */
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->_buf0_prev);
+  __Pyx_DECREF(__pyx_v_self->_buf0_prev);
+  __pyx_v_self->_buf0_prev = ((PyObject*)Py_None);
+
+  /* "asyncpg/protocol/buffer.pyx":240
+ *         self._buf0 = None
+ *         self._buf0_prev = None
+ *         self._pos0 = 0             # <<<<<<<<<<<<<<
+ *         self._len0 = 0
+ *         self._length = 0
+ */
+  __pyx_v_self->_pos0 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":241
+ *         self._buf0_prev = None
+ *         self._pos0 = 0
+ *         self._len0 = 0             # <<<<<<<<<<<<<<
+ *         self._length = 0
+ * 
+ */
+  __pyx_v_self->_len0 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":242
+ *         self._pos0 = 0
+ *         self._len0 = 0
+ *         self._length = 0             # <<<<<<<<<<<<<<
+ * 
+ *         self._current_message_type = 0
+ */
+  __pyx_v_self->_length = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":244
+ *         self._length = 0
+ * 
+ *         self._current_message_type = 0             # <<<<<<<<<<<<<<
+ *         self._current_message_len = 0
+ *         self._current_message_len_unread = 0
+ */
+  __pyx_v_self->_current_message_type = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":245
+ * 
+ *         self._current_message_type = 0
+ *         self._current_message_len = 0             # <<<<<<<<<<<<<<
+ *         self._current_message_len_unread = 0
+ *         self._current_message_ready = 0
+ */
+  __pyx_v_self->_current_message_len = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":246
+ *         self._current_message_type = 0
+ *         self._current_message_len = 0
+ *         self._current_message_len_unread = 0             # <<<<<<<<<<<<<<
+ *         self._current_message_ready = 0
+ * 
+ */
+  __pyx_v_self->_current_message_len_unread = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":247
+ *         self._current_message_len = 0
+ *         self._current_message_len_unread = 0
+ *         self._current_message_ready = 0             # <<<<<<<<<<<<<<
+ * 
+ *     cdef feed_data(self, data):
+ */
+  __pyx_v_self->_current_message_ready = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":233
+ * cdef class ReadBuffer:
+ * 
+ *     def __cinit__(self):             # <<<<<<<<<<<<<<
+ *         self._bufs = collections.deque()
+ *         self._bufs_append = self._bufs.append
+ */
+
+  /* function exit code */
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ReadBuffer.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":249
+ *         self._current_message_ready = 0
+ * 
+ *     cdef feed_data(self, data):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             ssize_t dlen
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_feed_data(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self, PyObject *__pyx_v_data) {
+  Py_ssize_t __pyx_v_dlen;
+  PyObject *__pyx_v_data_bytes = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  __Pyx_RefNannySetupContext("feed_data", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":254
+ *             bytes data_bytes
+ * 
+ *         if not cpython.PyBytes_CheckExact(data):             # <<<<<<<<<<<<<<
+ *             raise BufferError('feed_data: bytes object expected')
+ *         data_bytes = <bytes>data
+ */
+  __pyx_t_1 = ((!(PyBytes_CheckExact(__pyx_v_data) != 0)) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":255
+ * 
+ *         if not cpython.PyBytes_CheckExact(data):
+ *             raise BufferError('feed_data: bytes object expected')             # <<<<<<<<<<<<<<
+ *         data_bytes = <bytes>data
+ * 
+ */
+    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_BufferError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 255, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 255, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __PYX_ERR(1, 255, __pyx_L1_error)
+
+    /* "asyncpg/protocol/buffer.pyx":254
+ *             bytes data_bytes
+ * 
+ *         if not cpython.PyBytes_CheckExact(data):             # <<<<<<<<<<<<<<
+ *             raise BufferError('feed_data: bytes object expected')
+ *         data_bytes = <bytes>data
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":256
+ *         if not cpython.PyBytes_CheckExact(data):
+ *             raise BufferError('feed_data: bytes object expected')
+ *         data_bytes = <bytes>data             # <<<<<<<<<<<<<<
+ * 
+ *         dlen = cpython.Py_SIZE(data_bytes)
+ */
+  __pyx_t_3 = __pyx_v_data;
+  __Pyx_INCREF(__pyx_t_3);
+  __pyx_v_data_bytes = ((PyObject*)__pyx_t_3);
+  __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":258
+ *         data_bytes = <bytes>data
+ * 
+ *         dlen = cpython.Py_SIZE(data_bytes)             # <<<<<<<<<<<<<<
+ *         if dlen == 0:
+ *             # EOF?
+ */
+  __pyx_v_dlen = Py_SIZE(__pyx_v_data_bytes);
+
+  /* "asyncpg/protocol/buffer.pyx":259
+ * 
+ *         dlen = cpython.Py_SIZE(data_bytes)
+ *         if dlen == 0:             # <<<<<<<<<<<<<<
+ *             # EOF?
+ *             return
+ */
+  __pyx_t_1 = ((__pyx_v_dlen == 0) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":261
+ *         if dlen == 0:
+ *             # EOF?
+ *             return             # <<<<<<<<<<<<<<
+ * 
+ *         self._bufs_append(data_bytes)
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/buffer.pyx":259
+ * 
+ *         dlen = cpython.Py_SIZE(data_bytes)
+ *         if dlen == 0:             # <<<<<<<<<<<<<<
+ *             # EOF?
+ *             return
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":263
+ *             return
+ * 
+ *         self._bufs_append(data_bytes)             # <<<<<<<<<<<<<<
+ *         self._length += dlen
+ * 
+ */
+  __Pyx_INCREF(__pyx_v_self->_bufs_append);
+  __pyx_t_2 = __pyx_v_self->_bufs_append; __pyx_t_4 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_4)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_4);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (!__pyx_t_4) {
+    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_data_bytes); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 263, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_data_bytes};
+      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 263, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_data_bytes};
+      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 263, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+    } else
+    #endif
+    {
+      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 263, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
+      __Pyx_INCREF(__pyx_v_data_bytes);
+      __Pyx_GIVEREF(__pyx_v_data_bytes);
+      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_data_bytes);
+      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 263, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":264
+ * 
+ *         self._bufs_append(data_bytes)
+ *         self._length += dlen             # <<<<<<<<<<<<<<
+ * 
+ *         if self._bufs_len == 0:
+ */
+  __pyx_v_self->_length = (__pyx_v_self->_length + __pyx_v_dlen);
+
+  /* "asyncpg/protocol/buffer.pyx":266
+ *         self._length += dlen
+ * 
+ *         if self._bufs_len == 0:             # <<<<<<<<<<<<<<
+ *             # First buffer
+ *             self._len0 = dlen
+ */
+  __pyx_t_1 = ((__pyx_v_self->_bufs_len == 0) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":268
+ *         if self._bufs_len == 0:
+ *             # First buffer
+ *             self._len0 = dlen             # <<<<<<<<<<<<<<
+ *             self._buf0 = data_bytes
+ * 
+ */
+    __pyx_v_self->_len0 = __pyx_v_dlen;
+
+    /* "asyncpg/protocol/buffer.pyx":269
+ *             # First buffer
+ *             self._len0 = dlen
+ *             self._buf0 = data_bytes             # <<<<<<<<<<<<<<
+ * 
+ *         self._bufs_len += 1
+ */
+    __Pyx_INCREF(__pyx_v_data_bytes);
+    __Pyx_GIVEREF(__pyx_v_data_bytes);
+    __Pyx_GOTREF(__pyx_v_self->_buf0);
+    __Pyx_DECREF(__pyx_v_self->_buf0);
+    __pyx_v_self->_buf0 = __pyx_v_data_bytes;
+
+    /* "asyncpg/protocol/buffer.pyx":266
+ *         self._length += dlen
+ * 
+ *         if self._bufs_len == 0:             # <<<<<<<<<<<<<<
+ *             # First buffer
+ *             self._len0 = dlen
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":271
+ *             self._buf0 = data_bytes
+ * 
+ *         self._bufs_len += 1             # <<<<<<<<<<<<<<
+ * 
+ *     cdef inline _ensure_first_buf(self):
+ */
+  __pyx_v_self->_bufs_len = (__pyx_v_self->_bufs_len + 1);
+
+  /* "asyncpg/protocol/buffer.pyx":249
+ *         self._current_message_ready = 0
+ * 
+ *     cdef feed_data(self, data):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             ssize_t dlen
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ReadBuffer.feed_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_data_bytes);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":273
+ *         self._bufs_len += 1
+ * 
+ *     cdef inline _ensure_first_buf(self):             # <<<<<<<<<<<<<<
+ *         if self._len0 == 0:
+ *             raise BufferError('empty first buffer')
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__ensure_first_buf(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("_ensure_first_buf", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":274
+ * 
+ *     cdef inline _ensure_first_buf(self):
+ *         if self._len0 == 0:             # <<<<<<<<<<<<<<
+ *             raise BufferError('empty first buffer')
+ * 
+ */
+  __pyx_t_1 = ((__pyx_v_self->_len0 == 0) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":275
+ *     cdef inline _ensure_first_buf(self):
+ *         if self._len0 == 0:
+ *             raise BufferError('empty first buffer')             # <<<<<<<<<<<<<<
+ * 
+ *         if self._pos0 == self._len0:
+ */
+    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_BufferError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 275, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 275, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __PYX_ERR(1, 275, __pyx_L1_error)
+
+    /* "asyncpg/protocol/buffer.pyx":274
+ * 
+ *     cdef inline _ensure_first_buf(self):
+ *         if self._len0 == 0:             # <<<<<<<<<<<<<<
+ *             raise BufferError('empty first buffer')
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":277
+ *             raise BufferError('empty first buffer')
+ * 
+ *         if self._pos0 == self._len0:             # <<<<<<<<<<<<<<
+ *             self._switch_to_next_buf()
+ * 
+ */
+  __pyx_t_1 = ((__pyx_v_self->_pos0 == __pyx_v_self->_len0) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":278
+ * 
+ *         if self._pos0 == self._len0:
+ *             self._switch_to_next_buf()             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _switch_to_next_buf(self):
+ */
+    __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__switch_to_next_buf(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 278, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/buffer.pyx":277
+ *             raise BufferError('empty first buffer')
+ * 
+ *         if self._pos0 == self._len0:             # <<<<<<<<<<<<<<
+ *             self._switch_to_next_buf()
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":273
+ *         self._bufs_len += 1
+ * 
+ *     cdef inline _ensure_first_buf(self):             # <<<<<<<<<<<<<<
+ *         if self._len0 == 0:
+ *             raise BufferError('empty first buffer')
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ReadBuffer._ensure_first_buf", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":280
+ *             self._switch_to_next_buf()
+ * 
+ *     cdef _switch_to_next_buf(self):             # <<<<<<<<<<<<<<
+ *         # The first buffer is fully read, discard it
+ *         self._bufs_popleft()
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__switch_to_next_buf(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  Py_ssize_t __pyx_t_4;
+  int __pyx_t_5;
+  __Pyx_RefNannySetupContext("_switch_to_next_buf", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":282
+ *     cdef _switch_to_next_buf(self):
+ *         # The first buffer is fully read, discard it
+ *         self._bufs_popleft()             # <<<<<<<<<<<<<<
+ *         self._bufs_len -= 1
+ * 
+ */
+  __Pyx_INCREF(__pyx_v_self->_bufs_popleft);
+  __pyx_t_2 = __pyx_v_self->_bufs_popleft; __pyx_t_3 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (__pyx_t_3) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 282, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  } else {
+    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 282, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":283
+ *         # The first buffer is fully read, discard it
+ *         self._bufs_popleft()
+ *         self._bufs_len -= 1             # <<<<<<<<<<<<<<
+ * 
+ *         # Shouldn't fail, since we've checked that `_length >= 1`
+ */
+  __pyx_v_self->_bufs_len = (__pyx_v_self->_bufs_len - 1);
+
+  /* "asyncpg/protocol/buffer.pyx":287
+ *         # Shouldn't fail, since we've checked that `_length >= 1`
+ *         # in _ensure_first_buf()
+ *         self._buf0_prev = self._buf0             # <<<<<<<<<<<<<<
+ *         self._buf0 = <bytes>self._bufs[0]
+ * 
+ */
+  __pyx_t_1 = __pyx_v_self->_buf0;
+  __Pyx_INCREF(__pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  __Pyx_GOTREF(__pyx_v_self->_buf0_prev);
+  __Pyx_DECREF(__pyx_v_self->_buf0_prev);
+  __pyx_v_self->_buf0_prev = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":288
+ *         # in _ensure_first_buf()
+ *         self._buf0_prev = self._buf0
+ *         self._buf0 = <bytes>self._bufs[0]             # <<<<<<<<<<<<<<
+ * 
+ *         self._pos0 = 0
+ */
+  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->_bufs, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 288, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __pyx_t_1;
+  __Pyx_INCREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_GIVEREF(__pyx_t_2);
+  __Pyx_GOTREF(__pyx_v_self->_buf0);
+  __Pyx_DECREF(__pyx_v_self->_buf0);
+  __pyx_v_self->_buf0 = ((PyObject*)__pyx_t_2);
+  __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":290
+ *         self._buf0 = <bytes>self._bufs[0]
+ * 
+ *         self._pos0 = 0             # <<<<<<<<<<<<<<
+ *         self._len0 = len(self._buf0)
+ * 
+ */
+  __pyx_v_self->_pos0 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":291
+ * 
+ *         self._pos0 = 0
+ *         self._len0 = len(self._buf0)             # <<<<<<<<<<<<<<
+ * 
+ *         if ASYNCPG_DEBUG:
+ */
+  __pyx_t_2 = __pyx_v_self->_buf0;
+  __Pyx_INCREF(__pyx_t_2);
+  if (unlikely(__pyx_t_2 == Py_None)) {
+    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
+    __PYX_ERR(1, 291, __pyx_L1_error)
+  }
+  __pyx_t_4 = PyBytes_GET_SIZE(__pyx_t_2); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(1, 291, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_v_self->_len0 = __pyx_t_4;
+
+  /* "asyncpg/protocol/buffer.pyx":293
+ *         self._len0 = len(self._buf0)
+ * 
+ *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
+ *             if self._len0 < 1:
+ *                 raise RuntimeError(
+ */
+  __pyx_t_5 = (ASYNCPG_DEBUG != 0);
+  if (__pyx_t_5) {
+
+    /* "asyncpg/protocol/buffer.pyx":294
+ * 
+ *         if ASYNCPG_DEBUG:
+ *             if self._len0 < 1:             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError(
+ *                     'debug: second buffer of ReadBuffer is empty')
+ */
+    __pyx_t_5 = ((__pyx_v_self->_len0 < 1) != 0);
+    if (__pyx_t_5) {
+
+      /* "asyncpg/protocol/buffer.pyx":295
+ *         if ASYNCPG_DEBUG:
+ *             if self._len0 < 1:
+ *                 raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                     'debug: second buffer of ReadBuffer is empty')
+ * 
+ */
+      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 295, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __PYX_ERR(1, 295, __pyx_L1_error)
+
+      /* "asyncpg/protocol/buffer.pyx":294
+ * 
+ *         if ASYNCPG_DEBUG:
+ *             if self._len0 < 1:             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError(
+ *                     'debug: second buffer of ReadBuffer is empty')
+ */
+    }
+
+    /* "asyncpg/protocol/buffer.pyx":293
+ *         self._len0 = len(self._buf0)
+ * 
+ *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
+ *             if self._len0 < 1:
+ *                 raise RuntimeError(
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":280
+ *             self._switch_to_next_buf()
+ * 
+ *     cdef _switch_to_next_buf(self):             # <<<<<<<<<<<<<<
+ *         # The first buffer is fully read, discard it
+ *         self._bufs_popleft()
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ReadBuffer._switch_to_next_buf", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":298
+ *                     'debug: second buffer of ReadBuffer is empty')
+ * 
+ *     cdef inline char* _try_read_bytes(self, ssize_t nbytes):             # <<<<<<<<<<<<<<
+ *         # Important: caller must call _ensure_first_buf() prior
+ *         # to calling try_read_bytes, and must not overread
+ */
+
+static CYTHON_INLINE char *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__try_read_bytes(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self, Py_ssize_t __pyx_v_nbytes) {
+  char *__pyx_v_result;
+  char *__pyx_r;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("_try_read_bytes", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":305
+ *             char * result
+ * 
+ *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
+ *             if nbytes > self._length:
+ *                 return NULL
+ */
+  __pyx_t_1 = (ASYNCPG_DEBUG != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":306
+ * 
+ *         if ASYNCPG_DEBUG:
+ *             if nbytes > self._length:             # <<<<<<<<<<<<<<
+ *                 return NULL
+ * 
+ */
+    __pyx_t_1 = ((__pyx_v_nbytes > __pyx_v_self->_length) != 0);
+    if (__pyx_t_1) {
+
+      /* "asyncpg/protocol/buffer.pyx":307
+ *         if ASYNCPG_DEBUG:
+ *             if nbytes > self._length:
+ *                 return NULL             # <<<<<<<<<<<<<<
+ * 
+ *         if self._current_message_ready:
+ */
+      __pyx_r = NULL;
+      goto __pyx_L0;
+
+      /* "asyncpg/protocol/buffer.pyx":306
+ * 
+ *         if ASYNCPG_DEBUG:
+ *             if nbytes > self._length:             # <<<<<<<<<<<<<<
+ *                 return NULL
+ * 
+ */
+    }
+
+    /* "asyncpg/protocol/buffer.pyx":305
+ *             char * result
+ * 
+ *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
+ *             if nbytes > self._length:
+ *                 return NULL
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":309
+ *                 return NULL
+ * 
+ *         if self._current_message_ready:             # <<<<<<<<<<<<<<
+ *             if self._current_message_len_unread < nbytes:
+ *                 return NULL
+ */
+  __pyx_t_1 = (__pyx_v_self->_current_message_ready != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":310
+ * 
+ *         if self._current_message_ready:
+ *             if self._current_message_len_unread < nbytes:             # <<<<<<<<<<<<<<
+ *                 return NULL
+ * 
+ */
+    __pyx_t_1 = ((__pyx_v_self->_current_message_len_unread < __pyx_v_nbytes) != 0);
+    if (__pyx_t_1) {
+
+      /* "asyncpg/protocol/buffer.pyx":311
+ *         if self._current_message_ready:
+ *             if self._current_message_len_unread < nbytes:
+ *                 return NULL             # <<<<<<<<<<<<<<
+ * 
+ *         if self._pos0 + nbytes <= self._len0:
+ */
+      __pyx_r = NULL;
+      goto __pyx_L0;
+
+      /* "asyncpg/protocol/buffer.pyx":310
+ * 
+ *         if self._current_message_ready:
+ *             if self._current_message_len_unread < nbytes:             # <<<<<<<<<<<<<<
+ *                 return NULL
+ * 
+ */
+    }
+
+    /* "asyncpg/protocol/buffer.pyx":309
+ *                 return NULL
+ * 
+ *         if self._current_message_ready:             # <<<<<<<<<<<<<<
+ *             if self._current_message_len_unread < nbytes:
+ *                 return NULL
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":313
+ *                 return NULL
+ * 
+ *         if self._pos0 + nbytes <= self._len0:             # <<<<<<<<<<<<<<
+ *             result = cpython.PyBytes_AS_STRING(self._buf0)
+ *             result += self._pos0
+ */
+  __pyx_t_1 = (((__pyx_v_self->_pos0 + __pyx_v_nbytes) <= __pyx_v_self->_len0) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":314
+ * 
+ *         if self._pos0 + nbytes <= self._len0:
+ *             result = cpython.PyBytes_AS_STRING(self._buf0)             # <<<<<<<<<<<<<<
+ *             result += self._pos0
+ *             self._pos0 += nbytes
+ */
+    __pyx_t_2 = __pyx_v_self->_buf0;
+    __Pyx_INCREF(__pyx_t_2);
+    __pyx_v_result = PyBytes_AS_STRING(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "asyncpg/protocol/buffer.pyx":315
+ *         if self._pos0 + nbytes <= self._len0:
+ *             result = cpython.PyBytes_AS_STRING(self._buf0)
+ *             result += self._pos0             # <<<<<<<<<<<<<<
+ *             self._pos0 += nbytes
+ *             self._length -= nbytes
+ */
+    __pyx_v_result = (__pyx_v_result + __pyx_v_self->_pos0);
+
+    /* "asyncpg/protocol/buffer.pyx":316
+ *             result = cpython.PyBytes_AS_STRING(self._buf0)
+ *             result += self._pos0
+ *             self._pos0 += nbytes             # <<<<<<<<<<<<<<
+ *             self._length -= nbytes
+ *             if self._current_message_ready:
+ */
+    __pyx_v_self->_pos0 = (__pyx_v_self->_pos0 + __pyx_v_nbytes);
+
+    /* "asyncpg/protocol/buffer.pyx":317
+ *             result += self._pos0
+ *             self._pos0 += nbytes
+ *             self._length -= nbytes             # <<<<<<<<<<<<<<
+ *             if self._current_message_ready:
+ *                 self._current_message_len_unread -= nbytes
+ */
+    __pyx_v_self->_length = (__pyx_v_self->_length - __pyx_v_nbytes);
+
+    /* "asyncpg/protocol/buffer.pyx":318
+ *             self._pos0 += nbytes
+ *             self._length -= nbytes
+ *             if self._current_message_ready:             # <<<<<<<<<<<<<<
+ *                 self._current_message_len_unread -= nbytes
+ *             return result
+ */
+    __pyx_t_1 = (__pyx_v_self->_current_message_ready != 0);
+    if (__pyx_t_1) {
+
+      /* "asyncpg/protocol/buffer.pyx":319
+ *             self._length -= nbytes
+ *             if self._current_message_ready:
+ *                 self._current_message_len_unread -= nbytes             # <<<<<<<<<<<<<<
+ *             return result
+ *         else:
+ */
+      __pyx_v_self->_current_message_len_unread = (__pyx_v_self->_current_message_len_unread - __pyx_v_nbytes);
+
+      /* "asyncpg/protocol/buffer.pyx":318
+ *             self._pos0 += nbytes
+ *             self._length -= nbytes
+ *             if self._current_message_ready:             # <<<<<<<<<<<<<<
+ *                 self._current_message_len_unread -= nbytes
+ *             return result
+ */
+    }
+
+    /* "asyncpg/protocol/buffer.pyx":320
+ *             if self._current_message_ready:
+ *                 self._current_message_len_unread -= nbytes
+ *             return result             # <<<<<<<<<<<<<<
+ *         else:
+ *             return NULL
+ */
+    __pyx_r = __pyx_v_result;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/buffer.pyx":313
+ *                 return NULL
+ * 
+ *         if self._pos0 + nbytes <= self._len0:             # <<<<<<<<<<<<<<
+ *             result = cpython.PyBytes_AS_STRING(self._buf0)
+ *             result += self._pos0
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":322
+ *             return result
+ *         else:
+ *             return NULL             # <<<<<<<<<<<<<<
+ * 
+ *     cdef inline read(self, ssize_t nbytes):
+ */
+  /*else*/ {
+    __pyx_r = NULL;
+    goto __pyx_L0;
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":298
+ *                     'debug: second buffer of ReadBuffer is empty')
+ * 
+ *     cdef inline char* _try_read_bytes(self, ssize_t nbytes):             # <<<<<<<<<<<<<<
+ *         # Important: caller must call _ensure_first_buf() prior
+ *         # to calling try_read_bytes, and must not overread
+ */
+
+  /* function exit code */
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":324
+ *             return NULL
+ * 
+ *     cdef inline read(self, ssize_t nbytes):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             object result
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self, Py_ssize_t __pyx_v_nbytes) {
+  PyObject *__pyx_v_result = 0;
+  Py_ssize_t __pyx_v_nread;
+  char *__pyx_v_buf;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  Py_ssize_t __pyx_t_9;
+  Py_ssize_t __pyx_t_10;
+  __Pyx_RefNannySetupContext("read", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":330
+ *             char *buf
+ * 
+ *         self._ensure_first_buf()             # <<<<<<<<<<<<<<
+ *         buf = self._try_read_bytes(nbytes)
+ *         if buf != NULL:
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__ensure_first_buf(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 330, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":331
+ * 
+ *         self._ensure_first_buf()
+ *         buf = self._try_read_bytes(nbytes)             # <<<<<<<<<<<<<<
+ *         if buf != NULL:
+ *             return Memory.new(buf, self._buf0, nbytes)
+ */
+  __pyx_v_buf = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__try_read_bytes(__pyx_v_self, __pyx_v_nbytes);
+
+  /* "asyncpg/protocol/buffer.pyx":332
+ *         self._ensure_first_buf()
+ *         buf = self._try_read_bytes(nbytes)
+ *         if buf != NULL:             # <<<<<<<<<<<<<<
+ *             return Memory.new(buf, self._buf0, nbytes)
+ * 
+ */
+  __pyx_t_2 = ((__pyx_v_buf != NULL) != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/buffer.pyx":333
+ *         buf = self._try_read_bytes(nbytes)
+ *         if buf != NULL:
+ *             return Memory.new(buf, self._buf0, nbytes)             # <<<<<<<<<<<<<<
+ * 
+ *         if nbytes > self._length:
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_1 = __pyx_v_self->_buf0;
+    __Pyx_INCREF(__pyx_t_1);
+    __pyx_t_3 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_6Memory_new(__pyx_v_buf, __pyx_t_1, __pyx_v_nbytes)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 333, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_r = __pyx_t_3;
+    __pyx_t_3 = 0;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/buffer.pyx":332
+ *         self._ensure_first_buf()
+ *         buf = self._try_read_bytes(nbytes)
+ *         if buf != NULL:             # <<<<<<<<<<<<<<
+ *             return Memory.new(buf, self._buf0, nbytes)
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":335
+ *             return Memory.new(buf, self._buf0, nbytes)
+ * 
+ *         if nbytes > self._length:             # <<<<<<<<<<<<<<
+ *             raise BufferError(
+ *                 'not enough data to read {} bytes'.format(nbytes))
+ */
+  __pyx_t_2 = ((__pyx_v_nbytes > __pyx_v_self->_length) != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/buffer.pyx":336
+ * 
+ *         if nbytes > self._length:
+ *             raise BufferError(             # <<<<<<<<<<<<<<
+ *                 'not enough data to read {} bytes'.format(nbytes))
+ * 
+ */
+    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_BufferError); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 336, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+
+    /* "asyncpg/protocol/buffer.pyx":337
+ *         if nbytes > self._length:
+ *             raise BufferError(
+ *                 'not enough data to read {} bytes'.format(nbytes))             # <<<<<<<<<<<<<<
+ * 
+ *         if self._current_message_ready:
+ */
+    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_not_enough_data_to_read_bytes, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 337, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_nbytes); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 337, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_7 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
+      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
+      if (likely(__pyx_t_7)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+        __Pyx_INCREF(__pyx_t_7);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_5, function);
+      }
+    }
+    if (!__pyx_t_7) {
+      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 337, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_GOTREF(__pyx_t_4);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_5)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
+        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 337, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
+        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 337, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 337, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_8);
+        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
+        __Pyx_GIVEREF(__pyx_t_6);
+        PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_6);
+        __pyx_t_6 = 0;
+        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 337, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_5 = NULL;
+    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
+      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
+      if (likely(__pyx_t_5)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
+        __Pyx_INCREF(__pyx_t_5);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_1, function);
+      }
+    }
+    if (!__pyx_t_5) {
+      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 336, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_1)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
+        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 336, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
+        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 336, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 336, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_8);
+        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
+        __Pyx_GIVEREF(__pyx_t_4);
+        PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_4);
+        __pyx_t_4 = 0;
+        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 336, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __PYX_ERR(1, 336, __pyx_L1_error)
+
+    /* "asyncpg/protocol/buffer.pyx":335
+ *             return Memory.new(buf, self._buf0, nbytes)
+ * 
+ *         if nbytes > self._length:             # <<<<<<<<<<<<<<
+ *             raise BufferError(
+ *                 'not enough data to read {} bytes'.format(nbytes))
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":339
+ *                 'not enough data to read {} bytes'.format(nbytes))
+ * 
+ *         if self._current_message_ready:             # <<<<<<<<<<<<<<
+ *             self._current_message_len_unread -= nbytes
+ *             if self._current_message_len_unread < 0:
+ */
+  __pyx_t_2 = (__pyx_v_self->_current_message_ready != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/buffer.pyx":340
+ * 
+ *         if self._current_message_ready:
+ *             self._current_message_len_unread -= nbytes             # <<<<<<<<<<<<<<
+ *             if self._current_message_len_unread < 0:
+ *                 raise BufferError('buffer overread')
+ */
+    __pyx_v_self->_current_message_len_unread = (__pyx_v_self->_current_message_len_unread - __pyx_v_nbytes);
+
+    /* "asyncpg/protocol/buffer.pyx":341
+ *         if self._current_message_ready:
+ *             self._current_message_len_unread -= nbytes
+ *             if self._current_message_len_unread < 0:             # <<<<<<<<<<<<<<
+ *                 raise BufferError('buffer overread')
+ * 
+ */
+    __pyx_t_2 = ((__pyx_v_self->_current_message_len_unread < 0) != 0);
+    if (__pyx_t_2) {
+
+      /* "asyncpg/protocol/buffer.pyx":342
+ *             self._current_message_len_unread -= nbytes
+ *             if self._current_message_len_unread < 0:
+ *                 raise BufferError('buffer overread')             # <<<<<<<<<<<<<<
+ * 
+ *         result = bytearray()
+ */
+      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_BufferError); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 342, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 342, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __PYX_ERR(1, 342, __pyx_L1_error)
+
+      /* "asyncpg/protocol/buffer.pyx":341
+ *         if self._current_message_ready:
+ *             self._current_message_len_unread -= nbytes
+ *             if self._current_message_len_unread < 0:             # <<<<<<<<<<<<<<
+ *                 raise BufferError('buffer overread')
+ * 
+ */
+    }
+
+    /* "asyncpg/protocol/buffer.pyx":339
+ *                 'not enough data to read {} bytes'.format(nbytes))
+ * 
+ *         if self._current_message_ready:             # <<<<<<<<<<<<<<
+ *             self._current_message_len_unread -= nbytes
+ *             if self._current_message_len_unread < 0:
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":344
+ *                 raise BufferError('buffer overread')
+ * 
+ *         result = bytearray()             # <<<<<<<<<<<<<<
+ *         while True:
+ *             if self._pos0 + nbytes > self._len0:
+ */
+  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyByteArray_Type)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 344, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_result = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":345
+ * 
+ *         result = bytearray()
+ *         while True:             # <<<<<<<<<<<<<<
+ *             if self._pos0 + nbytes > self._len0:
+ *                 result.extend(self._buf0[self._pos0:])
+ */
+  while (1) {
+
+    /* "asyncpg/protocol/buffer.pyx":346
+ *         result = bytearray()
+ *         while True:
+ *             if self._pos0 + nbytes > self._len0:             # <<<<<<<<<<<<<<
+ *                 result.extend(self._buf0[self._pos0:])
+ *                 nread = self._len0 - self._pos0
+ */
+    __pyx_t_2 = (((__pyx_v_self->_pos0 + __pyx_v_nbytes) > __pyx_v_self->_len0) != 0);
+    if (__pyx_t_2) {
+
+      /* "asyncpg/protocol/buffer.pyx":347
+ *         while True:
+ *             if self._pos0 + nbytes > self._len0:
+ *                 result.extend(self._buf0[self._pos0:])             # <<<<<<<<<<<<<<
+ *                 nread = self._len0 - self._pos0
+ *                 self._pos0 = self._len0
+ */
+      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_result, __pyx_n_s_extend); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 347, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      if (unlikely(__pyx_v_self->_buf0 == Py_None)) {
+        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+        __PYX_ERR(1, 347, __pyx_L1_error)
+      }
+      __pyx_t_8 = PySequence_GetSlice(__pyx_v_self->_buf0, __pyx_v_self->_pos0, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 347, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_8);
+      __pyx_t_4 = NULL;
+      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
+        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
+        if (likely(__pyx_t_4)) {
+          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+          __Pyx_INCREF(__pyx_t_4);
+          __Pyx_INCREF(function);
+          __Pyx_DECREF_SET(__pyx_t_3, function);
+        }
+      }
+      if (!__pyx_t_4) {
+        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 347, __pyx_L1_error)
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        __Pyx_GOTREF(__pyx_t_1);
+      } else {
+        #if CYTHON_FAST_PYCALL
+        if (PyFunction_Check(__pyx_t_3)) {
+          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_8};
+          __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 347, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+          __Pyx_GOTREF(__pyx_t_1);
+          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        } else
+        #endif
+        #if CYTHON_FAST_PYCCALL
+        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
+          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_8};
+          __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 347, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+          __Pyx_GOTREF(__pyx_t_1);
+          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        } else
+        #endif
+        {
+          __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 347, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_5);
+          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
+          __Pyx_GIVEREF(__pyx_t_8);
+          PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_8);
+          __pyx_t_8 = 0;
+          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 347, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_1);
+          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        }
+      }
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+      /* "asyncpg/protocol/buffer.pyx":348
+ *             if self._pos0 + nbytes > self._len0:
+ *                 result.extend(self._buf0[self._pos0:])
+ *                 nread = self._len0 - self._pos0             # <<<<<<<<<<<<<<
+ *                 self._pos0 = self._len0
+ *                 self._length -= nread
+ */
+      __pyx_v_nread = (__pyx_v_self->_len0 - __pyx_v_self->_pos0);
+
+      /* "asyncpg/protocol/buffer.pyx":349
+ *                 result.extend(self._buf0[self._pos0:])
+ *                 nread = self._len0 - self._pos0
+ *                 self._pos0 = self._len0             # <<<<<<<<<<<<<<
+ *                 self._length -= nread
+ *                 nbytes -= nread
+ */
+      __pyx_t_9 = __pyx_v_self->_len0;
+      __pyx_v_self->_pos0 = __pyx_t_9;
+
+      /* "asyncpg/protocol/buffer.pyx":350
+ *                 nread = self._len0 - self._pos0
+ *                 self._pos0 = self._len0
+ *                 self._length -= nread             # <<<<<<<<<<<<<<
+ *                 nbytes -= nread
+ *                 self._ensure_first_buf()
+ */
+      __pyx_v_self->_length = (__pyx_v_self->_length - __pyx_v_nread);
+
+      /* "asyncpg/protocol/buffer.pyx":351
+ *                 self._pos0 = self._len0
+ *                 self._length -= nread
+ *                 nbytes -= nread             # <<<<<<<<<<<<<<
+ *                 self._ensure_first_buf()
+ * 
+ */
+      __pyx_v_nbytes = (__pyx_v_nbytes - __pyx_v_nread);
+
+      /* "asyncpg/protocol/buffer.pyx":352
+ *                 self._length -= nread
+ *                 nbytes -= nread
+ *                 self._ensure_first_buf()             # <<<<<<<<<<<<<<
+ * 
+ *             else:
+ */
+      __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__ensure_first_buf(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 352, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+      /* "asyncpg/protocol/buffer.pyx":346
+ *         result = bytearray()
+ *         while True:
+ *             if self._pos0 + nbytes > self._len0:             # <<<<<<<<<<<<<<
+ *                 result.extend(self._buf0[self._pos0:])
+ *                 nread = self._len0 - self._pos0
+ */
+      goto __pyx_L9;
+    }
+
+    /* "asyncpg/protocol/buffer.pyx":355
+ * 
+ *             else:
+ *                 result.extend(self._buf0[self._pos0:self._pos0 + nbytes])             # <<<<<<<<<<<<<<
+ *                 self._pos0 += nbytes
+ *                 self._length -= nbytes
+ */
+    /*else*/ {
+      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_result, __pyx_n_s_extend); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 355, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      if (unlikely(__pyx_v_self->_buf0 == Py_None)) {
+        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+        __PYX_ERR(1, 355, __pyx_L1_error)
+      }
+      __pyx_t_5 = PySequence_GetSlice(__pyx_v_self->_buf0, __pyx_v_self->_pos0, (__pyx_v_self->_pos0 + __pyx_v_nbytes)); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 355, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_5);
+      __pyx_t_8 = NULL;
+      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
+        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
+        if (likely(__pyx_t_8)) {
+          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+          __Pyx_INCREF(__pyx_t_8);
+          __Pyx_INCREF(function);
+          __Pyx_DECREF_SET(__pyx_t_3, function);
+        }
+      }
+      if (!__pyx_t_8) {
+        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 355, __pyx_L1_error)
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_GOTREF(__pyx_t_1);
+      } else {
+        #if CYTHON_FAST_PYCALL
+        if (PyFunction_Check(__pyx_t_3)) {
+          PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_5};
+          __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 355, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+          __Pyx_GOTREF(__pyx_t_1);
+          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        } else
+        #endif
+        #if CYTHON_FAST_PYCCALL
+        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
+          PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_5};
+          __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 355, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+          __Pyx_GOTREF(__pyx_t_1);
+          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        } else
+        #endif
+        {
+          __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 355, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_4);
+          __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_8); __pyx_t_8 = NULL;
+          __Pyx_GIVEREF(__pyx_t_5);
+          PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_5);
+          __pyx_t_5 = 0;
+          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 355, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_1);
+          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        }
+      }
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+      /* "asyncpg/protocol/buffer.pyx":356
+ *             else:
+ *                 result.extend(self._buf0[self._pos0:self._pos0 + nbytes])
+ *                 self._pos0 += nbytes             # <<<<<<<<<<<<<<
+ *                 self._length -= nbytes
+ *                 return Memory.new(
+ */
+      __pyx_v_self->_pos0 = (__pyx_v_self->_pos0 + __pyx_v_nbytes);
+
+      /* "asyncpg/protocol/buffer.pyx":357
+ *                 result.extend(self._buf0[self._pos0:self._pos0 + nbytes])
+ *                 self._pos0 += nbytes
+ *                 self._length -= nbytes             # <<<<<<<<<<<<<<
+ *                 return Memory.new(
+ *                     PyByteArray_AsString(result),
+ */
+      __pyx_v_self->_length = (__pyx_v_self->_length - __pyx_v_nbytes);
+
+      /* "asyncpg/protocol/buffer.pyx":358
+ *                 self._pos0 += nbytes
+ *                 self._length -= nbytes
+ *                 return Memory.new(             # <<<<<<<<<<<<<<
+ *                     PyByteArray_AsString(result),
+ *                     result,
+ */
+      __Pyx_XDECREF(__pyx_r);
+
+      /* "asyncpg/protocol/buffer.pyx":361
+ *                     PyByteArray_AsString(result),
+ *                     result,
+ *                     len(result))             # <<<<<<<<<<<<<<
+ * 
+ *     cdef inline read_byte(self):
+ */
+      __pyx_t_10 = PyObject_Length(__pyx_v_result); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(1, 361, __pyx_L1_error)
+
+      /* "asyncpg/protocol/buffer.pyx":358
+ *                 self._pos0 += nbytes
+ *                 self._length -= nbytes
+ *                 return Memory.new(             # <<<<<<<<<<<<<<
+ *                     PyByteArray_AsString(result),
+ *                     result,
+ */
+      __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_6Memory_new(PyByteArray_AsString(__pyx_v_result), __pyx_v_result, __pyx_t_10)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 358, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_r = __pyx_t_1;
+      __pyx_t_1 = 0;
+      goto __pyx_L0;
+    }
+    __pyx_L9:;
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":324
+ *             return NULL
+ * 
+ *     cdef inline read(self, ssize_t nbytes):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             object result
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ReadBuffer.read", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_result);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":363
+ *                     len(result))
+ * 
+ *     cdef inline read_byte(self):             # <<<<<<<<<<<<<<
+ *         cdef char* first_byte
+ * 
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_byte(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self) {
+  char *__pyx_v_first_byte;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  __Pyx_RefNannySetupContext("read_byte", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":366
+ *         cdef char* first_byte
+ * 
+ *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
+ *             if not self._buf0:
+ *                 raise RuntimeError(
+ */
+  __pyx_t_1 = (ASYNCPG_DEBUG != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":367
+ * 
+ *         if ASYNCPG_DEBUG:
+ *             if not self._buf0:             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError(
+ *                     'debug: first buffer of ReadBuffer is empty')
+ */
+    __pyx_t_1 = (__pyx_v_self->_buf0 != Py_None) && (PyBytes_GET_SIZE(__pyx_v_self->_buf0) != 0);
+    __pyx_t_2 = ((!__pyx_t_1) != 0);
+    if (__pyx_t_2) {
+
+      /* "asyncpg/protocol/buffer.pyx":368
+ *         if ASYNCPG_DEBUG:
+ *             if not self._buf0:
+ *                 raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                     'debug: first buffer of ReadBuffer is empty')
+ * 
+ */
+      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 368, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __PYX_ERR(1, 368, __pyx_L1_error)
+
+      /* "asyncpg/protocol/buffer.pyx":367
+ * 
+ *         if ASYNCPG_DEBUG:
+ *             if not self._buf0:             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError(
+ *                     'debug: first buffer of ReadBuffer is empty')
+ */
+    }
+
+    /* "asyncpg/protocol/buffer.pyx":366
+ *         cdef char* first_byte
+ * 
+ *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
+ *             if not self._buf0:
+ *                 raise RuntimeError(
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":371
+ *                     'debug: first buffer of ReadBuffer is empty')
+ * 
+ *         self._ensure_first_buf()             # <<<<<<<<<<<<<<
+ *         first_byte = self._try_read_bytes(1)
+ *         if first_byte is NULL:
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__ensure_first_buf(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 371, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":372
+ * 
+ *         self._ensure_first_buf()
+ *         first_byte = self._try_read_bytes(1)             # <<<<<<<<<<<<<<
+ *         if first_byte is NULL:
+ *             raise BufferError('not enough data to read one byte')
+ */
+  __pyx_v_first_byte = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__try_read_bytes(__pyx_v_self, 1);
+
+  /* "asyncpg/protocol/buffer.pyx":373
+ *         self._ensure_first_buf()
+ *         first_byte = self._try_read_bytes(1)
+ *         if first_byte is NULL:             # <<<<<<<<<<<<<<
+ *             raise BufferError('not enough data to read one byte')
+ * 
+ */
+  __pyx_t_2 = ((__pyx_v_first_byte == NULL) != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/buffer.pyx":374
+ *         first_byte = self._try_read_bytes(1)
+ *         if first_byte is NULL:
+ *             raise BufferError('not enough data to read one byte')             # <<<<<<<<<<<<<<
+ * 
+ *         return first_byte[0]
+ */
+    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_BufferError); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 374, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 374, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __PYX_ERR(1, 374, __pyx_L1_error)
+
+    /* "asyncpg/protocol/buffer.pyx":373
+ *         self._ensure_first_buf()
+ *         first_byte = self._try_read_bytes(1)
+ *         if first_byte is NULL:             # <<<<<<<<<<<<<<
+ *             raise BufferError('not enough data to read one byte')
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":376
+ *             raise BufferError('not enough data to read one byte')
+ * 
+ *         return first_byte[0]             # <<<<<<<<<<<<<<
+ * 
+ *     cdef inline read_bytes(self, ssize_t n):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_4 = __Pyx_PyInt_From_char((__pyx_v_first_byte[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 376, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_r = __pyx_t_4;
+  __pyx_t_4 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/buffer.pyx":363
+ *                     len(result))
+ * 
+ *     cdef inline read_byte(self):             # <<<<<<<<<<<<<<
+ *         cdef char* first_byte
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ReadBuffer.read_byte", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":378
+ *         return first_byte[0]
+ * 
+ *     cdef inline read_bytes(self, ssize_t n):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             Memory mem
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_bytes(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self, Py_ssize_t __pyx_v_n) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *__pyx_v_mem = 0;
+  char *__pyx_v_cbuf;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("read_bytes", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":383
+ *             char *cbuf
+ * 
+ *         self._ensure_first_buf()             # <<<<<<<<<<<<<<
+ *         cbuf = self._try_read_bytes(n)
+ *         if cbuf != NULL:
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__ensure_first_buf(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 383, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":384
+ * 
+ *         self._ensure_first_buf()
+ *         cbuf = self._try_read_bytes(n)             # <<<<<<<<<<<<<<
+ *         if cbuf != NULL:
+ *             return cbuf
+ */
+  __pyx_v_cbuf = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__try_read_bytes(__pyx_v_self, __pyx_v_n);
+
+  /* "asyncpg/protocol/buffer.pyx":385
+ *         self._ensure_first_buf()
+ *         cbuf = self._try_read_bytes(n)
+ *         if cbuf != NULL:             # <<<<<<<<<<<<<<
+ *             return cbuf
+ *         else:
+ */
+  __pyx_t_2 = ((__pyx_v_cbuf != NULL) != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/buffer.pyx":386
+ *         cbuf = self._try_read_bytes(n)
+ *         if cbuf != NULL:
+ *             return cbuf             # <<<<<<<<<<<<<<
+ *         else:
+ *             mem = <Memory>(self.read(n))
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_cbuf); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 386, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_r = __pyx_t_1;
+    __pyx_t_1 = 0;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/buffer.pyx":385
+ *         self._ensure_first_buf()
+ *         cbuf = self._try_read_bytes(n)
+ *         if cbuf != NULL:             # <<<<<<<<<<<<<<
+ *             return cbuf
+ *         else:
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":388
+ *             return cbuf
+ *         else:
+ *             mem = <Memory>(self.read(n))             # <<<<<<<<<<<<<<
+ *             return mem.buf
+ * 
+ */
+  /*else*/ {
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read(__pyx_v_self, __pyx_v_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 388, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_3 = __pyx_t_1;
+    __Pyx_INCREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_v_mem = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *)__pyx_t_3);
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/buffer.pyx":389
+ *         else:
+ *             mem = <Memory>(self.read(n))
+ *             return mem.buf             # <<<<<<<<<<<<<<
+ * 
+ *     cdef inline read_int32(self):
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_mem->buf); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 389, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_r = __pyx_t_3;
+    __pyx_t_3 = 0;
+    goto __pyx_L0;
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":378
+ *         return first_byte[0]
+ * 
+ *     cdef inline read_bytes(self, ssize_t n):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             Memory mem
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ReadBuffer.read_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_mem);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":391
+ *             return mem.buf
+ * 
+ *     cdef inline read_int32(self):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             Memory mem
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_int32(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *__pyx_v_mem = 0;
+  char *__pyx_v_cbuf;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("read_int32", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":396
+ *             char *cbuf
+ * 
+ *         self._ensure_first_buf()             # <<<<<<<<<<<<<<
+ *         cbuf = self._try_read_bytes(4)
+ *         if cbuf != NULL:
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__ensure_first_buf(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 396, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":397
+ * 
+ *         self._ensure_first_buf()
+ *         cbuf = self._try_read_bytes(4)             # <<<<<<<<<<<<<<
+ *         if cbuf != NULL:
+ *             return hton.unpack_int32(cbuf)
+ */
+  __pyx_v_cbuf = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__try_read_bytes(__pyx_v_self, 4);
+
+  /* "asyncpg/protocol/buffer.pyx":398
+ *         self._ensure_first_buf()
+ *         cbuf = self._try_read_bytes(4)
+ *         if cbuf != NULL:             # <<<<<<<<<<<<<<
+ *             return hton.unpack_int32(cbuf)
+ *         else:
+ */
+  __pyx_t_2 = ((__pyx_v_cbuf != NULL) != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/buffer.pyx":399
+ *         cbuf = self._try_read_bytes(4)
+ *         if cbuf != NULL:
+ *             return hton.unpack_int32(cbuf)             # <<<<<<<<<<<<<<
+ *         else:
+ *             mem = <Memory>(self.read(4))
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_1 = __Pyx_PyInt_From_int32_t(__pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_v_cbuf)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 399, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_r = __pyx_t_1;
+    __pyx_t_1 = 0;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/buffer.pyx":398
+ *         self._ensure_first_buf()
+ *         cbuf = self._try_read_bytes(4)
+ *         if cbuf != NULL:             # <<<<<<<<<<<<<<
+ *             return hton.unpack_int32(cbuf)
+ *         else:
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":401
+ *             return hton.unpack_int32(cbuf)
+ *         else:
+ *             mem = <Memory>(self.read(4))             # <<<<<<<<<<<<<<
+ *             return hton.unpack_int32(mem.buf)
+ * 
+ */
+  /*else*/ {
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read(__pyx_v_self, 4); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 401, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_3 = __pyx_t_1;
+    __Pyx_INCREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_v_mem = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *)__pyx_t_3);
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/buffer.pyx":402
+ *         else:
+ *             mem = <Memory>(self.read(4))
+ *             return hton.unpack_int32(mem.buf)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef inline read_int16(self):
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_3 = __Pyx_PyInt_From_int32_t(__pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_v_mem->buf)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 402, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_r = __pyx_t_3;
+    __pyx_t_3 = 0;
+    goto __pyx_L0;
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":391
+ *             return mem.buf
+ * 
+ *     cdef inline read_int32(self):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             Memory mem
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ReadBuffer.read_int32", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_mem);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":404
+ *             return hton.unpack_int32(mem.buf)
+ * 
+ *     cdef inline read_int16(self):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             Memory mem
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_int16(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *__pyx_v_mem = 0;
+  char *__pyx_v_cbuf;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("read_int16", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":409
+ *             char *cbuf
+ * 
+ *         self._ensure_first_buf()             # <<<<<<<<<<<<<<
+ *         cbuf = self._try_read_bytes(2)
+ *         if cbuf != NULL:
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__ensure_first_buf(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 409, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":410
+ * 
+ *         self._ensure_first_buf()
+ *         cbuf = self._try_read_bytes(2)             # <<<<<<<<<<<<<<
+ *         if cbuf != NULL:
+ *             return hton.unpack_int16(cbuf)
+ */
+  __pyx_v_cbuf = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__try_read_bytes(__pyx_v_self, 2);
+
+  /* "asyncpg/protocol/buffer.pyx":411
+ *         self._ensure_first_buf()
+ *         cbuf = self._try_read_bytes(2)
+ *         if cbuf != NULL:             # <<<<<<<<<<<<<<
+ *             return hton.unpack_int16(cbuf)
+ *         else:
+ */
+  __pyx_t_2 = ((__pyx_v_cbuf != NULL) != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/buffer.pyx":412
+ *         cbuf = self._try_read_bytes(2)
+ *         if cbuf != NULL:
+ *             return hton.unpack_int16(cbuf)             # <<<<<<<<<<<<<<
+ *         else:
+ *             mem = <Memory>(self.read(2))
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_1 = __Pyx_PyInt_From_int16_t(__pyx_f_7asyncpg_8protocol_4hton_unpack_int16(__pyx_v_cbuf)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 412, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_r = __pyx_t_1;
+    __pyx_t_1 = 0;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/buffer.pyx":411
+ *         self._ensure_first_buf()
+ *         cbuf = self._try_read_bytes(2)
+ *         if cbuf != NULL:             # <<<<<<<<<<<<<<
+ *             return hton.unpack_int16(cbuf)
+ *         else:
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":414
+ *             return hton.unpack_int16(cbuf)
+ *         else:
+ *             mem = <Memory>(self.read(2))             # <<<<<<<<<<<<<<
+ *             return hton.unpack_int16(mem.buf)
+ * 
+ */
+  /*else*/ {
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read(__pyx_v_self, 2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 414, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_3 = __pyx_t_1;
+    __Pyx_INCREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_v_mem = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *)__pyx_t_3);
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/buffer.pyx":415
+ *         else:
+ *             mem = <Memory>(self.read(2))
+ *             return hton.unpack_int16(mem.buf)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef inline read_cstr(self):
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_3 = __Pyx_PyInt_From_int16_t(__pyx_f_7asyncpg_8protocol_4hton_unpack_int16(__pyx_v_mem->buf)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 415, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_r = __pyx_t_3;
+    __pyx_t_3 = 0;
+    goto __pyx_L0;
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":404
+ *             return hton.unpack_int32(mem.buf)
+ * 
+ *     cdef inline read_int16(self):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             Memory mem
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ReadBuffer.read_int16", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_mem);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":417
+ *             return hton.unpack_int16(mem.buf)
+ * 
+ *     cdef inline read_cstr(self):             # <<<<<<<<<<<<<<
+ *         if not self._current_message_ready:
+ *             raise BufferError(
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_cstr(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self) {
+  Py_ssize_t __pyx_v_pos;
+  Py_ssize_t __pyx_v_nread;
+  PyObject *__pyx_v_result = 0;
+  char *__pyx_v_buf;
+  char *__pyx_v_buf_start;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  int __pyx_t_6;
+  PyObject *__pyx_t_7 = NULL;
+  Py_ssize_t __pyx_t_8;
+  __Pyx_RefNannySetupContext("read_cstr", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":418
+ * 
+ *     cdef inline read_cstr(self):
+ *         if not self._current_message_ready:             # <<<<<<<<<<<<<<
+ *             raise BufferError(
+ *                 'read_cstr only works when the message guaranteed '
+ */
+  __pyx_t_1 = ((!(__pyx_v_self->_current_message_ready != 0)) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":419
+ *     cdef inline read_cstr(self):
+ *         if not self._current_message_ready:
+ *             raise BufferError(             # <<<<<<<<<<<<<<
+ *                 'read_cstr only works when the message guaranteed '
+ *                 'to be in the buffer')
+ */
+    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_BufferError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 419, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 419, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __PYX_ERR(1, 419, __pyx_L1_error)
+
+    /* "asyncpg/protocol/buffer.pyx":418
+ * 
+ *     cdef inline read_cstr(self):
+ *         if not self._current_message_ready:             # <<<<<<<<<<<<<<
+ *             raise BufferError(
+ *                 'read_cstr only works when the message guaranteed '
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":430
+ *             char* buf_start
+ * 
+ *         self._ensure_first_buf()             # <<<<<<<<<<<<<<
+ * 
+ *         buf_start = cpython.PyBytes_AS_STRING(self._buf0)
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__ensure_first_buf(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 430, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":432
+ *         self._ensure_first_buf()
+ * 
+ *         buf_start = cpython.PyBytes_AS_STRING(self._buf0)             # <<<<<<<<<<<<<<
+ *         buf = buf_start + self._pos0
+ *         while buf - buf_start < self._len0:
+ */
+  __pyx_t_3 = __pyx_v_self->_buf0;
+  __Pyx_INCREF(__pyx_t_3);
+  __pyx_v_buf_start = PyBytes_AS_STRING(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":433
+ * 
+ *         buf_start = cpython.PyBytes_AS_STRING(self._buf0)
+ *         buf = buf_start + self._pos0             # <<<<<<<<<<<<<<
+ *         while buf - buf_start < self._len0:
+ *             if buf[0] == 0:
+ */
+  __pyx_v_buf = (__pyx_v_buf_start + __pyx_v_self->_pos0);
+
+  /* "asyncpg/protocol/buffer.pyx":434
+ *         buf_start = cpython.PyBytes_AS_STRING(self._buf0)
+ *         buf = buf_start + self._pos0
+ *         while buf - buf_start < self._len0:             # <<<<<<<<<<<<<<
+ *             if buf[0] == 0:
+ *                 pos = buf - buf_start
+ */
+  while (1) {
+    __pyx_t_1 = (((__pyx_v_buf - __pyx_v_buf_start) < __pyx_v_self->_len0) != 0);
+    if (!__pyx_t_1) break;
+
+    /* "asyncpg/protocol/buffer.pyx":435
+ *         buf = buf_start + self._pos0
+ *         while buf - buf_start < self._len0:
+ *             if buf[0] == 0:             # <<<<<<<<<<<<<<
+ *                 pos = buf - buf_start
+ *                 nread = pos - self._pos0
+ */
+    __pyx_t_1 = (((__pyx_v_buf[0]) == 0) != 0);
+    if (__pyx_t_1) {
+
+      /* "asyncpg/protocol/buffer.pyx":436
+ *         while buf - buf_start < self._len0:
+ *             if buf[0] == 0:
+ *                 pos = buf - buf_start             # <<<<<<<<<<<<<<
+ *                 nread = pos - self._pos0
+ *                 buf = self._try_read_bytes(nread + 1)
+ */
+      __pyx_v_pos = (__pyx_v_buf - __pyx_v_buf_start);
+
+      /* "asyncpg/protocol/buffer.pyx":437
+ *             if buf[0] == 0:
+ *                 pos = buf - buf_start
+ *                 nread = pos - self._pos0             # <<<<<<<<<<<<<<
+ *                 buf = self._try_read_bytes(nread + 1)
+ *                 if buf != NULL:
+ */
+      __pyx_v_nread = (__pyx_v_pos - __pyx_v_self->_pos0);
+
+      /* "asyncpg/protocol/buffer.pyx":438
+ *                 pos = buf - buf_start
+ *                 nread = pos - self._pos0
+ *                 buf = self._try_read_bytes(nread + 1)             # <<<<<<<<<<<<<<
+ *                 if buf != NULL:
+ *                     return cpython.PyBytes_FromStringAndSize(buf, nread)
+ */
+      __pyx_v_buf = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__try_read_bytes(__pyx_v_self, (__pyx_v_nread + 1));
+
+      /* "asyncpg/protocol/buffer.pyx":439
+ *                 nread = pos - self._pos0
+ *                 buf = self._try_read_bytes(nread + 1)
+ *                 if buf != NULL:             # <<<<<<<<<<<<<<
+ *                     return cpython.PyBytes_FromStringAndSize(buf, nread)
+ *                 else:
+ */
+      __pyx_t_1 = ((__pyx_v_buf != NULL) != 0);
+      if (__pyx_t_1) {
+
+        /* "asyncpg/protocol/buffer.pyx":440
+ *                 buf = self._try_read_bytes(nread + 1)
+ *                 if buf != NULL:
+ *                     return cpython.PyBytes_FromStringAndSize(buf, nread)             # <<<<<<<<<<<<<<
+ *                 else:
+ *                     break
+ */
+        __Pyx_XDECREF(__pyx_r);
+        __pyx_t_3 = PyBytes_FromStringAndSize(__pyx_v_buf, __pyx_v_nread); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 440, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_3);
+        __pyx_r = __pyx_t_3;
+        __pyx_t_3 = 0;
+        goto __pyx_L0;
+
+        /* "asyncpg/protocol/buffer.pyx":439
+ *                 nread = pos - self._pos0
+ *                 buf = self._try_read_bytes(nread + 1)
+ *                 if buf != NULL:             # <<<<<<<<<<<<<<
+ *                     return cpython.PyBytes_FromStringAndSize(buf, nread)
+ *                 else:
+ */
+      }
+
+      /* "asyncpg/protocol/buffer.pyx":442
+ *                     return cpython.PyBytes_FromStringAndSize(buf, nread)
+ *                 else:
+ *                     break             # <<<<<<<<<<<<<<
+ *             else:
+ *                 buf += 1
+ */
+      /*else*/ {
+        goto __pyx_L5_break;
+      }
+
+      /* "asyncpg/protocol/buffer.pyx":435
+ *         buf = buf_start + self._pos0
+ *         while buf - buf_start < self._len0:
+ *             if buf[0] == 0:             # <<<<<<<<<<<<<<
+ *                 pos = buf - buf_start
+ *                 nread = pos - self._pos0
+ */
+    }
+
+    /* "asyncpg/protocol/buffer.pyx":444
+ *                     break
+ *             else:
+ *                 buf += 1             # <<<<<<<<<<<<<<
+ * 
+ *         result = b''
+ */
+    /*else*/ {
+      __pyx_v_buf = (__pyx_v_buf + 1);
+    }
+  }
+  __pyx_L5_break:;
+
+  /* "asyncpg/protocol/buffer.pyx":446
+ *                 buf += 1
+ * 
+ *         result = b''             # <<<<<<<<<<<<<<
+ *         while True:
+ *             pos = self._buf0.find(b'\x00', self._pos0)
+ */
+  __Pyx_INCREF(__pyx_kp_b__18);
+  __pyx_v_result = __pyx_kp_b__18;
+
+  /* "asyncpg/protocol/buffer.pyx":447
+ * 
+ *         result = b''
+ *         while True:             # <<<<<<<<<<<<<<
+ *             pos = self._buf0.find(b'\x00', self._pos0)
+ *             if pos >= 0:
+ */
+  while (1) {
+
+    /* "asyncpg/protocol/buffer.pyx":448
+ *         result = b''
+ *         while True:
+ *             pos = self._buf0.find(b'\x00', self._pos0)             # <<<<<<<<<<<<<<
+ *             if pos >= 0:
+ *                 result += self._buf0[self._pos0 : pos]
+ */
+    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_buf0, __pyx_n_s_find); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 448, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_self->_pos0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 448, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = NULL;
+    __pyx_t_6 = 0;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
+      if (likely(__pyx_t_5)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+        __Pyx_INCREF(__pyx_t_5);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_2, function);
+        __pyx_t_6 = 1;
+      }
+    }
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_b__19, __pyx_t_4};
+      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 448, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_b__19, __pyx_t_4};
+      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 448, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    } else
+    #endif
+    {
+      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 448, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_7);
+      if (__pyx_t_5) {
+        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
+      }
+      __Pyx_INCREF(__pyx_kp_b__19);
+      __Pyx_GIVEREF(__pyx_kp_b__19);
+      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_kp_b__19);
+      __Pyx_GIVEREF(__pyx_t_4);
+      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4);
+      __pyx_t_4 = 0;
+      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 448, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_8 = PyInt_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 448, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_v_pos = __pyx_t_8;
+
+    /* "asyncpg/protocol/buffer.pyx":449
+ *         while True:
+ *             pos = self._buf0.find(b'\x00', self._pos0)
+ *             if pos >= 0:             # <<<<<<<<<<<<<<
+ *                 result += self._buf0[self._pos0 : pos]
+ *                 nread = pos - self._pos0 + 1
+ */
+    __pyx_t_1 = ((__pyx_v_pos >= 0) != 0);
+    if (__pyx_t_1) {
+
+      /* "asyncpg/protocol/buffer.pyx":450
+ *             pos = self._buf0.find(b'\x00', self._pos0)
+ *             if pos >= 0:
+ *                 result += self._buf0[self._pos0 : pos]             # <<<<<<<<<<<<<<
+ *                 nread = pos - self._pos0 + 1
+ *                 self._pos0 = pos + 1
+ */
+      if (unlikely(__pyx_v_self->_buf0 == Py_None)) {
+        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+        __PYX_ERR(1, 450, __pyx_L1_error)
+      }
+      __pyx_t_3 = PySequence_GetSlice(__pyx_v_self->_buf0, __pyx_v_self->_pos0, __pyx_v_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 450, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 450, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_2));
+      __pyx_t_2 = 0;
+
+      /* "asyncpg/protocol/buffer.pyx":451
+ *             if pos >= 0:
+ *                 result += self._buf0[self._pos0 : pos]
+ *                 nread = pos - self._pos0 + 1             # <<<<<<<<<<<<<<
+ *                 self._pos0 = pos + 1
+ *                 self._length -= nread
+ */
+      __pyx_v_nread = ((__pyx_v_pos - __pyx_v_self->_pos0) + 1);
+
+      /* "asyncpg/protocol/buffer.pyx":452
+ *                 result += self._buf0[self._pos0 : pos]
+ *                 nread = pos - self._pos0 + 1
+ *                 self._pos0 = pos + 1             # <<<<<<<<<<<<<<
+ *                 self._length -= nread
+ * 
+ */
+      __pyx_v_self->_pos0 = (__pyx_v_pos + 1);
+
+      /* "asyncpg/protocol/buffer.pyx":453
+ *                 nread = pos - self._pos0 + 1
+ *                 self._pos0 = pos + 1
+ *                 self._length -= nread             # <<<<<<<<<<<<<<
+ * 
+ *                 self._current_message_len_unread -= nread
+ */
+      __pyx_v_self->_length = (__pyx_v_self->_length - __pyx_v_nread);
+
+      /* "asyncpg/protocol/buffer.pyx":455
+ *                 self._length -= nread
+ * 
+ *                 self._current_message_len_unread -= nread             # <<<<<<<<<<<<<<
+ *                 if self._current_message_len_unread < 0:
+ *                     raise BufferError('read_cstr: buffer overread')
+ */
+      __pyx_v_self->_current_message_len_unread = (__pyx_v_self->_current_message_len_unread - __pyx_v_nread);
+
+      /* "asyncpg/protocol/buffer.pyx":456
+ * 
+ *                 self._current_message_len_unread -= nread
+ *                 if self._current_message_len_unread < 0:             # <<<<<<<<<<<<<<
+ *                     raise BufferError('read_cstr: buffer overread')
+ * 
+ */
+      __pyx_t_1 = ((__pyx_v_self->_current_message_len_unread < 0) != 0);
+      if (__pyx_t_1) {
+
+        /* "asyncpg/protocol/buffer.pyx":457
+ *                 self._current_message_len_unread -= nread
+ *                 if self._current_message_len_unread < 0:
+ *                     raise BufferError('read_cstr: buffer overread')             # <<<<<<<<<<<<<<
+ * 
+ *                 return result
+ */
+        __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_BufferError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 457, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 457, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __PYX_ERR(1, 457, __pyx_L1_error)
+
+        /* "asyncpg/protocol/buffer.pyx":456
+ * 
+ *                 self._current_message_len_unread -= nread
+ *                 if self._current_message_len_unread < 0:             # <<<<<<<<<<<<<<
+ *                     raise BufferError('read_cstr: buffer overread')
+ * 
+ */
+      }
+
+      /* "asyncpg/protocol/buffer.pyx":459
+ *                     raise BufferError('read_cstr: buffer overread')
+ * 
+ *                 return result             # <<<<<<<<<<<<<<
+ * 
+ *             else:
+ */
+      __Pyx_XDECREF(__pyx_r);
+      __Pyx_INCREF(__pyx_v_result);
+      __pyx_r = __pyx_v_result;
+      goto __pyx_L0;
+
+      /* "asyncpg/protocol/buffer.pyx":449
+ *         while True:
+ *             pos = self._buf0.find(b'\x00', self._pos0)
+ *             if pos >= 0:             # <<<<<<<<<<<<<<
+ *                 result += self._buf0[self._pos0 : pos]
+ *                 nread = pos - self._pos0 + 1
+ */
+    }
+
+    /* "asyncpg/protocol/buffer.pyx":462
+ * 
+ *             else:
+ *                 result += self._buf0[self._pos0:]             # <<<<<<<<<<<<<<
+ *                 nread = self._len0 - self._pos0
+ *                 self._pos0 = self._len0
+ */
+    /*else*/ {
+      if (unlikely(__pyx_v_self->_buf0 == Py_None)) {
+        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+        __PYX_ERR(1, 462, __pyx_L1_error)
+      }
+      __pyx_t_3 = PySequence_GetSlice(__pyx_v_self->_buf0, __pyx_v_self->_pos0, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 462, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 462, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_2));
+      __pyx_t_2 = 0;
+
+      /* "asyncpg/protocol/buffer.pyx":463
+ *             else:
+ *                 result += self._buf0[self._pos0:]
+ *                 nread = self._len0 - self._pos0             # <<<<<<<<<<<<<<
+ *                 self._pos0 = self._len0
+ *                 self._length -= nread
+ */
+      __pyx_v_nread = (__pyx_v_self->_len0 - __pyx_v_self->_pos0);
+
+      /* "asyncpg/protocol/buffer.pyx":464
+ *                 result += self._buf0[self._pos0:]
+ *                 nread = self._len0 - self._pos0
+ *                 self._pos0 = self._len0             # <<<<<<<<<<<<<<
+ *                 self._length -= nread
+ * 
+ */
+      __pyx_t_8 = __pyx_v_self->_len0;
+      __pyx_v_self->_pos0 = __pyx_t_8;
+
+      /* "asyncpg/protocol/buffer.pyx":465
+ *                 nread = self._len0 - self._pos0
+ *                 self._pos0 = self._len0
+ *                 self._length -= nread             # <<<<<<<<<<<<<<
+ * 
+ *                 self._current_message_len_unread -= nread
+ */
+      __pyx_v_self->_length = (__pyx_v_self->_length - __pyx_v_nread);
+
+      /* "asyncpg/protocol/buffer.pyx":467
+ *                 self._length -= nread
+ * 
+ *                 self._current_message_len_unread -= nread             # <<<<<<<<<<<<<<
+ *                 if self._current_message_len_unread < 0:
+ *                     raise BufferError('read_cstr: buffer overread')
+ */
+      __pyx_v_self->_current_message_len_unread = (__pyx_v_self->_current_message_len_unread - __pyx_v_nread);
+
+      /* "asyncpg/protocol/buffer.pyx":468
+ * 
+ *                 self._current_message_len_unread -= nread
+ *                 if self._current_message_len_unread < 0:             # <<<<<<<<<<<<<<
+ *                     raise BufferError('read_cstr: buffer overread')
+ * 
+ */
+      __pyx_t_1 = ((__pyx_v_self->_current_message_len_unread < 0) != 0);
+      if (__pyx_t_1) {
+
+        /* "asyncpg/protocol/buffer.pyx":469
+ *                 self._current_message_len_unread -= nread
+ *                 if self._current_message_len_unread < 0:
+ *                     raise BufferError('read_cstr: buffer overread')             # <<<<<<<<<<<<<<
+ * 
+ *                 self._ensure_first_buf()
+ */
+        __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_BufferError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 469, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 469, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __PYX_ERR(1, 469, __pyx_L1_error)
+
+        /* "asyncpg/protocol/buffer.pyx":468
+ * 
+ *                 self._current_message_len_unread -= nread
+ *                 if self._current_message_len_unread < 0:             # <<<<<<<<<<<<<<
+ *                     raise BufferError('read_cstr: buffer overread')
+ * 
+ */
+      }
+
+      /* "asyncpg/protocol/buffer.pyx":471
+ *                     raise BufferError('read_cstr: buffer overread')
+ * 
+ *                 self._ensure_first_buf()             # <<<<<<<<<<<<<<
+ * 
+ *     cdef int32_t has_message(self) except -1:
+ */
+      __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__ensure_first_buf(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 471, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    }
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":417
+ *             return hton.unpack_int16(mem.buf)
+ * 
+ *     cdef inline read_cstr(self):             # <<<<<<<<<<<<<<
+ *         if not self._current_message_ready:
+ *             raise BufferError(
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ReadBuffer.read_cstr", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_result);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":473
+ *                 self._ensure_first_buf()
+ * 
+ *     cdef int32_t has_message(self) except -1:             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             char* cbuf
+ */
+
+static int32_t __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_has_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self) {
+  char *__pyx_v_cbuf;
+  int32_t __pyx_r;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  __Pyx_RefNannySetupContext("has_message", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":477
+ *             char* cbuf
+ * 
+ *         if self._current_message_ready:             # <<<<<<<<<<<<<<
+ *             return 1
+ * 
+ */
+  __pyx_t_1 = (__pyx_v_self->_current_message_ready != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":478
+ * 
+ *         if self._current_message_ready:
+ *             return 1             # <<<<<<<<<<<<<<
+ * 
+ *         if self._current_message_type == 0:
+ */
+    __pyx_r = 1;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/buffer.pyx":477
+ *             char* cbuf
+ * 
+ *         if self._current_message_ready:             # <<<<<<<<<<<<<<
+ *             return 1
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":480
+ *             return 1
+ * 
+ *         if self._current_message_type == 0:             # <<<<<<<<<<<<<<
+ *             if self._length < 1:
+ *                 return 0
+ */
+  __pyx_t_1 = ((__pyx_v_self->_current_message_type == 0) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":481
+ * 
+ *         if self._current_message_type == 0:
+ *             if self._length < 1:             # <<<<<<<<<<<<<<
+ *                 return 0
+ *             self._ensure_first_buf()
+ */
+    __pyx_t_1 = ((__pyx_v_self->_length < 1) != 0);
+    if (__pyx_t_1) {
+
+      /* "asyncpg/protocol/buffer.pyx":482
+ *         if self._current_message_type == 0:
+ *             if self._length < 1:
+ *                 return 0             # <<<<<<<<<<<<<<
+ *             self._ensure_first_buf()
+ *             cbuf = self._try_read_bytes(1)
+ */
+      __pyx_r = 0;
+      goto __pyx_L0;
+
+      /* "asyncpg/protocol/buffer.pyx":481
+ * 
+ *         if self._current_message_type == 0:
+ *             if self._length < 1:             # <<<<<<<<<<<<<<
+ *                 return 0
+ *             self._ensure_first_buf()
+ */
+    }
+
+    /* "asyncpg/protocol/buffer.pyx":483
+ *             if self._length < 1:
+ *                 return 0
+ *             self._ensure_first_buf()             # <<<<<<<<<<<<<<
+ *             cbuf = self._try_read_bytes(1)
+ *             if cbuf == NULL:
+ */
+    __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__ensure_first_buf(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 483, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "asyncpg/protocol/buffer.pyx":484
+ *                 return 0
+ *             self._ensure_first_buf()
+ *             cbuf = self._try_read_bytes(1)             # <<<<<<<<<<<<<<
+ *             if cbuf == NULL:
+ *                 raise BufferError(
+ */
+    __pyx_v_cbuf = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__try_read_bytes(__pyx_v_self, 1);
+
+    /* "asyncpg/protocol/buffer.pyx":485
+ *             self._ensure_first_buf()
+ *             cbuf = self._try_read_bytes(1)
+ *             if cbuf == NULL:             # <<<<<<<<<<<<<<
+ *                 raise BufferError(
+ *                     'failed to read one byte on a non-empty buffer')
+ */
+    __pyx_t_1 = ((__pyx_v_cbuf == NULL) != 0);
+    if (__pyx_t_1) {
+
+      /* "asyncpg/protocol/buffer.pyx":486
+ *             cbuf = self._try_read_bytes(1)
+ *             if cbuf == NULL:
+ *                 raise BufferError(             # <<<<<<<<<<<<<<
+ *                     'failed to read one byte on a non-empty buffer')
+ *             self._current_message_type = cbuf[0]
+ */
+      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_BufferError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 486, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 486, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __PYX_ERR(1, 486, __pyx_L1_error)
+
+      /* "asyncpg/protocol/buffer.pyx":485
+ *             self._ensure_first_buf()
+ *             cbuf = self._try_read_bytes(1)
+ *             if cbuf == NULL:             # <<<<<<<<<<<<<<
+ *                 raise BufferError(
+ *                     'failed to read one byte on a non-empty buffer')
+ */
+    }
+
+    /* "asyncpg/protocol/buffer.pyx":488
+ *                 raise BufferError(
+ *                     'failed to read one byte on a non-empty buffer')
+ *             self._current_message_type = cbuf[0]             # <<<<<<<<<<<<<<
+ * 
+ *         if self._current_message_len == 0:
+ */
+    __pyx_v_self->_current_message_type = (__pyx_v_cbuf[0]);
+
+    /* "asyncpg/protocol/buffer.pyx":480
+ *             return 1
+ * 
+ *         if self._current_message_type == 0:             # <<<<<<<<<<<<<<
+ *             if self._length < 1:
+ *                 return 0
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":490
+ *             self._current_message_type = cbuf[0]
+ * 
+ *         if self._current_message_len == 0:             # <<<<<<<<<<<<<<
+ *             if self._length < 4:
+ *                 return 0
+ */
+  __pyx_t_1 = ((__pyx_v_self->_current_message_len == 0) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":491
+ * 
+ *         if self._current_message_len == 0:
+ *             if self._length < 4:             # <<<<<<<<<<<<<<
+ *                 return 0
+ * 
+ */
+    __pyx_t_1 = ((__pyx_v_self->_length < 4) != 0);
+    if (__pyx_t_1) {
+
+      /* "asyncpg/protocol/buffer.pyx":492
+ *         if self._current_message_len == 0:
+ *             if self._length < 4:
+ *                 return 0             # <<<<<<<<<<<<<<
+ * 
+ *             self._ensure_first_buf()
+ */
+      __pyx_r = 0;
+      goto __pyx_L0;
+
+      /* "asyncpg/protocol/buffer.pyx":491
+ * 
+ *         if self._current_message_len == 0:
+ *             if self._length < 4:             # <<<<<<<<<<<<<<
+ *                 return 0
+ * 
+ */
+    }
+
+    /* "asyncpg/protocol/buffer.pyx":494
+ *                 return 0
+ * 
+ *             self._ensure_first_buf()             # <<<<<<<<<<<<<<
+ *             cbuf = self._try_read_bytes(4)
+ *             if cbuf != NULL:
+ */
+    __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__ensure_first_buf(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 494, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/buffer.pyx":495
+ * 
+ *             self._ensure_first_buf()
+ *             cbuf = self._try_read_bytes(4)             # <<<<<<<<<<<<<<
+ *             if cbuf != NULL:
+ *                 self._current_message_len = hton.unpack_int32(cbuf)
+ */
+    __pyx_v_cbuf = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__try_read_bytes(__pyx_v_self, 4);
+
+    /* "asyncpg/protocol/buffer.pyx":496
+ *             self._ensure_first_buf()
+ *             cbuf = self._try_read_bytes(4)
+ *             if cbuf != NULL:             # <<<<<<<<<<<<<<
+ *                 self._current_message_len = hton.unpack_int32(cbuf)
+ *             else:
+ */
+    __pyx_t_1 = ((__pyx_v_cbuf != NULL) != 0);
+    if (__pyx_t_1) {
+
+      /* "asyncpg/protocol/buffer.pyx":497
+ *             cbuf = self._try_read_bytes(4)
+ *             if cbuf != NULL:
+ *                 self._current_message_len = hton.unpack_int32(cbuf)             # <<<<<<<<<<<<<<
+ *             else:
+ *                 self._current_message_len = self.read_int32()
+ */
+      __pyx_v_self->_current_message_len = __pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_v_cbuf);
+
+      /* "asyncpg/protocol/buffer.pyx":496
+ *             self._ensure_first_buf()
+ *             cbuf = self._try_read_bytes(4)
+ *             if cbuf != NULL:             # <<<<<<<<<<<<<<
+ *                 self._current_message_len = hton.unpack_int32(cbuf)
+ *             else:
+ */
+      goto __pyx_L9;
+    }
+
+    /* "asyncpg/protocol/buffer.pyx":499
+ *                 self._current_message_len = hton.unpack_int32(cbuf)
+ *             else:
+ *                 self._current_message_len = self.read_int32()             # <<<<<<<<<<<<<<
+ * 
+ *             self._current_message_len_unread = self._current_message_len - 4
+ */
+    /*else*/ {
+      __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_int32(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 499, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 499, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __pyx_v_self->_current_message_len = __pyx_t_4;
+    }
+    __pyx_L9:;
+
+    /* "asyncpg/protocol/buffer.pyx":501
+ *                 self._current_message_len = self.read_int32()
+ * 
+ *             self._current_message_len_unread = self._current_message_len - 4             # <<<<<<<<<<<<<<
+ * 
+ *         if self._length < self._current_message_len_unread:
+ */
+    __pyx_v_self->_current_message_len_unread = (__pyx_v_self->_current_message_len - 4);
+
+    /* "asyncpg/protocol/buffer.pyx":490
+ *             self._current_message_type = cbuf[0]
+ * 
+ *         if self._current_message_len == 0:             # <<<<<<<<<<<<<<
+ *             if self._length < 4:
+ *                 return 0
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":503
+ *             self._current_message_len_unread = self._current_message_len - 4
+ * 
+ *         if self._length < self._current_message_len_unread:             # <<<<<<<<<<<<<<
+ *             return 0
+ * 
+ */
+  __pyx_t_1 = ((__pyx_v_self->_length < __pyx_v_self->_current_message_len_unread) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":504
+ * 
+ *         if self._length < self._current_message_len_unread:
+ *             return 0             # <<<<<<<<<<<<<<
+ * 
+ *         self._current_message_ready = 1
+ */
+    __pyx_r = 0;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/buffer.pyx":503
+ *             self._current_message_len_unread = self._current_message_len - 4
+ * 
+ *         if self._length < self._current_message_len_unread:             # <<<<<<<<<<<<<<
+ *             return 0
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":506
+ *             return 0
+ * 
+ *         self._current_message_ready = 1             # <<<<<<<<<<<<<<
+ *         return 1
+ * 
+ */
+  __pyx_v_self->_current_message_ready = 1;
+
+  /* "asyncpg/protocol/buffer.pyx":507
+ * 
+ *         self._current_message_ready = 1
+ *         return 1             # <<<<<<<<<<<<<<
+ * 
+ *     cdef inline char* try_consume_message(self, ssize_t* len):
+ */
+  __pyx_r = 1;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/buffer.pyx":473
+ *                 self._ensure_first_buf()
+ * 
+ *     cdef int32_t has_message(self) except -1:             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             char* cbuf
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ReadBuffer.has_message", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":509
+ *         return 1
+ * 
+ *     cdef inline char* try_consume_message(self, ssize_t* len):             # <<<<<<<<<<<<<<
+ *         cdef ssize_t buf_len
+ * 
+ */
+
+static CYTHON_INLINE char *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_try_consume_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self, Py_ssize_t *__pyx_v_len) {
+  Py_ssize_t __pyx_v_buf_len;
+  char *__pyx_v_buf;
+  char *__pyx_r;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  Py_ssize_t __pyx_t_3;
+  __Pyx_RefNannySetupContext("try_consume_message", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":512
+ *         cdef ssize_t buf_len
+ * 
+ *         if not self._current_message_ready:             # <<<<<<<<<<<<<<
+ *             return NULL
+ * 
+ */
+  __pyx_t_1 = ((!(__pyx_v_self->_current_message_ready != 0)) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":513
+ * 
+ *         if not self._current_message_ready:
+ *             return NULL             # <<<<<<<<<<<<<<
+ * 
+ *         self._ensure_first_buf()
+ */
+    __pyx_r = NULL;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/buffer.pyx":512
+ *         cdef ssize_t buf_len
+ * 
+ *         if not self._current_message_ready:             # <<<<<<<<<<<<<<
+ *             return NULL
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":515
+ *             return NULL
+ * 
+ *         self._ensure_first_buf()             # <<<<<<<<<<<<<<
+ *         buf_len = self._current_message_len_unread
+ *         buf = self._try_read_bytes(buf_len)
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__ensure_first_buf(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 515, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":516
+ * 
+ *         self._ensure_first_buf()
+ *         buf_len = self._current_message_len_unread             # <<<<<<<<<<<<<<
+ *         buf = self._try_read_bytes(buf_len)
+ *         if buf != NULL:
+ */
+  __pyx_t_3 = __pyx_v_self->_current_message_len_unread;
+  __pyx_v_buf_len = __pyx_t_3;
+
+  /* "asyncpg/protocol/buffer.pyx":517
+ *         self._ensure_first_buf()
+ *         buf_len = self._current_message_len_unread
+ *         buf = self._try_read_bytes(buf_len)             # <<<<<<<<<<<<<<
+ *         if buf != NULL:
+ *             len[0] = buf_len
+ */
+  __pyx_v_buf = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__try_read_bytes(__pyx_v_self, __pyx_v_buf_len);
+
+  /* "asyncpg/protocol/buffer.pyx":518
+ *         buf_len = self._current_message_len_unread
+ *         buf = self._try_read_bytes(buf_len)
+ *         if buf != NULL:             # <<<<<<<<<<<<<<
+ *             len[0] = buf_len
+ *             self._discard_message()
+ */
+  __pyx_t_1 = ((__pyx_v_buf != NULL) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":519
+ *         buf = self._try_read_bytes(buf_len)
+ *         if buf != NULL:
+ *             len[0] = buf_len             # <<<<<<<<<<<<<<
+ *             self._discard_message()
+ *         return buf
+ */
+    (__pyx_v_len[0]) = __pyx_v_buf_len;
+
+    /* "asyncpg/protocol/buffer.pyx":520
+ *         if buf != NULL:
+ *             len[0] = buf_len
+ *             self._discard_message()             # <<<<<<<<<<<<<<
+ *         return buf
+ * 
+ */
+    __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__discard_message(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 520, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "asyncpg/protocol/buffer.pyx":518
+ *         buf_len = self._current_message_len_unread
+ *         buf = self._try_read_bytes(buf_len)
+ *         if buf != NULL:             # <<<<<<<<<<<<<<
+ *             len[0] = buf_len
+ *             self._discard_message()
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":521
+ *             len[0] = buf_len
+ *             self._discard_message()
+ *         return buf             # <<<<<<<<<<<<<<
+ * 
+ *     cdef Memory consume_message(self):
+ */
+  __pyx_r = __pyx_v_buf;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/buffer.pyx":509
+ *         return 1
+ * 
+ *     cdef inline char* try_consume_message(self, ssize_t* len):             # <<<<<<<<<<<<<<
+ *         cdef ssize_t buf_len
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_WriteUnraisable("asyncpg.protocol.protocol.ReadBuffer.try_consume_message", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":523
+ *         return buf
+ * 
+ *     cdef Memory consume_message(self):             # <<<<<<<<<<<<<<
+ *         if not self._current_message_ready:
+ *             raise BufferError('no message to consume')
+ */
+
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self) {
+  PyObject *__pyx_v_mem = NULL;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("consume_message", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":524
+ * 
+ *     cdef Memory consume_message(self):
+ *         if not self._current_message_ready:             # <<<<<<<<<<<<<<
+ *             raise BufferError('no message to consume')
+ *         if self._current_message_len_unread > 0:
+ */
+  __pyx_t_1 = ((!(__pyx_v_self->_current_message_ready != 0)) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":525
+ *     cdef Memory consume_message(self):
+ *         if not self._current_message_ready:
+ *             raise BufferError('no message to consume')             # <<<<<<<<<<<<<<
+ *         if self._current_message_len_unread > 0:
+ *             mem = self.read(self._current_message_len_unread)
+ */
+    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_BufferError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 525, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 525, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __PYX_ERR(1, 525, __pyx_L1_error)
+
+    /* "asyncpg/protocol/buffer.pyx":524
+ * 
+ *     cdef Memory consume_message(self):
+ *         if not self._current_message_ready:             # <<<<<<<<<<<<<<
+ *             raise BufferError('no message to consume')
+ *         if self._current_message_len_unread > 0:
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":526
+ *         if not self._current_message_ready:
+ *             raise BufferError('no message to consume')
+ *         if self._current_message_len_unread > 0:             # <<<<<<<<<<<<<<
+ *             mem = self.read(self._current_message_len_unread)
+ *         else:
+ */
+  __pyx_t_1 = ((__pyx_v_self->_current_message_len_unread > 0) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":527
+ *             raise BufferError('no message to consume')
+ *         if self._current_message_len_unread > 0:
+ *             mem = self.read(self._current_message_len_unread)             # <<<<<<<<<<<<<<
+ *         else:
+ *             mem = None
+ */
+    __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read(__pyx_v_self, __pyx_v_self->_current_message_len_unread); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 527, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_v_mem = __pyx_t_3;
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/buffer.pyx":526
+ *         if not self._current_message_ready:
+ *             raise BufferError('no message to consume')
+ *         if self._current_message_len_unread > 0:             # <<<<<<<<<<<<<<
+ *             mem = self.read(self._current_message_len_unread)
+ *         else:
+ */
+    goto __pyx_L4;
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":529
+ *             mem = self.read(self._current_message_len_unread)
+ *         else:
+ *             mem = None             # <<<<<<<<<<<<<<
+ *         self._discard_message()
+ *         return mem
+ */
+  /*else*/ {
+    __Pyx_INCREF(Py_None);
+    __pyx_v_mem = Py_None;
+  }
+  __pyx_L4:;
+
+  /* "asyncpg/protocol/buffer.pyx":530
+ *         else:
+ *             mem = None
+ *         self._discard_message()             # <<<<<<<<<<<<<<
+ *         return mem
+ * 
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__discard_message(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 530, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":531
+ *             mem = None
+ *         self._discard_message()
+ *         return mem             # <<<<<<<<<<<<<<
+ * 
+ *     cdef discard_message(self):
+ */
+  __Pyx_XDECREF(((PyObject *)__pyx_r));
+  if (!(likely(((__pyx_v_mem) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_mem, __pyx_ptype_7asyncpg_8protocol_8protocol_Memory))))) __PYX_ERR(1, 531, __pyx_L1_error)
+  __Pyx_INCREF(__pyx_v_mem);
+  __pyx_r = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *)__pyx_v_mem);
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/buffer.pyx":523
+ *         return buf
+ * 
+ *     cdef Memory consume_message(self):             # <<<<<<<<<<<<<<
+ *         if not self._current_message_ready:
+ *             raise BufferError('no message to consume')
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ReadBuffer.consume_message", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_mem);
+  __Pyx_XGIVEREF((PyObject *)__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":533
+ *         return mem
+ * 
+ *     cdef discard_message(self):             # <<<<<<<<<<<<<<
+ *         if self._current_message_type == 0:
+ *             # Already discarded
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_discard_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self) {
+  PyObject *__pyx_v_mtype = NULL;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *__pyx_v_discarded = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  int __pyx_t_6;
+  PyObject *__pyx_t_7 = NULL;
+  __Pyx_RefNannySetupContext("discard_message", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":534
+ * 
+ *     cdef discard_message(self):
+ *         if self._current_message_type == 0:             # <<<<<<<<<<<<<<
+ *             # Already discarded
+ *             return
+ */
+  __pyx_t_1 = ((__pyx_v_self->_current_message_type == 0) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":536
+ *         if self._current_message_type == 0:
+ *             # Already discarded
+ *             return             # <<<<<<<<<<<<<<
+ * 
+ *         if not self._current_message_ready:
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/buffer.pyx":534
+ * 
+ *     cdef discard_message(self):
+ *         if self._current_message_type == 0:             # <<<<<<<<<<<<<<
+ *             # Already discarded
+ *             return
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":538
+ *             return
+ * 
+ *         if not self._current_message_ready:             # <<<<<<<<<<<<<<
+ *             raise BufferError('no message to discard')
+ * 
+ */
+  __pyx_t_1 = ((!(__pyx_v_self->_current_message_ready != 0)) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":539
+ * 
+ *         if not self._current_message_ready:
+ *             raise BufferError('no message to discard')             # <<<<<<<<<<<<<<
+ * 
+ *         if self._current_message_len_unread:
+ */
+    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_BufferError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 539, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 539, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __PYX_ERR(1, 539, __pyx_L1_error)
+
+    /* "asyncpg/protocol/buffer.pyx":538
+ *             return
+ * 
+ *         if not self._current_message_ready:             # <<<<<<<<<<<<<<
+ *             raise BufferError('no message to discard')
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":541
+ *             raise BufferError('no message to discard')
+ * 
+ *         if self._current_message_len_unread:             # <<<<<<<<<<<<<<
+ *             if ASYNCPG_DEBUG:
+ *                 mtype = chr(self._current_message_type)
+ */
+  __pyx_t_1 = (__pyx_v_self->_current_message_len_unread != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":542
+ * 
+ *         if self._current_message_len_unread:
+ *             if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
+ *                 mtype = chr(self._current_message_type)
+ * 
+ */
+    __pyx_t_1 = (ASYNCPG_DEBUG != 0);
+    if (__pyx_t_1) {
+
+      /* "asyncpg/protocol/buffer.pyx":543
+ *         if self._current_message_len_unread:
+ *             if ASYNCPG_DEBUG:
+ *                 mtype = chr(self._current_message_type)             # <<<<<<<<<<<<<<
+ * 
+ *             discarded = self.consume_message()
+ */
+      __pyx_t_3 = __Pyx_PyInt_From_char(__pyx_v_self->_current_message_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 543, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 543, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_GIVEREF(__pyx_t_3);
+      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
+      __pyx_t_3 = 0;
+      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_chr, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 543, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_v_mtype = __pyx_t_3;
+      __pyx_t_3 = 0;
+
+      /* "asyncpg/protocol/buffer.pyx":542
+ * 
+ *         if self._current_message_len_unread:
+ *             if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
+ *                 mtype = chr(self._current_message_type)
+ * 
+ */
+    }
+
+    /* "asyncpg/protocol/buffer.pyx":545
+ *                 mtype = chr(self._current_message_type)
+ * 
+ *             discarded = self.consume_message()             # <<<<<<<<<<<<<<
+ * 
+ *             if ASYNCPG_DEBUG:
+ */
+    __pyx_t_3 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(__pyx_v_self)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 545, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_v_discarded = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *)__pyx_t_3);
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/buffer.pyx":547
+ *             discarded = self.consume_message()
+ * 
+ *             if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
+ *                 print('!!! discarding message {!r} unread data: {!r}'.format(
+ *                     mtype,
+ */
+    __pyx_t_1 = (ASYNCPG_DEBUG != 0);
+    if (__pyx_t_1) {
+
+      /* "asyncpg/protocol/buffer.pyx":548
+ * 
+ *             if ASYNCPG_DEBUG:
+ *                 print('!!! discarding message {!r} unread data: {!r}'.format(             # <<<<<<<<<<<<<<
+ *                     mtype,
+ *                     (<Memory>discarded).as_bytes()))
+ */
+      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_discarding_message_r_unread_dat, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 548, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+
+      /* "asyncpg/protocol/buffer.pyx":549
+ *             if ASYNCPG_DEBUG:
+ *                 print('!!! discarding message {!r} unread data: {!r}'.format(
+ *                     mtype,             # <<<<<<<<<<<<<<
+ *                     (<Memory>discarded).as_bytes()))
+ * 
+ */
+      if (unlikely(!__pyx_v_mtype)) { __Pyx_RaiseUnboundLocalError("mtype"); __PYX_ERR(1, 549, __pyx_L1_error) }
+
+      /* "asyncpg/protocol/buffer.pyx":550
+ *                 print('!!! discarding message {!r} unread data: {!r}'.format(
+ *                     mtype,
+ *                     (<Memory>discarded).as_bytes()))             # <<<<<<<<<<<<<<
+ * 
+ *         self._discard_message()
+ */
+      __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_6Memory_as_bytes(((struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *)__pyx_v_discarded)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 550, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_5 = NULL;
+      __pyx_t_6 = 0;
+      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
+        if (likely(__pyx_t_5)) {
+          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+          __Pyx_INCREF(__pyx_t_5);
+          __Pyx_INCREF(function);
+          __Pyx_DECREF_SET(__pyx_t_2, function);
+          __pyx_t_6 = 1;
+        }
+      }
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_2)) {
+        PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_mtype, __pyx_t_4};
+        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 548, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+        PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_mtype, __pyx_t_4};
+        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 548, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 548, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_7);
+        if (__pyx_t_5) {
+          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
+        }
+        __Pyx_INCREF(__pyx_v_mtype);
+        __Pyx_GIVEREF(__pyx_v_mtype);
+        PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_mtype);
+        __Pyx_GIVEREF(__pyx_t_4);
+        PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4);
+        __pyx_t_4 = 0;
+        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 548, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      }
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+      /* "asyncpg/protocol/buffer.pyx":548
+ * 
+ *             if ASYNCPG_DEBUG:
+ *                 print('!!! discarding message {!r} unread data: {!r}'.format(             # <<<<<<<<<<<<<<
+ *                     mtype,
+ *                     (<Memory>discarded).as_bytes()))
+ */
+      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 548, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_GIVEREF(__pyx_t_3);
+      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
+      __pyx_t_3 = 0;
+      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 548, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+      /* "asyncpg/protocol/buffer.pyx":547
+ *             discarded = self.consume_message()
+ * 
+ *             if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
+ *                 print('!!! discarding message {!r} unread data: {!r}'.format(
+ *                     mtype,
+ */
+    }
+
+    /* "asyncpg/protocol/buffer.pyx":541
+ *             raise BufferError('no message to discard')
+ * 
+ *         if self._current_message_len_unread:             # <<<<<<<<<<<<<<
+ *             if ASYNCPG_DEBUG:
+ *                 mtype = chr(self._current_message_type)
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":552
+ *                     (<Memory>discarded).as_bytes()))
+ * 
+ *         self._discard_message()             # <<<<<<<<<<<<<<
+ * 
+ *     cdef inline _discard_message(self):
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__discard_message(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 552, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":533
+ *         return mem
+ * 
+ *     cdef discard_message(self):             # <<<<<<<<<<<<<<
+ *         if self._current_message_type == 0:
+ *             # Already discarded
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ReadBuffer.discard_message", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_mtype);
+  __Pyx_XDECREF((PyObject *)__pyx_v_discarded);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":554
+ *         self._discard_message()
+ * 
+ *     cdef inline _discard_message(self):             # <<<<<<<<<<<<<<
+ *         self._current_message_type = 0
+ *         self._current_message_len = 0
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__discard_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("_discard_message", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":555
+ * 
+ *     cdef inline _discard_message(self):
+ *         self._current_message_type = 0             # <<<<<<<<<<<<<<
+ *         self._current_message_len = 0
+ *         self._current_message_ready = 0
+ */
+  __pyx_v_self->_current_message_type = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":556
+ *     cdef inline _discard_message(self):
+ *         self._current_message_type = 0
+ *         self._current_message_len = 0             # <<<<<<<<<<<<<<
+ *         self._current_message_ready = 0
+ *         self._current_message_len_unread = 0
+ */
+  __pyx_v_self->_current_message_len = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":557
+ *         self._current_message_type = 0
+ *         self._current_message_len = 0
+ *         self._current_message_ready = 0             # <<<<<<<<<<<<<<
+ *         self._current_message_len_unread = 0
+ * 
+ */
+  __pyx_v_self->_current_message_ready = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":558
+ *         self._current_message_len = 0
+ *         self._current_message_ready = 0
+ *         self._current_message_len_unread = 0             # <<<<<<<<<<<<<<
+ * 
+ *     cdef inline char get_message_type(self):
+ */
+  __pyx_v_self->_current_message_len_unread = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":554
+ *         self._discard_message()
+ * 
+ *     cdef inline _discard_message(self):             # <<<<<<<<<<<<<<
+ *         self._current_message_type = 0
+ *         self._current_message_len = 0
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":560
+ *         self._current_message_len_unread = 0
+ * 
+ *     cdef inline char get_message_type(self):             # <<<<<<<<<<<<<<
+ *         return self._current_message_type
+ * 
+ */
+
+static CYTHON_INLINE char __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_get_message_type(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self) {
+  char __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("get_message_type", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":561
+ * 
+ *     cdef inline char get_message_type(self):
+ *         return self._current_message_type             # <<<<<<<<<<<<<<
+ * 
+ *     cdef inline int32_t get_message_length(self):
+ */
+  __pyx_r = __pyx_v_self->_current_message_type;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/buffer.pyx":560
+ *         self._current_message_len_unread = 0
+ * 
+ *     cdef inline char get_message_type(self):             # <<<<<<<<<<<<<<
+ *         return self._current_message_type
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":563
+ *         return self._current_message_type
+ * 
+ *     cdef inline int32_t get_message_length(self):             # <<<<<<<<<<<<<<
+ *         return self._current_message_len
+ * 
+ */
+
+static CYTHON_INLINE int32_t __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_get_message_length(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self) {
+  int32_t __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("get_message_length", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":564
+ * 
+ *     cdef inline int32_t get_message_length(self):
+ *         return self._current_message_len             # <<<<<<<<<<<<<<
+ * 
+ *     @staticmethod
+ */
+  __pyx_r = __pyx_v_self->_current_message_len;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/buffer.pyx":563
+ *         return self._current_message_type
+ * 
+ *     cdef inline int32_t get_message_length(self):             # <<<<<<<<<<<<<<
+ *         return self._current_message_len
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":567
+ * 
+ *     @staticmethod
+ *     cdef ReadBuffer new_message_parser(object data):             # <<<<<<<<<<<<<<
+ *         cdef ReadBuffer buf
+ * 
+ */
+
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_new_message_parser(PyObject *__pyx_v_data) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_buf = 0;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  Py_ssize_t __pyx_t_2;
+  __Pyx_RefNannySetupContext("new_message_parser", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":570
+ *         cdef ReadBuffer buf
+ * 
+ *         buf = ReadBuffer.__new__(ReadBuffer)             # <<<<<<<<<<<<<<
+ *         buf.feed_data(data)
+ * 
+ */
+  __pyx_t_1 = __pyx_tp_new_7asyncpg_8protocol_8protocol_ReadBuffer(((PyTypeObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_ReadBuffer), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 570, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7asyncpg_8protocol_8protocol_ReadBuffer)))) __PYX_ERR(1, 570, __pyx_L1_error)
+  __pyx_v_buf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":571
+ * 
+ *         buf = ReadBuffer.__new__(ReadBuffer)
+ *         buf.feed_data(data)             # <<<<<<<<<<<<<<
+ * 
+ *         buf._current_message_ready = 1
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_feed_data(__pyx_v_buf, __pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 571, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":573
+ *         buf.feed_data(data)
+ * 
+ *         buf._current_message_ready = 1             # <<<<<<<<<<<<<<
+ *         buf._current_message_len_unread = buf._len0
+ * 
+ */
+  __pyx_v_buf->_current_message_ready = 1;
+
+  /* "asyncpg/protocol/buffer.pyx":574
+ * 
+ *         buf._current_message_ready = 1
+ *         buf._current_message_len_unread = buf._len0             # <<<<<<<<<<<<<<
+ * 
+ *         return buf
+ */
+  __pyx_t_2 = __pyx_v_buf->_len0;
+  __pyx_v_buf->_current_message_len_unread = __pyx_t_2;
+
+  /* "asyncpg/protocol/buffer.pyx":576
+ *         buf._current_message_len_unread = buf._len0
+ * 
+ *         return buf             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(((PyObject *)__pyx_r));
+  __Pyx_INCREF(((PyObject *)__pyx_v_buf));
+  __pyx_r = __pyx_v_buf;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/buffer.pyx":567
+ * 
+ *     @staticmethod
+ *     cdef ReadBuffer new_message_parser(object data):             # <<<<<<<<<<<<<<
+ *         cdef ReadBuffer buf
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.ReadBuffer.new_message_parser", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_buf);
+  __Pyx_XGIVEREF((PyObject *)__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":584
+ * cdef class FastReadBuffer:
+ * 
+ *     cdef inline const char* read(self, ssize_t n) except NULL:             # <<<<<<<<<<<<<<
+ *         cdef const char *result
+ * 
+ */
+
+static CYTHON_INLINE char const *__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_self, Py_ssize_t __pyx_v_n) {
+  char const *__pyx_v_result;
+  char const *__pyx_r;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  char const *__pyx_t_3;
+  __Pyx_RefNannySetupContext("read", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":587
+ *         cdef const char *result
+ * 
+ *         if n > self.len:             # <<<<<<<<<<<<<<
+ *             self._raise_ins_err(n, self.len)
+ * 
+ */
+  __pyx_t_1 = ((__pyx_v_n > __pyx_v_self->len) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/buffer.pyx":588
+ * 
+ *         if n > self.len:
+ *             self._raise_ins_err(n, self.len)             # <<<<<<<<<<<<<<
+ * 
+ *         result = self.buf
+ */
+    __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer__raise_ins_err(__pyx_v_self, __pyx_v_n, __pyx_v_self->len); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 588, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "asyncpg/protocol/buffer.pyx":587
+ *         cdef const char *result
+ * 
+ *         if n > self.len:             # <<<<<<<<<<<<<<
+ *             self._raise_ins_err(n, self.len)
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/buffer.pyx":590
+ *             self._raise_ins_err(n, self.len)
+ * 
+ *         result = self.buf             # <<<<<<<<<<<<<<
+ *         self.buf += n
+ *         self.len -= n
+ */
+  __pyx_t_3 = __pyx_v_self->buf;
+  __pyx_v_result = __pyx_t_3;
+
+  /* "asyncpg/protocol/buffer.pyx":591
+ * 
+ *         result = self.buf
+ *         self.buf += n             # <<<<<<<<<<<<<<
+ *         self.len -= n
+ * 
+ */
+  __pyx_v_self->buf = (__pyx_v_self->buf + __pyx_v_n);
+
+  /* "asyncpg/protocol/buffer.pyx":592
+ *         result = self.buf
+ *         self.buf += n
+ *         self.len -= n             # <<<<<<<<<<<<<<
+ * 
+ *         return result
+ */
+  __pyx_v_self->len = (__pyx_v_self->len - __pyx_v_n);
+
+  /* "asyncpg/protocol/buffer.pyx":594
+ *         self.len -= n
+ * 
+ *         return result             # <<<<<<<<<<<<<<
+ * 
+ *     cdef inline const char* read_all(self):
+ */
+  __pyx_r = __pyx_v_result;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/buffer.pyx":584
+ * cdef class FastReadBuffer:
+ * 
+ *     cdef inline const char* read(self, ssize_t n) except NULL:             # <<<<<<<<<<<<<<
+ *         cdef const char *result
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.FastReadBuffer.read", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":596
+ *         return result
+ * 
+ *     cdef inline const char* read_all(self):             # <<<<<<<<<<<<<<
+ *         cdef const char *result
+ *         result = self.buf
+ */
+
+static CYTHON_INLINE char const *__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read_all(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_self) {
+  char const *__pyx_v_result;
+  char const *__pyx_r;
+  __Pyx_RefNannyDeclarations
+  char const *__pyx_t_1;
+  __Pyx_RefNannySetupContext("read_all", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":598
+ *     cdef inline const char* read_all(self):
+ *         cdef const char *result
+ *         result = self.buf             # <<<<<<<<<<<<<<
+ *         self.buf += self.len
+ *         self.len = 0
+ */
+  __pyx_t_1 = __pyx_v_self->buf;
+  __pyx_v_result = __pyx_t_1;
+
+  /* "asyncpg/protocol/buffer.pyx":599
+ *         cdef const char *result
+ *         result = self.buf
+ *         self.buf += self.len             # <<<<<<<<<<<<<<
+ *         self.len = 0
+ *         return result
+ */
+  __pyx_v_self->buf = (__pyx_v_self->buf + __pyx_v_self->len);
+
+  /* "asyncpg/protocol/buffer.pyx":600
+ *         result = self.buf
+ *         self.buf += self.len
+ *         self.len = 0             # <<<<<<<<<<<<<<
+ *         return result
+ * 
+ */
+  __pyx_v_self->len = 0;
+
+  /* "asyncpg/protocol/buffer.pyx":601
+ *         self.buf += self.len
+ *         self.len = 0
+ *         return result             # <<<<<<<<<<<<<<
+ * 
+ *     cdef inline FastReadBuffer slice_from(self, FastReadBuffer source,
+ */
+  __pyx_r = __pyx_v_result;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/buffer.pyx":596
+ *         return result
+ * 
+ *     cdef inline const char* read_all(self):             # <<<<<<<<<<<<<<
+ *         cdef const char *result
+ *         result = self.buf
+ */
+
+  /* function exit code */
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":603
+ *         return result
+ * 
+ *     cdef inline FastReadBuffer slice_from(self, FastReadBuffer source,             # <<<<<<<<<<<<<<
+ *                                           ssize_t len):
+ *         self.buf = source.read(len)
+ */
+
+static CYTHON_INLINE struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_slice_from(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_source, Py_ssize_t __pyx_v_len) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  char const *__pyx_t_1;
+  __Pyx_RefNannySetupContext("slice_from", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":605
+ *     cdef inline FastReadBuffer slice_from(self, FastReadBuffer source,
+ *                                           ssize_t len):
+ *         self.buf = source.read(len)             # <<<<<<<<<<<<<<
+ *         self.len = len
+ *         return self
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_source, __pyx_v_len); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(1, 605, __pyx_L1_error)
+  __pyx_v_self->buf = __pyx_t_1;
+
+  /* "asyncpg/protocol/buffer.pyx":606
+ *                                           ssize_t len):
+ *         self.buf = source.read(len)
+ *         self.len = len             # <<<<<<<<<<<<<<
+ *         return self
+ * 
+ */
+  __pyx_v_self->len = __pyx_v_len;
+
+  /* "asyncpg/protocol/buffer.pyx":607
+ *         self.buf = source.read(len)
+ *         self.len = len
+ *         return self             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _raise_ins_err(self, ssize_t n, ssize_t len):
+ */
+  __Pyx_XDECREF(((PyObject *)__pyx_r));
+  __Pyx_INCREF(((PyObject *)__pyx_v_self));
+  __pyx_r = __pyx_v_self;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/buffer.pyx":603
+ *         return result
+ * 
+ *     cdef inline FastReadBuffer slice_from(self, FastReadBuffer source,             # <<<<<<<<<<<<<<
+ *                                           ssize_t len):
+ *         self.buf = source.read(len)
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.FastReadBuffer.slice_from", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF((PyObject *)__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":609
+ *         return self
+ * 
+ *     cdef _raise_ins_err(self, ssize_t n, ssize_t len):             # <<<<<<<<<<<<<<
+ *         raise BufferError(
+ *             'insufficient data in buffer: requested {}, remaining {}'.
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer__raise_ins_err(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_self, Py_ssize_t __pyx_v_n, CYTHON_UNUSED Py_ssize_t __pyx_v_len) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  int __pyx_t_8;
+  PyObject *__pyx_t_9 = NULL;
+  __Pyx_RefNannySetupContext("_raise_ins_err", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":610
+ * 
+ *     cdef _raise_ins_err(self, ssize_t n, ssize_t len):
+ *         raise BufferError(             # <<<<<<<<<<<<<<
+ *             'insufficient data in buffer: requested {}, remaining {}'.
+ *                 format(n, self.len))
+ */
+  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_BufferError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 610, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+
+  /* "asyncpg/protocol/buffer.pyx":611
+ *     cdef _raise_ins_err(self, ssize_t n, ssize_t len):
+ *         raise BufferError(
+ *             'insufficient data in buffer: requested {}, remaining {}'.             # <<<<<<<<<<<<<<
+ *                 format(n, self.len))
+ * 
+ */
+  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_insufficient_data_in_buffer_requ, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 611, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+
+  /* "asyncpg/protocol/buffer.pyx":612
+ *         raise BufferError(
+ *             'insufficient data in buffer: requested {}, remaining {}'.
+ *                 format(n, self.len))             # <<<<<<<<<<<<<<
+ * 
+ *     @staticmethod
+ */
+  __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 612, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_self->len); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 612, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_6);
+  __pyx_t_7 = NULL;
+  __pyx_t_8 = 0;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
+    if (likely(__pyx_t_7)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+      __Pyx_INCREF(__pyx_t_7);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_4, function);
+      __pyx_t_8 = 1;
+    }
+  }
+  #if CYTHON_FAST_PYCALL
+  if (PyFunction_Check(__pyx_t_4)) {
+    PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_5, __pyx_t_6};
+    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 612, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  } else
+  #endif
+  #if CYTHON_FAST_PYCCALL
+  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
+    PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_5, __pyx_t_6};
+    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 612, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  } else
+  #endif
+  {
+    __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 612, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_9);
+    if (__pyx_t_7) {
+      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
+    }
+    __Pyx_GIVEREF(__pyx_t_5);
+    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_5);
+    __Pyx_GIVEREF(__pyx_t_6);
+    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_6);
+    __pyx_t_5 = 0;
+    __pyx_t_6 = 0;
+    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 612, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = NULL;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_4)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_4);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (!__pyx_t_4) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 610, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
+      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 610, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
+      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 610, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    } else
+    #endif
+    {
+      __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 610, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); __pyx_t_4 = NULL;
+      __Pyx_GIVEREF(__pyx_t_3);
+      PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_3);
+      __pyx_t_3 = 0;
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 610, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __PYX_ERR(1, 610, __pyx_L1_error)
+
+  /* "asyncpg/protocol/buffer.pyx":609
+ *         return self
+ * 
+ *     cdef _raise_ins_err(self, ssize_t n, ssize_t len):             # <<<<<<<<<<<<<<
+ *         raise BufferError(
+ *             'insufficient data in buffer: requested {}, remaining {}'.
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.FastReadBuffer._raise_ins_err", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/buffer.pyx":615
+ * 
+ *     @staticmethod
+ *     cdef FastReadBuffer new():             # <<<<<<<<<<<<<<
+ *         return FastReadBuffer.__new__(FastReadBuffer)
+ */
+
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_new(void) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("new", 0);
+
+  /* "asyncpg/protocol/buffer.pyx":616
+ *     @staticmethod
+ *     cdef FastReadBuffer new():
+ *         return FastReadBuffer.__new__(FastReadBuffer)             # <<<<<<<<<<<<<<
+ */
+  __Pyx_XDECREF(((PyObject *)__pyx_r));
+  __pyx_t_1 = __pyx_tp_new_7asyncpg_8protocol_8protocol_FastReadBuffer(((PyTypeObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_FastReadBuffer), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 616, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7asyncpg_8protocol_8protocol_FastReadBuffer)))) __PYX_ERR(1, 616, __pyx_L1_error)
+  __pyx_r = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/buffer.pyx":615
+ * 
+ *     @staticmethod
+ *     cdef FastReadBuffer new():             # <<<<<<<<<<<<<<
+ *         return FastReadBuffer.__new__(FastReadBuffer)
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.FastReadBuffer.new", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF((PyObject *)__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":17
+ * cdef class Codec:
+ * 
+ *     def __cinit__(self, uint32_t oid):             # <<<<<<<<<<<<<<
+ *         self.oid = oid
+ *         self.type = CODEC_UNDEFINED
+ */
+
+/* Python wrapper */
+static int __pyx_pw_7asyncpg_8protocol_8protocol_5Codec_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pw_7asyncpg_8protocol_8protocol_5Codec_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  uint32_t __pyx_v_oid;
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_oid,0};
+    PyObject* values[1] = {0};
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_oid)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+      }
+      if (unlikely(kw_args > 0)) {
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(2, 17, __pyx_L3_error)
+      }
+    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
+      goto __pyx_L5_argtuple_error;
+    } else {
+      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+    }
+    __pyx_v_oid = __Pyx_PyInt_As_uint32_t(values[0]); if (unlikely((__pyx_v_oid == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(2, 17, __pyx_L3_error)
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 17, __pyx_L3_error)
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return -1;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_5Codec___cinit__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_v_self), __pyx_v_oid);
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static int __pyx_pf_7asyncpg_8protocol_8protocol_5Codec___cinit__(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, uint32_t __pyx_v_oid) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__cinit__", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":18
+ * 
+ *     def __cinit__(self, uint32_t oid):
+ *         self.oid = oid             # <<<<<<<<<<<<<<
+ *         self.type = CODEC_UNDEFINED
+ * 
+ */
+  __pyx_v_self->oid = __pyx_v_oid;
+
+  /* "asyncpg/protocol/codecs/base.pyx":19
+ *     def __cinit__(self, uint32_t oid):
+ *         self.oid = oid
+ *         self.type = CODEC_UNDEFINED             # <<<<<<<<<<<<<<
+ * 
+ *     cdef init(self, str name, str schema, str kind,
+ */
+  __pyx_v_self->type = __pyx_e_7asyncpg_8protocol_8protocol_CODEC_UNDEFINED;
+
+  /* "asyncpg/protocol/codecs/base.pyx":17
+ * cdef class Codec:
+ * 
+ *     def __cinit__(self, uint32_t oid):             # <<<<<<<<<<<<<<
+ *         self.oid = oid
+ *         self.type = CODEC_UNDEFINED
+ */
+
+  /* function exit code */
+  __pyx_r = 0;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":21
+ *         self.type = CODEC_UNDEFINED
+ * 
+ *     cdef init(self, str name, str schema, str kind,             # <<<<<<<<<<<<<<
+ *               CodecType type, CodecFormat format,
+ *               encode_func c_encoder, decode_func c_decoder,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_init(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_schema, PyObject *__pyx_v_kind, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecType __pyx_v_type, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat __pyx_v_format, __pyx_t_7asyncpg_8protocol_8protocol_encode_func __pyx_v_c_encoder, __pyx_t_7asyncpg_8protocol_8protocol_decode_func __pyx_v_c_decoder, PyObject *__pyx_v_py_encoder, PyObject *__pyx_v_py_decoder, struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_element_codec, PyObject *__pyx_v_element_type_oids, PyObject *__pyx_v_element_names, PyObject *__pyx_v_element_codecs, Py_UCS4 __pyx_v_element_delimiter) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  __Pyx_RefNannySetupContext("init", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":29
+ *               Py_UCS4 element_delimiter):
+ * 
+ *         self.name = name             # <<<<<<<<<<<<<<
+ *         self.schema = schema
+ *         self.kind = kind
+ */
+  __Pyx_INCREF(__pyx_v_name);
+  __Pyx_GIVEREF(__pyx_v_name);
+  __Pyx_GOTREF(__pyx_v_self->name);
+  __Pyx_DECREF(__pyx_v_self->name);
+  __pyx_v_self->name = __pyx_v_name;
+
+  /* "asyncpg/protocol/codecs/base.pyx":30
+ * 
+ *         self.name = name
+ *         self.schema = schema             # <<<<<<<<<<<<<<
+ *         self.kind = kind
+ *         self.type = type
+ */
+  __Pyx_INCREF(__pyx_v_schema);
+  __Pyx_GIVEREF(__pyx_v_schema);
+  __Pyx_GOTREF(__pyx_v_self->schema);
+  __Pyx_DECREF(__pyx_v_self->schema);
+  __pyx_v_self->schema = __pyx_v_schema;
+
+  /* "asyncpg/protocol/codecs/base.pyx":31
+ *         self.name = name
+ *         self.schema = schema
+ *         self.kind = kind             # <<<<<<<<<<<<<<
+ *         self.type = type
+ *         self.format = format
+ */
+  __Pyx_INCREF(__pyx_v_kind);
+  __Pyx_GIVEREF(__pyx_v_kind);
+  __Pyx_GOTREF(__pyx_v_self->kind);
+  __Pyx_DECREF(__pyx_v_self->kind);
+  __pyx_v_self->kind = __pyx_v_kind;
+
+  /* "asyncpg/protocol/codecs/base.pyx":32
+ *         self.schema = schema
+ *         self.kind = kind
+ *         self.type = type             # <<<<<<<<<<<<<<
+ *         self.format = format
+ *         self.c_encoder = c_encoder
+ */
+  __pyx_v_self->type = __pyx_v_type;
+
+  /* "asyncpg/protocol/codecs/base.pyx":33
+ *         self.kind = kind
+ *         self.type = type
+ *         self.format = format             # <<<<<<<<<<<<<<
+ *         self.c_encoder = c_encoder
+ *         self.c_decoder = c_decoder
+ */
+  __pyx_v_self->format = __pyx_v_format;
+
+  /* "asyncpg/protocol/codecs/base.pyx":34
+ *         self.type = type
+ *         self.format = format
+ *         self.c_encoder = c_encoder             # <<<<<<<<<<<<<<
+ *         self.c_decoder = c_decoder
+ *         self.py_encoder = py_encoder
+ */
+  __pyx_v_self->c_encoder = __pyx_v_c_encoder;
+
+  /* "asyncpg/protocol/codecs/base.pyx":35
+ *         self.format = format
+ *         self.c_encoder = c_encoder
+ *         self.c_decoder = c_decoder             # <<<<<<<<<<<<<<
+ *         self.py_encoder = py_encoder
+ *         self.py_decoder = py_decoder
+ */
+  __pyx_v_self->c_decoder = __pyx_v_c_decoder;
+
+  /* "asyncpg/protocol/codecs/base.pyx":36
+ *         self.c_encoder = c_encoder
+ *         self.c_decoder = c_decoder
+ *         self.py_encoder = py_encoder             # <<<<<<<<<<<<<<
+ *         self.py_decoder = py_decoder
+ *         self.element_codec = element_codec
+ */
+  __Pyx_INCREF(__pyx_v_py_encoder);
+  __Pyx_GIVEREF(__pyx_v_py_encoder);
+  __Pyx_GOTREF(__pyx_v_self->py_encoder);
+  __Pyx_DECREF(__pyx_v_self->py_encoder);
+  __pyx_v_self->py_encoder = __pyx_v_py_encoder;
+
+  /* "asyncpg/protocol/codecs/base.pyx":37
+ *         self.c_decoder = c_decoder
+ *         self.py_encoder = py_encoder
+ *         self.py_decoder = py_decoder             # <<<<<<<<<<<<<<
+ *         self.element_codec = element_codec
+ *         self.element_type_oids = element_type_oids
+ */
+  __Pyx_INCREF(__pyx_v_py_decoder);
+  __Pyx_GIVEREF(__pyx_v_py_decoder);
+  __Pyx_GOTREF(__pyx_v_self->py_decoder);
+  __Pyx_DECREF(__pyx_v_self->py_decoder);
+  __pyx_v_self->py_decoder = __pyx_v_py_decoder;
+
+  /* "asyncpg/protocol/codecs/base.pyx":38
+ *         self.py_encoder = py_encoder
+ *         self.py_decoder = py_decoder
+ *         self.element_codec = element_codec             # <<<<<<<<<<<<<<
+ *         self.element_type_oids = element_type_oids
+ *         self.element_codecs = element_codecs
+ */
+  __Pyx_INCREF(((PyObject *)__pyx_v_element_codec));
+  __Pyx_GIVEREF(((PyObject *)__pyx_v_element_codec));
+  __Pyx_GOTREF(__pyx_v_self->element_codec);
+  __Pyx_DECREF(((PyObject *)__pyx_v_self->element_codec));
+  __pyx_v_self->element_codec = __pyx_v_element_codec;
+
+  /* "asyncpg/protocol/codecs/base.pyx":39
+ *         self.py_decoder = py_decoder
+ *         self.element_codec = element_codec
+ *         self.element_type_oids = element_type_oids             # <<<<<<<<<<<<<<
+ *         self.element_codecs = element_codecs
+ *         self.element_delimiter = element_delimiter
+ */
+  __Pyx_INCREF(__pyx_v_element_type_oids);
+  __Pyx_GIVEREF(__pyx_v_element_type_oids);
+  __Pyx_GOTREF(__pyx_v_self->element_type_oids);
+  __Pyx_DECREF(__pyx_v_self->element_type_oids);
+  __pyx_v_self->element_type_oids = __pyx_v_element_type_oids;
+
+  /* "asyncpg/protocol/codecs/base.pyx":40
+ *         self.element_codec = element_codec
+ *         self.element_type_oids = element_type_oids
+ *         self.element_codecs = element_codecs             # <<<<<<<<<<<<<<
+ *         self.element_delimiter = element_delimiter
+ * 
+ */
+  __Pyx_INCREF(__pyx_v_element_codecs);
+  __Pyx_GIVEREF(__pyx_v_element_codecs);
+  __Pyx_GOTREF(__pyx_v_self->element_codecs);
+  __Pyx_DECREF(__pyx_v_self->element_codecs);
+  __pyx_v_self->element_codecs = __pyx_v_element_codecs;
+
+  /* "asyncpg/protocol/codecs/base.pyx":41
+ *         self.element_type_oids = element_type_oids
+ *         self.element_codecs = element_codecs
+ *         self.element_delimiter = element_delimiter             # <<<<<<<<<<<<<<
+ * 
+ *         if element_names is not None:
+ */
+  __pyx_v_self->element_delimiter = __pyx_v_element_delimiter;
+
+  /* "asyncpg/protocol/codecs/base.pyx":43
+ *         self.element_delimiter = element_delimiter
+ * 
+ *         if element_names is not None:             # <<<<<<<<<<<<<<
+ *             self.element_names = record.ApgRecordDesc_New(
+ *                 element_names, tuple(element_names))
+ */
+  __pyx_t_1 = (__pyx_v_element_names != Py_None);
+  __pyx_t_2 = (__pyx_t_1 != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/codecs/base.pyx":45
+ *         if element_names is not None:
+ *             self.element_names = record.ApgRecordDesc_New(
+ *                 element_names, tuple(element_names))             # <<<<<<<<<<<<<<
+ *         else:
+ *             self.element_names = None
+ */
+    __pyx_t_3 = PySequence_Tuple(__pyx_v_element_names); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 45, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+
+    /* "asyncpg/protocol/codecs/base.pyx":44
+ * 
+ *         if element_names is not None:
+ *             self.element_names = record.ApgRecordDesc_New(             # <<<<<<<<<<<<<<
+ *                 element_names, tuple(element_names))
+ *         else:
+ */
+    __pyx_t_4 = ApgRecordDesc_New(__pyx_v_element_names, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 44, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_GIVEREF(__pyx_t_4);
+    __Pyx_GOTREF(__pyx_v_self->element_names);
+    __Pyx_DECREF(__pyx_v_self->element_names);
+    __pyx_v_self->element_names = __pyx_t_4;
+    __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":43
+ *         self.element_delimiter = element_delimiter
+ * 
+ *         if element_names is not None:             # <<<<<<<<<<<<<<
+ *             self.element_names = record.ApgRecordDesc_New(
+ *                 element_names, tuple(element_names))
+ */
+    goto __pyx_L3;
+  }
+
+  /* "asyncpg/protocol/codecs/base.pyx":47
+ *                 element_names, tuple(element_names))
+ *         else:
+ *             self.element_names = None             # <<<<<<<<<<<<<<
+ * 
+ *         if type == CODEC_C:
+ */
+  /*else*/ {
+    __Pyx_INCREF(Py_None);
+    __Pyx_GIVEREF(Py_None);
+    __Pyx_GOTREF(__pyx_v_self->element_names);
+    __Pyx_DECREF(__pyx_v_self->element_names);
+    __pyx_v_self->element_names = Py_None;
+  }
+  __pyx_L3:;
+
+  /* "asyncpg/protocol/codecs/base.pyx":49
+ *             self.element_names = None
+ * 
+ *         if type == CODEC_C:             # <<<<<<<<<<<<<<
+ *             self.encoder = <codec_encode_func>&self.encode_scalar
+ *             self.decoder = <codec_decode_func>&self.decode_scalar
+ */
+  switch (__pyx_v_type) {
+    case __pyx_e_7asyncpg_8protocol_8protocol_CODEC_C:
+
+    /* "asyncpg/protocol/codecs/base.pyx":50
+ * 
+ *         if type == CODEC_C:
+ *             self.encoder = <codec_encode_func>&self.encode_scalar             # <<<<<<<<<<<<<<
+ *             self.decoder = <codec_decode_func>&self.decode_scalar
+ *         elif type == CODEC_ARRAY:
+ */
+    __pyx_v_self->encoder = ((__pyx_t_7asyncpg_8protocol_8protocol_codec_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_scalar));
+
+    /* "asyncpg/protocol/codecs/base.pyx":51
+ *         if type == CODEC_C:
+ *             self.encoder = <codec_encode_func>&self.encode_scalar
+ *             self.decoder = <codec_decode_func>&self.decode_scalar             # <<<<<<<<<<<<<<
+ *         elif type == CODEC_ARRAY:
+ *             self.encoder = <codec_encode_func>&self.encode_array
+ */
+    __pyx_v_self->decoder = ((__pyx_t_7asyncpg_8protocol_8protocol_codec_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_scalar));
+
+    /* "asyncpg/protocol/codecs/base.pyx":49
+ *             self.element_names = None
+ * 
+ *         if type == CODEC_C:             # <<<<<<<<<<<<<<
+ *             self.encoder = <codec_encode_func>&self.encode_scalar
+ *             self.decoder = <codec_decode_func>&self.decode_scalar
+ */
+    break;
+
+    /* "asyncpg/protocol/codecs/base.pyx":52
+ *             self.encoder = <codec_encode_func>&self.encode_scalar
+ *             self.decoder = <codec_decode_func>&self.decode_scalar
+ *         elif type == CODEC_ARRAY:             # <<<<<<<<<<<<<<
+ *             self.encoder = <codec_encode_func>&self.encode_array
+ *             if format == PG_FORMAT_BINARY:
+ */
+    case __pyx_e_7asyncpg_8protocol_8protocol_CODEC_ARRAY:
+
+    /* "asyncpg/protocol/codecs/base.pyx":53
+ *             self.decoder = <codec_decode_func>&self.decode_scalar
+ *         elif type == CODEC_ARRAY:
+ *             self.encoder = <codec_encode_func>&self.encode_array             # <<<<<<<<<<<<<<
+ *             if format == PG_FORMAT_BINARY:
+ *                 self.decoder = <codec_decode_func>&self.decode_array
+ */
+    __pyx_v_self->encoder = ((__pyx_t_7asyncpg_8protocol_8protocol_codec_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_array));
+
+    /* "asyncpg/protocol/codecs/base.pyx":54
+ *         elif type == CODEC_ARRAY:
+ *             self.encoder = <codec_encode_func>&self.encode_array
+ *             if format == PG_FORMAT_BINARY:             # <<<<<<<<<<<<<<
+ *                 self.decoder = <codec_decode_func>&self.decode_array
+ *             else:
+ */
+    __pyx_t_2 = ((__pyx_v_format == __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY) != 0);
+    if (__pyx_t_2) {
+
+      /* "asyncpg/protocol/codecs/base.pyx":55
+ *             self.encoder = <codec_encode_func>&self.encode_array
+ *             if format == PG_FORMAT_BINARY:
+ *                 self.decoder = <codec_decode_func>&self.decode_array             # <<<<<<<<<<<<<<
+ *             else:
+ *                 self.decoder = <codec_decode_func>&self.decode_array_text
+ */
+      __pyx_v_self->decoder = ((__pyx_t_7asyncpg_8protocol_8protocol_codec_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_array));
+
+      /* "asyncpg/protocol/codecs/base.pyx":54
+ *         elif type == CODEC_ARRAY:
+ *             self.encoder = <codec_encode_func>&self.encode_array
+ *             if format == PG_FORMAT_BINARY:             # <<<<<<<<<<<<<<
+ *                 self.decoder = <codec_decode_func>&self.decode_array
+ *             else:
+ */
+      goto __pyx_L4;
+    }
+
+    /* "asyncpg/protocol/codecs/base.pyx":57
+ *                 self.decoder = <codec_decode_func>&self.decode_array
+ *             else:
+ *                 self.decoder = <codec_decode_func>&self.decode_array_text             # <<<<<<<<<<<<<<
+ *         elif type == CODEC_RANGE:
+ *             self.encoder = <codec_encode_func>&self.encode_range
+ */
+    /*else*/ {
+      __pyx_v_self->decoder = ((__pyx_t_7asyncpg_8protocol_8protocol_codec_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_array_text));
+    }
+    __pyx_L4:;
+
+    /* "asyncpg/protocol/codecs/base.pyx":52
+ *             self.encoder = <codec_encode_func>&self.encode_scalar
+ *             self.decoder = <codec_decode_func>&self.decode_scalar
+ *         elif type == CODEC_ARRAY:             # <<<<<<<<<<<<<<
+ *             self.encoder = <codec_encode_func>&self.encode_array
+ *             if format == PG_FORMAT_BINARY:
+ */
+    break;
+
+    /* "asyncpg/protocol/codecs/base.pyx":58
+ *             else:
+ *                 self.decoder = <codec_decode_func>&self.decode_array_text
+ *         elif type == CODEC_RANGE:             # <<<<<<<<<<<<<<
+ *             self.encoder = <codec_encode_func>&self.encode_range
+ *             self.decoder = <codec_decode_func>&self.decode_range
+ */
+    case __pyx_e_7asyncpg_8protocol_8protocol_CODEC_RANGE:
+
+    /* "asyncpg/protocol/codecs/base.pyx":59
+ *                 self.decoder = <codec_decode_func>&self.decode_array_text
+ *         elif type == CODEC_RANGE:
+ *             self.encoder = <codec_encode_func>&self.encode_range             # <<<<<<<<<<<<<<
+ *             self.decoder = <codec_decode_func>&self.decode_range
+ *         elif type == CODEC_COMPOSITE:
+ */
+    __pyx_v_self->encoder = ((__pyx_t_7asyncpg_8protocol_8protocol_codec_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_range));
+
+    /* "asyncpg/protocol/codecs/base.pyx":60
+ *         elif type == CODEC_RANGE:
+ *             self.encoder = <codec_encode_func>&self.encode_range
+ *             self.decoder = <codec_decode_func>&self.decode_range             # <<<<<<<<<<<<<<
+ *         elif type == CODEC_COMPOSITE:
+ *             self.encoder = <codec_encode_func>&self.encode_composite
+ */
+    __pyx_v_self->decoder = ((__pyx_t_7asyncpg_8protocol_8protocol_codec_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_range));
+
+    /* "asyncpg/protocol/codecs/base.pyx":58
+ *             else:
+ *                 self.decoder = <codec_decode_func>&self.decode_array_text
+ *         elif type == CODEC_RANGE:             # <<<<<<<<<<<<<<
+ *             self.encoder = <codec_encode_func>&self.encode_range
+ *             self.decoder = <codec_decode_func>&self.decode_range
+ */
+    break;
+
+    /* "asyncpg/protocol/codecs/base.pyx":61
+ *             self.encoder = <codec_encode_func>&self.encode_range
+ *             self.decoder = <codec_decode_func>&self.decode_range
+ *         elif type == CODEC_COMPOSITE:             # <<<<<<<<<<<<<<
+ *             self.encoder = <codec_encode_func>&self.encode_composite
+ *             self.decoder = <codec_decode_func>&self.decode_composite
+ */
+    case __pyx_e_7asyncpg_8protocol_8protocol_CODEC_COMPOSITE:
+
+    /* "asyncpg/protocol/codecs/base.pyx":62
+ *             self.decoder = <codec_decode_func>&self.decode_range
+ *         elif type == CODEC_COMPOSITE:
+ *             self.encoder = <codec_encode_func>&self.encode_composite             # <<<<<<<<<<<<<<
+ *             self.decoder = <codec_decode_func>&self.decode_composite
+ *         elif type == CODEC_PY:
+ */
+    __pyx_v_self->encoder = ((__pyx_t_7asyncpg_8protocol_8protocol_codec_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_composite));
+
+    /* "asyncpg/protocol/codecs/base.pyx":63
+ *         elif type == CODEC_COMPOSITE:
+ *             self.encoder = <codec_encode_func>&self.encode_composite
+ *             self.decoder = <codec_decode_func>&self.decode_composite             # <<<<<<<<<<<<<<
+ *         elif type == CODEC_PY:
+ *             self.encoder = <codec_encode_func>&self.encode_in_python
+ */
+    __pyx_v_self->decoder = ((__pyx_t_7asyncpg_8protocol_8protocol_codec_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_composite));
+
+    /* "asyncpg/protocol/codecs/base.pyx":61
+ *             self.encoder = <codec_encode_func>&self.encode_range
+ *             self.decoder = <codec_decode_func>&self.decode_range
+ *         elif type == CODEC_COMPOSITE:             # <<<<<<<<<<<<<<
+ *             self.encoder = <codec_encode_func>&self.encode_composite
+ *             self.decoder = <codec_decode_func>&self.decode_composite
+ */
+    break;
+
+    /* "asyncpg/protocol/codecs/base.pyx":64
+ *             self.encoder = <codec_encode_func>&self.encode_composite
+ *             self.decoder = <codec_decode_func>&self.decode_composite
+ *         elif type == CODEC_PY:             # <<<<<<<<<<<<<<
+ *             self.encoder = <codec_encode_func>&self.encode_in_python
+ *             self.decoder = <codec_decode_func>&self.decode_in_python
+ */
+    case __pyx_e_7asyncpg_8protocol_8protocol_CODEC_PY:
+
+    /* "asyncpg/protocol/codecs/base.pyx":65
+ *             self.decoder = <codec_decode_func>&self.decode_composite
+ *         elif type == CODEC_PY:
+ *             self.encoder = <codec_encode_func>&self.encode_in_python             # <<<<<<<<<<<<<<
+ *             self.decoder = <codec_decode_func>&self.decode_in_python
+ *         else:
+ */
+    __pyx_v_self->encoder = ((__pyx_t_7asyncpg_8protocol_8protocol_codec_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_in_python));
+
+    /* "asyncpg/protocol/codecs/base.pyx":66
+ *         elif type == CODEC_PY:
+ *             self.encoder = <codec_encode_func>&self.encode_in_python
+ *             self.decoder = <codec_decode_func>&self.decode_in_python             # <<<<<<<<<<<<<<
+ *         else:
+ *             raise RuntimeError('unexpected codec type: {}'.format(type))
+ */
+    __pyx_v_self->decoder = ((__pyx_t_7asyncpg_8protocol_8protocol_codec_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_in_python));
+
+    /* "asyncpg/protocol/codecs/base.pyx":64
+ *             self.encoder = <codec_encode_func>&self.encode_composite
+ *             self.decoder = <codec_decode_func>&self.decode_composite
+ *         elif type == CODEC_PY:             # <<<<<<<<<<<<<<
+ *             self.encoder = <codec_encode_func>&self.encode_in_python
+ *             self.decoder = <codec_decode_func>&self.decode_in_python
+ */
+    break;
+    default:
+
+    /* "asyncpg/protocol/codecs/base.pyx":68
+ *             self.decoder = <codec_decode_func>&self.decode_in_python
+ *         else:
+ *             raise RuntimeError('unexpected codec type: {}'.format(type))             # <<<<<<<<<<<<<<
+ * 
+ *     cdef Codec copy(self):
+ */
+    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_unexpected_codec_type, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 68, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_5 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_CodecType(__pyx_v_type); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 68, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
+      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
+      if (likely(__pyx_t_6)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+        __Pyx_INCREF(__pyx_t_6);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_3, function);
+      }
+    }
+    if (!__pyx_t_6) {
+      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 68, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_GOTREF(__pyx_t_4);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_3)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
+        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 68, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
+        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 68, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 68, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
+        __Pyx_GIVEREF(__pyx_t_5);
+        PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5);
+        __pyx_t_5 = 0;
+        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 68, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 68, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_GIVEREF(__pyx_t_4);
+    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
+    __pyx_t_4 = 0;
+    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 68, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __PYX_ERR(2, 68, __pyx_L1_error)
+    break;
+  }
+
+  /* "asyncpg/protocol/codecs/base.pyx":21
+ *         self.type = CODEC_UNDEFINED
+ * 
+ *     cdef init(self, str name, str schema, str kind,             # <<<<<<<<<<<<<<
+ *               CodecType type, CodecFormat format,
+ *               encode_func c_encoder, decode_func c_decoder,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.init", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":70
+ *             raise RuntimeError('unexpected codec type: {}'.format(type))
+ * 
+ *     cdef Codec copy(self):             # <<<<<<<<<<<<<<
+ *         cdef Codec codec
+ * 
+ */
+
+static CYTHON_INLINE struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_copy(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_codec = 0;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  PyObject *__pyx_t_10 = NULL;
+  __Pyx_RefNannySetupContext("copy", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":73
+ *         cdef Codec codec
+ * 
+ *         codec = Codec(self.oid)             # <<<<<<<<<<<<<<
+ *         codec.init(self.name, self.schema, self.kind,
+ *                    self.type, self.format,
+ */
+  __pyx_t_1 = __Pyx_PyInt_From_uint32_t(__pyx_v_self->oid); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 73, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 73, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
+  __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_Codec), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 73, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_v_codec = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":74
+ * 
+ *         codec = Codec(self.oid)
+ *         codec.init(self.name, self.schema, self.kind,             # <<<<<<<<<<<<<<
+ *                    self.type, self.format,
+ *                    self.c_encoder, self.c_decoder,
+ */
+  __pyx_t_1 = __pyx_v_self->name;
+  __Pyx_INCREF(__pyx_t_1);
+  __pyx_t_2 = __pyx_v_self->schema;
+  __Pyx_INCREF(__pyx_t_2);
+  __pyx_t_3 = __pyx_v_self->kind;
+  __Pyx_INCREF(__pyx_t_3);
+
+  /* "asyncpg/protocol/codecs/base.pyx":77
+ *                    self.type, self.format,
+ *                    self.c_encoder, self.c_decoder,
+ *                    self.py_encoder, self.py_decoder,             # <<<<<<<<<<<<<<
+ *                    self.element_codec,
+ *                    self.element_type_oids, self.element_names,
+ */
+  __pyx_t_4 = __pyx_v_self->py_encoder;
+  __Pyx_INCREF(__pyx_t_4);
+  __pyx_t_5 = __pyx_v_self->py_decoder;
+  __Pyx_INCREF(__pyx_t_5);
+
+  /* "asyncpg/protocol/codecs/base.pyx":78
+ *                    self.c_encoder, self.c_decoder,
+ *                    self.py_encoder, self.py_decoder,
+ *                    self.element_codec,             # <<<<<<<<<<<<<<
+ *                    self.element_type_oids, self.element_names,
+ *                    self.element_codecs, self.element_delimiter)
+ */
+  __pyx_t_6 = ((PyObject *)__pyx_v_self->element_codec);
+  __Pyx_INCREF(__pyx_t_6);
+
+  /* "asyncpg/protocol/codecs/base.pyx":79
+ *                    self.py_encoder, self.py_decoder,
+ *                    self.element_codec,
+ *                    self.element_type_oids, self.element_names,             # <<<<<<<<<<<<<<
+ *                    self.element_codecs, self.element_delimiter)
+ * 
+ */
+  __pyx_t_7 = __pyx_v_self->element_type_oids;
+  __Pyx_INCREF(__pyx_t_7);
+  __pyx_t_8 = __pyx_v_self->element_names;
+  __Pyx_INCREF(__pyx_t_8);
+
+  /* "asyncpg/protocol/codecs/base.pyx":80
+ *                    self.element_codec,
+ *                    self.element_type_oids, self.element_names,
+ *                    self.element_codecs, self.element_delimiter)             # <<<<<<<<<<<<<<
+ * 
+ *         return codec
+ */
+  __pyx_t_9 = __pyx_v_self->element_codecs;
+  __Pyx_INCREF(__pyx_t_9);
+
+  /* "asyncpg/protocol/codecs/base.pyx":74
+ * 
+ *         codec = Codec(self.oid)
+ *         codec.init(self.name, self.schema, self.kind,             # <<<<<<<<<<<<<<
+ *                    self.type, self.format,
+ *                    self.c_encoder, self.c_decoder,
+ */
+  __pyx_t_10 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_init(__pyx_v_codec, ((PyObject*)__pyx_t_1), ((PyObject*)__pyx_t_2), ((PyObject*)__pyx_t_3), __pyx_v_self->type, __pyx_v_self->format, __pyx_v_self->c_encoder, __pyx_v_self->c_decoder, __pyx_t_4, __pyx_t_5, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_6), ((PyObject*)__pyx_t_7), __pyx_t_8, ((PyObject*)__pyx_t_9), __pyx_v_self->element_delimiter); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 74, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_10);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":82
+ *                    self.element_codecs, self.element_delimiter)
+ * 
+ *         return codec             # <<<<<<<<<<<<<<
+ * 
+ *     cdef encode_scalar(self, ConnectionSettings settings, WriteBuffer buf,
+ */
+  __Pyx_XDECREF(((PyObject *)__pyx_r));
+  __Pyx_INCREF(((PyObject *)__pyx_v_codec));
+  __pyx_r = __pyx_v_codec;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":70
+ *             raise RuntimeError('unexpected codec type: {}'.format(type))
+ * 
+ *     cdef Codec copy(self):             # <<<<<<<<<<<<<<
+ *         cdef Codec codec
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
+  __Pyx_XGIVEREF((PyObject *)__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":84
+ *         return codec
+ * 
+ *     cdef encode_scalar(self, ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
+ *                        object obj):
+ *         self.c_encoder(settings, buf, obj)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_scalar(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("encode_scalar", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":86
+ *     cdef encode_scalar(self, ConnectionSettings settings, WriteBuffer buf,
+ *                        object obj):
+ *         self.c_encoder(settings, buf, obj)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef encode_array(self, ConnectionSettings settings, WriteBuffer buf,
+ */
+  __pyx_t_1 = __pyx_v_self->c_encoder(__pyx_v_settings, __pyx_v_buf, __pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 86, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":84
+ *         return codec
+ * 
+ *     cdef encode_scalar(self, ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
+ *                        object obj):
+ *         self.c_encoder(settings, buf, obj)
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.encode_scalar", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":88
+ *         self.c_encoder(settings, buf, obj)
+ * 
+ *     cdef encode_array(self, ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
+ *                       object obj):
+ *         array_encode(settings, buf, obj, self.element_codec.oid,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_array(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("encode_array", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":90
+ *     cdef encode_array(self, ConnectionSettings settings, WriteBuffer buf,
+ *                       object obj):
+ *         array_encode(settings, buf, obj, self.element_codec.oid,             # <<<<<<<<<<<<<<
+ *                      codec_encode_func_ex,
+ *                      <void*>(<cpython.PyObject>self.element_codec))
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_array_encode(__pyx_v_settings, __pyx_v_buf, __pyx_v_obj, __pyx_v_self->element_codec->oid, __pyx_f_7asyncpg_8protocol_8protocol_codec_encode_func_ex, ((void *)__pyx_v_self->element_codec)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 90, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":88
+ *         self.c_encoder(settings, buf, obj)
+ * 
+ *     cdef encode_array(self, ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
+ *                       object obj):
+ *         array_encode(settings, buf, obj, self.element_codec.oid,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.encode_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":94
+ *                      <void*>(<cpython.PyObject>self.element_codec))
+ * 
+ *     cdef encode_range(self, ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
+ *                       object obj):
+ *         range_encode(settings, buf, obj, self.element_codec.oid,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_range(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("encode_range", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":96
+ *     cdef encode_range(self, ConnectionSettings settings, WriteBuffer buf,
+ *                       object obj):
+ *         range_encode(settings, buf, obj, self.element_codec.oid,             # <<<<<<<<<<<<<<
+ *                      codec_encode_func_ex,
+ *                      <void*>(<cpython.PyObject>self.element_codec))
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_range_encode(__pyx_v_settings, __pyx_v_buf, __pyx_v_obj, __pyx_v_self->element_codec->oid, __pyx_f_7asyncpg_8protocol_8protocol_codec_encode_func_ex, ((void *)__pyx_v_self->element_codec)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 96, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":94
+ *                      <void*>(<cpython.PyObject>self.element_codec))
+ * 
+ *     cdef encode_range(self, ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
+ *                       object obj):
+ *         range_encode(settings, buf, obj, self.element_codec.oid,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.encode_range", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":100
+ *                      <void*>(<cpython.PyObject>self.element_codec))
+ * 
+ *     cdef encode_composite(self, ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
+ *                           object obj):
+ *         cdef:
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_composite(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_elem_data = 0;
+  int __pyx_v_i;
+  PyObject *__pyx_v_elem_codecs = 0;
+  Py_ssize_t __pyx_v_count;
+  PyObject *__pyx_v_item = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  Py_ssize_t __pyx_t_2;
+  int __pyx_t_3;
+  PyObject *(*__pyx_t_4)(PyObject *);
+  PyObject *__pyx_t_5 = NULL;
+  int32_t __pyx_t_6;
+  int __pyx_t_7;
+  PyObject *__pyx_t_8 = NULL;
+  __Pyx_RefNannySetupContext("encode_composite", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":105
+ *             WriteBuffer elem_data
+ *             int i
+ *             list elem_codecs = self.element_codecs             # <<<<<<<<<<<<<<
+ *             ssize_t count
+ * 
+ */
+  __pyx_t_1 = __pyx_v_self->element_codecs;
+  __Pyx_INCREF(__pyx_t_1);
+  __pyx_v_elem_codecs = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":108
+ *             ssize_t count
+ * 
+ *         count = len(obj)             # <<<<<<<<<<<<<<
+ *         if count > _MAXINT32:
+ *             raise ValueError('too many elements in composite type record')
+ */
+  __pyx_t_2 = PyObject_Length(__pyx_v_obj); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(2, 108, __pyx_L1_error)
+  __pyx_v_count = __pyx_t_2;
+
+  /* "asyncpg/protocol/codecs/base.pyx":109
+ * 
+ *         count = len(obj)
+ *         if count > _MAXINT32:             # <<<<<<<<<<<<<<
+ *             raise ValueError('too many elements in composite type record')
+ * 
+ */
+  __pyx_t_3 = ((__pyx_v_count > 0x7FFFFFFF) != 0);
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/codecs/base.pyx":110
+ *         count = len(obj)
+ *         if count > _MAXINT32:
+ *             raise ValueError('too many elements in composite type record')             # <<<<<<<<<<<<<<
+ * 
+ *         elem_data = WriteBuffer.new()
+ */
+    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 110, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __PYX_ERR(2, 110, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/base.pyx":109
+ * 
+ *         count = len(obj)
+ *         if count > _MAXINT32:             # <<<<<<<<<<<<<<
+ *             raise ValueError('too many elements in composite type record')
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/base.pyx":112
+ *             raise ValueError('too many elements in composite type record')
+ * 
+ *         elem_data = WriteBuffer.new()             # <<<<<<<<<<<<<<
+ *         i = 0
+ *         for item in obj:
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new()); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 112, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_elem_data = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":113
+ * 
+ *         elem_data = WriteBuffer.new()
+ *         i = 0             # <<<<<<<<<<<<<<
+ *         for item in obj:
+ *             elem_data.write_int32(<int32_t>self.element_type_oids[i])
+ */
+  __pyx_v_i = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":114
+ *         elem_data = WriteBuffer.new()
+ *         i = 0
+ *         for item in obj:             # <<<<<<<<<<<<<<
+ *             elem_data.write_int32(<int32_t>self.element_type_oids[i])
+ *             if item is None:
+ */
+  if (likely(PyList_CheckExact(__pyx_v_obj)) || PyTuple_CheckExact(__pyx_v_obj)) {
+    __pyx_t_1 = __pyx_v_obj; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
+    __pyx_t_4 = NULL;
+  } else {
+    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 114, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 114, __pyx_L1_error)
+  }
+  for (;;) {
+    if (likely(!__pyx_t_4)) {
+      if (likely(PyList_CheckExact(__pyx_t_1))) {
+        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
+        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(2, 114, __pyx_L1_error)
+        #else
+        __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 114, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_5);
+        #endif
+      } else {
+        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(2, 114, __pyx_L1_error)
+        #else
+        __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 114, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_5);
+        #endif
+      }
+    } else {
+      __pyx_t_5 = __pyx_t_4(__pyx_t_1);
+      if (unlikely(!__pyx_t_5)) {
+        PyObject* exc_type = PyErr_Occurred();
+        if (exc_type) {
+          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+          else __PYX_ERR(2, 114, __pyx_L1_error)
+        }
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_5);
+    }
+    __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_5);
+    __pyx_t_5 = 0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":115
+ *         i = 0
+ *         for item in obj:
+ *             elem_data.write_int32(<int32_t>self.element_type_oids[i])             # <<<<<<<<<<<<<<
+ *             if item is None:
+ *                 elem_data.write_int32(-1)
+ */
+    if (unlikely(__pyx_v_self->element_type_oids == Py_None)) {
+      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+      __PYX_ERR(2, 115, __pyx_L1_error)
+    }
+    __pyx_t_5 = __Pyx_GetItemInt_Tuple(__pyx_v_self->element_type_oids, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 115, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = __Pyx_PyInt_As_int32_t(__pyx_t_5); if (unlikely((__pyx_t_6 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(2, 115, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_5 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_elem_data, ((int32_t)__pyx_t_6)); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 115, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":116
+ *         for item in obj:
+ *             elem_data.write_int32(<int32_t>self.element_type_oids[i])
+ *             if item is None:             # <<<<<<<<<<<<<<
+ *                 elem_data.write_int32(-1)
+ *             else:
+ */
+    __pyx_t_3 = (__pyx_v_item == Py_None);
+    __pyx_t_7 = (__pyx_t_3 != 0);
+    if (__pyx_t_7) {
+
+      /* "asyncpg/protocol/codecs/base.pyx":117
+ *             elem_data.write_int32(<int32_t>self.element_type_oids[i])
+ *             if item is None:
+ *                 elem_data.write_int32(-1)             # <<<<<<<<<<<<<<
+ *             else:
+ *                 (<Codec>elem_codecs[i]).encode(settings, elem_data, item)
+ */
+      __pyx_t_5 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_elem_data, -1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 117, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+      /* "asyncpg/protocol/codecs/base.pyx":116
+ *         for item in obj:
+ *             elem_data.write_int32(<int32_t>self.element_type_oids[i])
+ *             if item is None:             # <<<<<<<<<<<<<<
+ *                 elem_data.write_int32(-1)
+ *             else:
+ */
+      goto __pyx_L6;
+    }
+
+    /* "asyncpg/protocol/codecs/base.pyx":119
+ *                 elem_data.write_int32(-1)
+ *             else:
+ *                 (<Codec>elem_codecs[i]).encode(settings, elem_data, item)             # <<<<<<<<<<<<<<
+ *             i += 1
+ * 
+ */
+    /*else*/ {
+      if (unlikely(__pyx_v_elem_codecs == Py_None)) {
+        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+        __PYX_ERR(2, 119, __pyx_L1_error)
+      }
+      __pyx_t_5 = __Pyx_GetItemInt_List(__pyx_v_elem_codecs, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 119, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_5);
+      __pyx_t_8 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode(((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_5), __pyx_v_settings, __pyx_v_elem_data, __pyx_v_item); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 119, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_8);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+    }
+    __pyx_L6:;
+
+    /* "asyncpg/protocol/codecs/base.pyx":120
+ *             else:
+ *                 (<Codec>elem_codecs[i]).encode(settings, elem_data, item)
+ *             i += 1             # <<<<<<<<<<<<<<
+ * 
+ *         record_encode_frame(settings, buf, elem_data, <int32_t>count)
+ */
+    __pyx_v_i = (__pyx_v_i + 1);
+
+    /* "asyncpg/protocol/codecs/base.pyx":114
+ *         elem_data = WriteBuffer.new()
+ *         i = 0
+ *         for item in obj:             # <<<<<<<<<<<<<<
+ *             elem_data.write_int32(<int32_t>self.element_type_oids[i])
+ *             if item is None:
+ */
+  }
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":122
+ *             i += 1
+ * 
+ *         record_encode_frame(settings, buf, elem_data, <int32_t>count)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef encode_in_python(self, ConnectionSettings settings, WriteBuffer buf,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_record_encode_frame(__pyx_v_settings, __pyx_v_buf, __pyx_v_elem_data, ((int32_t)__pyx_v_count)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 122, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":100
+ *                      <void*>(<cpython.PyObject>self.element_codec))
+ * 
+ *     cdef encode_composite(self, ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
+ *                           object obj):
+ *         cdef:
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.encode_composite", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_elem_data);
+  __Pyx_XDECREF(__pyx_v_elem_codecs);
+  __Pyx_XDECREF(__pyx_v_item);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":124
+ *         record_encode_frame(settings, buf, elem_data, <int32_t>count)
+ * 
+ *     cdef encode_in_python(self, ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
+ *                           object obj):
+ *         bb = self.py_encoder(obj)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_in_python(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
+  PyObject *__pyx_v_bb = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  int __pyx_t_5;
+  __Pyx_RefNannySetupContext("encode_in_python", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":126
+ *     cdef encode_in_python(self, ConnectionSettings settings, WriteBuffer buf,
+ *                           object obj):
+ *         bb = self.py_encoder(obj)             # <<<<<<<<<<<<<<
+ *         if self.format == PG_FORMAT_BINARY:
+ *             bytea_encode(settings, buf, bb)
+ */
+  __Pyx_INCREF(__pyx_v_self->py_encoder);
+  __pyx_t_2 = __pyx_v_self->py_encoder; __pyx_t_3 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (!__pyx_t_3) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 126, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_obj};
+      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 126, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_obj};
+      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 126, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else
+    #endif
+    {
+      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 126, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
+      __Pyx_INCREF(__pyx_v_obj);
+      __Pyx_GIVEREF(__pyx_v_obj);
+      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_obj);
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 126, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_v_bb = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":127
+ *                           object obj):
+ *         bb = self.py_encoder(obj)
+ *         if self.format == PG_FORMAT_BINARY:             # <<<<<<<<<<<<<<
+ *             bytea_encode(settings, buf, bb)
+ *         else:
+ */
+  __pyx_t_5 = ((__pyx_v_self->format == __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY) != 0);
+  if (__pyx_t_5) {
+
+    /* "asyncpg/protocol/codecs/base.pyx":128
+ *         bb = self.py_encoder(obj)
+ *         if self.format == PG_FORMAT_BINARY:
+ *             bytea_encode(settings, buf, bb)             # <<<<<<<<<<<<<<
+ *         else:
+ *             text_encode(settings, buf, bb)
+ */
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_bytea_encode(__pyx_v_settings, __pyx_v_buf, __pyx_v_bb); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 128, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":127
+ *                           object obj):
+ *         bb = self.py_encoder(obj)
+ *         if self.format == PG_FORMAT_BINARY:             # <<<<<<<<<<<<<<
+ *             bytea_encode(settings, buf, bb)
+ *         else:
+ */
+    goto __pyx_L3;
+  }
+
+  /* "asyncpg/protocol/codecs/base.pyx":130
+ *             bytea_encode(settings, buf, bb)
+ *         else:
+ *             text_encode(settings, buf, bb)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef encode(self, ConnectionSettings settings, WriteBuffer buf,
+ */
+  /*else*/ {
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_text_encode(__pyx_v_settings, __pyx_v_buf, __pyx_v_bb); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 130, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  }
+  __pyx_L3:;
+
+  /* "asyncpg/protocol/codecs/base.pyx":124
+ *         record_encode_frame(settings, buf, elem_data, <int32_t>count)
+ * 
+ *     cdef encode_in_python(self, ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
+ *                           object obj):
+ *         bb = self.py_encoder(obj)
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.encode_in_python", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_bb);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":132
+ *             text_encode(settings, buf, bb)
+ * 
+ *     cdef encode(self, ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
+ *                 object obj):
+ *         return self.encoder(self, settings, buf, obj)
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("encode", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":134
+ *     cdef encode(self, ConnectionSettings settings, WriteBuffer buf,
+ *                 object obj):
+ *         return self.encoder(self, settings, buf, obj)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef decode_scalar(self, ConnectionSettings settings, FastReadBuffer buf):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __pyx_v_self->encoder(__pyx_v_self, __pyx_v_settings, __pyx_v_buf, __pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 134, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":132
+ *             text_encode(settings, buf, bb)
+ * 
+ *     cdef encode(self, ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
+ *                 object obj):
+ *         return self.encoder(self, settings, buf, obj)
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":136
+ *         return self.encoder(self, settings, buf, obj)
+ * 
+ *     cdef decode_scalar(self, ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *         return self.c_decoder(settings, buf)
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_scalar(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("decode_scalar", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":137
+ * 
+ *     cdef decode_scalar(self, ConnectionSettings settings, FastReadBuffer buf):
+ *         return self.c_decoder(settings, buf)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef decode_array(self, ConnectionSettings settings, FastReadBuffer buf):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __pyx_v_self->c_decoder(__pyx_v_settings, __pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 137, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":136
+ *         return self.encoder(self, settings, buf, obj)
+ * 
+ *     cdef decode_scalar(self, ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *         return self.c_decoder(settings, buf)
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.decode_scalar", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":139
+ *         return self.c_decoder(settings, buf)
+ * 
+ *     cdef decode_array(self, ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *         return array_decode(settings, buf, codec_decode_func_ex,
+ *                             <void*>(<cpython.PyObject>self.element_codec))
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_array(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("decode_array", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":140
+ * 
+ *     cdef decode_array(self, ConnectionSettings settings, FastReadBuffer buf):
+ *         return array_decode(settings, buf, codec_decode_func_ex,             # <<<<<<<<<<<<<<
+ *                             <void*>(<cpython.PyObject>self.element_codec))
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+
+  /* "asyncpg/protocol/codecs/base.pyx":141
+ *     cdef decode_array(self, ConnectionSettings settings, FastReadBuffer buf):
+ *         return array_decode(settings, buf, codec_decode_func_ex,
+ *                             <void*>(<cpython.PyObject>self.element_codec))             # <<<<<<<<<<<<<<
+ * 
+ *     cdef decode_array_text(self, ConnectionSettings settings,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_array_decode(__pyx_v_settings, __pyx_v_buf, __pyx_f_7asyncpg_8protocol_8protocol_codec_decode_func_ex, ((void *)__pyx_v_self->element_codec)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 140, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":139
+ *         return self.c_decoder(settings, buf)
+ * 
+ *     cdef decode_array(self, ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *         return array_decode(settings, buf, codec_decode_func_ex,
+ *                             <void*>(<cpython.PyObject>self.element_codec))
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.decode_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":143
+ *                             <void*>(<cpython.PyObject>self.element_codec))
+ * 
+ *     cdef decode_array_text(self, ConnectionSettings settings,             # <<<<<<<<<<<<<<
+ *                            FastReadBuffer buf):
+ *         return textarray_decode(settings, buf, codec_decode_func_ex,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_array_text(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("decode_array_text", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":145
+ *     cdef decode_array_text(self, ConnectionSettings settings,
+ *                            FastReadBuffer buf):
+ *         return textarray_decode(settings, buf, codec_decode_func_ex,             # <<<<<<<<<<<<<<
+ *                                 <void*>(<cpython.PyObject>self.element_codec),
+ *                                 self.element_delimiter)
+ */
+  __Pyx_XDECREF(__pyx_r);
+
+  /* "asyncpg/protocol/codecs/base.pyx":147
+ *         return textarray_decode(settings, buf, codec_decode_func_ex,
+ *                                 <void*>(<cpython.PyObject>self.element_codec),
+ *                                 self.element_delimiter)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef decode_range(self, ConnectionSettings settings, FastReadBuffer buf):
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_textarray_decode(__pyx_v_settings, __pyx_v_buf, __pyx_f_7asyncpg_8protocol_8protocol_codec_decode_func_ex, ((void *)__pyx_v_self->element_codec), __pyx_v_self->element_delimiter); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 145, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":143
+ *                             <void*>(<cpython.PyObject>self.element_codec))
+ * 
+ *     cdef decode_array_text(self, ConnectionSettings settings,             # <<<<<<<<<<<<<<
+ *                            FastReadBuffer buf):
+ *         return textarray_decode(settings, buf, codec_decode_func_ex,
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.decode_array_text", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":149
+ *                                 self.element_delimiter)
+ * 
+ *     cdef decode_range(self, ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *         return range_decode(settings, buf, codec_decode_func_ex,
+ *                             <void*>(<cpython.PyObject>self.element_codec))
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_range(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("decode_range", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":150
+ * 
+ *     cdef decode_range(self, ConnectionSettings settings, FastReadBuffer buf):
+ *         return range_decode(settings, buf, codec_decode_func_ex,             # <<<<<<<<<<<<<<
+ *                             <void*>(<cpython.PyObject>self.element_codec))
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+
+  /* "asyncpg/protocol/codecs/base.pyx":151
+ *     cdef decode_range(self, ConnectionSettings settings, FastReadBuffer buf):
+ *         return range_decode(settings, buf, codec_decode_func_ex,
+ *                             <void*>(<cpython.PyObject>self.element_codec))             # <<<<<<<<<<<<<<
+ * 
+ *     cdef decode_composite(self, ConnectionSettings settings,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_range_decode(__pyx_v_settings, __pyx_v_buf, __pyx_f_7asyncpg_8protocol_8protocol_codec_decode_func_ex, ((void *)__pyx_v_self->element_codec)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 150, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":149
+ *                                 self.element_delimiter)
+ * 
+ *     cdef decode_range(self, ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *         return range_decode(settings, buf, codec_decode_func_ex,
+ *                             <void*>(<cpython.PyObject>self.element_codec))
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.decode_range", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":153
+ *                             <void*>(<cpython.PyObject>self.element_codec))
+ * 
+ *     cdef decode_composite(self, ConnectionSettings settings,             # <<<<<<<<<<<<<<
+ *                           FastReadBuffer buf):
+ *         cdef:
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_composite(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  PyObject *__pyx_v_result = 0;
+  uint32_t __pyx_v_elem_count;
+  uint32_t __pyx_v_i;
+  int32_t __pyx_v_elem_len;
+  uint32_t __pyx_v_elem_typ;
+  uint32_t __pyx_v_received_elem_typ;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_elem_codec = 0;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_elem_buf = 0;
+  PyObject *__pyx_v_elem = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  char const *__pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  uint32_t __pyx_t_4;
+  uint32_t __pyx_t_5;
+  uint32_t __pyx_t_6;
+  int __pyx_t_7;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  PyObject *__pyx_t_10 = NULL;
+  PyObject *__pyx_t_11 = NULL;
+  PyObject *__pyx_t_12 = NULL;
+  PyObject *__pyx_t_13 = NULL;
+  int __pyx_t_14;
+  PyObject *__pyx_t_15 = NULL;
+  PyObject *__pyx_t_16 = NULL;
+  __Pyx_RefNannySetupContext("decode_composite", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":163
+ *             uint32_t received_elem_typ
+ *             Codec elem_codec
+ *             FastReadBuffer elem_buf = FastReadBuffer.new()             # <<<<<<<<<<<<<<
+ * 
+ *         elem_count = <uint32_t>hton.unpack_int32(buf.read(4))
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_new()); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 163, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_elem_buf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":165
+ *             FastReadBuffer elem_buf = FastReadBuffer.new()
+ * 
+ *         elem_count = <uint32_t>hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ *         result = record.ApgRecord_New(self.element_names, elem_count)
+ *         for i in range(elem_count):
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_2 == NULL)) __PYX_ERR(2, 165, __pyx_L1_error)
+  __pyx_v_elem_count = ((uint32_t)__pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_2));
+
+  /* "asyncpg/protocol/codecs/base.pyx":166
+ * 
+ *         elem_count = <uint32_t>hton.unpack_int32(buf.read(4))
+ *         result = record.ApgRecord_New(self.element_names, elem_count)             # <<<<<<<<<<<<<<
+ *         for i in range(elem_count):
+ *             elem_typ = self.element_type_oids[i]
+ */
+  __pyx_t_1 = __pyx_v_self->element_names;
+  __Pyx_INCREF(__pyx_t_1);
+  __pyx_t_3 = ApgRecord_New(__pyx_t_1, __pyx_v_elem_count); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 166, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_result = __pyx_t_3;
+  __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":167
+ *         elem_count = <uint32_t>hton.unpack_int32(buf.read(4))
+ *         result = record.ApgRecord_New(self.element_names, elem_count)
+ *         for i in range(elem_count):             # <<<<<<<<<<<<<<
+ *             elem_typ = self.element_type_oids[i]
+ *             received_elem_typ = <uint32_t>hton.unpack_int32(buf.read(4))
+ */
+  __pyx_t_4 = __pyx_v_elem_count;
+  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
+    __pyx_v_i = __pyx_t_5;
+
+    /* "asyncpg/protocol/codecs/base.pyx":168
+ *         result = record.ApgRecord_New(self.element_names, elem_count)
+ *         for i in range(elem_count):
+ *             elem_typ = self.element_type_oids[i]             # <<<<<<<<<<<<<<
+ *             received_elem_typ = <uint32_t>hton.unpack_int32(buf.read(4))
+ * 
+ */
+    if (unlikely(__pyx_v_self->element_type_oids == Py_None)) {
+      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+      __PYX_ERR(2, 168, __pyx_L1_error)
+    }
+    __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_self->element_type_oids, __pyx_v_i, uint32_t, 0, __Pyx_PyInt_From_uint32_t, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 168, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_6 = __Pyx_PyInt_As_uint32_t(__pyx_t_3); if (unlikely((__pyx_t_6 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(2, 168, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_v_elem_typ = __pyx_t_6;
+
+    /* "asyncpg/protocol/codecs/base.pyx":169
+ *         for i in range(elem_count):
+ *             elem_typ = self.element_type_oids[i]
+ *             received_elem_typ = <uint32_t>hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ * 
+ *             if received_elem_typ != elem_typ:
+ */
+    __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_2 == NULL)) __PYX_ERR(2, 169, __pyx_L1_error)
+    __pyx_v_received_elem_typ = ((uint32_t)__pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_2));
+
+    /* "asyncpg/protocol/codecs/base.pyx":171
+ *             received_elem_typ = <uint32_t>hton.unpack_int32(buf.read(4))
+ * 
+ *             if received_elem_typ != elem_typ:             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError(
+ *                     'unexpected data type of composite type attribute {}: '
+ */
+    __pyx_t_7 = ((__pyx_v_received_elem_typ != __pyx_v_elem_typ) != 0);
+    if (__pyx_t_7) {
+
+      /* "asyncpg/protocol/codecs/base.pyx":175
+ *                     'unexpected data type of composite type attribute {}: '
+ *                     '{!r}, expected {!r}'
+ *                         .format(             # <<<<<<<<<<<<<<
+ *                             i,
+ *                             TYPEMAP.get(received_elem_typ, received_elem_typ),
+ */
+      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_unexpected_data_type_of_composit, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 175, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+
+      /* "asyncpg/protocol/codecs/base.pyx":176
+ *                     '{!r}, expected {!r}'
+ *                         .format(
+ *                             i,             # <<<<<<<<<<<<<<
+ *                             TYPEMAP.get(received_elem_typ, received_elem_typ),
+ *                             TYPEMAP.get(elem_typ, elem_typ)
+ */
+      __pyx_t_8 = __Pyx_PyInt_From_uint32_t(__pyx_v_i); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 176, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_8);
+
+      /* "asyncpg/protocol/codecs/base.pyx":177
+ *                         .format(
+ *                             i,
+ *                             TYPEMAP.get(received_elem_typ, received_elem_typ),             # <<<<<<<<<<<<<<
+ *                             TYPEMAP.get(elem_typ, elem_typ)
+ *                         )
+ */
+      __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_TYPEMAP); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 177, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_10);
+      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_get); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 177, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_11);
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      __pyx_t_10 = __Pyx_PyInt_From_uint32_t(__pyx_v_received_elem_typ); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 177, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_10);
+      __pyx_t_12 = __Pyx_PyInt_From_uint32_t(__pyx_v_received_elem_typ); if (unlikely(!__pyx_t_12)) __PYX_ERR(2, 177, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_12);
+      __pyx_t_13 = NULL;
+      __pyx_t_14 = 0;
+      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
+        __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_11);
+        if (likely(__pyx_t_13)) {
+          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
+          __Pyx_INCREF(__pyx_t_13);
+          __Pyx_INCREF(function);
+          __Pyx_DECREF_SET(__pyx_t_11, function);
+          __pyx_t_14 = 1;
+        }
+      }
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_11)) {
+        PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_10, __pyx_t_12};
+        __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 177, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
+        __Pyx_GOTREF(__pyx_t_9);
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
+        PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_10, __pyx_t_12};
+        __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 177, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
+        __Pyx_GOTREF(__pyx_t_9);
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_15 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(2, 177, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_15);
+        if (__pyx_t_13) {
+          __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_13); __pyx_t_13 = NULL;
+        }
+        __Pyx_GIVEREF(__pyx_t_10);
+        PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_14, __pyx_t_10);
+        __Pyx_GIVEREF(__pyx_t_12);
+        PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_14, __pyx_t_12);
+        __pyx_t_10 = 0;
+        __pyx_t_12 = 0;
+        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_15, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 177, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_9);
+        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+      }
+      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+
+      /* "asyncpg/protocol/codecs/base.pyx":178
+ *                             i,
+ *                             TYPEMAP.get(received_elem_typ, received_elem_typ),
+ *                             TYPEMAP.get(elem_typ, elem_typ)             # <<<<<<<<<<<<<<
+ *                         )
+ *                 )
+ */
+      __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_TYPEMAP); if (unlikely(!__pyx_t_15)) __PYX_ERR(2, 178, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_15);
+      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_get); if (unlikely(!__pyx_t_12)) __PYX_ERR(2, 178, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_12);
+      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+      __pyx_t_15 = __Pyx_PyInt_From_uint32_t(__pyx_v_elem_typ); if (unlikely(!__pyx_t_15)) __PYX_ERR(2, 178, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_15);
+      __pyx_t_10 = __Pyx_PyInt_From_uint32_t(__pyx_v_elem_typ); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 178, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_10);
+      __pyx_t_13 = NULL;
+      __pyx_t_14 = 0;
+      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
+        __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_12);
+        if (likely(__pyx_t_13)) {
+          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
+          __Pyx_INCREF(__pyx_t_13);
+          __Pyx_INCREF(function);
+          __Pyx_DECREF_SET(__pyx_t_12, function);
+          __pyx_t_14 = 1;
+        }
+      }
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_12)) {
+        PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_15, __pyx_t_10};
+        __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 178, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
+        __Pyx_GOTREF(__pyx_t_11);
+        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
+        PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_15, __pyx_t_10};
+        __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 178, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
+        __Pyx_GOTREF(__pyx_t_11);
+        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_16 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_16)) __PYX_ERR(2, 178, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_16);
+        if (__pyx_t_13) {
+          __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_13); __pyx_t_13 = NULL;
+        }
+        __Pyx_GIVEREF(__pyx_t_15);
+        PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_14, __pyx_t_15);
+        __Pyx_GIVEREF(__pyx_t_10);
+        PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_14, __pyx_t_10);
+        __pyx_t_15 = 0;
+        __pyx_t_10 = 0;
+        __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_16, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 178, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_11);
+        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
+      }
+      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+      __pyx_t_12 = NULL;
+      __pyx_t_14 = 0;
+      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
+        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_1);
+        if (likely(__pyx_t_12)) {
+          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
+          __Pyx_INCREF(__pyx_t_12);
+          __Pyx_INCREF(function);
+          __Pyx_DECREF_SET(__pyx_t_1, function);
+          __pyx_t_14 = 1;
+        }
+      }
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_1)) {
+        PyObject *__pyx_temp[4] = {__pyx_t_12, __pyx_t_8, __pyx_t_9, __pyx_t_11};
+        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_14, 3+__pyx_t_14); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 175, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
+        PyObject *__pyx_temp[4] = {__pyx_t_12, __pyx_t_8, __pyx_t_9, __pyx_t_11};
+        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_14, 3+__pyx_t_14); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 175, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_16 = PyTuple_New(3+__pyx_t_14); if (unlikely(!__pyx_t_16)) __PYX_ERR(2, 175, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_16);
+        if (__pyx_t_12) {
+          __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_12); __pyx_t_12 = NULL;
+        }
+        __Pyx_GIVEREF(__pyx_t_8);
+        PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_14, __pyx_t_8);
+        __Pyx_GIVEREF(__pyx_t_9);
+        PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_14, __pyx_t_9);
+        __Pyx_GIVEREF(__pyx_t_11);
+        PyTuple_SET_ITEM(__pyx_t_16, 2+__pyx_t_14, __pyx_t_11);
+        __pyx_t_8 = 0;
+        __pyx_t_9 = 0;
+        __pyx_t_11 = 0;
+        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_16, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 175, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
+      }
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+      /* "asyncpg/protocol/codecs/base.pyx":172
+ * 
+ *             if received_elem_typ != elem_typ:
+ *                 raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                     'unexpected data type of composite type attribute {}: '
+ *                     '{!r}, expected {!r}'
+ */
+      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 172, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_GIVEREF(__pyx_t_3);
+      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
+      __pyx_t_3 = 0;
+      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 172, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __PYX_ERR(2, 172, __pyx_L1_error)
+
+      /* "asyncpg/protocol/codecs/base.pyx":171
+ *             received_elem_typ = <uint32_t>hton.unpack_int32(buf.read(4))
+ * 
+ *             if received_elem_typ != elem_typ:             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError(
+ *                     'unexpected data type of composite type attribute {}: '
+ */
+    }
+
+    /* "asyncpg/protocol/codecs/base.pyx":182
+ *                 )
+ * 
+ *             elem_len = hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ *             if elem_len == -1:
+ *                 elem = None
+ */
+    __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_2 == NULL)) __PYX_ERR(2, 182, __pyx_L1_error)
+    __pyx_v_elem_len = __pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_2);
+
+    /* "asyncpg/protocol/codecs/base.pyx":183
+ * 
+ *             elem_len = hton.unpack_int32(buf.read(4))
+ *             if elem_len == -1:             # <<<<<<<<<<<<<<
+ *                 elem = None
+ *             else:
+ */
+    __pyx_t_7 = ((__pyx_v_elem_len == -1L) != 0);
+    if (__pyx_t_7) {
+
+      /* "asyncpg/protocol/codecs/base.pyx":184
+ *             elem_len = hton.unpack_int32(buf.read(4))
+ *             if elem_len == -1:
+ *                 elem = None             # <<<<<<<<<<<<<<
+ *             else:
+ *                 elem_codec = self.element_codecs[i]
+ */
+      __Pyx_INCREF(Py_None);
+      __Pyx_XDECREF_SET(__pyx_v_elem, Py_None);
+
+      /* "asyncpg/protocol/codecs/base.pyx":183
+ * 
+ *             elem_len = hton.unpack_int32(buf.read(4))
+ *             if elem_len == -1:             # <<<<<<<<<<<<<<
+ *                 elem = None
+ *             else:
+ */
+      goto __pyx_L6;
+    }
+
+    /* "asyncpg/protocol/codecs/base.pyx":186
+ *                 elem = None
+ *             else:
+ *                 elem_codec = self.element_codecs[i]             # <<<<<<<<<<<<<<
+ *                 elem = elem_codec.decode(settings,
+ *                                          elem_buf.slice_from(buf, elem_len))
+ */
+    /*else*/ {
+      if (unlikely(__pyx_v_self->element_codecs == Py_None)) {
+        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+        __PYX_ERR(2, 186, __pyx_L1_error)
+      }
+      __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_self->element_codecs, __pyx_v_i, uint32_t, 0, __Pyx_PyInt_From_uint32_t, 1, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 186, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_7asyncpg_8protocol_8protocol_Codec))))) __PYX_ERR(2, 186, __pyx_L1_error)
+      __Pyx_XDECREF_SET(__pyx_v_elem_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_3));
+      __pyx_t_3 = 0;
+
+      /* "asyncpg/protocol/codecs/base.pyx":188
+ *                 elem_codec = self.element_codecs[i]
+ *                 elem = elem_codec.decode(settings,
+ *                                          elem_buf.slice_from(buf, elem_len))             # <<<<<<<<<<<<<<
+ * 
+ *             cpython.Py_INCREF(elem)
+ */
+      __pyx_t_3 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_slice_from(__pyx_v_elem_buf, __pyx_v_buf, __pyx_v_elem_len)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 188, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+
+      /* "asyncpg/protocol/codecs/base.pyx":187
+ *             else:
+ *                 elem_codec = self.element_codecs[i]
+ *                 elem = elem_codec.decode(settings,             # <<<<<<<<<<<<<<
+ *                                          elem_buf.slice_from(buf, elem_len))
+ * 
+ */
+      __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode(__pyx_v_elem_codec, __pyx_v_settings, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 187, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_XDECREF_SET(__pyx_v_elem, __pyx_t_1);
+      __pyx_t_1 = 0;
+    }
+    __pyx_L6:;
+
+    /* "asyncpg/protocol/codecs/base.pyx":190
+ *                                          elem_buf.slice_from(buf, elem_len))
+ * 
+ *             cpython.Py_INCREF(elem)             # <<<<<<<<<<<<<<
+ *             record.ApgRecord_SET_ITEM(result, i, elem)
+ * 
+ */
+    Py_INCREF(__pyx_v_elem);
+
+    /* "asyncpg/protocol/codecs/base.pyx":191
+ * 
+ *             cpython.Py_INCREF(elem)
+ *             record.ApgRecord_SET_ITEM(result, i, elem)             # <<<<<<<<<<<<<<
+ * 
+ *         return result
+ */
+    ApgRecord_SET_ITEM(__pyx_v_result, __pyx_v_i, __pyx_v_elem);
+  }
+
+  /* "asyncpg/protocol/codecs/base.pyx":193
+ *             record.ApgRecord_SET_ITEM(result, i, elem)
+ * 
+ *         return result             # <<<<<<<<<<<<<<
+ * 
+ *     cdef decode_in_python(self, ConnectionSettings settings,
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_result);
+  __pyx_r = __pyx_v_result;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":153
+ *                             <void*>(<cpython.PyObject>self.element_codec))
+ * 
+ *     cdef decode_composite(self, ConnectionSettings settings,             # <<<<<<<<<<<<<<
+ *                           FastReadBuffer buf):
+ *         cdef:
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_XDECREF(__pyx_t_11);
+  __Pyx_XDECREF(__pyx_t_12);
+  __Pyx_XDECREF(__pyx_t_13);
+  __Pyx_XDECREF(__pyx_t_15);
+  __Pyx_XDECREF(__pyx_t_16);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.decode_composite", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_result);
+  __Pyx_XDECREF((PyObject *)__pyx_v_elem_codec);
+  __Pyx_XDECREF((PyObject *)__pyx_v_elem_buf);
+  __Pyx_XDECREF(__pyx_v_elem);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":195
+ *         return result
+ * 
+ *     cdef decode_in_python(self, ConnectionSettings settings,             # <<<<<<<<<<<<<<
+ *                           FastReadBuffer buf):
+ *         if self.format == PG_FORMAT_BINARY:
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_in_python(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  PyObject *__pyx_v_bb = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  __Pyx_RefNannySetupContext("decode_in_python", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":197
+ *     cdef decode_in_python(self, ConnectionSettings settings,
+ *                           FastReadBuffer buf):
+ *         if self.format == PG_FORMAT_BINARY:             # <<<<<<<<<<<<<<
+ *             bb = bytea_decode(settings, buf)
+ *         else:
+ */
+  __pyx_t_1 = ((__pyx_v_self->format == __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/base.pyx":198
+ *                           FastReadBuffer buf):
+ *         if self.format == PG_FORMAT_BINARY:
+ *             bb = bytea_decode(settings, buf)             # <<<<<<<<<<<<<<
+ *         else:
+ *             bb = text_decode(settings, buf)
+ */
+    __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_bytea_decode(__pyx_v_settings, __pyx_v_buf); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 198, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_v_bb = __pyx_t_2;
+    __pyx_t_2 = 0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":197
+ *     cdef decode_in_python(self, ConnectionSettings settings,
+ *                           FastReadBuffer buf):
+ *         if self.format == PG_FORMAT_BINARY:             # <<<<<<<<<<<<<<
+ *             bb = bytea_decode(settings, buf)
+ *         else:
+ */
+    goto __pyx_L3;
+  }
+
+  /* "asyncpg/protocol/codecs/base.pyx":200
+ *             bb = bytea_decode(settings, buf)
+ *         else:
+ *             bb = text_decode(settings, buf)             # <<<<<<<<<<<<<<
+ * 
+ *         return self.py_decoder(bb)
+ */
+  /*else*/ {
+    __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_text_decode(__pyx_v_settings, __pyx_v_buf); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 200, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_v_bb = __pyx_t_2;
+    __pyx_t_2 = 0;
+  }
+  __pyx_L3:;
+
+  /* "asyncpg/protocol/codecs/base.pyx":202
+ *             bb = text_decode(settings, buf)
+ * 
+ *         return self.py_decoder(bb)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef inline decode(self, ConnectionSettings settings, FastReadBuffer buf):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_self->py_decoder);
+  __pyx_t_3 = __pyx_v_self->py_decoder; __pyx_t_4 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
+    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
+    if (likely(__pyx_t_4)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+      __Pyx_INCREF(__pyx_t_4);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_3, function);
+    }
+  }
+  if (!__pyx_t_4) {
+    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_bb); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 202, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_3)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_bb};
+      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 202, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_GOTREF(__pyx_t_2);
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_bb};
+      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 202, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_GOTREF(__pyx_t_2);
+    } else
+    #endif
+    {
+      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 202, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
+      __Pyx_INCREF(__pyx_v_bb);
+      __Pyx_GIVEREF(__pyx_v_bb);
+      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_bb);
+      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 202, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_r = __pyx_t_2;
+  __pyx_t_2 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":195
+ *         return result
+ * 
+ *     cdef decode_in_python(self, ConnectionSettings settings,             # <<<<<<<<<<<<<<
+ *                           FastReadBuffer buf):
+ *         if self.format == PG_FORMAT_BINARY:
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.decode_in_python", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_bb);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":204
+ *         return self.py_decoder(bb)
+ * 
+ *     cdef inline decode(self, ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *         return self.decoder(self, settings, buf)
+ * 
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("decode", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":205
+ * 
+ *     cdef inline decode(self, ConnectionSettings settings, FastReadBuffer buf):
+ *         return self.decoder(self, settings, buf)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef inline has_encoder(self):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __pyx_v_self->decoder(__pyx_v_self, __pyx_v_settings, __pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 205, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":204
+ *         return self.py_decoder(bb)
+ * 
+ *     cdef inline decode(self, ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *         return self.decoder(self, settings, buf)
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":207
+ *         return self.decoder(self, settings, buf)
+ * 
+ *     cdef inline has_encoder(self):             # <<<<<<<<<<<<<<
+ *         cdef Codec elem_codec
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_has_encoder(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_elem_codec = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  int __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  Py_ssize_t __pyx_t_5;
+  PyObject *__pyx_t_6 = NULL;
+  __Pyx_RefNannySetupContext("has_encoder", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":210
+ *         cdef Codec elem_codec
+ * 
+ *         if self.c_encoder is not NULL or self.py_encoder is not None:             # <<<<<<<<<<<<<<
+ *             return True
+ * 
+ */
+  __pyx_t_2 = ((__pyx_v_self->c_encoder != NULL) != 0);
+  if (!__pyx_t_2) {
+  } else {
+    __pyx_t_1 = __pyx_t_2;
+    goto __pyx_L4_bool_binop_done;
+  }
+  __pyx_t_2 = (__pyx_v_self->py_encoder != Py_None);
+  __pyx_t_3 = (__pyx_t_2 != 0);
+  __pyx_t_1 = __pyx_t_3;
+  __pyx_L4_bool_binop_done:;
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/base.pyx":211
+ * 
+ *         if self.c_encoder is not NULL or self.py_encoder is not None:
+ *             return True             # <<<<<<<<<<<<<<
+ * 
+ *         elif self.type == CODEC_ARRAY or self.type == CODEC_RANGE:
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(Py_True);
+    __pyx_r = Py_True;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":210
+ *         cdef Codec elem_codec
+ * 
+ *         if self.c_encoder is not NULL or self.py_encoder is not None:             # <<<<<<<<<<<<<<
+ *             return True
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/base.pyx":213
+ *             return True
+ * 
+ *         elif self.type == CODEC_ARRAY or self.type == CODEC_RANGE:             # <<<<<<<<<<<<<<
+ *             return self.element_codec.has_encoder()
+ * 
+ */
+  switch (__pyx_v_self->type) {
+    case __pyx_e_7asyncpg_8protocol_8protocol_CODEC_ARRAY:
+    case __pyx_e_7asyncpg_8protocol_8protocol_CODEC_RANGE:
+    __pyx_t_1 = 1;
+    break;
+    default:
+    __pyx_t_1 = 0;
+    break;
+  }
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/base.pyx":214
+ * 
+ *         elif self.type == CODEC_ARRAY or self.type == CODEC_RANGE:
+ *             return self.element_codec.has_encoder()             # <<<<<<<<<<<<<<
+ * 
+ *         elif self.type == CODEC_COMPOSITE:
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_has_encoder(__pyx_v_self->element_codec); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 214, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_r = __pyx_t_4;
+    __pyx_t_4 = 0;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":213
+ *             return True
+ * 
+ *         elif self.type == CODEC_ARRAY or self.type == CODEC_RANGE:             # <<<<<<<<<<<<<<
+ *             return self.element_codec.has_encoder()
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/base.pyx":216
+ *             return self.element_codec.has_encoder()
+ * 
+ *         elif self.type == CODEC_COMPOSITE:             # <<<<<<<<<<<<<<
+ *             for elem_codec in self.element_codecs:
+ *                 if not elem_codec.has_encoder():
+ */
+  __pyx_t_1 = ((__pyx_v_self->type == __pyx_e_7asyncpg_8protocol_8protocol_CODEC_COMPOSITE) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/base.pyx":217
+ * 
+ *         elif self.type == CODEC_COMPOSITE:
+ *             for elem_codec in self.element_codecs:             # <<<<<<<<<<<<<<
+ *                 if not elem_codec.has_encoder():
+ *                     return False
+ */
+    if (unlikely(__pyx_v_self->element_codecs == Py_None)) {
+      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
+      __PYX_ERR(2, 217, __pyx_L1_error)
+    }
+    __pyx_t_4 = __pyx_v_self->element_codecs; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
+    for (;;) {
+      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
+      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+      __pyx_t_6 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_6); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(2, 217, __pyx_L1_error)
+      #else
+      __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 217, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_6);
+      #endif
+      if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_7asyncpg_8protocol_8protocol_Codec))))) __PYX_ERR(2, 217, __pyx_L1_error)
+      __Pyx_XDECREF_SET(__pyx_v_elem_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_6));
+      __pyx_t_6 = 0;
+
+      /* "asyncpg/protocol/codecs/base.pyx":218
+ *         elif self.type == CODEC_COMPOSITE:
+ *             for elem_codec in self.element_codecs:
+ *                 if not elem_codec.has_encoder():             # <<<<<<<<<<<<<<
+ *                     return False
+ *             return True
+ */
+      __pyx_t_6 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_has_encoder(__pyx_v_elem_codec); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 218, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_6);
+      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 218, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __pyx_t_3 = ((!__pyx_t_1) != 0);
+      if (__pyx_t_3) {
+
+        /* "asyncpg/protocol/codecs/base.pyx":219
+ *             for elem_codec in self.element_codecs:
+ *                 if not elem_codec.has_encoder():
+ *                     return False             # <<<<<<<<<<<<<<
+ *             return True
+ * 
+ */
+        __Pyx_XDECREF(__pyx_r);
+        __Pyx_INCREF(Py_False);
+        __pyx_r = Py_False;
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        goto __pyx_L0;
+
+        /* "asyncpg/protocol/codecs/base.pyx":218
+ *         elif self.type == CODEC_COMPOSITE:
+ *             for elem_codec in self.element_codecs:
+ *                 if not elem_codec.has_encoder():             # <<<<<<<<<<<<<<
+ *                     return False
+ *             return True
+ */
+      }
+
+      /* "asyncpg/protocol/codecs/base.pyx":217
+ * 
+ *         elif self.type == CODEC_COMPOSITE:
+ *             for elem_codec in self.element_codecs:             # <<<<<<<<<<<<<<
+ *                 if not elem_codec.has_encoder():
+ *                     return False
+ */
+    }
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":220
+ *                 if not elem_codec.has_encoder():
+ *                     return False
+ *             return True             # <<<<<<<<<<<<<<
+ * 
+ *         else:
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(Py_True);
+    __pyx_r = Py_True;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":216
+ *             return self.element_codec.has_encoder()
+ * 
+ *         elif self.type == CODEC_COMPOSITE:             # <<<<<<<<<<<<<<
+ *             for elem_codec in self.element_codecs:
+ *                 if not elem_codec.has_encoder():
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/base.pyx":223
+ * 
+ *         else:
+ *             return False             # <<<<<<<<<<<<<<
+ * 
+ *     cdef has_decoder(self):
+ */
+  /*else*/ {
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(Py_False);
+    __pyx_r = Py_False;
+    goto __pyx_L0;
+  }
+
+  /* "asyncpg/protocol/codecs/base.pyx":207
+ *         return self.decoder(self, settings, buf)
+ * 
+ *     cdef inline has_encoder(self):             # <<<<<<<<<<<<<<
+ *         cdef Codec elem_codec
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.has_encoder", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_elem_codec);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":225
+ *             return False
+ * 
+ *     cdef has_decoder(self):             # <<<<<<<<<<<<<<
+ *         cdef Codec elem_codec
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_has_decoder(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_elem_codec = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  int __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  Py_ssize_t __pyx_t_5;
+  PyObject *__pyx_t_6 = NULL;
+  __Pyx_RefNannySetupContext("has_decoder", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":228
+ *         cdef Codec elem_codec
+ * 
+ *         if self.c_decoder is not NULL or self.py_decoder is not None:             # <<<<<<<<<<<<<<
+ *             return True
+ * 
+ */
+  __pyx_t_2 = ((__pyx_v_self->c_decoder != NULL) != 0);
+  if (!__pyx_t_2) {
+  } else {
+    __pyx_t_1 = __pyx_t_2;
+    goto __pyx_L4_bool_binop_done;
+  }
+  __pyx_t_2 = (__pyx_v_self->py_decoder != Py_None);
+  __pyx_t_3 = (__pyx_t_2 != 0);
+  __pyx_t_1 = __pyx_t_3;
+  __pyx_L4_bool_binop_done:;
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/base.pyx":229
+ * 
+ *         if self.c_decoder is not NULL or self.py_decoder is not None:
+ *             return True             # <<<<<<<<<<<<<<
+ * 
+ *         elif self.type == CODEC_ARRAY or self.type == CODEC_RANGE:
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(Py_True);
+    __pyx_r = Py_True;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":228
+ *         cdef Codec elem_codec
+ * 
+ *         if self.c_decoder is not NULL or self.py_decoder is not None:             # <<<<<<<<<<<<<<
+ *             return True
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/base.pyx":231
+ *             return True
+ * 
+ *         elif self.type == CODEC_ARRAY or self.type == CODEC_RANGE:             # <<<<<<<<<<<<<<
+ *             return self.element_codec.has_decoder()
+ * 
+ */
+  switch (__pyx_v_self->type) {
+    case __pyx_e_7asyncpg_8protocol_8protocol_CODEC_ARRAY:
+    case __pyx_e_7asyncpg_8protocol_8protocol_CODEC_RANGE:
+    __pyx_t_1 = 1;
+    break;
+    default:
+    __pyx_t_1 = 0;
+    break;
+  }
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/base.pyx":232
+ * 
+ *         elif self.type == CODEC_ARRAY or self.type == CODEC_RANGE:
+ *             return self.element_codec.has_decoder()             # <<<<<<<<<<<<<<
+ * 
+ *         elif self.type == CODEC_COMPOSITE:
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_has_decoder(__pyx_v_self->element_codec); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 232, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_r = __pyx_t_4;
+    __pyx_t_4 = 0;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":231
+ *             return True
+ * 
+ *         elif self.type == CODEC_ARRAY or self.type == CODEC_RANGE:             # <<<<<<<<<<<<<<
+ *             return self.element_codec.has_decoder()
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/base.pyx":234
+ *             return self.element_codec.has_decoder()
+ * 
+ *         elif self.type == CODEC_COMPOSITE:             # <<<<<<<<<<<<<<
+ *             for elem_codec in self.element_codecs:
+ *                 if not elem_codec.has_decoder():
+ */
+  __pyx_t_1 = ((__pyx_v_self->type == __pyx_e_7asyncpg_8protocol_8protocol_CODEC_COMPOSITE) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/base.pyx":235
+ * 
+ *         elif self.type == CODEC_COMPOSITE:
+ *             for elem_codec in self.element_codecs:             # <<<<<<<<<<<<<<
+ *                 if not elem_codec.has_decoder():
+ *                     return False
+ */
+    if (unlikely(__pyx_v_self->element_codecs == Py_None)) {
+      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
+      __PYX_ERR(2, 235, __pyx_L1_error)
+    }
+    __pyx_t_4 = __pyx_v_self->element_codecs; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
+    for (;;) {
+      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
+      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+      __pyx_t_6 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_6); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(2, 235, __pyx_L1_error)
+      #else
+      __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 235, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_6);
+      #endif
+      if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_7asyncpg_8protocol_8protocol_Codec))))) __PYX_ERR(2, 235, __pyx_L1_error)
+      __Pyx_XDECREF_SET(__pyx_v_elem_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_6));
+      __pyx_t_6 = 0;
+
+      /* "asyncpg/protocol/codecs/base.pyx":236
+ *         elif self.type == CODEC_COMPOSITE:
+ *             for elem_codec in self.element_codecs:
+ *                 if not elem_codec.has_decoder():             # <<<<<<<<<<<<<<
+ *                     return False
+ *             return True
+ */
+      __pyx_t_6 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_has_decoder(__pyx_v_elem_codec); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 236, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_6);
+      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 236, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __pyx_t_3 = ((!__pyx_t_1) != 0);
+      if (__pyx_t_3) {
+
+        /* "asyncpg/protocol/codecs/base.pyx":237
+ *             for elem_codec in self.element_codecs:
+ *                 if not elem_codec.has_decoder():
+ *                     return False             # <<<<<<<<<<<<<<
+ *             return True
+ * 
+ */
+        __Pyx_XDECREF(__pyx_r);
+        __Pyx_INCREF(Py_False);
+        __pyx_r = Py_False;
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        goto __pyx_L0;
+
+        /* "asyncpg/protocol/codecs/base.pyx":236
+ *         elif self.type == CODEC_COMPOSITE:
+ *             for elem_codec in self.element_codecs:
+ *                 if not elem_codec.has_decoder():             # <<<<<<<<<<<<<<
+ *                     return False
+ *             return True
+ */
+      }
+
+      /* "asyncpg/protocol/codecs/base.pyx":235
+ * 
+ *         elif self.type == CODEC_COMPOSITE:
+ *             for elem_codec in self.element_codecs:             # <<<<<<<<<<<<<<
+ *                 if not elem_codec.has_decoder():
+ *                     return False
+ */
+    }
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":238
+ *                 if not elem_codec.has_decoder():
+ *                     return False
+ *             return True             # <<<<<<<<<<<<<<
+ * 
+ *         else:
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(Py_True);
+    __pyx_r = Py_True;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":234
+ *             return self.element_codec.has_decoder()
+ * 
+ *         elif self.type == CODEC_COMPOSITE:             # <<<<<<<<<<<<<<
+ *             for elem_codec in self.element_codecs:
+ *                 if not elem_codec.has_decoder():
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/base.pyx":241
+ * 
+ *         else:
+ *             return False             # <<<<<<<<<<<<<<
+ * 
+ *     cdef is_binary(self):
+ */
+  /*else*/ {
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(Py_False);
+    __pyx_r = Py_False;
+    goto __pyx_L0;
+  }
+
+  /* "asyncpg/protocol/codecs/base.pyx":225
+ *             return False
+ * 
+ *     cdef has_decoder(self):             # <<<<<<<<<<<<<<
+ *         cdef Codec elem_codec
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.has_decoder", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_elem_codec);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":243
+ *             return False
+ * 
+ *     cdef is_binary(self):             # <<<<<<<<<<<<<<
+ *         return self.format == PG_FORMAT_BINARY
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_is_binary(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("is_binary", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":244
+ * 
+ *     cdef is_binary(self):
+ *         return self.format == PG_FORMAT_BINARY             # <<<<<<<<<<<<<<
+ * 
+ *     def __repr__(self):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_self->format == __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 244, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":243
+ *             return False
+ * 
+ *     cdef is_binary(self):             # <<<<<<<<<<<<<<
+ *         return self.format == PG_FORMAT_BINARY
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.is_binary", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":246
+ *         return self.format == PG_FORMAT_BINARY
+ * 
+ *     def __repr__(self):             # <<<<<<<<<<<<<<
+ *         return '<Codec oid={} elem_oid={} core={}>'.format(
+ *             self.oid,
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_5Codec_3__repr__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_5Codec_3__repr__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_5Codec_2__repr__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_5Codec_2__repr__(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  int __pyx_t_5;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  int __pyx_t_8;
+  PyObject *__pyx_t_9 = NULL;
+  __Pyx_RefNannySetupContext("__repr__", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":247
+ * 
+ *     def __repr__(self):
+ *         return '<Codec oid={} elem_oid={} core={}>'.format(             # <<<<<<<<<<<<<<
+ *             self.oid,
+ *             'NA' if self.element_codec is None else self.element_codec.oid,
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Codec_oid_elem_oid_core, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 247, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+
+  /* "asyncpg/protocol/codecs/base.pyx":248
+ *     def __repr__(self):
+ *         return '<Codec oid={} elem_oid={} core={}>'.format(
+ *             self.oid,             # <<<<<<<<<<<<<<
+ *             'NA' if self.element_codec is None else self.element_codec.oid,
+ *             has_core_codec(self.oid))
+ */
+  __pyx_t_3 = __Pyx_PyInt_From_uint32_t(__pyx_v_self->oid); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 248, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+
+  /* "asyncpg/protocol/codecs/base.pyx":249
+ *         return '<Codec oid={} elem_oid={} core={}>'.format(
+ *             self.oid,
+ *             'NA' if self.element_codec is None else self.element_codec.oid,             # <<<<<<<<<<<<<<
+ *             has_core_codec(self.oid))
+ * 
+ */
+  __pyx_t_5 = (((PyObject *)__pyx_v_self->element_codec) == Py_None);
+  if ((__pyx_t_5 != 0)) {
+    __Pyx_INCREF(__pyx_n_u_NA);
+    __pyx_t_4 = __pyx_n_u_NA;
+  } else {
+    __pyx_t_6 = __Pyx_PyInt_From_uint32_t(__pyx_v_self->element_codec->oid); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 249, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_4 = __pyx_t_6;
+    __pyx_t_6 = 0;
+  }
+
+  /* "asyncpg/protocol/codecs/base.pyx":250
+ *             self.oid,
+ *             'NA' if self.element_codec is None else self.element_codec.oid,
+ *             has_core_codec(self.oid))             # <<<<<<<<<<<<<<
+ * 
+ *     @staticmethod
+ */
+  __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_f_7asyncpg_8protocol_8protocol_has_core_codec(__pyx_v_self->oid)); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 250, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_6);
+  __pyx_t_7 = NULL;
+  __pyx_t_8 = 0;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_7)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_7);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+      __pyx_t_8 = 1;
+    }
+  }
+  #if CYTHON_FAST_PYCALL
+  if (PyFunction_Check(__pyx_t_2)) {
+    PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_3, __pyx_t_4, __pyx_t_6};
+    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 247, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  } else
+  #endif
+  #if CYTHON_FAST_PYCCALL
+  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+    PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_3, __pyx_t_4, __pyx_t_6};
+    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 247, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  } else
+  #endif
+  {
+    __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 247, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_9);
+    if (__pyx_t_7) {
+      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
+    }
+    __Pyx_GIVEREF(__pyx_t_3);
+    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_3);
+    __Pyx_GIVEREF(__pyx_t_4);
+    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_6);
+    PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_6);
+    __pyx_t_3 = 0;
+    __pyx_t_4 = 0;
+    __pyx_t_6 = 0;
+    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 247, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":246
+ *         return self.format == PG_FORMAT_BINARY
+ * 
+ *     def __repr__(self):             # <<<<<<<<<<<<<<
+ *         return '<Codec oid={} elem_oid={} core={}>'.format(
+ *             self.oid,
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":253
+ * 
+ *     @staticmethod
+ *     cdef Codec new_array_codec(uint32_t oid,             # <<<<<<<<<<<<<<
+ *                                str name,
+ *                                str schema,
+ */
+
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_new_array_codec(uint32_t __pyx_v_oid, PyObject *__pyx_v_name, PyObject *__pyx_v_schema, struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_element_codec, Py_UCS4 __pyx_v_element_delimiter) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_codec = 0;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("new_array_codec", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":259
+ *                                Py_UCS4 element_delimiter):
+ *         cdef Codec codec
+ *         codec = Codec(oid)             # <<<<<<<<<<<<<<
+ *         codec.init(name, schema, 'array', CODEC_ARRAY, element_codec.format,
+ *                    NULL, NULL, None, None, element_codec, None, None, None,
+ */
+  __pyx_t_1 = __Pyx_PyInt_From_uint32_t(__pyx_v_oid); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 259, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 259, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
+  __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_Codec), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 259, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_v_codec = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":260
+ *         cdef Codec codec
+ *         codec = Codec(oid)
+ *         codec.init(name, schema, 'array', CODEC_ARRAY, element_codec.format,             # <<<<<<<<<<<<<<
+ *                    NULL, NULL, None, None, element_codec, None, None, None,
+ *                    element_delimiter)
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_init(__pyx_v_codec, __pyx_v_name, __pyx_v_schema, __pyx_n_u_array, __pyx_e_7asyncpg_8protocol_8protocol_CODEC_ARRAY, __pyx_v_element_codec->format, NULL, NULL, Py_None, Py_None, __pyx_v_element_codec, ((PyObject*)Py_None), Py_None, ((PyObject*)Py_None), __pyx_v_element_delimiter); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 260, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":263
+ *                    NULL, NULL, None, None, element_codec, None, None, None,
+ *                    element_delimiter)
+ *         return codec             # <<<<<<<<<<<<<<
+ * 
+ *     @staticmethod
+ */
+  __Pyx_XDECREF(((PyObject *)__pyx_r));
+  __Pyx_INCREF(((PyObject *)__pyx_v_codec));
+  __pyx_r = __pyx_v_codec;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":253
+ * 
+ *     @staticmethod
+ *     cdef Codec new_array_codec(uint32_t oid,             # <<<<<<<<<<<<<<
+ *                                str name,
+ *                                str schema,
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.new_array_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
+  __Pyx_XGIVEREF((PyObject *)__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":266
+ * 
+ *     @staticmethod
+ *     cdef Codec new_range_codec(uint32_t oid,             # <<<<<<<<<<<<<<
+ *                                str name,
+ *                                str schema,
+ */
+
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_new_range_codec(uint32_t __pyx_v_oid, PyObject *__pyx_v_name, PyObject *__pyx_v_schema, struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_element_codec) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_codec = 0;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("new_range_codec", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":271
+ *                                Codec element_codec):
+ *         cdef Codec codec
+ *         codec = Codec(oid)             # <<<<<<<<<<<<<<
+ *         codec.init(name, schema, 'range', CODEC_RANGE, PG_FORMAT_BINARY,
+ *                    NULL, NULL, None, None, element_codec, None, None, None,
+ */
+  __pyx_t_1 = __Pyx_PyInt_From_uint32_t(__pyx_v_oid); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 271, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 271, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
+  __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_Codec), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 271, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_v_codec = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":272
+ *         cdef Codec codec
+ *         codec = Codec(oid)
+ *         codec.init(name, schema, 'range', CODEC_RANGE, PG_FORMAT_BINARY,             # <<<<<<<<<<<<<<
+ *                    NULL, NULL, None, None, element_codec, None, None, None,
+ *                    0)
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_init(__pyx_v_codec, __pyx_v_name, __pyx_v_schema, __pyx_n_u_range, __pyx_e_7asyncpg_8protocol_8protocol_CODEC_RANGE, __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY, NULL, NULL, Py_None, Py_None, __pyx_v_element_codec, ((PyObject*)Py_None), Py_None, ((PyObject*)Py_None), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 272, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":275
+ *                    NULL, NULL, None, None, element_codec, None, None, None,
+ *                    0)
+ *         return codec             # <<<<<<<<<<<<<<
+ * 
+ *     @staticmethod
+ */
+  __Pyx_XDECREF(((PyObject *)__pyx_r));
+  __Pyx_INCREF(((PyObject *)__pyx_v_codec));
+  __pyx_r = __pyx_v_codec;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":266
+ * 
+ *     @staticmethod
+ *     cdef Codec new_range_codec(uint32_t oid,             # <<<<<<<<<<<<<<
+ *                                str name,
+ *                                str schema,
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.new_range_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
+  __Pyx_XGIVEREF((PyObject *)__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":278
+ * 
+ *     @staticmethod
+ *     cdef Codec new_composite_codec(uint32_t oid,             # <<<<<<<<<<<<<<
+ *                                    str name,
+ *                                    str schema,
+ */
+
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_new_composite_codec(uint32_t __pyx_v_oid, PyObject *__pyx_v_name, PyObject *__pyx_v_schema, PyObject *__pyx_v_element_codecs, PyObject *__pyx_v_element_type_oids, PyObject *__pyx_v_element_names) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_codec = 0;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("new_composite_codec", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":285
+ *                                    object element_names):
+ *         cdef Codec codec
+ *         codec = Codec(oid)             # <<<<<<<<<<<<<<
+ *         codec.init(name, schema, 'composite', CODEC_COMPOSITE,
+ *                    PG_FORMAT_BINARY, NULL, NULL, None, None, None,
+ */
+  __pyx_t_1 = __Pyx_PyInt_From_uint32_t(__pyx_v_oid); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 285, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 285, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
+  __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_Codec), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 285, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_v_codec = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":286
+ *         cdef Codec codec
+ *         codec = Codec(oid)
+ *         codec.init(name, schema, 'composite', CODEC_COMPOSITE,             # <<<<<<<<<<<<<<
+ *                    PG_FORMAT_BINARY, NULL, NULL, None, None, None,
+ *                    element_type_oids, element_names, element_codecs, 0)
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_init(__pyx_v_codec, __pyx_v_name, __pyx_v_schema, __pyx_n_u_composite, __pyx_e_7asyncpg_8protocol_8protocol_CODEC_COMPOSITE, __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY, NULL, NULL, Py_None, Py_None, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)Py_None), __pyx_v_element_type_oids, __pyx_v_element_names, __pyx_v_element_codecs, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 286, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":289
+ *                    PG_FORMAT_BINARY, NULL, NULL, None, None, None,
+ *                    element_type_oids, element_names, element_codecs, 0)
+ *         return codec             # <<<<<<<<<<<<<<
+ * 
+ *     @staticmethod
+ */
+  __Pyx_XDECREF(((PyObject *)__pyx_r));
+  __Pyx_INCREF(((PyObject *)__pyx_v_codec));
+  __pyx_r = __pyx_v_codec;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":278
+ * 
+ *     @staticmethod
+ *     cdef Codec new_composite_codec(uint32_t oid,             # <<<<<<<<<<<<<<
+ *                                    str name,
+ *                                    str schema,
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.new_composite_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
+  __Pyx_XGIVEREF((PyObject *)__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":292
+ * 
+ *     @staticmethod
+ *     cdef Codec new_python_codec(uint32_t oid,             # <<<<<<<<<<<<<<
+ *                                 str name,
+ *                                 str schema,
+ */
+
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_new_python_codec(uint32_t __pyx_v_oid, PyObject *__pyx_v_name, PyObject *__pyx_v_schema, PyObject *__pyx_v_kind, PyObject *__pyx_v_encoder, PyObject *__pyx_v_decoder, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat __pyx_v_format) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_codec = 0;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("new_python_codec", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":300
+ *                                 CodecFormat format):
+ *         cdef Codec codec
+ *         codec = Codec(oid)             # <<<<<<<<<<<<<<
+ *         codec.init(name, schema, kind, CODEC_PY, format, NULL, NULL,
+ *                    encoder, decoder, None, None, None, None, 0)
+ */
+  __pyx_t_1 = __Pyx_PyInt_From_uint32_t(__pyx_v_oid); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 300, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 300, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
+  __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_Codec), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 300, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_v_codec = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":301
+ *         cdef Codec codec
+ *         codec = Codec(oid)
+ *         codec.init(name, schema, kind, CODEC_PY, format, NULL, NULL,             # <<<<<<<<<<<<<<
+ *                    encoder, decoder, None, None, None, None, 0)
+ *         return codec
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_init(__pyx_v_codec, __pyx_v_name, __pyx_v_schema, __pyx_v_kind, __pyx_e_7asyncpg_8protocol_8protocol_CODEC_PY, __pyx_v_format, NULL, NULL, __pyx_v_encoder, __pyx_v_decoder, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)Py_None), ((PyObject*)Py_None), Py_None, ((PyObject*)Py_None), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 301, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":303
+ *         codec.init(name, schema, kind, CODEC_PY, format, NULL, NULL,
+ *                    encoder, decoder, None, None, None, None, 0)
+ *         return codec             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(((PyObject *)__pyx_r));
+  __Pyx_INCREF(((PyObject *)__pyx_v_codec));
+  __pyx_r = __pyx_v_codec;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":292
+ * 
+ *     @staticmethod
+ *     cdef Codec new_python_codec(uint32_t oid,             # <<<<<<<<<<<<<<
+ *                                 str name,
+ *                                 str schema,
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.new_python_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
+  __Pyx_XGIVEREF((PyObject *)__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":307
+ * 
+ * # Encode callback for arrays
+ * cdef codec_encode_func_ex(ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
+ *                           object obj, const void *arg):
+ *     return (<Codec>arg).encode(settings, buf, obj)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_codec_encode_func_ex(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj, void const *__pyx_v_arg) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("codec_encode_func_ex", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":309
+ * cdef codec_encode_func_ex(ConnectionSettings settings, WriteBuffer buf,
+ *                           object obj, const void *arg):
+ *     return (<Codec>arg).encode(settings, buf, obj)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode(((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_v_arg), __pyx_v_settings, __pyx_v_buf, __pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 309, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":307
+ * 
+ * # Encode callback for arrays
+ * cdef codec_encode_func_ex(ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
+ *                           object obj, const void *arg):
+ *     return (<Codec>arg).encode(settings, buf, obj)
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.codec_encode_func_ex", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":313
+ * 
+ * # Decode callback for arrays
+ * cdef codec_decode_func_ex(ConnectionSettings settings, FastReadBuffer buf,             # <<<<<<<<<<<<<<
+ *                           const void *arg):
+ *     return (<Codec>arg).decode(settings, buf)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_codec_decode_func_ex(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf, void const *__pyx_v_arg) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("codec_decode_func_ex", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":315
+ * cdef codec_decode_func_ex(ConnectionSettings settings, FastReadBuffer buf,
+ *                           const void *arg):
+ *     return (<Codec>arg).decode(settings, buf)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode(((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_v_arg), __pyx_v_settings, __pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 315, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":313
+ * 
+ * # Decode callback for arrays
+ * cdef codec_decode_func_ex(ConnectionSettings settings, FastReadBuffer buf,             # <<<<<<<<<<<<<<
+ *                           const void *arg):
+ *     return (<Codec>arg).decode(settings, buf)
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.codec_decode_func_ex", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":319
+ * 
+ * cdef class DataCodecConfig:
+ *     def __init__(self, cache_key):             # <<<<<<<<<<<<<<
+ *         try:
+ *             self._type_codecs_cache = TYPE_CODECS_CACHE[cache_key]
+ */
+
+/* Python wrapper */
+static int __pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_cache_key = 0;
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cache_key,0};
+    PyObject* values[1] = {0};
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_cache_key)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+      }
+      if (unlikely(kw_args > 0)) {
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(2, 319, __pyx_L3_error)
+      }
+    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
+      goto __pyx_L5_argtuple_error;
+    } else {
+      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+    }
+    __pyx_v_cache_key = values[0];
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 319, __pyx_L3_error)
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.DataCodecConfig.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return -1;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig___init__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *)__pyx_v_self), __pyx_v_cache_key);
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static int __pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig___init__(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *__pyx_v_self, PyObject *__pyx_v_cache_key) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  int __pyx_t_5;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  __Pyx_RefNannySetupContext("__init__", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":320
+ * cdef class DataCodecConfig:
+ *     def __init__(self, cache_key):
+ *         try:             # <<<<<<<<<<<<<<
+ *             self._type_codecs_cache = TYPE_CODECS_CACHE[cache_key]
+ *         except KeyError:
+ */
+  {
+    __Pyx_PyThreadState_declare
+    __Pyx_PyThreadState_assign
+    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
+    __Pyx_XGOTREF(__pyx_t_1);
+    __Pyx_XGOTREF(__pyx_t_2);
+    __Pyx_XGOTREF(__pyx_t_3);
+    /*try:*/ {
+
+      /* "asyncpg/protocol/codecs/base.pyx":321
+ *     def __init__(self, cache_key):
+ *         try:
+ *             self._type_codecs_cache = TYPE_CODECS_CACHE[cache_key]             # <<<<<<<<<<<<<<
+ *         except KeyError:
+ *             self._type_codecs_cache = TYPE_CODECS_CACHE[cache_key] = {}
+ */
+      if (unlikely(__pyx_v_7asyncpg_8protocol_8protocol_TYPE_CODECS_CACHE == Py_None)) {
+        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+        __PYX_ERR(2, 321, __pyx_L3_error)
+      }
+      __pyx_t_4 = __Pyx_PyDict_GetItem(__pyx_v_7asyncpg_8protocol_8protocol_TYPE_CODECS_CACHE, __pyx_v_cache_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 321, __pyx_L3_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      if (!(likely(PyDict_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(2, 321, __pyx_L3_error)
+      __Pyx_GIVEREF(__pyx_t_4);
+      __Pyx_GOTREF(__pyx_v_self->_type_codecs_cache);
+      __Pyx_DECREF(__pyx_v_self->_type_codecs_cache);
+      __pyx_v_self->_type_codecs_cache = ((PyObject*)__pyx_t_4);
+      __pyx_t_4 = 0;
+
+      /* "asyncpg/protocol/codecs/base.pyx":320
+ * cdef class DataCodecConfig:
+ *     def __init__(self, cache_key):
+ *         try:             # <<<<<<<<<<<<<<
+ *             self._type_codecs_cache = TYPE_CODECS_CACHE[cache_key]
+ *         except KeyError:
+ */
+    }
+    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+    goto __pyx_L10_try_end;
+    __pyx_L3_error:;
+    __Pyx_PyThreadState_assign
+    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":322
+ *         try:
+ *             self._type_codecs_cache = TYPE_CODECS_CACHE[cache_key]
+ *         except KeyError:             # <<<<<<<<<<<<<<
+ *             self._type_codecs_cache = TYPE_CODECS_CACHE[cache_key] = {}
+ * 
+ */
+    __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
+    if (__pyx_t_5) {
+      __Pyx_AddTraceback("asyncpg.protocol.protocol.DataCodecConfig.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 322, __pyx_L5_except_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_GOTREF(__pyx_t_7);
+
+      /* "asyncpg/protocol/codecs/base.pyx":323
+ *             self._type_codecs_cache = TYPE_CODECS_CACHE[cache_key]
+ *         except KeyError:
+ *             self._type_codecs_cache = TYPE_CODECS_CACHE[cache_key] = {}             # <<<<<<<<<<<<<<
+ * 
+ *         self._local_type_codecs = {}
+ */
+      __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 323, __pyx_L5_except_error)
+      __Pyx_GOTREF(__pyx_t_8);
+      __Pyx_INCREF(__pyx_t_8);
+      __Pyx_GIVEREF(__pyx_t_8);
+      __Pyx_GOTREF(__pyx_v_self->_type_codecs_cache);
+      __Pyx_DECREF(__pyx_v_self->_type_codecs_cache);
+      __pyx_v_self->_type_codecs_cache = __pyx_t_8;
+      if (unlikely(__pyx_v_7asyncpg_8protocol_8protocol_TYPE_CODECS_CACHE == Py_None)) {
+        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+        __PYX_ERR(2, 323, __pyx_L5_except_error)
+      }
+      if (unlikely(PyDict_SetItem(__pyx_v_7asyncpg_8protocol_8protocol_TYPE_CODECS_CACHE, __pyx_v_cache_key, __pyx_t_8) < 0)) __PYX_ERR(2, 323, __pyx_L5_except_error)
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      goto __pyx_L4_exception_handled;
+    }
+    goto __pyx_L5_except_error;
+    __pyx_L5_except_error:;
+
+    /* "asyncpg/protocol/codecs/base.pyx":320
+ * cdef class DataCodecConfig:
+ *     def __init__(self, cache_key):
+ *         try:             # <<<<<<<<<<<<<<
+ *             self._type_codecs_cache = TYPE_CODECS_CACHE[cache_key]
+ *         except KeyError:
+ */
+    __Pyx_PyThreadState_assign
+    __Pyx_XGIVEREF(__pyx_t_1);
+    __Pyx_XGIVEREF(__pyx_t_2);
+    __Pyx_XGIVEREF(__pyx_t_3);
+    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
+    goto __pyx_L1_error;
+    __pyx_L4_exception_handled:;
+    __Pyx_PyThreadState_assign
+    __Pyx_XGIVEREF(__pyx_t_1);
+    __Pyx_XGIVEREF(__pyx_t_2);
+    __Pyx_XGIVEREF(__pyx_t_3);
+    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
+    __pyx_L10_try_end:;
+  }
+
+  /* "asyncpg/protocol/codecs/base.pyx":325
+ *             self._type_codecs_cache = TYPE_CODECS_CACHE[cache_key] = {}
+ * 
+ *         self._local_type_codecs = {}             # <<<<<<<<<<<<<<
+ * 
+ *     def add_types(self, types):
+ */
+  __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 325, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_7);
+  __Pyx_GIVEREF(__pyx_t_7);
+  __Pyx_GOTREF(__pyx_v_self->_local_type_codecs);
+  __Pyx_DECREF(__pyx_v_self->_local_type_codecs);
+  __pyx_v_self->_local_type_codecs = ((PyObject*)__pyx_t_7);
+  __pyx_t_7 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":319
+ * 
+ * cdef class DataCodecConfig:
+ *     def __init__(self, cache_key):             # <<<<<<<<<<<<<<
+ *         try:
+ *             self._type_codecs_cache = TYPE_CODECS_CACHE[cache_key]
+ */
+
+  /* function exit code */
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.DataCodecConfig.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":327
+ *         self._local_type_codecs = {}
+ * 
+ *     def add_types(self, types):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             Codec elem_codec
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_3add_types(PyObject *__pyx_v_self, PyObject *__pyx_v_types); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_3add_types(PyObject *__pyx_v_self, PyObject *__pyx_v_types) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("add_types (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig_2add_types(((struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *)__pyx_v_self), ((PyObject *)__pyx_v_types));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig_2add_types(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *__pyx_v_self, PyObject *__pyx_v_types) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_elem_codec = 0;
+  PyObject *__pyx_v_comp_elem_codecs = 0;
+  enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat __pyx_v_format;
+  enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat __pyx_v_elem_format;
+  int __pyx_v_has_text_elements;
+  Py_UCS4 __pyx_v_elem_delim;
+  PyObject *__pyx_v_ti = NULL;
+  PyObject *__pyx_v_oid = NULL;
+  PyObject *__pyx_v_name = NULL;
+  PyObject *__pyx_v_schema = NULL;
+  PyObject *__pyx_v_array_element_oid = NULL;
+  PyObject *__pyx_v_range_subtype_oid = NULL;
+  PyObject *__pyx_v_comp_type_attrs = NULL;
+  PyObject *__pyx_v_base_type = NULL;
+  PyObject *__pyx_v_typoid = NULL;
+  PyObject *__pyx_v_element_names = NULL;
+  PyObject *__pyx_v_i = NULL;
+  PyObject *__pyx_v_attrname = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  Py_ssize_t __pyx_t_2;
+  PyObject *(*__pyx_t_3)(PyObject *);
+  PyObject *__pyx_t_4 = NULL;
+  int __pyx_t_5;
+  int __pyx_t_6;
+  uint32_t __pyx_t_7;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  PyObject *__pyx_t_10 = NULL;
+  Py_UCS4 __pyx_t_11;
+  Py_ssize_t __pyx_t_12;
+  PyObject *(*__pyx_t_13)(PyObject *);
+  PyObject *__pyx_t_14 = NULL;
+  int __pyx_t_15;
+  int __pyx_t_16;
+  __Pyx_RefNannySetupContext("add_types", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":336
+ *             Py_UCS4 elem_delim
+ * 
+ *         for ti in types:             # <<<<<<<<<<<<<<
+ *             oid = ti['oid']
+ * 
+ */
+  if (likely(PyList_CheckExact(__pyx_v_types)) || PyTuple_CheckExact(__pyx_v_types)) {
+    __pyx_t_1 = __pyx_v_types; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
+    __pyx_t_3 = NULL;
+  } else {
+    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_types); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 336, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 336, __pyx_L1_error)
+  }
+  for (;;) {
+    if (likely(!__pyx_t_3)) {
+      if (likely(PyList_CheckExact(__pyx_t_1))) {
+        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
+        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(2, 336, __pyx_L1_error)
+        #else
+        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 336, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        #endif
+      } else {
+        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(2, 336, __pyx_L1_error)
+        #else
+        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 336, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        #endif
+      }
+    } else {
+      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
+      if (unlikely(!__pyx_t_4)) {
+        PyObject* exc_type = PyErr_Occurred();
+        if (exc_type) {
+          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+          else __PYX_ERR(2, 336, __pyx_L1_error)
+        }
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_4);
+    }
+    __Pyx_XDECREF_SET(__pyx_v_ti, __pyx_t_4);
+    __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":337
+ * 
+ *         for ti in types:
+ *             oid = ti['oid']             # <<<<<<<<<<<<<<
+ * 
+ *             if not ti['has_bin_io']:
+ */
+    __pyx_t_4 = PyObject_GetItem(__pyx_v_ti, __pyx_n_u_oid); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 337, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_XDECREF_SET(__pyx_v_oid, __pyx_t_4);
+    __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":339
+ *             oid = ti['oid']
+ * 
+ *             if not ti['has_bin_io']:             # <<<<<<<<<<<<<<
+ *                 format = PG_FORMAT_TEXT
+ *             else:
+ */
+    __pyx_t_4 = PyObject_GetItem(__pyx_v_ti, __pyx_n_u_has_bin_io); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 339, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(2, 339, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_6 = ((!__pyx_t_5) != 0);
+    if (__pyx_t_6) {
+
+      /* "asyncpg/protocol/codecs/base.pyx":340
+ * 
+ *             if not ti['has_bin_io']:
+ *                 format = PG_FORMAT_TEXT             # <<<<<<<<<<<<<<
+ *             else:
+ *                 format = PG_FORMAT_BINARY
+ */
+      __pyx_v_format = __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT;
+
+      /* "asyncpg/protocol/codecs/base.pyx":339
+ *             oid = ti['oid']
+ * 
+ *             if not ti['has_bin_io']:             # <<<<<<<<<<<<<<
+ *                 format = PG_FORMAT_TEXT
+ *             else:
+ */
+      goto __pyx_L5;
+    }
+
+    /* "asyncpg/protocol/codecs/base.pyx":342
+ *                 format = PG_FORMAT_TEXT
+ *             else:
+ *                 format = PG_FORMAT_BINARY             # <<<<<<<<<<<<<<
+ * 
+ *             has_text_elements = False
+ */
+    /*else*/ {
+      __pyx_v_format = __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY;
+    }
+    __pyx_L5:;
+
+    /* "asyncpg/protocol/codecs/base.pyx":344
+ *                 format = PG_FORMAT_BINARY
+ * 
+ *             has_text_elements = False             # <<<<<<<<<<<<<<
+ * 
+ *             if self.get_codec(oid, format) is not None:
+ */
+    __pyx_v_has_text_elements = 0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":346
+ *             has_text_elements = False
+ * 
+ *             if self.get_codec(oid, format) is not None:             # <<<<<<<<<<<<<<
+ *                 continue
+ * 
+ */
+    __pyx_t_7 = __Pyx_PyInt_As_uint32_t(__pyx_v_oid); if (unlikely((__pyx_t_7 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(2, 346, __pyx_L1_error)
+    __pyx_t_4 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_15DataCodecConfig_get_codec(__pyx_v_self, __pyx_t_7, __pyx_v_format)); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 346, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_6 = (__pyx_t_4 != Py_None);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_5 = (__pyx_t_6 != 0);
+    if (__pyx_t_5) {
+
+      /* "asyncpg/protocol/codecs/base.pyx":347
+ * 
+ *             if self.get_codec(oid, format) is not None:
+ *                 continue             # <<<<<<<<<<<<<<
+ * 
+ *             name = ti['name']
+ */
+      goto __pyx_L3_continue;
+
+      /* "asyncpg/protocol/codecs/base.pyx":346
+ *             has_text_elements = False
+ * 
+ *             if self.get_codec(oid, format) is not None:             # <<<<<<<<<<<<<<
+ *                 continue
+ * 
+ */
+    }
+
+    /* "asyncpg/protocol/codecs/base.pyx":349
+ *                 continue
+ * 
+ *             name = ti['name']             # <<<<<<<<<<<<<<
+ *             schema = ti['ns']
+ *             array_element_oid = ti['elemtype']
+ */
+    __pyx_t_4 = PyObject_GetItem(__pyx_v_ti, __pyx_n_u_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 349, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_4);
+    __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":350
+ * 
+ *             name = ti['name']
+ *             schema = ti['ns']             # <<<<<<<<<<<<<<
+ *             array_element_oid = ti['elemtype']
+ *             range_subtype_oid = ti['range_subtype']
+ */
+    __pyx_t_4 = PyObject_GetItem(__pyx_v_ti, __pyx_n_u_ns); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 350, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_XDECREF_SET(__pyx_v_schema, __pyx_t_4);
+    __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":351
+ *             name = ti['name']
+ *             schema = ti['ns']
+ *             array_element_oid = ti['elemtype']             # <<<<<<<<<<<<<<
+ *             range_subtype_oid = ti['range_subtype']
+ *             if ti['attrtypoids']:
+ */
+    __pyx_t_4 = PyObject_GetItem(__pyx_v_ti, __pyx_n_u_elemtype); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 351, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_XDECREF_SET(__pyx_v_array_element_oid, __pyx_t_4);
+    __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":352
+ *             schema = ti['ns']
+ *             array_element_oid = ti['elemtype']
+ *             range_subtype_oid = ti['range_subtype']             # <<<<<<<<<<<<<<
+ *             if ti['attrtypoids']:
+ *                 comp_type_attrs = tuple(ti['attrtypoids'])
+ */
+    __pyx_t_4 = PyObject_GetItem(__pyx_v_ti, __pyx_n_u_range_subtype); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 352, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_XDECREF_SET(__pyx_v_range_subtype_oid, __pyx_t_4);
+    __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":353
+ *             array_element_oid = ti['elemtype']
+ *             range_subtype_oid = ti['range_subtype']
+ *             if ti['attrtypoids']:             # <<<<<<<<<<<<<<
+ *                 comp_type_attrs = tuple(ti['attrtypoids'])
+ *             else:
+ */
+    __pyx_t_4 = PyObject_GetItem(__pyx_v_ti, __pyx_n_u_attrtypoids); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 353, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(2, 353, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    if (__pyx_t_5) {
+
+      /* "asyncpg/protocol/codecs/base.pyx":354
+ *             range_subtype_oid = ti['range_subtype']
+ *             if ti['attrtypoids']:
+ *                 comp_type_attrs = tuple(ti['attrtypoids'])             # <<<<<<<<<<<<<<
+ *             else:
+ *                 comp_type_attrs = None
+ */
+      __pyx_t_4 = PyObject_GetItem(__pyx_v_ti, __pyx_n_u_attrtypoids); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 354, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_8 = PySequence_Tuple(__pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 354, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_8);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_XDECREF_SET(__pyx_v_comp_type_attrs, __pyx_t_8);
+      __pyx_t_8 = 0;
+
+      /* "asyncpg/protocol/codecs/base.pyx":353
+ *             array_element_oid = ti['elemtype']
+ *             range_subtype_oid = ti['range_subtype']
+ *             if ti['attrtypoids']:             # <<<<<<<<<<<<<<
+ *                 comp_type_attrs = tuple(ti['attrtypoids'])
+ *             else:
+ */
+      goto __pyx_L7;
+    }
+
+    /* "asyncpg/protocol/codecs/base.pyx":356
+ *                 comp_type_attrs = tuple(ti['attrtypoids'])
+ *             else:
+ *                 comp_type_attrs = None             # <<<<<<<<<<<<<<
+ *             base_type = ti['basetype']
+ * 
+ */
+    /*else*/ {
+      __Pyx_INCREF(Py_None);
+      __Pyx_XDECREF_SET(__pyx_v_comp_type_attrs, Py_None);
+    }
+    __pyx_L7:;
+
+    /* "asyncpg/protocol/codecs/base.pyx":357
+ *             else:
+ *                 comp_type_attrs = None
+ *             base_type = ti['basetype']             # <<<<<<<<<<<<<<
+ * 
+ *             if array_element_oid:
+ */
+    __pyx_t_8 = PyObject_GetItem(__pyx_v_ti, __pyx_n_u_basetype); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 357, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_8);
+    __Pyx_XDECREF_SET(__pyx_v_base_type, __pyx_t_8);
+    __pyx_t_8 = 0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":359
+ *             base_type = ti['basetype']
+ * 
+ *             if array_element_oid:             # <<<<<<<<<<<<<<
+ *                 # Array type (note, there is no separate 'kind' for arrays)
+ * 
+ */
+    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_array_element_oid); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(2, 359, __pyx_L1_error)
+    if (__pyx_t_5) {
+
+      /* "asyncpg/protocol/codecs/base.pyx":363
+ * 
+ *                 # Canonicalize type name to "elemtype[]"
+ *                 if name.startswith('_'):             # <<<<<<<<<<<<<<
+ *                     name = name[1:]
+ *                 name = '{}[]'.format(name)
+ */
+      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_name, __pyx_n_s_startswith); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 363, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_8);
+      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 363, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(2, 363, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      if (__pyx_t_5) {
+
+        /* "asyncpg/protocol/codecs/base.pyx":364
+ *                 # Canonicalize type name to "elemtype[]"
+ *                 if name.startswith('_'):
+ *                     name = name[1:]             # <<<<<<<<<<<<<<
+ *                 name = '{}[]'.format(name)
+ * 
+ */
+        __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_v_name, 1, 0, NULL, NULL, &__pyx_slice__27, 1, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 364, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF_SET(__pyx_v_name, __pyx_t_4);
+        __pyx_t_4 = 0;
+
+        /* "asyncpg/protocol/codecs/base.pyx":363
+ * 
+ *                 # Canonicalize type name to "elemtype[]"
+ *                 if name.startswith('_'):             # <<<<<<<<<<<<<<
+ *                     name = name[1:]
+ *                 name = '{}[]'.format(name)
+ */
+      }
+
+      /* "asyncpg/protocol/codecs/base.pyx":365
+ *                 if name.startswith('_'):
+ *                     name = name[1:]
+ *                 name = '{}[]'.format(name)             # <<<<<<<<<<<<<<
+ * 
+ *                 if ti['elem_has_bin_io']:
+ */
+      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u__28, __pyx_n_s_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 365, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_8);
+      __pyx_t_9 = NULL;
+      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
+        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
+        if (likely(__pyx_t_9)) {
+          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
+          __Pyx_INCREF(__pyx_t_9);
+          __Pyx_INCREF(function);
+          __Pyx_DECREF_SET(__pyx_t_8, function);
+        }
+      }
+      if (!__pyx_t_9) {
+        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 365, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+      } else {
+        #if CYTHON_FAST_PYCALL
+        if (PyFunction_Check(__pyx_t_8)) {
+          PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_name};
+          __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 365, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
+          __Pyx_GOTREF(__pyx_t_4);
+        } else
+        #endif
+        #if CYTHON_FAST_PYCCALL
+        if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
+          PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_name};
+          __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 365, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
+          __Pyx_GOTREF(__pyx_t_4);
+        } else
+        #endif
+        {
+          __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 365, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_10);
+          __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
+          __Pyx_INCREF(__pyx_v_name);
+          __Pyx_GIVEREF(__pyx_v_name);
+          PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_name);
+          __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 365, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_4);
+          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        }
+      }
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __Pyx_DECREF_SET(__pyx_v_name, __pyx_t_4);
+      __pyx_t_4 = 0;
+
+      /* "asyncpg/protocol/codecs/base.pyx":367
+ *                 name = '{}[]'.format(name)
+ * 
+ *                 if ti['elem_has_bin_io']:             # <<<<<<<<<<<<<<
+ *                     elem_format = PG_FORMAT_BINARY
+ *                 else:
+ */
+      __pyx_t_4 = PyObject_GetItem(__pyx_v_ti, __pyx_n_u_elem_has_bin_io); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 367, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(2, 367, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      if (__pyx_t_5) {
+
+        /* "asyncpg/protocol/codecs/base.pyx":368
+ * 
+ *                 if ti['elem_has_bin_io']:
+ *                     elem_format = PG_FORMAT_BINARY             # <<<<<<<<<<<<<<
+ *                 else:
+ *                     elem_format = PG_FORMAT_TEXT
+ */
+        __pyx_v_elem_format = __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY;
+
+        /* "asyncpg/protocol/codecs/base.pyx":367
+ *                 name = '{}[]'.format(name)
+ * 
+ *                 if ti['elem_has_bin_io']:             # <<<<<<<<<<<<<<
+ *                     elem_format = PG_FORMAT_BINARY
+ *                 else:
+ */
+        goto __pyx_L10;
+      }
+
+      /* "asyncpg/protocol/codecs/base.pyx":370
+ *                     elem_format = PG_FORMAT_BINARY
+ *                 else:
+ *                     elem_format = PG_FORMAT_TEXT             # <<<<<<<<<<<<<<
+ *                 elem_codec = self.get_codec(array_element_oid, elem_format)
+ *                 if elem_codec is None:
+ */
+      /*else*/ {
+        __pyx_v_elem_format = __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT;
+      }
+      __pyx_L10:;
+
+      /* "asyncpg/protocol/codecs/base.pyx":371
+ *                 else:
+ *                     elem_format = PG_FORMAT_TEXT
+ *                 elem_codec = self.get_codec(array_element_oid, elem_format)             # <<<<<<<<<<<<<<
+ *                 if elem_codec is None:
+ *                     raise RuntimeError(
+ */
+      __pyx_t_7 = __Pyx_PyInt_As_uint32_t(__pyx_v_array_element_oid); if (unlikely((__pyx_t_7 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(2, 371, __pyx_L1_error)
+      __pyx_t_4 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_15DataCodecConfig_get_codec(__pyx_v_self, __pyx_t_7, __pyx_v_elem_format)); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 371, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_XDECREF_SET(__pyx_v_elem_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_4));
+      __pyx_t_4 = 0;
+
+      /* "asyncpg/protocol/codecs/base.pyx":372
+ *                     elem_format = PG_FORMAT_TEXT
+ *                 elem_codec = self.get_codec(array_element_oid, elem_format)
+ *                 if elem_codec is None:             # <<<<<<<<<<<<<<
+ *                     raise RuntimeError(
+ *                         'no codec for array element type {}'.format(
+ */
+      __pyx_t_5 = (((PyObject *)__pyx_v_elem_codec) == Py_None);
+      __pyx_t_6 = (__pyx_t_5 != 0);
+      if (__pyx_t_6) {
+
+        /* "asyncpg/protocol/codecs/base.pyx":374
+ *                 if elem_codec is None:
+ *                     raise RuntimeError(
+ *                         'no codec for array element type {}'.format(             # <<<<<<<<<<<<<<
+ *                             array_element_oid))
+ * 
+ */
+        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_no_codec_for_array_element_type, __pyx_n_s_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 374, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_8);
+
+        /* "asyncpg/protocol/codecs/base.pyx":375
+ *                     raise RuntimeError(
+ *                         'no codec for array element type {}'.format(
+ *                             array_element_oid))             # <<<<<<<<<<<<<<
+ * 
+ *                 elem_delim = <Py_UCS4>ti['elemdelim'][0]
+ */
+        __pyx_t_10 = NULL;
+        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
+          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_8);
+          if (likely(__pyx_t_10)) {
+            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
+            __Pyx_INCREF(__pyx_t_10);
+            __Pyx_INCREF(function);
+            __Pyx_DECREF_SET(__pyx_t_8, function);
+          }
+        }
+        if (!__pyx_t_10) {
+          __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_array_element_oid); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 374, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_4);
+        } else {
+          #if CYTHON_FAST_PYCALL
+          if (PyFunction_Check(__pyx_t_8)) {
+            PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_array_element_oid};
+            __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 374, __pyx_L1_error)
+            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
+            __Pyx_GOTREF(__pyx_t_4);
+          } else
+          #endif
+          #if CYTHON_FAST_PYCCALL
+          if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
+            PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_array_element_oid};
+            __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 374, __pyx_L1_error)
+            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
+            __Pyx_GOTREF(__pyx_t_4);
+          } else
+          #endif
+          {
+            __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 374, __pyx_L1_error)
+            __Pyx_GOTREF(__pyx_t_9);
+            __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10); __pyx_t_10 = NULL;
+            __Pyx_INCREF(__pyx_v_array_element_oid);
+            __Pyx_GIVEREF(__pyx_v_array_element_oid);
+            PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_array_element_oid);
+            __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 374, __pyx_L1_error)
+            __Pyx_GOTREF(__pyx_t_4);
+            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+          }
+        }
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+
+        /* "asyncpg/protocol/codecs/base.pyx":373
+ *                 elem_codec = self.get_codec(array_element_oid, elem_format)
+ *                 if elem_codec is None:
+ *                     raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                         'no codec for array element type {}'.format(
+ *                             array_element_oid))
+ */
+        __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 373, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_8);
+        __Pyx_GIVEREF(__pyx_t_4);
+        PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4);
+        __pyx_t_4 = 0;
+        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 373, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __PYX_ERR(2, 373, __pyx_L1_error)
+
+        /* "asyncpg/protocol/codecs/base.pyx":372
+ *                     elem_format = PG_FORMAT_TEXT
+ *                 elem_codec = self.get_codec(array_element_oid, elem_format)
+ *                 if elem_codec is None:             # <<<<<<<<<<<<<<
+ *                     raise RuntimeError(
+ *                         'no codec for array element type {}'.format(
+ */
+      }
+
+      /* "asyncpg/protocol/codecs/base.pyx":377
+ *                             array_element_oid))
+ * 
+ *                 elem_delim = <Py_UCS4>ti['elemdelim'][0]             # <<<<<<<<<<<<<<
+ * 
+ *                 self._type_codecs_cache[oid, elem_format] = \
+ */
+      __pyx_t_4 = PyObject_GetItem(__pyx_v_ti, __pyx_n_u_elemdelim); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 377, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 377, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_8);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __pyx_t_11 = __Pyx_PyObject_AsPy_UCS4(__pyx_t_8); if (unlikely((__pyx_t_11 == (Py_UCS4)-1) && PyErr_Occurred())) __PYX_ERR(2, 377, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __pyx_v_elem_delim = ((Py_UCS4)__pyx_t_11);
+
+      /* "asyncpg/protocol/codecs/base.pyx":381
+ *                 self._type_codecs_cache[oid, elem_format] = \
+ *                     Codec.new_array_codec(
+ *                         oid, name, schema, elem_codec, elem_delim)             # <<<<<<<<<<<<<<
+ * 
+ *             elif ti['kind'] == b'c':
+ */
+      __pyx_t_7 = __Pyx_PyInt_As_uint32_t(__pyx_v_oid); if (unlikely((__pyx_t_7 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(2, 381, __pyx_L1_error)
+      if (!(likely(PyUnicode_CheckExact(__pyx_v_name))||((__pyx_v_name) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_v_name)->tp_name), 0))) __PYX_ERR(2, 381, __pyx_L1_error)
+      if (!(likely(PyUnicode_CheckExact(__pyx_v_schema))||((__pyx_v_schema) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_v_schema)->tp_name), 0))) __PYX_ERR(2, 381, __pyx_L1_error)
+
+      /* "asyncpg/protocol/codecs/base.pyx":380
+ * 
+ *                 self._type_codecs_cache[oid, elem_format] = \
+ *                     Codec.new_array_codec(             # <<<<<<<<<<<<<<
+ *                         oid, name, schema, elem_codec, elem_delim)
+ * 
+ */
+      __pyx_t_8 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_5Codec_new_array_codec(__pyx_t_7, ((PyObject*)__pyx_v_name), ((PyObject*)__pyx_v_schema), __pyx_v_elem_codec, __pyx_v_elem_delim)); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 380, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_8);
+
+      /* "asyncpg/protocol/codecs/base.pyx":379
+ *                 elem_delim = <Py_UCS4>ti['elemdelim'][0]
+ * 
+ *                 self._type_codecs_cache[oid, elem_format] = \             # <<<<<<<<<<<<<<
+ *                     Codec.new_array_codec(
+ *                         oid, name, schema, elem_codec, elem_delim)
+ */
+      if (unlikely(__pyx_v_self->_type_codecs_cache == Py_None)) {
+        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+        __PYX_ERR(2, 379, __pyx_L1_error)
+      }
+      __pyx_t_4 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_CodecFormat(__pyx_v_elem_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 379, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 379, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_INCREF(__pyx_v_oid);
+      __Pyx_GIVEREF(__pyx_v_oid);
+      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_oid);
+      __Pyx_GIVEREF(__pyx_t_4);
+      PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_4);
+      __pyx_t_4 = 0;
+      if (unlikely(PyDict_SetItem(__pyx_v_self->_type_codecs_cache, __pyx_t_9, __pyx_t_8) < 0)) __PYX_ERR(2, 379, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+
+      /* "asyncpg/protocol/codecs/base.pyx":359
+ *             base_type = ti['basetype']
+ * 
+ *             if array_element_oid:             # <<<<<<<<<<<<<<
+ *                 # Array type (note, there is no separate 'kind' for arrays)
+ * 
+ */
+      goto __pyx_L8;
+    }
+
+    /* "asyncpg/protocol/codecs/base.pyx":383
+ *                         oid, name, schema, elem_codec, elem_delim)
+ * 
+ *             elif ti['kind'] == b'c':             # <<<<<<<<<<<<<<
+ *                 if not comp_type_attrs:
+ *                     raise RuntimeError(
+ */
+    __pyx_t_8 = PyObject_GetItem(__pyx_v_ti, __pyx_n_u_kind); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 383, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_8);
+    __pyx_t_6 = (__Pyx_PyBytes_Equals(__pyx_t_8, __pyx_n_b_c, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 383, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+    if (__pyx_t_6) {
+
+      /* "asyncpg/protocol/codecs/base.pyx":384
+ * 
+ *             elif ti['kind'] == b'c':
+ *                 if not comp_type_attrs:             # <<<<<<<<<<<<<<
+ *                     raise RuntimeError(
+ *                         'type record missing field types for '
+ */
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_comp_type_attrs); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 384, __pyx_L1_error)
+      __pyx_t_5 = ((!__pyx_t_6) != 0);
+      if (__pyx_t_5) {
+
+        /* "asyncpg/protocol/codecs/base.pyx":387
+ *                     raise RuntimeError(
+ *                         'type record missing field types for '
+ *                         'composite {}'.format(oid))             # <<<<<<<<<<<<<<
+ * 
+ *                 # Composite type
+ */
+        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_type_record_missing_field_types, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 387, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_9);
+        __pyx_t_4 = NULL;
+        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
+          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_9);
+          if (likely(__pyx_t_4)) {
+            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
+            __Pyx_INCREF(__pyx_t_4);
+            __Pyx_INCREF(function);
+            __Pyx_DECREF_SET(__pyx_t_9, function);
+          }
+        }
+        if (!__pyx_t_4) {
+          __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_oid); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 387, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_8);
+        } else {
+          #if CYTHON_FAST_PYCALL
+          if (PyFunction_Check(__pyx_t_9)) {
+            PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_oid};
+            __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 387, __pyx_L1_error)
+            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+            __Pyx_GOTREF(__pyx_t_8);
+          } else
+          #endif
+          #if CYTHON_FAST_PYCCALL
+          if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
+            PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_oid};
+            __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 387, __pyx_L1_error)
+            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+            __Pyx_GOTREF(__pyx_t_8);
+          } else
+          #endif
+          {
+            __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 387, __pyx_L1_error)
+            __Pyx_GOTREF(__pyx_t_10);
+            __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_4); __pyx_t_4 = NULL;
+            __Pyx_INCREF(__pyx_v_oid);
+            __Pyx_GIVEREF(__pyx_v_oid);
+            PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_oid);
+            __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 387, __pyx_L1_error)
+            __Pyx_GOTREF(__pyx_t_8);
+            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+          }
+        }
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+
+        /* "asyncpg/protocol/codecs/base.pyx":385
+ *             elif ti['kind'] == b'c':
+ *                 if not comp_type_attrs:
+ *                     raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                         'type record missing field types for '
+ *                         'composite {}'.format(oid))
+ */
+        __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 385, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_9);
+        __Pyx_GIVEREF(__pyx_t_8);
+        PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8);
+        __pyx_t_8 = 0;
+        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_9, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 385, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_8);
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_Raise(__pyx_t_8, 0, 0, 0);
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        __PYX_ERR(2, 385, __pyx_L1_error)
+
+        /* "asyncpg/protocol/codecs/base.pyx":384
+ * 
+ *             elif ti['kind'] == b'c':
+ *                 if not comp_type_attrs:             # <<<<<<<<<<<<<<
+ *                     raise RuntimeError(
+ *                         'type record missing field types for '
+ */
+      }
+
+      /* "asyncpg/protocol/codecs/base.pyx":391
+ *                 # Composite type
+ * 
+ *                 comp_elem_codecs = []             # <<<<<<<<<<<<<<
+ * 
+ *                 for typoid in comp_type_attrs:
+ */
+      __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 391, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_8);
+      __Pyx_XDECREF_SET(__pyx_v_comp_elem_codecs, ((PyObject*)__pyx_t_8));
+      __pyx_t_8 = 0;
+
+      /* "asyncpg/protocol/codecs/base.pyx":393
+ *                 comp_elem_codecs = []
+ * 
+ *                 for typoid in comp_type_attrs:             # <<<<<<<<<<<<<<
+ *                     elem_codec = self.get_codec(typoid, PG_FORMAT_BINARY)
+ *                     if elem_codec is None:
+ */
+      if (likely(PyList_CheckExact(__pyx_v_comp_type_attrs)) || PyTuple_CheckExact(__pyx_v_comp_type_attrs)) {
+        __pyx_t_8 = __pyx_v_comp_type_attrs; __Pyx_INCREF(__pyx_t_8); __pyx_t_12 = 0;
+        __pyx_t_13 = NULL;
+      } else {
+        __pyx_t_12 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_v_comp_type_attrs); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 393, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_8);
+        __pyx_t_13 = Py_TYPE(__pyx_t_8)->tp_iternext; if (unlikely(!__pyx_t_13)) __PYX_ERR(2, 393, __pyx_L1_error)
+      }
+      for (;;) {
+        if (likely(!__pyx_t_13)) {
+          if (likely(PyList_CheckExact(__pyx_t_8))) {
+            if (__pyx_t_12 >= PyList_GET_SIZE(__pyx_t_8)) break;
+            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+            __pyx_t_9 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_12); __Pyx_INCREF(__pyx_t_9); __pyx_t_12++; if (unlikely(0 < 0)) __PYX_ERR(2, 393, __pyx_L1_error)
+            #else
+            __pyx_t_9 = PySequence_ITEM(__pyx_t_8, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 393, __pyx_L1_error)
+            __Pyx_GOTREF(__pyx_t_9);
+            #endif
+          } else {
+            if (__pyx_t_12 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
+            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+            __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_12); __Pyx_INCREF(__pyx_t_9); __pyx_t_12++; if (unlikely(0 < 0)) __PYX_ERR(2, 393, __pyx_L1_error)
+            #else
+            __pyx_t_9 = PySequence_ITEM(__pyx_t_8, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 393, __pyx_L1_error)
+            __Pyx_GOTREF(__pyx_t_9);
+            #endif
+          }
+        } else {
+          __pyx_t_9 = __pyx_t_13(__pyx_t_8);
+          if (unlikely(!__pyx_t_9)) {
+            PyObject* exc_type = PyErr_Occurred();
+            if (exc_type) {
+              if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+              else __PYX_ERR(2, 393, __pyx_L1_error)
+            }
+            break;
+          }
+          __Pyx_GOTREF(__pyx_t_9);
+        }
+        __Pyx_XDECREF_SET(__pyx_v_typoid, __pyx_t_9);
+        __pyx_t_9 = 0;
+
+        /* "asyncpg/protocol/codecs/base.pyx":394
+ * 
+ *                 for typoid in comp_type_attrs:
+ *                     elem_codec = self.get_codec(typoid, PG_FORMAT_BINARY)             # <<<<<<<<<<<<<<
+ *                     if elem_codec is None:
+ *                         elem_codec = self.get_codec(typoid, PG_FORMAT_TEXT)
+ */
+        __pyx_t_7 = __Pyx_PyInt_As_uint32_t(__pyx_v_typoid); if (unlikely((__pyx_t_7 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(2, 394, __pyx_L1_error)
+        __pyx_t_9 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_15DataCodecConfig_get_codec(__pyx_v_self, __pyx_t_7, __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY)); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 394, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_9);
+        __Pyx_XDECREF_SET(__pyx_v_elem_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_9));
+        __pyx_t_9 = 0;
+
+        /* "asyncpg/protocol/codecs/base.pyx":395
+ *                 for typoid in comp_type_attrs:
+ *                     elem_codec = self.get_codec(typoid, PG_FORMAT_BINARY)
+ *                     if elem_codec is None:             # <<<<<<<<<<<<<<
+ *                         elem_codec = self.get_codec(typoid, PG_FORMAT_TEXT)
+ *                         has_text_elements = True
+ */
+        __pyx_t_5 = (((PyObject *)__pyx_v_elem_codec) == Py_None);
+        __pyx_t_6 = (__pyx_t_5 != 0);
+        if (__pyx_t_6) {
+
+          /* "asyncpg/protocol/codecs/base.pyx":396
+ *                     elem_codec = self.get_codec(typoid, PG_FORMAT_BINARY)
+ *                     if elem_codec is None:
+ *                         elem_codec = self.get_codec(typoid, PG_FORMAT_TEXT)             # <<<<<<<<<<<<<<
+ *                         has_text_elements = True
+ *                     if elem_codec is None:
+ */
+          __pyx_t_7 = __Pyx_PyInt_As_uint32_t(__pyx_v_typoid); if (unlikely((__pyx_t_7 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(2, 396, __pyx_L1_error)
+          __pyx_t_9 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_15DataCodecConfig_get_codec(__pyx_v_self, __pyx_t_7, __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT)); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 396, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_9);
+          __Pyx_DECREF_SET(__pyx_v_elem_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_9));
+          __pyx_t_9 = 0;
+
+          /* "asyncpg/protocol/codecs/base.pyx":397
+ *                     if elem_codec is None:
+ *                         elem_codec = self.get_codec(typoid, PG_FORMAT_TEXT)
+ *                         has_text_elements = True             # <<<<<<<<<<<<<<
+ *                     if elem_codec is None:
+ *                         raise RuntimeError(
+ */
+          __pyx_v_has_text_elements = 1;
+
+          /* "asyncpg/protocol/codecs/base.pyx":395
+ *                 for typoid in comp_type_attrs:
+ *                     elem_codec = self.get_codec(typoid, PG_FORMAT_BINARY)
+ *                     if elem_codec is None:             # <<<<<<<<<<<<<<
+ *                         elem_codec = self.get_codec(typoid, PG_FORMAT_TEXT)
+ *                         has_text_elements = True
+ */
+        }
+
+        /* "asyncpg/protocol/codecs/base.pyx":398
+ *                         elem_codec = self.get_codec(typoid, PG_FORMAT_TEXT)
+ *                         has_text_elements = True
+ *                     if elem_codec is None:             # <<<<<<<<<<<<<<
+ *                         raise RuntimeError(
+ *                             'no codec for composite attribute type {}'.format(
+ */
+        __pyx_t_6 = (((PyObject *)__pyx_v_elem_codec) == Py_None);
+        __pyx_t_5 = (__pyx_t_6 != 0);
+        if (__pyx_t_5) {
+
+          /* "asyncpg/protocol/codecs/base.pyx":400
+ *                     if elem_codec is None:
+ *                         raise RuntimeError(
+ *                             'no codec for composite attribute type {}'.format(             # <<<<<<<<<<<<<<
+ *                                 typoid))
+ *                     comp_elem_codecs.append(elem_codec)
+ */
+          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_no_codec_for_composite_attribute, __pyx_n_s_format); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 400, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_10);
+
+          /* "asyncpg/protocol/codecs/base.pyx":401
+ *                         raise RuntimeError(
+ *                             'no codec for composite attribute type {}'.format(
+ *                                 typoid))             # <<<<<<<<<<<<<<
+ *                     comp_elem_codecs.append(elem_codec)
+ * 
+ */
+          __pyx_t_4 = NULL;
+          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
+            __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10);
+            if (likely(__pyx_t_4)) {
+              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
+              __Pyx_INCREF(__pyx_t_4);
+              __Pyx_INCREF(function);
+              __Pyx_DECREF_SET(__pyx_t_10, function);
+            }
+          }
+          if (!__pyx_t_4) {
+            __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_typoid); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 400, __pyx_L1_error)
+            __Pyx_GOTREF(__pyx_t_9);
+          } else {
+            #if CYTHON_FAST_PYCALL
+            if (PyFunction_Check(__pyx_t_10)) {
+              PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_typoid};
+              __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 400, __pyx_L1_error)
+              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+              __Pyx_GOTREF(__pyx_t_9);
+            } else
+            #endif
+            #if CYTHON_FAST_PYCCALL
+            if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
+              PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_typoid};
+              __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 400, __pyx_L1_error)
+              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+              __Pyx_GOTREF(__pyx_t_9);
+            } else
+            #endif
+            {
+              __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(2, 400, __pyx_L1_error)
+              __Pyx_GOTREF(__pyx_t_14);
+              __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_4); __pyx_t_4 = NULL;
+              __Pyx_INCREF(__pyx_v_typoid);
+              __Pyx_GIVEREF(__pyx_v_typoid);
+              PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_v_typoid);
+              __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_14, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 400, __pyx_L1_error)
+              __Pyx_GOTREF(__pyx_t_9);
+              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+            }
+          }
+          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+
+          /* "asyncpg/protocol/codecs/base.pyx":399
+ *                         has_text_elements = True
+ *                     if elem_codec is None:
+ *                         raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                             'no codec for composite attribute type {}'.format(
+ *                                 typoid))
+ */
+          __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 399, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_10);
+          __Pyx_GIVEREF(__pyx_t_9);
+          PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9);
+          __pyx_t_9 = 0;
+          __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 399, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_9);
+          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+          __Pyx_Raise(__pyx_t_9, 0, 0, 0);
+          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+          __PYX_ERR(2, 399, __pyx_L1_error)
+
+          /* "asyncpg/protocol/codecs/base.pyx":398
+ *                         elem_codec = self.get_codec(typoid, PG_FORMAT_TEXT)
+ *                         has_text_elements = True
+ *                     if elem_codec is None:             # <<<<<<<<<<<<<<
+ *                         raise RuntimeError(
+ *                             'no codec for composite attribute type {}'.format(
+ */
+        }
+
+        /* "asyncpg/protocol/codecs/base.pyx":402
+ *                             'no codec for composite attribute type {}'.format(
+ *                                 typoid))
+ *                     comp_elem_codecs.append(elem_codec)             # <<<<<<<<<<<<<<
+ * 
+ *                 element_names = collections.OrderedDict()
+ */
+        __pyx_t_15 = __Pyx_PyList_Append(__pyx_v_comp_elem_codecs, ((PyObject *)__pyx_v_elem_codec)); if (unlikely(__pyx_t_15 == -1)) __PYX_ERR(2, 402, __pyx_L1_error)
+
+        /* "asyncpg/protocol/codecs/base.pyx":393
+ *                 comp_elem_codecs = []
+ * 
+ *                 for typoid in comp_type_attrs:             # <<<<<<<<<<<<<<
+ *                     elem_codec = self.get_codec(typoid, PG_FORMAT_BINARY)
+ *                     if elem_codec is None:
+ */
+      }
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+
+      /* "asyncpg/protocol/codecs/base.pyx":404
+ *                     comp_elem_codecs.append(elem_codec)
+ * 
+ *                 element_names = collections.OrderedDict()             # <<<<<<<<<<<<<<
+ *                 for i, attrname in enumerate(ti['attrnames']):
+ *                     element_names[attrname] = i
+ */
+      __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_collections); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 404, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_9);
+      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_OrderedDict); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 404, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_10);
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __pyx_t_9 = NULL;
+      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
+        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_10);
+        if (likely(__pyx_t_9)) {
+          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
+          __Pyx_INCREF(__pyx_t_9);
+          __Pyx_INCREF(function);
+          __Pyx_DECREF_SET(__pyx_t_10, function);
+        }
+      }
+      if (__pyx_t_9) {
+        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 404, __pyx_L1_error)
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      } else {
+        __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 404, __pyx_L1_error)
+      }
+      __Pyx_GOTREF(__pyx_t_8);
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      __Pyx_XDECREF_SET(__pyx_v_element_names, __pyx_t_8);
+      __pyx_t_8 = 0;
+
+      /* "asyncpg/protocol/codecs/base.pyx":405
+ * 
+ *                 element_names = collections.OrderedDict()
+ *                 for i, attrname in enumerate(ti['attrnames']):             # <<<<<<<<<<<<<<
+ *                     element_names[attrname] = i
+ * 
+ */
+      __Pyx_INCREF(__pyx_int_0);
+      __pyx_t_8 = __pyx_int_0;
+      __pyx_t_10 = PyObject_GetItem(__pyx_v_ti, __pyx_n_u_attrnames); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 405, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_10);
+      if (likely(PyList_CheckExact(__pyx_t_10)) || PyTuple_CheckExact(__pyx_t_10)) {
+        __pyx_t_9 = __pyx_t_10; __Pyx_INCREF(__pyx_t_9); __pyx_t_12 = 0;
+        __pyx_t_13 = NULL;
+      } else {
+        __pyx_t_12 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 405, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_9);
+        __pyx_t_13 = Py_TYPE(__pyx_t_9)->tp_iternext; if (unlikely(!__pyx_t_13)) __PYX_ERR(2, 405, __pyx_L1_error)
+      }
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      for (;;) {
+        if (likely(!__pyx_t_13)) {
+          if (likely(PyList_CheckExact(__pyx_t_9))) {
+            if (__pyx_t_12 >= PyList_GET_SIZE(__pyx_t_9)) break;
+            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+            __pyx_t_10 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_12); __Pyx_INCREF(__pyx_t_10); __pyx_t_12++; if (unlikely(0 < 0)) __PYX_ERR(2, 405, __pyx_L1_error)
+            #else
+            __pyx_t_10 = PySequence_ITEM(__pyx_t_9, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 405, __pyx_L1_error)
+            __Pyx_GOTREF(__pyx_t_10);
+            #endif
+          } else {
+            if (__pyx_t_12 >= PyTuple_GET_SIZE(__pyx_t_9)) break;
+            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+            __pyx_t_10 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_12); __Pyx_INCREF(__pyx_t_10); __pyx_t_12++; if (unlikely(0 < 0)) __PYX_ERR(2, 405, __pyx_L1_error)
+            #else
+            __pyx_t_10 = PySequence_ITEM(__pyx_t_9, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 405, __pyx_L1_error)
+            __Pyx_GOTREF(__pyx_t_10);
+            #endif
+          }
+        } else {
+          __pyx_t_10 = __pyx_t_13(__pyx_t_9);
+          if (unlikely(!__pyx_t_10)) {
+            PyObject* exc_type = PyErr_Occurred();
+            if (exc_type) {
+              if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+              else __PYX_ERR(2, 405, __pyx_L1_error)
+            }
+            break;
+          }
+          __Pyx_GOTREF(__pyx_t_10);
+        }
+        __Pyx_XDECREF_SET(__pyx_v_attrname, __pyx_t_10);
+        __pyx_t_10 = 0;
+        __Pyx_INCREF(__pyx_t_8);
+        __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_8);
+        __pyx_t_10 = __Pyx_PyInt_AddObjC(__pyx_t_8, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 405, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_10);
+        __Pyx_DECREF(__pyx_t_8);
+        __pyx_t_8 = __pyx_t_10;
+        __pyx_t_10 = 0;
+
+        /* "asyncpg/protocol/codecs/base.pyx":406
+ *                 element_names = collections.OrderedDict()
+ *                 for i, attrname in enumerate(ti['attrnames']):
+ *                     element_names[attrname] = i             # <<<<<<<<<<<<<<
+ * 
+ *                 if has_text_elements:
+ */
+        if (unlikely(PyObject_SetItem(__pyx_v_element_names, __pyx_v_attrname, __pyx_v_i) < 0)) __PYX_ERR(2, 406, __pyx_L1_error)
+
+        /* "asyncpg/protocol/codecs/base.pyx":405
+ * 
+ *                 element_names = collections.OrderedDict()
+ *                 for i, attrname in enumerate(ti['attrnames']):             # <<<<<<<<<<<<<<
+ *                     element_names[attrname] = i
+ * 
+ */
+      }
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+
+      /* "asyncpg/protocol/codecs/base.pyx":408
+ *                     element_names[attrname] = i
+ * 
+ *                 if has_text_elements:             # <<<<<<<<<<<<<<
+ *                     format = PG_FORMAT_TEXT
+ * 
+ */
+      __pyx_t_5 = (__pyx_v_has_text_elements != 0);
+      if (__pyx_t_5) {
+
+        /* "asyncpg/protocol/codecs/base.pyx":409
+ * 
+ *                 if has_text_elements:
+ *                     format = PG_FORMAT_TEXT             # <<<<<<<<<<<<<<
+ * 
+ *                 self._type_codecs_cache[oid, format] = \
+ */
+        __pyx_v_format = __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT;
+
+        /* "asyncpg/protocol/codecs/base.pyx":408
+ *                     element_names[attrname] = i
+ * 
+ *                 if has_text_elements:             # <<<<<<<<<<<<<<
+ *                     format = PG_FORMAT_TEXT
+ * 
+ */
+      }
+
+      /* "asyncpg/protocol/codecs/base.pyx":413
+ *                 self._type_codecs_cache[oid, format] = \
+ *                     Codec.new_composite_codec(
+ *                         oid, name, schema, comp_elem_codecs,             # <<<<<<<<<<<<<<
+ *                         comp_type_attrs,
+ *                         element_names)
+ */
+      __pyx_t_7 = __Pyx_PyInt_As_uint32_t(__pyx_v_oid); if (unlikely((__pyx_t_7 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(2, 413, __pyx_L1_error)
+      if (!(likely(PyUnicode_CheckExact(__pyx_v_name))||((__pyx_v_name) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_v_name)->tp_name), 0))) __PYX_ERR(2, 413, __pyx_L1_error)
+      if (!(likely(PyUnicode_CheckExact(__pyx_v_schema))||((__pyx_v_schema) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_v_schema)->tp_name), 0))) __PYX_ERR(2, 413, __pyx_L1_error)
+
+      /* "asyncpg/protocol/codecs/base.pyx":414
+ *                     Codec.new_composite_codec(
+ *                         oid, name, schema, comp_elem_codecs,
+ *                         comp_type_attrs,             # <<<<<<<<<<<<<<
+ *                         element_names)
+ * 
+ */
+      if (!(likely(PyTuple_CheckExact(__pyx_v_comp_type_attrs))||((__pyx_v_comp_type_attrs) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_comp_type_attrs)->tp_name), 0))) __PYX_ERR(2, 414, __pyx_L1_error)
+
+      /* "asyncpg/protocol/codecs/base.pyx":412
+ * 
+ *                 self._type_codecs_cache[oid, format] = \
+ *                     Codec.new_composite_codec(             # <<<<<<<<<<<<<<
+ *                         oid, name, schema, comp_elem_codecs,
+ *                         comp_type_attrs,
+ */
+      __pyx_t_8 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_5Codec_new_composite_codec(__pyx_t_7, ((PyObject*)__pyx_v_name), ((PyObject*)__pyx_v_schema), __pyx_v_comp_elem_codecs, ((PyObject*)__pyx_v_comp_type_attrs), __pyx_v_element_names)); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 412, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_8);
+
+      /* "asyncpg/protocol/codecs/base.pyx":411
+ *                     format = PG_FORMAT_TEXT
+ * 
+ *                 self._type_codecs_cache[oid, format] = \             # <<<<<<<<<<<<<<
+ *                     Codec.new_composite_codec(
+ *                         oid, name, schema, comp_elem_codecs,
+ */
+      if (unlikely(__pyx_v_self->_type_codecs_cache == Py_None)) {
+        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+        __PYX_ERR(2, 411, __pyx_L1_error)
+      }
+      __pyx_t_9 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_CodecFormat(__pyx_v_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 411, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_9);
+      __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 411, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_10);
+      __Pyx_INCREF(__pyx_v_oid);
+      __Pyx_GIVEREF(__pyx_v_oid);
+      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_oid);
+      __Pyx_GIVEREF(__pyx_t_9);
+      PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_9);
+      __pyx_t_9 = 0;
+      if (unlikely(PyDict_SetItem(__pyx_v_self->_type_codecs_cache, __pyx_t_10, __pyx_t_8) < 0)) __PYX_ERR(2, 411, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+
+      /* "asyncpg/protocol/codecs/base.pyx":383
+ *                         oid, name, schema, elem_codec, elem_delim)
+ * 
+ *             elif ti['kind'] == b'c':             # <<<<<<<<<<<<<<
+ *                 if not comp_type_attrs:
+ *                     raise RuntimeError(
+ */
+      goto __pyx_L8;
+    }
+
+    /* "asyncpg/protocol/codecs/base.pyx":417
+ *                         element_names)
+ * 
+ *             elif ti['kind'] == b'd':             # <<<<<<<<<<<<<<
+ *                 # Domain type
+ * 
+ */
+    __pyx_t_8 = PyObject_GetItem(__pyx_v_ti, __pyx_n_u_kind); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 417, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_8);
+    __pyx_t_5 = (__Pyx_PyBytes_Equals(__pyx_t_8, __pyx_n_b_d, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(2, 417, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+    if (__pyx_t_5) {
+
+      /* "asyncpg/protocol/codecs/base.pyx":420
+ *                 # Domain type
+ * 
+ *                 if not base_type:             # <<<<<<<<<<<<<<
+ *                     raise RuntimeError(
+ *                         'type record missing base type for domain {}'.format(
+ */
+      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_base_type); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(2, 420, __pyx_L1_error)
+      __pyx_t_6 = ((!__pyx_t_5) != 0);
+      if (__pyx_t_6) {
+
+        /* "asyncpg/protocol/codecs/base.pyx":422
+ *                 if not base_type:
+ *                     raise RuntimeError(
+ *                         'type record missing base type for domain {}'.format(             # <<<<<<<<<<<<<<
+ *                             oid))
+ * 
+ */
+        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_type_record_missing_base_type_fo, __pyx_n_s_format); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 422, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_10);
+
+        /* "asyncpg/protocol/codecs/base.pyx":423
+ *                     raise RuntimeError(
+ *                         'type record missing base type for domain {}'.format(
+ *                             oid))             # <<<<<<<<<<<<<<
+ * 
+ *                 elem_codec = self.get_codec(base_type, format)
+ */
+        __pyx_t_9 = NULL;
+        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
+          __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_10);
+          if (likely(__pyx_t_9)) {
+            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
+            __Pyx_INCREF(__pyx_t_9);
+            __Pyx_INCREF(function);
+            __Pyx_DECREF_SET(__pyx_t_10, function);
+          }
+        }
+        if (!__pyx_t_9) {
+          __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_oid); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 422, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_8);
+        } else {
+          #if CYTHON_FAST_PYCALL
+          if (PyFunction_Check(__pyx_t_10)) {
+            PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_oid};
+            __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 422, __pyx_L1_error)
+            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
+            __Pyx_GOTREF(__pyx_t_8);
+          } else
+          #endif
+          #if CYTHON_FAST_PYCCALL
+          if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
+            PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_oid};
+            __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 422, __pyx_L1_error)
+            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
+            __Pyx_GOTREF(__pyx_t_8);
+          } else
+          #endif
+          {
+            __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(2, 422, __pyx_L1_error)
+            __Pyx_GOTREF(__pyx_t_14);
+            __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_9); __pyx_t_9 = NULL;
+            __Pyx_INCREF(__pyx_v_oid);
+            __Pyx_GIVEREF(__pyx_v_oid);
+            PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_v_oid);
+            __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_14, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 422, __pyx_L1_error)
+            __Pyx_GOTREF(__pyx_t_8);
+            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+          }
+        }
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+
+        /* "asyncpg/protocol/codecs/base.pyx":421
+ * 
+ *                 if not base_type:
+ *                     raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                         'type record missing base type for domain {}'.format(
+ *                             oid))
+ */
+        __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 421, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_10);
+        __Pyx_GIVEREF(__pyx_t_8);
+        PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8);
+        __pyx_t_8 = 0;
+        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_10, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 421, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_8);
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        __Pyx_Raise(__pyx_t_8, 0, 0, 0);
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        __PYX_ERR(2, 421, __pyx_L1_error)
+
+        /* "asyncpg/protocol/codecs/base.pyx":420
+ *                 # Domain type
+ * 
+ *                 if not base_type:             # <<<<<<<<<<<<<<
+ *                     raise RuntimeError(
+ *                         'type record missing base type for domain {}'.format(
+ */
+      }
+
+      /* "asyncpg/protocol/codecs/base.pyx":425
+ *                             oid))
+ * 
+ *                 elem_codec = self.get_codec(base_type, format)             # <<<<<<<<<<<<<<
+ *                 if elem_codec is None:
+ *                     raise RuntimeError(
+ */
+      __pyx_t_7 = __Pyx_PyInt_As_uint32_t(__pyx_v_base_type); if (unlikely((__pyx_t_7 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(2, 425, __pyx_L1_error)
+      __pyx_t_8 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_15DataCodecConfig_get_codec(__pyx_v_self, __pyx_t_7, __pyx_v_format)); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 425, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_8);
+      __Pyx_XDECREF_SET(__pyx_v_elem_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_8));
+      __pyx_t_8 = 0;
+
+      /* "asyncpg/protocol/codecs/base.pyx":426
+ * 
+ *                 elem_codec = self.get_codec(base_type, format)
+ *                 if elem_codec is None:             # <<<<<<<<<<<<<<
+ *                     raise RuntimeError(
+ *                         'no codec for domain base type {}'.format(base_type))
+ */
+      __pyx_t_6 = (((PyObject *)__pyx_v_elem_codec) == Py_None);
+      __pyx_t_5 = (__pyx_t_6 != 0);
+      if (__pyx_t_5) {
+
+        /* "asyncpg/protocol/codecs/base.pyx":428
+ *                 if elem_codec is None:
+ *                     raise RuntimeError(
+ *                         'no codec for domain base type {}'.format(base_type))             # <<<<<<<<<<<<<<
+ * 
+ *                 self._type_codecs_cache[oid, format] = elem_codec
+ */
+        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_no_codec_for_domain_base_type, __pyx_n_s_format); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 428, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_10);
+        __pyx_t_14 = NULL;
+        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
+          __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_10);
+          if (likely(__pyx_t_14)) {
+            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
+            __Pyx_INCREF(__pyx_t_14);
+            __Pyx_INCREF(function);
+            __Pyx_DECREF_SET(__pyx_t_10, function);
+          }
+        }
+        if (!__pyx_t_14) {
+          __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_base_type); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 428, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_8);
+        } else {
+          #if CYTHON_FAST_PYCALL
+          if (PyFunction_Check(__pyx_t_10)) {
+            PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_v_base_type};
+            __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 428, __pyx_L1_error)
+            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
+            __Pyx_GOTREF(__pyx_t_8);
+          } else
+          #endif
+          #if CYTHON_FAST_PYCCALL
+          if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
+            PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_v_base_type};
+            __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 428, __pyx_L1_error)
+            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
+            __Pyx_GOTREF(__pyx_t_8);
+          } else
+          #endif
+          {
+            __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 428, __pyx_L1_error)
+            __Pyx_GOTREF(__pyx_t_9);
+            __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_14); __pyx_t_14 = NULL;
+            __Pyx_INCREF(__pyx_v_base_type);
+            __Pyx_GIVEREF(__pyx_v_base_type);
+            PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_base_type);
+            __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_9, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 428, __pyx_L1_error)
+            __Pyx_GOTREF(__pyx_t_8);
+            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+          }
+        }
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+
+        /* "asyncpg/protocol/codecs/base.pyx":427
+ *                 elem_codec = self.get_codec(base_type, format)
+ *                 if elem_codec is None:
+ *                     raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                         'no codec for domain base type {}'.format(base_type))
+ * 
+ */
+        __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 427, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_10);
+        __Pyx_GIVEREF(__pyx_t_8);
+        PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8);
+        __pyx_t_8 = 0;
+        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_10, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 427, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_8);
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        __Pyx_Raise(__pyx_t_8, 0, 0, 0);
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        __PYX_ERR(2, 427, __pyx_L1_error)
+
+        /* "asyncpg/protocol/codecs/base.pyx":426
+ * 
+ *                 elem_codec = self.get_codec(base_type, format)
+ *                 if elem_codec is None:             # <<<<<<<<<<<<<<
+ *                     raise RuntimeError(
+ *                         'no codec for domain base type {}'.format(base_type))
+ */
+      }
+
+      /* "asyncpg/protocol/codecs/base.pyx":430
+ *                         'no codec for domain base type {}'.format(base_type))
+ * 
+ *                 self._type_codecs_cache[oid, format] = elem_codec             # <<<<<<<<<<<<<<
+ * 
+ *             elif ti['kind'] == b'r':
+ */
+      if (unlikely(__pyx_v_self->_type_codecs_cache == Py_None)) {
+        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+        __PYX_ERR(2, 430, __pyx_L1_error)
+      }
+      __pyx_t_8 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_CodecFormat(__pyx_v_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 430, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_8);
+      __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 430, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_10);
+      __Pyx_INCREF(__pyx_v_oid);
+      __Pyx_GIVEREF(__pyx_v_oid);
+      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_oid);
+      __Pyx_GIVEREF(__pyx_t_8);
+      PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_8);
+      __pyx_t_8 = 0;
+      if (unlikely(PyDict_SetItem(__pyx_v_self->_type_codecs_cache, __pyx_t_10, ((PyObject *)__pyx_v_elem_codec)) < 0)) __PYX_ERR(2, 430, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+
+      /* "asyncpg/protocol/codecs/base.pyx":417
+ *                         element_names)
+ * 
+ *             elif ti['kind'] == b'd':             # <<<<<<<<<<<<<<
+ *                 # Domain type
+ * 
+ */
+      goto __pyx_L8;
+    }
+
+    /* "asyncpg/protocol/codecs/base.pyx":432
+ *                 self._type_codecs_cache[oid, format] = elem_codec
+ * 
+ *             elif ti['kind'] == b'r':             # <<<<<<<<<<<<<<
+ *                 # Range type
+ * 
+ */
+    __pyx_t_10 = PyObject_GetItem(__pyx_v_ti, __pyx_n_u_kind); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 432, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_10);
+    __pyx_t_5 = (__Pyx_PyBytes_Equals(__pyx_t_10, __pyx_n_b_r, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(2, 432, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+    if (__pyx_t_5) {
+
+      /* "asyncpg/protocol/codecs/base.pyx":435
+ *                 # Range type
+ * 
+ *                 if not range_subtype_oid:             # <<<<<<<<<<<<<<
+ *                     raise RuntimeError(
+ *                         'type record missing base type for range {}'.format(
+ */
+      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_range_subtype_oid); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(2, 435, __pyx_L1_error)
+      __pyx_t_6 = ((!__pyx_t_5) != 0);
+      if (__pyx_t_6) {
+
+        /* "asyncpg/protocol/codecs/base.pyx":437
+ *                 if not range_subtype_oid:
+ *                     raise RuntimeError(
+ *                         'type record missing base type for range {}'.format(             # <<<<<<<<<<<<<<
+ *                             oid))
+ * 
+ */
+        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_type_record_missing_base_type_fo_2, __pyx_n_s_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 437, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_8);
+
+        /* "asyncpg/protocol/codecs/base.pyx":438
+ *                     raise RuntimeError(
+ *                         'type record missing base type for range {}'.format(
+ *                             oid))             # <<<<<<<<<<<<<<
+ * 
+ *                 if ti['elem_has_bin_io']:
+ */
+        __pyx_t_9 = NULL;
+        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
+          __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
+          if (likely(__pyx_t_9)) {
+            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
+            __Pyx_INCREF(__pyx_t_9);
+            __Pyx_INCREF(function);
+            __Pyx_DECREF_SET(__pyx_t_8, function);
+          }
+        }
+        if (!__pyx_t_9) {
+          __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_oid); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 437, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_10);
+        } else {
+          #if CYTHON_FAST_PYCALL
+          if (PyFunction_Check(__pyx_t_8)) {
+            PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_oid};
+            __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 437, __pyx_L1_error)
+            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
+            __Pyx_GOTREF(__pyx_t_10);
+          } else
+          #endif
+          #if CYTHON_FAST_PYCCALL
+          if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
+            PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_oid};
+            __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 437, __pyx_L1_error)
+            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
+            __Pyx_GOTREF(__pyx_t_10);
+          } else
+          #endif
+          {
+            __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(2, 437, __pyx_L1_error)
+            __Pyx_GOTREF(__pyx_t_14);
+            __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_9); __pyx_t_9 = NULL;
+            __Pyx_INCREF(__pyx_v_oid);
+            __Pyx_GIVEREF(__pyx_v_oid);
+            PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_v_oid);
+            __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_14, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 437, __pyx_L1_error)
+            __Pyx_GOTREF(__pyx_t_10);
+            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+          }
+        }
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+
+        /* "asyncpg/protocol/codecs/base.pyx":436
+ * 
+ *                 if not range_subtype_oid:
+ *                     raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                         'type record missing base type for range {}'.format(
+ *                             oid))
+ */
+        __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 436, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_8);
+        __Pyx_GIVEREF(__pyx_t_10);
+        PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_10);
+        __pyx_t_10 = 0;
+        __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_8, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 436, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_10);
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        __Pyx_Raise(__pyx_t_10, 0, 0, 0);
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        __PYX_ERR(2, 436, __pyx_L1_error)
+
+        /* "asyncpg/protocol/codecs/base.pyx":435
+ *                 # Range type
+ * 
+ *                 if not range_subtype_oid:             # <<<<<<<<<<<<<<
+ *                     raise RuntimeError(
+ *                         'type record missing base type for range {}'.format(
+ */
+      }
+
+      /* "asyncpg/protocol/codecs/base.pyx":440
+ *                             oid))
+ * 
+ *                 if ti['elem_has_bin_io']:             # <<<<<<<<<<<<<<
+ *                     elem_format = PG_FORMAT_BINARY
+ *                 else:
+ */
+      __pyx_t_10 = PyObject_GetItem(__pyx_v_ti, __pyx_n_u_elem_has_bin_io); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 440, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_10);
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 440, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      if (__pyx_t_6) {
+
+        /* "asyncpg/protocol/codecs/base.pyx":441
+ * 
+ *                 if ti['elem_has_bin_io']:
+ *                     elem_format = PG_FORMAT_BINARY             # <<<<<<<<<<<<<<
+ *                 else:
+ *                     elem_format = PG_FORMAT_TEXT
+ */
+        __pyx_v_elem_format = __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY;
+
+        /* "asyncpg/protocol/codecs/base.pyx":440
+ *                             oid))
+ * 
+ *                 if ti['elem_has_bin_io']:             # <<<<<<<<<<<<<<
+ *                     elem_format = PG_FORMAT_BINARY
+ *                 else:
+ */
+        goto __pyx_L23;
+      }
+
+      /* "asyncpg/protocol/codecs/base.pyx":443
+ *                     elem_format = PG_FORMAT_BINARY
+ *                 else:
+ *                     elem_format = PG_FORMAT_TEXT             # <<<<<<<<<<<<<<
+ *                 elem_codec = self.get_codec(range_subtype_oid, elem_format)
+ *                 if elem_codec is None:
+ */
+      /*else*/ {
+        __pyx_v_elem_format = __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT;
+      }
+      __pyx_L23:;
+
+      /* "asyncpg/protocol/codecs/base.pyx":444
+ *                 else:
+ *                     elem_format = PG_FORMAT_TEXT
+ *                 elem_codec = self.get_codec(range_subtype_oid, elem_format)             # <<<<<<<<<<<<<<
+ *                 if elem_codec is None:
+ *                     raise RuntimeError(
+ */
+      __pyx_t_7 = __Pyx_PyInt_As_uint32_t(__pyx_v_range_subtype_oid); if (unlikely((__pyx_t_7 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(2, 444, __pyx_L1_error)
+      __pyx_t_10 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_15DataCodecConfig_get_codec(__pyx_v_self, __pyx_t_7, __pyx_v_elem_format)); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 444, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_10);
+      __Pyx_XDECREF_SET(__pyx_v_elem_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_10));
+      __pyx_t_10 = 0;
+
+      /* "asyncpg/protocol/codecs/base.pyx":445
+ *                     elem_format = PG_FORMAT_TEXT
+ *                 elem_codec = self.get_codec(range_subtype_oid, elem_format)
+ *                 if elem_codec is None:             # <<<<<<<<<<<<<<
+ *                     raise RuntimeError(
+ *                         'no codec for range element type {}'.format(
+ */
+      __pyx_t_6 = (((PyObject *)__pyx_v_elem_codec) == Py_None);
+      __pyx_t_5 = (__pyx_t_6 != 0);
+      if (__pyx_t_5) {
+
+        /* "asyncpg/protocol/codecs/base.pyx":447
+ *                 if elem_codec is None:
+ *                     raise RuntimeError(
+ *                         'no codec for range element type {}'.format(             # <<<<<<<<<<<<<<
+ *                             range_subtype_oid))
+ * 
+ */
+        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_no_codec_for_range_element_type, __pyx_n_s_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 447, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_8);
+
+        /* "asyncpg/protocol/codecs/base.pyx":448
+ *                     raise RuntimeError(
+ *                         'no codec for range element type {}'.format(
+ *                             range_subtype_oid))             # <<<<<<<<<<<<<<
+ * 
+ *                 self._type_codecs_cache[oid, elem_format] = \
+ */
+        __pyx_t_14 = NULL;
+        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
+          __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_8);
+          if (likely(__pyx_t_14)) {
+            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
+            __Pyx_INCREF(__pyx_t_14);
+            __Pyx_INCREF(function);
+            __Pyx_DECREF_SET(__pyx_t_8, function);
+          }
+        }
+        if (!__pyx_t_14) {
+          __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_range_subtype_oid); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 447, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_10);
+        } else {
+          #if CYTHON_FAST_PYCALL
+          if (PyFunction_Check(__pyx_t_8)) {
+            PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_v_range_subtype_oid};
+            __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 447, __pyx_L1_error)
+            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
+            __Pyx_GOTREF(__pyx_t_10);
+          } else
+          #endif
+          #if CYTHON_FAST_PYCCALL
+          if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
+            PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_v_range_subtype_oid};
+            __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 447, __pyx_L1_error)
+            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
+            __Pyx_GOTREF(__pyx_t_10);
+          } else
+          #endif
+          {
+            __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 447, __pyx_L1_error)
+            __Pyx_GOTREF(__pyx_t_9);
+            __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_14); __pyx_t_14 = NULL;
+            __Pyx_INCREF(__pyx_v_range_subtype_oid);
+            __Pyx_GIVEREF(__pyx_v_range_subtype_oid);
+            PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_range_subtype_oid);
+            __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_9, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 447, __pyx_L1_error)
+            __Pyx_GOTREF(__pyx_t_10);
+            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+          }
+        }
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+
+        /* "asyncpg/protocol/codecs/base.pyx":446
+ *                 elem_codec = self.get_codec(range_subtype_oid, elem_format)
+ *                 if elem_codec is None:
+ *                     raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                         'no codec for range element type {}'.format(
+ *                             range_subtype_oid))
+ */
+        __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 446, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_8);
+        __Pyx_GIVEREF(__pyx_t_10);
+        PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_10);
+        __pyx_t_10 = 0;
+        __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_8, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 446, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_10);
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        __Pyx_Raise(__pyx_t_10, 0, 0, 0);
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        __PYX_ERR(2, 446, __pyx_L1_error)
+
+        /* "asyncpg/protocol/codecs/base.pyx":445
+ *                     elem_format = PG_FORMAT_TEXT
+ *                 elem_codec = self.get_codec(range_subtype_oid, elem_format)
+ *                 if elem_codec is None:             # <<<<<<<<<<<<<<
+ *                     raise RuntimeError(
+ *                         'no codec for range element type {}'.format(
+ */
+      }
+
+      /* "asyncpg/protocol/codecs/base.pyx":451
+ * 
+ *                 self._type_codecs_cache[oid, elem_format] = \
+ *                     Codec.new_range_codec(oid, name, schema, elem_codec)             # <<<<<<<<<<<<<<
+ * 
+ *             else:
+ */
+      __pyx_t_7 = __Pyx_PyInt_As_uint32_t(__pyx_v_oid); if (unlikely((__pyx_t_7 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(2, 451, __pyx_L1_error)
+      if (!(likely(PyUnicode_CheckExact(__pyx_v_name))||((__pyx_v_name) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_v_name)->tp_name), 0))) __PYX_ERR(2, 451, __pyx_L1_error)
+      if (!(likely(PyUnicode_CheckExact(__pyx_v_schema))||((__pyx_v_schema) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_v_schema)->tp_name), 0))) __PYX_ERR(2, 451, __pyx_L1_error)
+      __pyx_t_10 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_5Codec_new_range_codec(__pyx_t_7, ((PyObject*)__pyx_v_name), ((PyObject*)__pyx_v_schema), __pyx_v_elem_codec)); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 451, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_10);
+
+      /* "asyncpg/protocol/codecs/base.pyx":450
+ *                             range_subtype_oid))
+ * 
+ *                 self._type_codecs_cache[oid, elem_format] = \             # <<<<<<<<<<<<<<
+ *                     Codec.new_range_codec(oid, name, schema, elem_codec)
+ * 
+ */
+      if (unlikely(__pyx_v_self->_type_codecs_cache == Py_None)) {
+        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+        __PYX_ERR(2, 450, __pyx_L1_error)
+      }
+      __pyx_t_8 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_CodecFormat(__pyx_v_elem_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 450, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_8);
+      __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 450, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_INCREF(__pyx_v_oid);
+      __Pyx_GIVEREF(__pyx_v_oid);
+      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_oid);
+      __Pyx_GIVEREF(__pyx_t_8);
+      PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_8);
+      __pyx_t_8 = 0;
+      if (unlikely(PyDict_SetItem(__pyx_v_self->_type_codecs_cache, __pyx_t_9, __pyx_t_10) < 0)) __PYX_ERR(2, 450, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+
+      /* "asyncpg/protocol/codecs/base.pyx":432
+ *                 self._type_codecs_cache[oid, format] = elem_codec
+ * 
+ *             elif ti['kind'] == b'r':             # <<<<<<<<<<<<<<
+ *                 # Range type
+ * 
+ */
+      goto __pyx_L8;
+    }
+
+    /* "asyncpg/protocol/codecs/base.pyx":454
+ * 
+ *             else:
+ *                 if oid <= MAXBUILTINOID:             # <<<<<<<<<<<<<<
+ *                     # This is a non-BKI type, for which ayncpg has no
+ *                     # defined codec.  This should only happen for newly
+ */
+    /*else*/ {
+      __pyx_t_10 = PyObject_RichCompare(__pyx_v_oid, __pyx_int_9999, Py_LE); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 454, __pyx_L1_error)
+      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(2, 454, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      if (__pyx_t_5) {
+
+        /* "asyncpg/protocol/codecs/base.pyx":461
+ *                     #
+ *                     raise NotImplementedError(
+ *                         'unhandled standard data type {!r} (OID {})'.format(             # <<<<<<<<<<<<<<
+ *                             name, oid))
+ *                 else:
+ */
+        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_unhandled_standard_data_type_r_O, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 461, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_9);
+
+        /* "asyncpg/protocol/codecs/base.pyx":462
+ *                     raise NotImplementedError(
+ *                         'unhandled standard data type {!r} (OID {})'.format(
+ *                             name, oid))             # <<<<<<<<<<<<<<
+ *                 else:
+ *                     # This is a non-BKI type, and as such, has no
+ */
+        __pyx_t_8 = NULL;
+        __pyx_t_16 = 0;
+        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
+          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9);
+          if (likely(__pyx_t_8)) {
+            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
+            __Pyx_INCREF(__pyx_t_8);
+            __Pyx_INCREF(function);
+            __Pyx_DECREF_SET(__pyx_t_9, function);
+            __pyx_t_16 = 1;
+          }
+        }
+        #if CYTHON_FAST_PYCALL
+        if (PyFunction_Check(__pyx_t_9)) {
+          PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_name, __pyx_v_oid};
+          __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_16, 2+__pyx_t_16); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 461, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+          __Pyx_GOTREF(__pyx_t_10);
+        } else
+        #endif
+        #if CYTHON_FAST_PYCCALL
+        if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
+          PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_name, __pyx_v_oid};
+          __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_16, 2+__pyx_t_16); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 461, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+          __Pyx_GOTREF(__pyx_t_10);
+        } else
+        #endif
+        {
+          __pyx_t_14 = PyTuple_New(2+__pyx_t_16); if (unlikely(!__pyx_t_14)) __PYX_ERR(2, 461, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_14);
+          if (__pyx_t_8) {
+            __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_8); __pyx_t_8 = NULL;
+          }
+          __Pyx_INCREF(__pyx_v_name);
+          __Pyx_GIVEREF(__pyx_v_name);
+          PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_16, __pyx_v_name);
+          __Pyx_INCREF(__pyx_v_oid);
+          __Pyx_GIVEREF(__pyx_v_oid);
+          PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_16, __pyx_v_oid);
+          __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_14, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 461, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_10);
+          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+        }
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+
+        /* "asyncpg/protocol/codecs/base.pyx":460
+ *                     # asyncpg is lacking support.
+ *                     #
+ *                     raise NotImplementedError(             # <<<<<<<<<<<<<<
+ *                         'unhandled standard data type {!r} (OID {})'.format(
+ *                             name, oid))
+ */
+        __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 460, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_9);
+        __Pyx_GIVEREF(__pyx_t_10);
+        PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10);
+        __pyx_t_10 = 0;
+        __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_t_9, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 460, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_10);
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_Raise(__pyx_t_10, 0, 0, 0);
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        __PYX_ERR(2, 460, __pyx_L1_error)
+
+        /* "asyncpg/protocol/codecs/base.pyx":454
+ * 
+ *             else:
+ *                 if oid <= MAXBUILTINOID:             # <<<<<<<<<<<<<<
+ *                     # This is a non-BKI type, for which ayncpg has no
+ *                     # defined codec.  This should only happen for newly
+ */
+      }
+
+      /* "asyncpg/protocol/codecs/base.pyx":470
+ *                     # using Connection.set_type_codec().
+ *                     #
+ *                     self.set_builtin_type_codec(oid, name, schema, 'scalar',             # <<<<<<<<<<<<<<
+ *                                                 UNKNOWNOID)
+ * 
+ */
+      /*else*/ {
+        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set_builtin_type_codec); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 470, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_9);
+        __pyx_t_14 = NULL;
+        __pyx_t_16 = 0;
+        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
+          __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_9);
+          if (likely(__pyx_t_14)) {
+            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
+            __Pyx_INCREF(__pyx_t_14);
+            __Pyx_INCREF(function);
+            __Pyx_DECREF_SET(__pyx_t_9, function);
+            __pyx_t_16 = 1;
+          }
+        }
+        #if CYTHON_FAST_PYCALL
+        if (PyFunction_Check(__pyx_t_9)) {
+          PyObject *__pyx_temp[6] = {__pyx_t_14, __pyx_v_oid, __pyx_v_name, __pyx_v_schema, __pyx_n_u_scalar, __pyx_int_705};
+          __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_16, 5+__pyx_t_16); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 470, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
+          __Pyx_GOTREF(__pyx_t_10);
+        } else
+        #endif
+        #if CYTHON_FAST_PYCCALL
+        if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
+          PyObject *__pyx_temp[6] = {__pyx_t_14, __pyx_v_oid, __pyx_v_name, __pyx_v_schema, __pyx_n_u_scalar, __pyx_int_705};
+          __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_16, 5+__pyx_t_16); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 470, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
+          __Pyx_GOTREF(__pyx_t_10);
+        } else
+        #endif
+        {
+          __pyx_t_8 = PyTuple_New(5+__pyx_t_16); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 470, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_8);
+          if (__pyx_t_14) {
+            __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_14); __pyx_t_14 = NULL;
+          }
+          __Pyx_INCREF(__pyx_v_oid);
+          __Pyx_GIVEREF(__pyx_v_oid);
+          PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_16, __pyx_v_oid);
+          __Pyx_INCREF(__pyx_v_name);
+          __Pyx_GIVEREF(__pyx_v_name);
+          PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_16, __pyx_v_name);
+          __Pyx_INCREF(__pyx_v_schema);
+          __Pyx_GIVEREF(__pyx_v_schema);
+          PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_16, __pyx_v_schema);
+          __Pyx_INCREF(__pyx_n_u_scalar);
+          __Pyx_GIVEREF(__pyx_n_u_scalar);
+          PyTuple_SET_ITEM(__pyx_t_8, 3+__pyx_t_16, __pyx_n_u_scalar);
+          __Pyx_INCREF(__pyx_int_705);
+          __Pyx_GIVEREF(__pyx_int_705);
+          PyTuple_SET_ITEM(__pyx_t_8, 4+__pyx_t_16, __pyx_int_705);
+          __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_8, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 470, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_10);
+          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        }
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      }
+    }
+    __pyx_L8:;
+
+    /* "asyncpg/protocol/codecs/base.pyx":336
+ *             Py_UCS4 elem_delim
+ * 
+ *         for ti in types:             # <<<<<<<<<<<<<<
+ *             oid = ti['oid']
+ * 
+ */
+    __pyx_L3_continue:;
+  }
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":327
+ *         self._local_type_codecs = {}
+ * 
+ *     def add_types(self, types):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             Codec elem_codec
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_XDECREF(__pyx_t_14);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.DataCodecConfig.add_types", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_elem_codec);
+  __Pyx_XDECREF(__pyx_v_comp_elem_codecs);
+  __Pyx_XDECREF(__pyx_v_ti);
+  __Pyx_XDECREF(__pyx_v_oid);
+  __Pyx_XDECREF(__pyx_v_name);
+  __Pyx_XDECREF(__pyx_v_schema);
+  __Pyx_XDECREF(__pyx_v_array_element_oid);
+  __Pyx_XDECREF(__pyx_v_range_subtype_oid);
+  __Pyx_XDECREF(__pyx_v_comp_type_attrs);
+  __Pyx_XDECREF(__pyx_v_base_type);
+  __Pyx_XDECREF(__pyx_v_typoid);
+  __Pyx_XDECREF(__pyx_v_element_names);
+  __Pyx_XDECREF(__pyx_v_i);
+  __Pyx_XDECREF(__pyx_v_attrname);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":473
+ *                                                 UNKNOWNOID)
+ * 
+ *     def add_python_codec(self, typeoid, typename, typeschema, typekind,             # <<<<<<<<<<<<<<
+ *                          encoder, decoder, binary):
+ *         format = PG_FORMAT_BINARY if binary else PG_FORMAT_TEXT
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_5add_python_codec(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_5add_python_codec(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_typeoid = 0;
+  PyObject *__pyx_v_typename = 0;
+  PyObject *__pyx_v_typeschema = 0;
+  PyObject *__pyx_v_typekind = 0;
+  PyObject *__pyx_v_encoder = 0;
+  PyObject *__pyx_v_decoder = 0;
+  PyObject *__pyx_v_binary = 0;
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("add_python_codec (wrapper)", 0);
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_typeoid,&__pyx_n_s_typename,&__pyx_n_s_typeschema,&__pyx_n_s_typekind,&__pyx_n_s_encoder,&__pyx_n_s_decoder,&__pyx_n_s_binary,0};
+    PyObject* values[7] = {0,0,0,0,0,0,0};
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
+        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
+        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typeoid)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+        case  1:
+        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typename)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("add_python_codec", 1, 7, 7, 1); __PYX_ERR(2, 473, __pyx_L3_error)
+        }
+        case  2:
+        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typeschema)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("add_python_codec", 1, 7, 7, 2); __PYX_ERR(2, 473, __pyx_L3_error)
+        }
+        case  3:
+        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typekind)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("add_python_codec", 1, 7, 7, 3); __PYX_ERR(2, 473, __pyx_L3_error)
+        }
+        case  4:
+        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_encoder)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("add_python_codec", 1, 7, 7, 4); __PYX_ERR(2, 473, __pyx_L3_error)
+        }
+        case  5:
+        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_decoder)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("add_python_codec", 1, 7, 7, 5); __PYX_ERR(2, 473, __pyx_L3_error)
+        }
+        case  6:
+        if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_binary)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("add_python_codec", 1, 7, 7, 6); __PYX_ERR(2, 473, __pyx_L3_error)
+        }
+      }
+      if (unlikely(kw_args > 0)) {
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_python_codec") < 0)) __PYX_ERR(2, 473, __pyx_L3_error)
+      }
+    } else if (PyTuple_GET_SIZE(__pyx_args) != 7) {
+      goto __pyx_L5_argtuple_error;
+    } else {
+      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
+      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
+    }
+    __pyx_v_typeoid = values[0];
+    __pyx_v_typename = values[1];
+    __pyx_v_typeschema = values[2];
+    __pyx_v_typekind = values[3];
+    __pyx_v_encoder = values[4];
+    __pyx_v_decoder = values[5];
+    __pyx_v_binary = values[6];
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("add_python_codec", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 473, __pyx_L3_error)
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.DataCodecConfig.add_python_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig_4add_python_codec(((struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *)__pyx_v_self), __pyx_v_typeoid, __pyx_v_typename, __pyx_v_typeschema, __pyx_v_typekind, __pyx_v_encoder, __pyx_v_decoder, __pyx_v_binary);
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig_4add_python_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *__pyx_v_self, PyObject *__pyx_v_typeoid, PyObject *__pyx_v_typename, PyObject *__pyx_v_typeschema, PyObject *__pyx_v_typekind, PyObject *__pyx_v_encoder, PyObject *__pyx_v_decoder, PyObject *__pyx_v_binary) {
+  enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat __pyx_v_format;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat __pyx_t_1;
+  int __pyx_t_2;
+  uint32_t __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  int __pyx_t_5;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  __Pyx_RefNannySetupContext("add_python_codec", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":475
+ *     def add_python_codec(self, typeoid, typename, typeschema, typekind,
+ *                          encoder, decoder, binary):
+ *         format = PG_FORMAT_BINARY if binary else PG_FORMAT_TEXT             # <<<<<<<<<<<<<<
+ * 
+ *         if self.get_codec(typeoid, format) is not None:
+ */
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_binary); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(2, 475, __pyx_L1_error)
+  if (__pyx_t_2) {
+    __pyx_t_1 = __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY;
+  } else {
+    __pyx_t_1 = __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT;
+  }
+  __pyx_v_format = __pyx_t_1;
+
+  /* "asyncpg/protocol/codecs/base.pyx":477
+ *         format = PG_FORMAT_BINARY if binary else PG_FORMAT_TEXT
+ * 
+ *         if self.get_codec(typeoid, format) is not None:             # <<<<<<<<<<<<<<
+ *             raise ValueError('cannot override codec for type {}'.format(
+ *                 typeoid))
+ */
+  __pyx_t_3 = __Pyx_PyInt_As_uint32_t(__pyx_v_typeoid); if (unlikely((__pyx_t_3 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(2, 477, __pyx_L1_error)
+  __pyx_t_4 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_15DataCodecConfig_get_codec(__pyx_v_self, __pyx_t_3, __pyx_v_format)); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 477, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_2 = (__pyx_t_4 != Py_None);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_5 = (__pyx_t_2 != 0);
+  if (__pyx_t_5) {
+
+    /* "asyncpg/protocol/codecs/base.pyx":478
+ * 
+ *         if self.get_codec(typeoid, format) is not None:
+ *             raise ValueError('cannot override codec for type {}'.format(             # <<<<<<<<<<<<<<
+ *                 typeoid))
+ * 
+ */
+    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_cannot_override_codec_for_type, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 478, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_6);
+
+    /* "asyncpg/protocol/codecs/base.pyx":479
+ *         if self.get_codec(typeoid, format) is not None:
+ *             raise ValueError('cannot override codec for type {}'.format(
+ *                 typeoid))             # <<<<<<<<<<<<<<
+ * 
+ *         self._local_type_codecs[typeoid, format] = \
+ */
+    __pyx_t_7 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
+      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
+      if (likely(__pyx_t_7)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
+        __Pyx_INCREF(__pyx_t_7);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_6, function);
+      }
+    }
+    if (!__pyx_t_7) {
+      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_typeoid); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 478, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_6)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_typeoid};
+        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 478, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __Pyx_GOTREF(__pyx_t_4);
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_typeoid};
+        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 478, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __Pyx_GOTREF(__pyx_t_4);
+      } else
+      #endif
+      {
+        __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 478, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_8);
+        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
+        __Pyx_INCREF(__pyx_v_typeoid);
+        __Pyx_GIVEREF(__pyx_v_typeoid);
+        PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_typeoid);
+        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 478, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":478
+ * 
+ *         if self.get_codec(typeoid, format) is not None:
+ *             raise ValueError('cannot override codec for type {}'.format(             # <<<<<<<<<<<<<<
+ *                 typeoid))
+ * 
+ */
+    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 478, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_GIVEREF(__pyx_t_4);
+    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
+    __pyx_t_4 = 0;
+    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 478, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __PYX_ERR(2, 478, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/base.pyx":477
+ *         format = PG_FORMAT_BINARY if binary else PG_FORMAT_TEXT
+ * 
+ *         if self.get_codec(typeoid, format) is not None:             # <<<<<<<<<<<<<<
+ *             raise ValueError('cannot override codec for type {}'.format(
+ *                 typeoid))
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/base.pyx":482
+ * 
+ *         self._local_type_codecs[typeoid, format] = \
+ *             Codec.new_python_codec(typeoid, typename, typeschema, typekind,             # <<<<<<<<<<<<<<
+ *                                    encoder, decoder, format)
+ * 
+ */
+  __pyx_t_3 = __Pyx_PyInt_As_uint32_t(__pyx_v_typeoid); if (unlikely((__pyx_t_3 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(2, 482, __pyx_L1_error)
+  if (!(likely(PyUnicode_CheckExact(__pyx_v_typename))||((__pyx_v_typename) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_v_typename)->tp_name), 0))) __PYX_ERR(2, 482, __pyx_L1_error)
+  if (!(likely(PyUnicode_CheckExact(__pyx_v_typeschema))||((__pyx_v_typeschema) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_v_typeschema)->tp_name), 0))) __PYX_ERR(2, 482, __pyx_L1_error)
+  if (!(likely(PyUnicode_CheckExact(__pyx_v_typekind))||((__pyx_v_typekind) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_v_typekind)->tp_name), 0))) __PYX_ERR(2, 482, __pyx_L1_error)
+
+  /* "asyncpg/protocol/codecs/base.pyx":483
+ *         self._local_type_codecs[typeoid, format] = \
+ *             Codec.new_python_codec(typeoid, typename, typeschema, typekind,
+ *                                    encoder, decoder, format)             # <<<<<<<<<<<<<<
+ * 
+ *     def set_builtin_type_codec(self, typeoid, typename, typeschema, typekind,
+ */
+  __pyx_t_4 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_5Codec_new_python_codec(__pyx_t_3, ((PyObject*)__pyx_v_typename), ((PyObject*)__pyx_v_typeschema), ((PyObject*)__pyx_v_typekind), __pyx_v_encoder, __pyx_v_decoder, __pyx_v_format)); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 482, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+
+  /* "asyncpg/protocol/codecs/base.pyx":481
+ *                 typeoid))
+ * 
+ *         self._local_type_codecs[typeoid, format] = \             # <<<<<<<<<<<<<<
+ *             Codec.new_python_codec(typeoid, typename, typeschema, typekind,
+ *                                    encoder, decoder, format)
+ */
+  if (unlikely(__pyx_v_self->_local_type_codecs == Py_None)) {
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+    __PYX_ERR(2, 481, __pyx_L1_error)
+  }
+  __pyx_t_6 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_CodecFormat(__pyx_v_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 481, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_6);
+  __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 481, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_8);
+  __Pyx_INCREF(__pyx_v_typeoid);
+  __Pyx_GIVEREF(__pyx_v_typeoid);
+  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_typeoid);
+  __Pyx_GIVEREF(__pyx_t_6);
+  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6);
+  __pyx_t_6 = 0;
+  if (unlikely(PyDict_SetItem(__pyx_v_self->_local_type_codecs, __pyx_t_8, __pyx_t_4) < 0)) __PYX_ERR(2, 481, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":473
+ *                                                 UNKNOWNOID)
+ * 
+ *     def add_python_codec(self, typeoid, typename, typeschema, typekind,             # <<<<<<<<<<<<<<
+ *                          encoder, decoder, binary):
+ *         format = PG_FORMAT_BINARY if binary else PG_FORMAT_TEXT
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.DataCodecConfig.add_python_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":485
+ *                                    encoder, decoder, format)
+ * 
+ *     def set_builtin_type_codec(self, typeoid, typename, typeschema, typekind,             # <<<<<<<<<<<<<<
+ *                                alias_to):
+ *         cdef:
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_7set_builtin_type_codec(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_7set_builtin_type_codec(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_typeoid = 0;
+  PyObject *__pyx_v_typename = 0;
+  PyObject *__pyx_v_typeschema = 0;
+  PyObject *__pyx_v_typekind = 0;
+  PyObject *__pyx_v_alias_to = 0;
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("set_builtin_type_codec (wrapper)", 0);
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_typeoid,&__pyx_n_s_typename,&__pyx_n_s_typeschema,&__pyx_n_s_typekind,&__pyx_n_s_alias_to,0};
+    PyObject* values[5] = {0,0,0,0,0};
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typeoid)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+        case  1:
+        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typename)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("set_builtin_type_codec", 1, 5, 5, 1); __PYX_ERR(2, 485, __pyx_L3_error)
+        }
+        case  2:
+        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typeschema)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("set_builtin_type_codec", 1, 5, 5, 2); __PYX_ERR(2, 485, __pyx_L3_error)
+        }
+        case  3:
+        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typekind)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("set_builtin_type_codec", 1, 5, 5, 3); __PYX_ERR(2, 485, __pyx_L3_error)
+        }
+        case  4:
+        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_alias_to)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("set_builtin_type_codec", 1, 5, 5, 4); __PYX_ERR(2, 485, __pyx_L3_error)
+        }
+      }
+      if (unlikely(kw_args > 0)) {
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_builtin_type_codec") < 0)) __PYX_ERR(2, 485, __pyx_L3_error)
+      }
+    } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
+      goto __pyx_L5_argtuple_error;
+    } else {
+      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+    }
+    __pyx_v_typeoid = values[0];
+    __pyx_v_typename = values[1];
+    __pyx_v_typeschema = values[2];
+    __pyx_v_typekind = values[3];
+    __pyx_v_alias_to = values[4];
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("set_builtin_type_codec", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 485, __pyx_L3_error)
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.DataCodecConfig.set_builtin_type_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig_6set_builtin_type_codec(((struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *)__pyx_v_self), __pyx_v_typeoid, __pyx_v_typename, __pyx_v_typeschema, __pyx_v_typekind, __pyx_v_alias_to);
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig_6set_builtin_type_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *__pyx_v_self, PyObject *__pyx_v_typeoid, PyObject *__pyx_v_typename, PyObject *__pyx_v_typeschema, PyObject *__pyx_v_typekind, PyObject *__pyx_v_alias_to) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_codec = 0;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_target_codec = 0;
+  PyObject *__pyx_v_format = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  Py_ssize_t __pyx_t_4;
+  uint32_t __pyx_t_5;
+  enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat __pyx_t_6;
+  int __pyx_t_7;
+  int __pyx_t_8;
+  PyObject *__pyx_t_9 = NULL;
+  PyObject *__pyx_t_10 = NULL;
+  int __pyx_t_11;
+  __Pyx_RefNannySetupContext("set_builtin_type_codec", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":491
+ *             Codec target_codec
+ * 
+ *         for format in (PG_FORMAT_BINARY, PG_FORMAT_TEXT):             # <<<<<<<<<<<<<<
+ *             if self.get_codec(typeoid, format) is not None:
+ *                 raise ValueError('cannot override codec for type {}'.format(
+ */
+  __pyx_t_1 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_CodecFormat(__pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 491, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_CodecFormat(__pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 491, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 491, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_2);
+  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
+  __pyx_t_1 = 0;
+  __pyx_t_2 = 0;
+  __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  for (;;) {
+    if (__pyx_t_4 >= 2) break;
+    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+    __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(2, 491, __pyx_L1_error)
+    #else
+    __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 491, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    #endif
+    __Pyx_XDECREF_SET(__pyx_v_format, __pyx_t_3);
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":492
+ * 
+ *         for format in (PG_FORMAT_BINARY, PG_FORMAT_TEXT):
+ *             if self.get_codec(typeoid, format) is not None:             # <<<<<<<<<<<<<<
+ *                 raise ValueError('cannot override codec for type {}'.format(
+ *                     typeoid))
+ */
+    __pyx_t_5 = __Pyx_PyInt_As_uint32_t(__pyx_v_typeoid); if (unlikely((__pyx_t_5 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(2, 492, __pyx_L1_error)
+    __pyx_t_6 = ((enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)__Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_CodecFormat(__pyx_v_format)); if (unlikely(PyErr_Occurred())) __PYX_ERR(2, 492, __pyx_L1_error)
+    __pyx_t_3 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_15DataCodecConfig_get_codec(__pyx_v_self, __pyx_t_5, __pyx_t_6)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 492, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_7 = (__pyx_t_3 != Py_None);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_8 = (__pyx_t_7 != 0);
+    if (__pyx_t_8) {
+
+      /* "asyncpg/protocol/codecs/base.pyx":493
+ *         for format in (PG_FORMAT_BINARY, PG_FORMAT_TEXT):
+ *             if self.get_codec(typeoid, format) is not None:
+ *                 raise ValueError('cannot override codec for type {}'.format(             # <<<<<<<<<<<<<<
+ *                     typeoid))
+ * 
+ */
+      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_cannot_override_codec_for_type, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 493, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+
+      /* "asyncpg/protocol/codecs/base.pyx":494
+ *             if self.get_codec(typeoid, format) is not None:
+ *                 raise ValueError('cannot override codec for type {}'.format(
+ *                     typeoid))             # <<<<<<<<<<<<<<
+ * 
+ *             if isinstance(alias_to, int):
+ */
+      __pyx_t_9 = NULL;
+      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
+        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
+        if (likely(__pyx_t_9)) {
+          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
+          __Pyx_INCREF(__pyx_t_9);
+          __Pyx_INCREF(function);
+          __Pyx_DECREF_SET(__pyx_t_1, function);
+        }
+      }
+      if (!__pyx_t_9) {
+        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_typeoid); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 493, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_3);
+      } else {
+        #if CYTHON_FAST_PYCALL
+        if (PyFunction_Check(__pyx_t_1)) {
+          PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_typeoid};
+          __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 493, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
+          __Pyx_GOTREF(__pyx_t_3);
+        } else
+        #endif
+        #if CYTHON_FAST_PYCCALL
+        if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
+          PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_typeoid};
+          __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 493, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
+          __Pyx_GOTREF(__pyx_t_3);
+        } else
+        #endif
+        {
+          __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 493, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_10);
+          __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
+          __Pyx_INCREF(__pyx_v_typeoid);
+          __Pyx_GIVEREF(__pyx_v_typeoid);
+          PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_typeoid);
+          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 493, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_3);
+          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        }
+      }
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+      /* "asyncpg/protocol/codecs/base.pyx":493
+ *         for format in (PG_FORMAT_BINARY, PG_FORMAT_TEXT):
+ *             if self.get_codec(typeoid, format) is not None:
+ *                 raise ValueError('cannot override codec for type {}'.format(             # <<<<<<<<<<<<<<
+ *                     typeoid))
+ * 
+ */
+      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 493, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_GIVEREF(__pyx_t_3);
+      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
+      __pyx_t_3 = 0;
+      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 493, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __PYX_ERR(2, 493, __pyx_L1_error)
+
+      /* "asyncpg/protocol/codecs/base.pyx":492
+ * 
+ *         for format in (PG_FORMAT_BINARY, PG_FORMAT_TEXT):
+ *             if self.get_codec(typeoid, format) is not None:             # <<<<<<<<<<<<<<
+ *                 raise ValueError('cannot override codec for type {}'.format(
+ *                     typeoid))
+ */
+    }
+
+    /* "asyncpg/protocol/codecs/base.pyx":496
+ *                     typeoid))
+ * 
+ *             if isinstance(alias_to, int):             # <<<<<<<<<<<<<<
+ *                 target_codec = self.get_codec(alias_to, format)
+ *             else:
+ */
+    __pyx_t_8 = PyInt_Check(__pyx_v_alias_to); 
+    __pyx_t_7 = (__pyx_t_8 != 0);
+    if (__pyx_t_7) {
+
+      /* "asyncpg/protocol/codecs/base.pyx":497
+ * 
+ *             if isinstance(alias_to, int):
+ *                 target_codec = self.get_codec(alias_to, format)             # <<<<<<<<<<<<<<
+ *             else:
+ *                 target_codec = get_extra_codec(alias_to, format)
+ */
+      __pyx_t_5 = __Pyx_PyInt_As_uint32_t(__pyx_v_alias_to); if (unlikely((__pyx_t_5 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(2, 497, __pyx_L1_error)
+      __pyx_t_6 = ((enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)__Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_CodecFormat(__pyx_v_format)); if (unlikely(PyErr_Occurred())) __PYX_ERR(2, 497, __pyx_L1_error)
+      __pyx_t_3 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_15DataCodecConfig_get_codec(__pyx_v_self, __pyx_t_5, __pyx_t_6)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 497, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_XDECREF_SET(__pyx_v_target_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_3));
+      __pyx_t_3 = 0;
+
+      /* "asyncpg/protocol/codecs/base.pyx":496
+ *                     typeoid))
+ * 
+ *             if isinstance(alias_to, int):             # <<<<<<<<<<<<<<
+ *                 target_codec = self.get_codec(alias_to, format)
+ *             else:
+ */
+      goto __pyx_L6;
+    }
+
+    /* "asyncpg/protocol/codecs/base.pyx":499
+ *                 target_codec = self.get_codec(alias_to, format)
+ *             else:
+ *                 target_codec = get_extra_codec(alias_to, format)             # <<<<<<<<<<<<<<
+ * 
+ *             if target_codec is None:
+ */
+    /*else*/ {
+      if (!(likely(PyUnicode_CheckExact(__pyx_v_alias_to))||((__pyx_v_alias_to) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_v_alias_to)->tp_name), 0))) __PYX_ERR(2, 499, __pyx_L1_error)
+      __pyx_t_6 = ((enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)__Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_CodecFormat(__pyx_v_format)); if (unlikely(PyErr_Occurred())) __PYX_ERR(2, 499, __pyx_L1_error)
+      __pyx_t_3 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_get_extra_codec(((PyObject*)__pyx_v_alias_to), __pyx_t_6)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 499, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_XDECREF_SET(__pyx_v_target_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_3));
+      __pyx_t_3 = 0;
+    }
+    __pyx_L6:;
+
+    /* "asyncpg/protocol/codecs/base.pyx":501
+ *                 target_codec = get_extra_codec(alias_to, format)
+ * 
+ *             if target_codec is None:             # <<<<<<<<<<<<<<
+ *                 continue
+ * 
+ */
+    __pyx_t_7 = (((PyObject *)__pyx_v_target_codec) == Py_None);
+    __pyx_t_8 = (__pyx_t_7 != 0);
+    if (__pyx_t_8) {
+
+      /* "asyncpg/protocol/codecs/base.pyx":502
+ * 
+ *             if target_codec is None:
+ *                 continue             # <<<<<<<<<<<<<<
+ * 
+ *             codec = target_codec.copy()
+ */
+      goto __pyx_L3_continue;
+
+      /* "asyncpg/protocol/codecs/base.pyx":501
+ *                 target_codec = get_extra_codec(alias_to, format)
+ * 
+ *             if target_codec is None:             # <<<<<<<<<<<<<<
+ *                 continue
+ * 
+ */
+    }
+
+    /* "asyncpg/protocol/codecs/base.pyx":504
+ *                 continue
+ * 
+ *             codec = target_codec.copy()             # <<<<<<<<<<<<<<
+ *             codec.oid = typeoid
+ *             codec.name = typename
+ */
+    __pyx_t_3 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_5Codec_copy(__pyx_v_target_codec)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 504, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_XDECREF_SET(__pyx_v_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_3));
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":505
+ * 
+ *             codec = target_codec.copy()
+ *             codec.oid = typeoid             # <<<<<<<<<<<<<<
+ *             codec.name = typename
+ *             codec.schema = typeschema
+ */
+    __pyx_t_5 = __Pyx_PyInt_As_uint32_t(__pyx_v_typeoid); if (unlikely((__pyx_t_5 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(2, 505, __pyx_L1_error)
+    __pyx_v_codec->oid = __pyx_t_5;
+
+    /* "asyncpg/protocol/codecs/base.pyx":506
+ *             codec = target_codec.copy()
+ *             codec.oid = typeoid
+ *             codec.name = typename             # <<<<<<<<<<<<<<
+ *             codec.schema = typeschema
+ *             codec.kind = typekind
+ */
+    if (!(likely(PyUnicode_CheckExact(__pyx_v_typename))||((__pyx_v_typename) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_v_typename)->tp_name), 0))) __PYX_ERR(2, 506, __pyx_L1_error)
+    __pyx_t_3 = __pyx_v_typename;
+    __Pyx_INCREF(__pyx_t_3);
+    __Pyx_GIVEREF(__pyx_t_3);
+    __Pyx_GOTREF(__pyx_v_codec->name);
+    __Pyx_DECREF(__pyx_v_codec->name);
+    __pyx_v_codec->name = ((PyObject*)__pyx_t_3);
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":507
+ *             codec.oid = typeoid
+ *             codec.name = typename
+ *             codec.schema = typeschema             # <<<<<<<<<<<<<<
+ *             codec.kind = typekind
+ * 
+ */
+    if (!(likely(PyUnicode_CheckExact(__pyx_v_typeschema))||((__pyx_v_typeschema) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_v_typeschema)->tp_name), 0))) __PYX_ERR(2, 507, __pyx_L1_error)
+    __pyx_t_3 = __pyx_v_typeschema;
+    __Pyx_INCREF(__pyx_t_3);
+    __Pyx_GIVEREF(__pyx_t_3);
+    __Pyx_GOTREF(__pyx_v_codec->schema);
+    __Pyx_DECREF(__pyx_v_codec->schema);
+    __pyx_v_codec->schema = ((PyObject*)__pyx_t_3);
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":508
+ *             codec.name = typename
+ *             codec.schema = typeschema
+ *             codec.kind = typekind             # <<<<<<<<<<<<<<
+ * 
+ *             self._local_type_codecs[typeoid, format] = codec
+ */
+    if (!(likely(PyUnicode_CheckExact(__pyx_v_typekind))||((__pyx_v_typekind) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_v_typekind)->tp_name), 0))) __PYX_ERR(2, 508, __pyx_L1_error)
+    __pyx_t_3 = __pyx_v_typekind;
+    __Pyx_INCREF(__pyx_t_3);
+    __Pyx_GIVEREF(__pyx_t_3);
+    __Pyx_GOTREF(__pyx_v_codec->kind);
+    __Pyx_DECREF(__pyx_v_codec->kind);
+    __pyx_v_codec->kind = ((PyObject*)__pyx_t_3);
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":510
+ *             codec.kind = typekind
+ * 
+ *             self._local_type_codecs[typeoid, format] = codec             # <<<<<<<<<<<<<<
+ * 
+ *         if ((typeoid, PG_FORMAT_BINARY) not in self._local_type_codecs and
+ */
+    if (unlikely(__pyx_v_self->_local_type_codecs == Py_None)) {
+      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+      __PYX_ERR(2, 510, __pyx_L1_error)
+    }
+    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 510, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_INCREF(__pyx_v_typeoid);
+    __Pyx_GIVEREF(__pyx_v_typeoid);
+    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_typeoid);
+    __Pyx_INCREF(__pyx_v_format);
+    __Pyx_GIVEREF(__pyx_v_format);
+    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_format);
+    if (unlikely(PyDict_SetItem(__pyx_v_self->_local_type_codecs, __pyx_t_3, ((PyObject *)__pyx_v_codec)) < 0)) __PYX_ERR(2, 510, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":491
+ *             Codec target_codec
+ * 
+ *         for format in (PG_FORMAT_BINARY, PG_FORMAT_TEXT):             # <<<<<<<<<<<<<<
+ *             if self.get_codec(typeoid, format) is not None:
+ *                 raise ValueError('cannot override codec for type {}'.format(
+ */
+    __pyx_L3_continue:;
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":512
+ *             self._local_type_codecs[typeoid, format] = codec
+ * 
+ *         if ((typeoid, PG_FORMAT_BINARY) not in self._local_type_codecs and             # <<<<<<<<<<<<<<
+ *                 (typeoid, PG_FORMAT_TEXT) not in self._local_type_codecs):
+ *             raise ValueError('unknown alias target: {}'.format(alias_to))
+ */
+  __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_CodecFormat(__pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 512, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 512, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_INCREF(__pyx_v_typeoid);
+  __Pyx_GIVEREF(__pyx_v_typeoid);
+  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_typeoid);
+  __Pyx_GIVEREF(__pyx_t_2);
+  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
+  __pyx_t_2 = 0;
+  if (unlikely(__pyx_v_self->_local_type_codecs == Py_None)) {
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
+    __PYX_ERR(2, 512, __pyx_L1_error)
+  }
+  __pyx_t_7 = (__Pyx_PyDict_ContainsTF(__pyx_t_3, __pyx_v_self->_local_type_codecs, Py_NE)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(2, 512, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_11 = (__pyx_t_7 != 0);
+  if (__pyx_t_11) {
+  } else {
+    __pyx_t_8 = __pyx_t_11;
+    goto __pyx_L9_bool_binop_done;
+  }
+
+  /* "asyncpg/protocol/codecs/base.pyx":513
+ * 
+ *         if ((typeoid, PG_FORMAT_BINARY) not in self._local_type_codecs and
+ *                 (typeoid, PG_FORMAT_TEXT) not in self._local_type_codecs):             # <<<<<<<<<<<<<<
+ *             raise ValueError('unknown alias target: {}'.format(alias_to))
+ * 
+ */
+  __pyx_t_3 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_CodecFormat(__pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 513, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 513, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_v_typeoid);
+  __Pyx_GIVEREF(__pyx_v_typeoid);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_typeoid);
+  __Pyx_GIVEREF(__pyx_t_3);
+  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
+  __pyx_t_3 = 0;
+  if (unlikely(__pyx_v_self->_local_type_codecs == Py_None)) {
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
+    __PYX_ERR(2, 513, __pyx_L1_error)
+  }
+  __pyx_t_11 = (__Pyx_PyDict_ContainsTF(__pyx_t_2, __pyx_v_self->_local_type_codecs, Py_NE)); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(2, 513, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_7 = (__pyx_t_11 != 0);
+  __pyx_t_8 = __pyx_t_7;
+  __pyx_L9_bool_binop_done:;
+
+  /* "asyncpg/protocol/codecs/base.pyx":512
+ *             self._local_type_codecs[typeoid, format] = codec
+ * 
+ *         if ((typeoid, PG_FORMAT_BINARY) not in self._local_type_codecs and             # <<<<<<<<<<<<<<
+ *                 (typeoid, PG_FORMAT_TEXT) not in self._local_type_codecs):
+ *             raise ValueError('unknown alias target: {}'.format(alias_to))
+ */
+  if (__pyx_t_8) {
+
+    /* "asyncpg/protocol/codecs/base.pyx":514
+ *         if ((typeoid, PG_FORMAT_BINARY) not in self._local_type_codecs and
+ *                 (typeoid, PG_FORMAT_TEXT) not in self._local_type_codecs):
+ *             raise ValueError('unknown alias target: {}'.format(alias_to))             # <<<<<<<<<<<<<<
+ * 
+ *     def clear_type_cache(self):
+ */
+    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_unknown_alias_target, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 514, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_1 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
+      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
+      if (likely(__pyx_t_1)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+        __Pyx_INCREF(__pyx_t_1);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_3, function);
+      }
+    }
+    if (!__pyx_t_1) {
+      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_alias_to); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 514, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_3)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_alias_to};
+        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 514, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __Pyx_GOTREF(__pyx_t_2);
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_alias_to};
+        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 514, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __Pyx_GOTREF(__pyx_t_2);
+      } else
+      #endif
+      {
+        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 514, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_10);
+        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_1); __pyx_t_1 = NULL;
+        __Pyx_INCREF(__pyx_v_alias_to);
+        __Pyx_GIVEREF(__pyx_v_alias_to);
+        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_alias_to);
+        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 514, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 514, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_GIVEREF(__pyx_t_2);
+    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
+    __pyx_t_2 = 0;
+    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 514, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __PYX_ERR(2, 514, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/base.pyx":512
+ *             self._local_type_codecs[typeoid, format] = codec
+ * 
+ *         if ((typeoid, PG_FORMAT_BINARY) not in self._local_type_codecs and             # <<<<<<<<<<<<<<
+ *                 (typeoid, PG_FORMAT_TEXT) not in self._local_type_codecs):
+ *             raise ValueError('unknown alias target: {}'.format(alias_to))
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/base.pyx":485
+ *                                    encoder, decoder, format)
+ * 
+ *     def set_builtin_type_codec(self, typeoid, typename, typeschema, typekind,             # <<<<<<<<<<<<<<
+ *                                alias_to):
+ *         cdef:
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.DataCodecConfig.set_builtin_type_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
+  __Pyx_XDECREF((PyObject *)__pyx_v_target_codec);
+  __Pyx_XDECREF(__pyx_v_format);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":516
+ *             raise ValueError('unknown alias target: {}'.format(alias_to))
+ * 
+ *     def clear_type_cache(self):             # <<<<<<<<<<<<<<
+ *         self._type_codecs_cache.clear()
+ * 
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_9clear_type_cache(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_9clear_type_cache(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("clear_type_cache (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig_8clear_type_cache(((struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig_8clear_type_cache(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  __Pyx_RefNannySetupContext("clear_type_cache", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":517
+ * 
+ *     def clear_type_cache(self):
+ *         self._type_codecs_cache.clear()             # <<<<<<<<<<<<<<
+ * 
+ *     cdef inline Codec get_codec(self, uint32_t oid, CodecFormat format):
+ */
+  if (unlikely(__pyx_v_self->_type_codecs_cache == Py_None)) {
+    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "clear");
+    __PYX_ERR(2, 517, __pyx_L1_error)
+  }
+  __pyx_t_1 = __Pyx_PyDict_Clear(__pyx_v_self->_type_codecs_cache); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(2, 517, __pyx_L1_error)
+
+  /* "asyncpg/protocol/codecs/base.pyx":516
+ *             raise ValueError('unknown alias target: {}'.format(alias_to))
+ * 
+ *     def clear_type_cache(self):             # <<<<<<<<<<<<<<
+ *         self._type_codecs_cache.clear()
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.DataCodecConfig.clear_type_cache", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":519
+ *         self._type_codecs_cache.clear()
+ * 
+ *     cdef inline Codec get_codec(self, uint32_t oid, CodecFormat format):             # <<<<<<<<<<<<<<
+ *         cdef Codec codec
+ * 
+ */
+
+static CYTHON_INLINE struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_15DataCodecConfig_get_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *__pyx_v_self, uint32_t __pyx_v_oid, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat __pyx_v_format) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_codec = 0;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  int __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  int __pyx_t_9;
+  PyObject *__pyx_t_10 = NULL;
+  PyObject *__pyx_t_11 = NULL;
+  PyObject *__pyx_t_12 = NULL;
+  PyObject *__pyx_t_13 = NULL;
+  PyObject *__pyx_t_14 = NULL;
+  PyObject *__pyx_t_15 = NULL;
+  __Pyx_RefNannySetupContext("get_codec", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":522
+ *         cdef Codec codec
+ * 
+ *         codec = get_core_codec(oid, format)             # <<<<<<<<<<<<<<
+ *         if codec is not None:
+ *             return codec
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_get_core_codec(__pyx_v_oid, __pyx_v_format)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 522, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_codec = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":523
+ * 
+ *         codec = get_core_codec(oid, format)
+ *         if codec is not None:             # <<<<<<<<<<<<<<
+ *             return codec
+ * 
+ */
+  __pyx_t_2 = (((PyObject *)__pyx_v_codec) != Py_None);
+  __pyx_t_3 = (__pyx_t_2 != 0);
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/codecs/base.pyx":524
+ *         codec = get_core_codec(oid, format)
+ *         if codec is not None:
+ *             return codec             # <<<<<<<<<<<<<<
+ * 
+ *         try:
+ */
+    __Pyx_XDECREF(((PyObject *)__pyx_r));
+    __Pyx_INCREF(((PyObject *)__pyx_v_codec));
+    __pyx_r = __pyx_v_codec;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":523
+ * 
+ *         codec = get_core_codec(oid, format)
+ *         if codec is not None:             # <<<<<<<<<<<<<<
+ *             return codec
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/base.pyx":526
+ *             return codec
+ * 
+ *         try:             # <<<<<<<<<<<<<<
+ *             return self._type_codecs_cache[oid, format]
+ *         except KeyError:
+ */
+  {
+    __Pyx_PyThreadState_declare
+    __Pyx_PyThreadState_assign
+    __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
+    __Pyx_XGOTREF(__pyx_t_4);
+    __Pyx_XGOTREF(__pyx_t_5);
+    __Pyx_XGOTREF(__pyx_t_6);
+    /*try:*/ {
+
+      /* "asyncpg/protocol/codecs/base.pyx":527
+ * 
+ *         try:
+ *             return self._type_codecs_cache[oid, format]             # <<<<<<<<<<<<<<
+ *         except KeyError:
+ *             try:
+ */
+      __Pyx_XDECREF(((PyObject *)__pyx_r));
+      if (unlikely(__pyx_v_self->_type_codecs_cache == Py_None)) {
+        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+        __PYX_ERR(2, 527, __pyx_L4_error)
+      }
+      __pyx_t_1 = __Pyx_PyInt_From_uint32_t(__pyx_v_oid); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 527, __pyx_L4_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_7 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_CodecFormat(__pyx_v_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 527, __pyx_L4_error)
+      __Pyx_GOTREF(__pyx_t_7);
+      __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 527, __pyx_L4_error)
+      __Pyx_GOTREF(__pyx_t_8);
+      __Pyx_GIVEREF(__pyx_t_1);
+      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
+      __Pyx_GIVEREF(__pyx_t_7);
+      PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7);
+      __pyx_t_1 = 0;
+      __pyx_t_7 = 0;
+      __pyx_t_7 = __Pyx_PyDict_GetItem(__pyx_v_self->_type_codecs_cache, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 527, __pyx_L4_error)
+      __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+      if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_7asyncpg_8protocol_8protocol_Codec))))) __PYX_ERR(2, 527, __pyx_L4_error)
+      __pyx_r = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_7);
+      __pyx_t_7 = 0;
+      goto __pyx_L8_try_return;
+
+      /* "asyncpg/protocol/codecs/base.pyx":526
+ *             return codec
+ * 
+ *         try:             # <<<<<<<<<<<<<<
+ *             return self._type_codecs_cache[oid, format]
+ *         except KeyError:
+ */
+    }
+    __pyx_L4_error:;
+    __Pyx_PyThreadState_assign
+    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":528
+ *         try:
+ *             return self._type_codecs_cache[oid, format]
+ *         except KeyError:             # <<<<<<<<<<<<<<
+ *             try:
+ *                 return self._local_type_codecs[oid, format]
+ */
+    __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
+    if (__pyx_t_9) {
+      __Pyx_AddTraceback("asyncpg.protocol.protocol.DataCodecConfig.get_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
+      if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_1) < 0) __PYX_ERR(2, 528, __pyx_L6_except_error)
+      __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_GOTREF(__pyx_t_8);
+      __Pyx_GOTREF(__pyx_t_1);
+
+      /* "asyncpg/protocol/codecs/base.pyx":529
+ *             return self._type_codecs_cache[oid, format]
+ *         except KeyError:
+ *             try:             # <<<<<<<<<<<<<<
+ *                 return self._local_type_codecs[oid, format]
+ *             except KeyError:
+ */
+      {
+        __Pyx_PyThreadState_declare
+        __Pyx_PyThreadState_assign
+        __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
+        __Pyx_XGOTREF(__pyx_t_10);
+        __Pyx_XGOTREF(__pyx_t_11);
+        __Pyx_XGOTREF(__pyx_t_12);
+        /*try:*/ {
+
+          /* "asyncpg/protocol/codecs/base.pyx":530
+ *         except KeyError:
+ *             try:
+ *                 return self._local_type_codecs[oid, format]             # <<<<<<<<<<<<<<
+ *             except KeyError:
+ *                 return None
+ */
+          __Pyx_XDECREF(((PyObject *)__pyx_r));
+          if (unlikely(__pyx_v_self->_local_type_codecs == Py_None)) {
+            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+            __PYX_ERR(2, 530, __pyx_L14_error)
+          }
+          __pyx_t_13 = __Pyx_PyInt_From_uint32_t(__pyx_v_oid); if (unlikely(!__pyx_t_13)) __PYX_ERR(2, 530, __pyx_L14_error)
+          __Pyx_GOTREF(__pyx_t_13);
+          __pyx_t_14 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_CodecFormat(__pyx_v_format); if (unlikely(!__pyx_t_14)) __PYX_ERR(2, 530, __pyx_L14_error)
+          __Pyx_GOTREF(__pyx_t_14);
+          __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(2, 530, __pyx_L14_error)
+          __Pyx_GOTREF(__pyx_t_15);
+          __Pyx_GIVEREF(__pyx_t_13);
+          PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_13);
+          __Pyx_GIVEREF(__pyx_t_14);
+          PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_14);
+          __pyx_t_13 = 0;
+          __pyx_t_14 = 0;
+          __pyx_t_14 = __Pyx_PyDict_GetItem(__pyx_v_self->_local_type_codecs, __pyx_t_15); if (unlikely(!__pyx_t_14)) __PYX_ERR(2, 530, __pyx_L14_error)
+          __Pyx_GOTREF(__pyx_t_14);
+          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+          if (!(likely(((__pyx_t_14) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_14, __pyx_ptype_7asyncpg_8protocol_8protocol_Codec))))) __PYX_ERR(2, 530, __pyx_L14_error)
+          __pyx_r = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_14);
+          __pyx_t_14 = 0;
+          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+          goto __pyx_L18_try_return;
+
+          /* "asyncpg/protocol/codecs/base.pyx":529
+ *             return self._type_codecs_cache[oid, format]
+ *         except KeyError:
+ *             try:             # <<<<<<<<<<<<<<
+ *                 return self._local_type_codecs[oid, format]
+ *             except KeyError:
+ */
+        }
+        __pyx_L14_error:;
+        __Pyx_PyThreadState_assign
+        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
+        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
+        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
+
+        /* "asyncpg/protocol/codecs/base.pyx":531
+ *             try:
+ *                 return self._local_type_codecs[oid, format]
+ *             except KeyError:             # <<<<<<<<<<<<<<
+ *                 return None
+ * 
+ */
+        __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
+        if (__pyx_t_9) {
+          __Pyx_AddTraceback("asyncpg.protocol.protocol.DataCodecConfig.get_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
+          if (__Pyx_GetException(&__pyx_t_14, &__pyx_t_15, &__pyx_t_13) < 0) __PYX_ERR(2, 531, __pyx_L16_except_error)
+          __Pyx_GOTREF(__pyx_t_14);
+          __Pyx_GOTREF(__pyx_t_15);
+          __Pyx_GOTREF(__pyx_t_13);
+
+          /* "asyncpg/protocol/codecs/base.pyx":532
+ *                 return self._local_type_codecs[oid, format]
+ *             except KeyError:
+ *                 return None             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+          __Pyx_XDECREF(((PyObject *)__pyx_r));
+          __Pyx_INCREF(Py_None);
+          __pyx_r = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)Py_None);
+          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+          goto __pyx_L17_except_return;
+        }
+        goto __pyx_L16_except_error;
+        __pyx_L16_except_error:;
+
+        /* "asyncpg/protocol/codecs/base.pyx":529
+ *             return self._type_codecs_cache[oid, format]
+ *         except KeyError:
+ *             try:             # <<<<<<<<<<<<<<
+ *                 return self._local_type_codecs[oid, format]
+ *             except KeyError:
+ */
+        __Pyx_PyThreadState_assign
+        __Pyx_XGIVEREF(__pyx_t_10);
+        __Pyx_XGIVEREF(__pyx_t_11);
+        __Pyx_XGIVEREF(__pyx_t_12);
+        __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
+        goto __pyx_L6_except_error;
+        __pyx_L18_try_return:;
+        __Pyx_PyThreadState_assign
+        __Pyx_XGIVEREF(__pyx_t_10);
+        __Pyx_XGIVEREF(__pyx_t_11);
+        __Pyx_XGIVEREF(__pyx_t_12);
+        __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
+        goto __pyx_L7_except_return;
+        __pyx_L17_except_return:;
+        __Pyx_PyThreadState_assign
+        __Pyx_XGIVEREF(__pyx_t_10);
+        __Pyx_XGIVEREF(__pyx_t_11);
+        __Pyx_XGIVEREF(__pyx_t_12);
+        __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
+        goto __pyx_L7_except_return;
+      }
+    }
+    goto __pyx_L6_except_error;
+    __pyx_L6_except_error:;
+
+    /* "asyncpg/protocol/codecs/base.pyx":526
+ *             return codec
+ * 
+ *         try:             # <<<<<<<<<<<<<<
+ *             return self._type_codecs_cache[oid, format]
+ *         except KeyError:
+ */
+    __Pyx_PyThreadState_assign
+    __Pyx_XGIVEREF(__pyx_t_4);
+    __Pyx_XGIVEREF(__pyx_t_5);
+    __Pyx_XGIVEREF(__pyx_t_6);
+    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
+    goto __pyx_L1_error;
+    __pyx_L8_try_return:;
+    __Pyx_PyThreadState_assign
+    __Pyx_XGIVEREF(__pyx_t_4);
+    __Pyx_XGIVEREF(__pyx_t_5);
+    __Pyx_XGIVEREF(__pyx_t_6);
+    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
+    goto __pyx_L0;
+    __pyx_L7_except_return:;
+    __Pyx_PyThreadState_assign
+    __Pyx_XGIVEREF(__pyx_t_4);
+    __Pyx_XGIVEREF(__pyx_t_5);
+    __Pyx_XGIVEREF(__pyx_t_6);
+    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
+    goto __pyx_L0;
+  }
+
+  /* "asyncpg/protocol/codecs/base.pyx":519
+ *         self._type_codecs_cache.clear()
+ * 
+ *     cdef inline Codec get_codec(self, uint32_t oid, CodecFormat format):             # <<<<<<<<<<<<<<
+ *         cdef Codec codec
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_13);
+  __Pyx_XDECREF(__pyx_t_14);
+  __Pyx_XDECREF(__pyx_t_15);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.DataCodecConfig.get_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
+  __Pyx_XGIVEREF((PyObject *)__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":535
+ * 
+ * 
+ * cdef inline Codec get_core_codec(uint32_t oid, CodecFormat format):             # <<<<<<<<<<<<<<
+ *     cdef void *ptr
+ *     if oid > MAXSUPPORTEDOID:
+ */
+
+static CYTHON_INLINE struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_get_core_codec(uint32_t __pyx_v_oid, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat __pyx_v_format) {
+  void *__pyx_v_ptr;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  __Pyx_RefNannySetupContext("get_core_codec", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":537
+ * cdef inline Codec get_core_codec(uint32_t oid, CodecFormat format):
+ *     cdef void *ptr
+ *     if oid > MAXSUPPORTEDOID:             # <<<<<<<<<<<<<<
+ *         return None
+ *     if format == PG_FORMAT_BINARY:
+ */
+  __pyx_t_1 = ((__pyx_v_oid > 0x1000) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/base.pyx":538
+ *     cdef void *ptr
+ *     if oid > MAXSUPPORTEDOID:
+ *         return None             # <<<<<<<<<<<<<<
+ *     if format == PG_FORMAT_BINARY:
+ *         ptr = binary_codec_map[oid]
+ */
+    __Pyx_XDECREF(((PyObject *)__pyx_r));
+    __Pyx_INCREF(Py_None);
+    __pyx_r = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)Py_None);
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":537
+ * cdef inline Codec get_core_codec(uint32_t oid, CodecFormat format):
+ *     cdef void *ptr
+ *     if oid > MAXSUPPORTEDOID:             # <<<<<<<<<<<<<<
+ *         return None
+ *     if format == PG_FORMAT_BINARY:
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/base.pyx":539
+ *     if oid > MAXSUPPORTEDOID:
+ *         return None
+ *     if format == PG_FORMAT_BINARY:             # <<<<<<<<<<<<<<
+ *         ptr = binary_codec_map[oid]
+ *     else:
+ */
+  __pyx_t_1 = ((__pyx_v_format == __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/base.pyx":540
+ *         return None
+ *     if format == PG_FORMAT_BINARY:
+ *         ptr = binary_codec_map[oid]             # <<<<<<<<<<<<<<
+ *     else:
+ *         ptr = text_codec_map[oid]
+ */
+    __pyx_v_ptr = (__pyx_v_7asyncpg_8protocol_8protocol_binary_codec_map[__pyx_v_oid]);
+
+    /* "asyncpg/protocol/codecs/base.pyx":539
+ *     if oid > MAXSUPPORTEDOID:
+ *         return None
+ *     if format == PG_FORMAT_BINARY:             # <<<<<<<<<<<<<<
+ *         ptr = binary_codec_map[oid]
+ *     else:
+ */
+    goto __pyx_L4;
+  }
+
+  /* "asyncpg/protocol/codecs/base.pyx":542
+ *         ptr = binary_codec_map[oid]
+ *     else:
+ *         ptr = text_codec_map[oid]             # <<<<<<<<<<<<<<
+ *     if ptr is NULL:
+ *         return None
+ */
+  /*else*/ {
+    __pyx_v_ptr = (__pyx_v_7asyncpg_8protocol_8protocol_text_codec_map[__pyx_v_oid]);
+  }
+  __pyx_L4:;
+
+  /* "asyncpg/protocol/codecs/base.pyx":543
+ *     else:
+ *         ptr = text_codec_map[oid]
+ *     if ptr is NULL:             # <<<<<<<<<<<<<<
+ *         return None
+ *     return <Codec>ptr
+ */
+  __pyx_t_1 = ((__pyx_v_ptr == NULL) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/base.pyx":544
+ *         ptr = text_codec_map[oid]
+ *     if ptr is NULL:
+ *         return None             # <<<<<<<<<<<<<<
+ *     return <Codec>ptr
+ * 
+ */
+    __Pyx_XDECREF(((PyObject *)__pyx_r));
+    __Pyx_INCREF(Py_None);
+    __pyx_r = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)Py_None);
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":543
+ *     else:
+ *         ptr = text_codec_map[oid]
+ *     if ptr is NULL:             # <<<<<<<<<<<<<<
+ *         return None
+ *     return <Codec>ptr
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/base.pyx":545
+ *     if ptr is NULL:
+ *         return None
+ *     return <Codec>ptr             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(((PyObject *)__pyx_r));
+  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_v_ptr)));
+  __pyx_r = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_v_ptr);
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":535
+ * 
+ * 
+ * cdef inline Codec get_core_codec(uint32_t oid, CodecFormat format):             # <<<<<<<<<<<<<<
+ *     cdef void *ptr
+ *     if oid > MAXSUPPORTEDOID:
+ */
+
+  /* function exit code */
+  __pyx_L0:;
+  __Pyx_XGIVEREF((PyObject *)__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":548
+ * 
+ * 
+ * cdef inline int has_core_codec(uint32_t oid):             # <<<<<<<<<<<<<<
+ *     return binary_codec_map[oid] != NULL or text_codec_map[oid] != NULL
+ * 
+ */
+
+static CYTHON_INLINE int __pyx_f_7asyncpg_8protocol_8protocol_has_core_codec(uint32_t __pyx_v_oid) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  __Pyx_RefNannySetupContext("has_core_codec", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":549
+ * 
+ * cdef inline int has_core_codec(uint32_t oid):
+ *     return binary_codec_map[oid] != NULL or text_codec_map[oid] != NULL             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_2 = ((__pyx_v_7asyncpg_8protocol_8protocol_binary_codec_map[__pyx_v_oid]) != NULL);
+  if (!__pyx_t_2) {
+  } else {
+    __pyx_t_1 = __pyx_t_2;
+    goto __pyx_L3_bool_binop_done;
+  }
+  __pyx_t_2 = ((__pyx_v_7asyncpg_8protocol_8protocol_text_codec_map[__pyx_v_oid]) != NULL);
+  __pyx_t_1 = __pyx_t_2;
+  __pyx_L3_bool_binop_done:;
+  __pyx_r = __pyx_t_1;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":548
+ * 
+ * 
+ * cdef inline int has_core_codec(uint32_t oid):             # <<<<<<<<<<<<<<
+ *     return binary_codec_map[oid] != NULL or text_codec_map[oid] != NULL
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":552
+ * 
+ * 
+ * cdef register_core_codec(uint32_t oid,             # <<<<<<<<<<<<<<
+ *                          encode_func encode,
+ *                          decode_func decode,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(uint32_t __pyx_v_oid, __pyx_t_7asyncpg_8protocol_8protocol_encode_func __pyx_v_encode, __pyx_t_7asyncpg_8protocol_8protocol_decode_func __pyx_v_decode, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat __pyx_v_format) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_codec = 0;
+  PyObject *__pyx_v_name = 0;
+  PyObject *__pyx_v_kind = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  int __pyx_t_6;
+  PyObject *__pyx_t_7 = NULL;
+  __Pyx_RefNannySetupContext("register_core_codec", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":557
+ *                          CodecFormat format):
+ * 
+ *     if oid > MAXSUPPORTEDOID:             # <<<<<<<<<<<<<<
+ *         raise RuntimeError(
+ *             'cannot register core codec for OID {}: it is greater '
+ */
+  __pyx_t_1 = ((__pyx_v_oid > 0x1000) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/base.pyx":560
+ *         raise RuntimeError(
+ *             'cannot register core codec for OID {}: it is greater '
+ *             'than MAXSUPPORTEDOID ({})'.format(oid, MAXSUPPORTEDOID))             # <<<<<<<<<<<<<<
+ * 
+ *     cdef:
+ */
+    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_cannot_register_core_codec_for_O, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 560, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_4 = __Pyx_PyInt_From_uint32_t(__pyx_v_oid); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 560, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = NULL;
+    __pyx_t_6 = 0;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
+      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
+      if (likely(__pyx_t_5)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+        __Pyx_INCREF(__pyx_t_5);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_3, function);
+        __pyx_t_6 = 1;
+      }
+    }
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_3)) {
+      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_4, __pyx_int_4096};
+      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 560, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
+      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_4, __pyx_int_4096};
+      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 560, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    } else
+    #endif
+    {
+      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 560, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_7);
+      if (__pyx_t_5) {
+        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
+      }
+      __Pyx_GIVEREF(__pyx_t_4);
+      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_4);
+      __Pyx_INCREF(__pyx_int_4096);
+      __Pyx_GIVEREF(__pyx_int_4096);
+      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_int_4096);
+      __pyx_t_4 = 0;
+      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 560, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/codecs/base.pyx":558
+ * 
+ *     if oid > MAXSUPPORTEDOID:
+ *         raise RuntimeError(             # <<<<<<<<<<<<<<
+ *             'cannot register core codec for OID {}: it is greater '
+ *             'than MAXSUPPORTEDOID ({})'.format(oid, MAXSUPPORTEDOID))
+ */
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 558, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_GIVEREF(__pyx_t_2);
+    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
+    __pyx_t_2 = 0;
+    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 558, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __PYX_ERR(2, 558, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/base.pyx":557
+ *                          CodecFormat format):
+ * 
+ *     if oid > MAXSUPPORTEDOID:             # <<<<<<<<<<<<<<
+ *         raise RuntimeError(
+ *             'cannot register core codec for OID {}: it is greater '
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/base.pyx":567
+ *         str kind
+ * 
+ *     name = TYPEMAP[oid]             # <<<<<<<<<<<<<<
+ *     kind = 'array' if oid in ARRAY_TYPES else 'scalar'
+ * 
+ */
+  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_TYPEMAP); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 567, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, __pyx_v_oid, uint32_t, 0, __Pyx_PyInt_From_uint32_t, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 567, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (!(likely(PyUnicode_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(2, 567, __pyx_L1_error)
+  __pyx_v_name = ((PyObject*)__pyx_t_3);
+  __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":568
+ * 
+ *     name = TYPEMAP[oid]
+ *     kind = 'array' if oid in ARRAY_TYPES else 'scalar'             # <<<<<<<<<<<<<<
+ * 
+ *     codec = Codec(oid)
+ */
+  __pyx_t_2 = __Pyx_PyInt_From_uint32_t(__pyx_v_oid); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 568, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_t_2, __pyx_v_7asyncpg_8protocol_8protocol_ARRAY_TYPES, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 568, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if ((__pyx_t_1 != 0)) {
+    __Pyx_INCREF(__pyx_n_u_array);
+    __pyx_t_3 = __pyx_n_u_array;
+  } else {
+    __Pyx_INCREF(__pyx_n_u_scalar);
+    __pyx_t_3 = __pyx_n_u_scalar;
+  }
+  __pyx_v_kind = ((PyObject*)__pyx_t_3);
+  __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":570
+ *     kind = 'array' if oid in ARRAY_TYPES else 'scalar'
+ * 
+ *     codec = Codec(oid)             # <<<<<<<<<<<<<<
+ *     codec.init(name, 'pg_catalog', kind, CODEC_C, format, encode,
+ *                decode, None, None, None, None, None, None, 0)
+ */
+  __pyx_t_3 = __Pyx_PyInt_From_uint32_t(__pyx_v_oid); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 570, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 570, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_3);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
+  __pyx_t_3 = 0;
+  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_Codec), __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 570, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_v_codec = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_3);
+  __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":571
+ * 
+ *     codec = Codec(oid)
+ *     codec.init(name, 'pg_catalog', kind, CODEC_C, format, encode,             # <<<<<<<<<<<<<<
+ *                decode, None, None, None, None, None, None, 0)
+ *     cpython.Py_INCREF(codec)  # immortalize
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_init(__pyx_v_codec, __pyx_v_name, __pyx_n_u_pg_catalog, __pyx_v_kind, __pyx_e_7asyncpg_8protocol_8protocol_CODEC_C, __pyx_v_format, __pyx_v_encode, __pyx_v_decode, Py_None, Py_None, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)Py_None), ((PyObject*)Py_None), Py_None, ((PyObject*)Py_None), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 571, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":573
+ *     codec.init(name, 'pg_catalog', kind, CODEC_C, format, encode,
+ *                decode, None, None, None, None, None, None, 0)
+ *     cpython.Py_INCREF(codec)  # immortalize             # <<<<<<<<<<<<<<
+ * 
+ *     if format == PG_FORMAT_BINARY:
+ */
+  Py_INCREF(((PyObject *)__pyx_v_codec));
+
+  /* "asyncpg/protocol/codecs/base.pyx":575
+ *     cpython.Py_INCREF(codec)  # immortalize
+ * 
+ *     if format == PG_FORMAT_BINARY:             # <<<<<<<<<<<<<<
+ *         binary_codec_map[oid] = <void*>codec
+ *     else:
+ */
+  __pyx_t_1 = ((__pyx_v_format == __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/base.pyx":576
+ * 
+ *     if format == PG_FORMAT_BINARY:
+ *         binary_codec_map[oid] = <void*>codec             # <<<<<<<<<<<<<<
+ *     else:
+ *         text_codec_map[oid] = <void*>codec
+ */
+    (__pyx_v_7asyncpg_8protocol_8protocol_binary_codec_map[__pyx_v_oid]) = ((void *)__pyx_v_codec);
+
+    /* "asyncpg/protocol/codecs/base.pyx":575
+ *     cpython.Py_INCREF(codec)  # immortalize
+ * 
+ *     if format == PG_FORMAT_BINARY:             # <<<<<<<<<<<<<<
+ *         binary_codec_map[oid] = <void*>codec
+ *     else:
+ */
+    goto __pyx_L4;
+  }
+
+  /* "asyncpg/protocol/codecs/base.pyx":578
+ *         binary_codec_map[oid] = <void*>codec
+ *     else:
+ *         text_codec_map[oid] = <void*>codec             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  /*else*/ {
+    (__pyx_v_7asyncpg_8protocol_8protocol_text_codec_map[__pyx_v_oid]) = ((void *)__pyx_v_codec);
+  }
+  __pyx_L4:;
+
+  /* "asyncpg/protocol/codecs/base.pyx":552
+ * 
+ * 
+ * cdef register_core_codec(uint32_t oid,             # <<<<<<<<<<<<<<
+ *                          encode_func encode,
+ *                          decode_func decode,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.register_core_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
+  __Pyx_XDECREF(__pyx_v_name);
+  __Pyx_XDECREF(__pyx_v_kind);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":581
+ * 
+ * 
+ * cdef register_extra_codec(str name,             # <<<<<<<<<<<<<<
+ *                           encode_func encode,
+ *                           decode_func decode,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_register_extra_codec(PyObject *__pyx_v_name, __pyx_t_7asyncpg_8protocol_8protocol_encode_func __pyx_v_encode, __pyx_t_7asyncpg_8protocol_8protocol_decode_func __pyx_v_decode, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat __pyx_v_format) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_codec = 0;
+  PyObject *__pyx_v_kind = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("register_extra_codec", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":589
+ *         str kind
+ * 
+ *     kind = 'scalar'             # <<<<<<<<<<<<<<
+ * 
+ *     codec = Codec(INVALIDOID)
+ */
+  __Pyx_INCREF(__pyx_n_u_scalar);
+  __pyx_v_kind = __pyx_n_u_scalar;
+
+  /* "asyncpg/protocol/codecs/base.pyx":591
+ *     kind = 'scalar'
+ * 
+ *     codec = Codec(INVALIDOID)             # <<<<<<<<<<<<<<
+ *     codec.init(name, None, kind, CODEC_C, format, encode,
+ *                decode, None, None, None, None, None, None, 0)
+ */
+  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_Codec), __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 591, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_codec = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":592
+ * 
+ *     codec = Codec(INVALIDOID)
+ *     codec.init(name, None, kind, CODEC_C, format, encode,             # <<<<<<<<<<<<<<
+ *                decode, None, None, None, None, None, None, 0)
+ *     EXTRA_CODECS[name, format] = codec
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_init(__pyx_v_codec, __pyx_v_name, ((PyObject*)Py_None), __pyx_v_kind, __pyx_e_7asyncpg_8protocol_8protocol_CODEC_C, __pyx_v_format, __pyx_v_encode, __pyx_v_decode, Py_None, Py_None, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)Py_None), ((PyObject*)Py_None), Py_None, ((PyObject*)Py_None), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 592, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":594
+ *     codec.init(name, None, kind, CODEC_C, format, encode,
+ *                decode, None, None, None, None, None, None, 0)
+ *     EXTRA_CODECS[name, format] = codec             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  if (unlikely(__pyx_v_7asyncpg_8protocol_8protocol_EXTRA_CODECS == Py_None)) {
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+    __PYX_ERR(2, 594, __pyx_L1_error)
+  }
+  __pyx_t_1 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_CodecFormat(__pyx_v_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 594, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 594, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_v_name);
+  __Pyx_GIVEREF(__pyx_v_name);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_name);
+  __Pyx_GIVEREF(__pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
+  __pyx_t_1 = 0;
+  if (unlikely(PyDict_SetItem(__pyx_v_7asyncpg_8protocol_8protocol_EXTRA_CODECS, __pyx_t_2, ((PyObject *)__pyx_v_codec)) < 0)) __PYX_ERR(2, 594, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":581
+ * 
+ * 
+ * cdef register_extra_codec(str name,             # <<<<<<<<<<<<<<
+ *                           encode_func encode,
+ *                           decode_func decode,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.register_extra_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
+  __Pyx_XDECREF(__pyx_v_kind);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/base.pyx":597
+ * 
+ * 
+ * cdef inline Codec get_extra_codec(str name, CodecFormat format):             # <<<<<<<<<<<<<<
+ *     return EXTRA_CODECS.get((name, format))
+ */
+
+static CYTHON_INLINE struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_get_extra_codec(PyObject *__pyx_v_name, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat __pyx_v_format) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("get_extra_codec", 0);
+
+  /* "asyncpg/protocol/codecs/base.pyx":598
+ * 
+ * cdef inline Codec get_extra_codec(str name, CodecFormat format):
+ *     return EXTRA_CODECS.get((name, format))             # <<<<<<<<<<<<<<
+ */
+  __Pyx_XDECREF(((PyObject *)__pyx_r));
+  if (unlikely(__pyx_v_7asyncpg_8protocol_8protocol_EXTRA_CODECS == Py_None)) {
+    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
+    __PYX_ERR(2, 598, __pyx_L1_error)
+  }
+  __pyx_t_1 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_CodecFormat(__pyx_v_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 598, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 598, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_v_name);
+  __Pyx_GIVEREF(__pyx_v_name);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_name);
+  __Pyx_GIVEREF(__pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
+  __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(__pyx_v_7asyncpg_8protocol_8protocol_EXTRA_CODECS, __pyx_t_2, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 598, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7asyncpg_8protocol_8protocol_Codec))))) __PYX_ERR(2, 598, __pyx_L1_error)
+  __pyx_r = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_1);
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":597
+ * 
+ * 
+ * cdef inline Codec get_extra_codec(str name, CodecFormat format):             # <<<<<<<<<<<<<<
+ *     return EXTRA_CODECS.get((name, format))
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.get_extra_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF((PyObject *)__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/textutils.pyx":9
+ * 
+ * 
+ * cdef int apg_strcasecmp(const Py_UCS4 *s1, const Py_UCS4 *s2):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         uint32_t c1
+ */
+
+static int __pyx_f_7asyncpg_8protocol_8protocol_apg_strcasecmp(Py_UCS4 const *__pyx_v_s1, Py_UCS4 const *__pyx_v_s2) {
+  uint32_t __pyx_v_c1;
+  uint32_t __pyx_v_c2;
+  int __pyx_v_i;
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  __Pyx_RefNannySetupContext("apg_strcasecmp", 0);
+
+  /* "asyncpg/protocol/codecs/textutils.pyx":13
+ *         uint32_t c1
+ *         uint32_t c2
+ *         int i = 0             # <<<<<<<<<<<<<<
+ * 
+ *     while True:
+ */
+  __pyx_v_i = 0;
+
+  /* "asyncpg/protocol/codecs/textutils.pyx":15
+ *         int i = 0
+ * 
+ *     while True:             # <<<<<<<<<<<<<<
+ *         c1 = s1[i]
+ *         c2 = s2[i]
+ */
+  while (1) {
+
+    /* "asyncpg/protocol/codecs/textutils.pyx":16
+ * 
+ *     while True:
+ *         c1 = s1[i]             # <<<<<<<<<<<<<<
+ *         c2 = s2[i]
+ * 
+ */
+    __pyx_v_c1 = (__pyx_v_s1[__pyx_v_i]);
+
+    /* "asyncpg/protocol/codecs/textutils.pyx":17
+ *     while True:
+ *         c1 = s1[i]
+ *         c2 = s2[i]             # <<<<<<<<<<<<<<
+ * 
+ *         if c1 != c2:
+ */
+    __pyx_v_c2 = (__pyx_v_s2[__pyx_v_i]);
+
+    /* "asyncpg/protocol/codecs/textutils.pyx":19
+ *         c2 = s2[i]
+ * 
+ *         if c1 != c2:             # <<<<<<<<<<<<<<
+ *             if c1 >= <uint32_t><Py_UCS4>'A' and c1 <= <uint32_t><Py_UCS4>'Z':
+ *                 c1 += <uint32_t><Py_UCS4>'a' - <uint32_t><Py_UCS4>'A'
+ */
+    __pyx_t_1 = ((__pyx_v_c1 != __pyx_v_c2) != 0);
+    if (__pyx_t_1) {
+
+      /* "asyncpg/protocol/codecs/textutils.pyx":20
+ * 
+ *         if c1 != c2:
+ *             if c1 >= <uint32_t><Py_UCS4>'A' and c1 <= <uint32_t><Py_UCS4>'Z':             # <<<<<<<<<<<<<<
+ *                 c1 += <uint32_t><Py_UCS4>'a' - <uint32_t><Py_UCS4>'A'
+ *             if c2 >= <uint32_t><Py_UCS4>'A' and c2 <= <uint32_t><Py_UCS4>'Z':
+ */
+      __pyx_t_2 = ((__pyx_v_c1 >= ((uint32_t)((Py_UCS4)65))) != 0);
+      if (__pyx_t_2) {
+      } else {
+        __pyx_t_1 = __pyx_t_2;
+        goto __pyx_L7_bool_binop_done;
+      }
+      __pyx_t_2 = ((__pyx_v_c1 <= ((uint32_t)((Py_UCS4)90))) != 0);
+      __pyx_t_1 = __pyx_t_2;
+      __pyx_L7_bool_binop_done:;
+      if (__pyx_t_1) {
+
+        /* "asyncpg/protocol/codecs/textutils.pyx":21
+ *         if c1 != c2:
+ *             if c1 >= <uint32_t><Py_UCS4>'A' and c1 <= <uint32_t><Py_UCS4>'Z':
+ *                 c1 += <uint32_t><Py_UCS4>'a' - <uint32_t><Py_UCS4>'A'             # <<<<<<<<<<<<<<
+ *             if c2 >= <uint32_t><Py_UCS4>'A' and c2 <= <uint32_t><Py_UCS4>'Z':
+ *                 c2 += <uint32_t><Py_UCS4>'a' - <uint32_t><Py_UCS4>'A'
+ */
+        __pyx_v_c1 = (__pyx_v_c1 + (((uint32_t)((Py_UCS4)97)) - ((uint32_t)((Py_UCS4)65))));
+
+        /* "asyncpg/protocol/codecs/textutils.pyx":20
+ * 
+ *         if c1 != c2:
+ *             if c1 >= <uint32_t><Py_UCS4>'A' and c1 <= <uint32_t><Py_UCS4>'Z':             # <<<<<<<<<<<<<<
+ *                 c1 += <uint32_t><Py_UCS4>'a' - <uint32_t><Py_UCS4>'A'
+ *             if c2 >= <uint32_t><Py_UCS4>'A' and c2 <= <uint32_t><Py_UCS4>'Z':
+ */
+      }
+
+      /* "asyncpg/protocol/codecs/textutils.pyx":22
+ *             if c1 >= <uint32_t><Py_UCS4>'A' and c1 <= <uint32_t><Py_UCS4>'Z':
+ *                 c1 += <uint32_t><Py_UCS4>'a' - <uint32_t><Py_UCS4>'A'
+ *             if c2 >= <uint32_t><Py_UCS4>'A' and c2 <= <uint32_t><Py_UCS4>'Z':             # <<<<<<<<<<<<<<
+ *                 c2 += <uint32_t><Py_UCS4>'a' - <uint32_t><Py_UCS4>'A'
+ * 
+ */
+      __pyx_t_2 = ((__pyx_v_c2 >= ((uint32_t)((Py_UCS4)65))) != 0);
+      if (__pyx_t_2) {
+      } else {
+        __pyx_t_1 = __pyx_t_2;
+        goto __pyx_L10_bool_binop_done;
+      }
+      __pyx_t_2 = ((__pyx_v_c2 <= ((uint32_t)((Py_UCS4)90))) != 0);
+      __pyx_t_1 = __pyx_t_2;
+      __pyx_L10_bool_binop_done:;
+      if (__pyx_t_1) {
+
+        /* "asyncpg/protocol/codecs/textutils.pyx":23
+ *                 c1 += <uint32_t><Py_UCS4>'a' - <uint32_t><Py_UCS4>'A'
+ *             if c2 >= <uint32_t><Py_UCS4>'A' and c2 <= <uint32_t><Py_UCS4>'Z':
+ *                 c2 += <uint32_t><Py_UCS4>'a' - <uint32_t><Py_UCS4>'A'             # <<<<<<<<<<<<<<
+ * 
+ *             if c1 != c2:
+ */
+        __pyx_v_c2 = (__pyx_v_c2 + (((uint32_t)((Py_UCS4)97)) - ((uint32_t)((Py_UCS4)65))));
+
+        /* "asyncpg/protocol/codecs/textutils.pyx":22
+ *             if c1 >= <uint32_t><Py_UCS4>'A' and c1 <= <uint32_t><Py_UCS4>'Z':
+ *                 c1 += <uint32_t><Py_UCS4>'a' - <uint32_t><Py_UCS4>'A'
+ *             if c2 >= <uint32_t><Py_UCS4>'A' and c2 <= <uint32_t><Py_UCS4>'Z':             # <<<<<<<<<<<<<<
+ *                 c2 += <uint32_t><Py_UCS4>'a' - <uint32_t><Py_UCS4>'A'
+ * 
+ */
+      }
+
+      /* "asyncpg/protocol/codecs/textutils.pyx":25
+ *                 c2 += <uint32_t><Py_UCS4>'a' - <uint32_t><Py_UCS4>'A'
+ * 
+ *             if c1 != c2:             # <<<<<<<<<<<<<<
+ *                 return <int32_t>c1 - <int32_t>c2
+ * 
+ */
+      __pyx_t_1 = ((__pyx_v_c1 != __pyx_v_c2) != 0);
+      if (__pyx_t_1) {
+
+        /* "asyncpg/protocol/codecs/textutils.pyx":26
+ * 
+ *             if c1 != c2:
+ *                 return <int32_t>c1 - <int32_t>c2             # <<<<<<<<<<<<<<
+ * 
+ *         if c1 == 0 or c2 == 0:
+ */
+        __pyx_r = (((int32_t)__pyx_v_c1) - ((int32_t)__pyx_v_c2));
+        goto __pyx_L0;
+
+        /* "asyncpg/protocol/codecs/textutils.pyx":25
+ *                 c2 += <uint32_t><Py_UCS4>'a' - <uint32_t><Py_UCS4>'A'
+ * 
+ *             if c1 != c2:             # <<<<<<<<<<<<<<
+ *                 return <int32_t>c1 - <int32_t>c2
+ * 
+ */
+      }
+
+      /* "asyncpg/protocol/codecs/textutils.pyx":19
+ *         c2 = s2[i]
+ * 
+ *         if c1 != c2:             # <<<<<<<<<<<<<<
+ *             if c1 >= <uint32_t><Py_UCS4>'A' and c1 <= <uint32_t><Py_UCS4>'Z':
+ *                 c1 += <uint32_t><Py_UCS4>'a' - <uint32_t><Py_UCS4>'A'
+ */
+    }
+
+    /* "asyncpg/protocol/codecs/textutils.pyx":28
+ *                 return <int32_t>c1 - <int32_t>c2
+ * 
+ *         if c1 == 0 or c2 == 0:             # <<<<<<<<<<<<<<
+ *             break
+ * 
+ */
+    __pyx_t_2 = ((__pyx_v_c1 == 0) != 0);
+    if (!__pyx_t_2) {
+    } else {
+      __pyx_t_1 = __pyx_t_2;
+      goto __pyx_L14_bool_binop_done;
+    }
+    __pyx_t_2 = ((__pyx_v_c2 == 0) != 0);
+    __pyx_t_1 = __pyx_t_2;
+    __pyx_L14_bool_binop_done:;
+    if (__pyx_t_1) {
+
+      /* "asyncpg/protocol/codecs/textutils.pyx":29
+ * 
+ *         if c1 == 0 or c2 == 0:
+ *             break             # <<<<<<<<<<<<<<
+ * 
+ *         i += 1
+ */
+      goto __pyx_L4_break;
+
+      /* "asyncpg/protocol/codecs/textutils.pyx":28
+ *                 return <int32_t>c1 - <int32_t>c2
+ * 
+ *         if c1 == 0 or c2 == 0:             # <<<<<<<<<<<<<<
+ *             break
+ * 
+ */
+    }
+
+    /* "asyncpg/protocol/codecs/textutils.pyx":31
+ *             break
+ * 
+ *         i += 1             # <<<<<<<<<<<<<<
+ * 
+ *     return 0
+ */
+    __pyx_v_i = (__pyx_v_i + 1);
+  }
+  __pyx_L4_break:;
+
+  /* "asyncpg/protocol/codecs/textutils.pyx":33
+ *         i += 1
+ * 
+ *     return 0             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_r = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/textutils.pyx":9
+ * 
+ * 
+ * cdef int apg_strcasecmp(const Py_UCS4 *s1, const Py_UCS4 *s2):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         uint32_t c1
+ */
+
+  /* function exit code */
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/textutils.pyx":36
+ * 
+ * 
+ * cdef inline bint apg_ascii_isspace(Py_UCS4 ch):             # <<<<<<<<<<<<<<
+ *     return (
+ *         ch == ' ' or
+ */
+
+static CYTHON_INLINE int __pyx_f_7asyncpg_8protocol_8protocol_apg_ascii_isspace(Py_UCS4 __pyx_v_ch) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  __Pyx_RefNannySetupContext("apg_ascii_isspace", 0);
+
+  /* "asyncpg/protocol/codecs/textutils.pyx":38
+ * cdef inline bint apg_ascii_isspace(Py_UCS4 ch):
+ *     return (
+ *         ch == ' ' or             # <<<<<<<<<<<<<<
+ *         ch == '\n' or
+ *         ch == '\r' or
+ */
+  switch (__pyx_v_ch) {
+    case 32:
+
+    /* "asyncpg/protocol/codecs/textutils.pyx":39
+ *     return (
+ *         ch == ' ' or
+ *         ch == '\n' or             # <<<<<<<<<<<<<<
+ *         ch == '\r' or
+ *         ch == '\t' or
+ */
+    case 10:
+
+    /* "asyncpg/protocol/codecs/textutils.pyx":40
+ *         ch == ' ' or
+ *         ch == '\n' or
+ *         ch == '\r' or             # <<<<<<<<<<<<<<
+ *         ch == '\t' or
+ *         ch == '\v' or
+ */
+    case 13:
+
+    /* "asyncpg/protocol/codecs/textutils.pyx":41
+ *         ch == '\n' or
+ *         ch == '\r' or
+ *         ch == '\t' or             # <<<<<<<<<<<<<<
+ *         ch == '\v' or
+ *         ch == '\f'
+ */
+    case 9:
+
+    /* "asyncpg/protocol/codecs/textutils.pyx":42
+ *         ch == '\r' or
+ *         ch == '\t' or
+ *         ch == '\v' or             # <<<<<<<<<<<<<<
+ *         ch == '\f'
+ *     )
+ */
+    case 11:
+
+    /* "asyncpg/protocol/codecs/textutils.pyx":43
+ *         ch == '\t' or
+ *         ch == '\v' or
+ *         ch == '\f'             # <<<<<<<<<<<<<<
+ *     )
+ * 
+ */
+    case 12:
+
+    /* "asyncpg/protocol/codecs/textutils.pyx":38
+ * cdef inline bint apg_ascii_isspace(Py_UCS4 ch):
+ *     return (
+ *         ch == ' ' or             # <<<<<<<<<<<<<<
+ *         ch == '\n' or
+ *         ch == '\r' or
+ */
+    __pyx_t_1 = 1;
+    break;
+    default:
+    __pyx_t_1 = 0;
+    break;
+  }
+  __pyx_r = __pyx_t_1;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/textutils.pyx":36
+ * 
+ * 
+ * cdef inline bint apg_ascii_isspace(Py_UCS4 ch):             # <<<<<<<<<<<<<<
+ *     return (
+ *         ch == ' ' or
+ */
+
+  /* function exit code */
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/textutils.pyx":47
+ * 
+ * 
+ * cdef Py_UCS4 *apg_parse_int32(Py_UCS4 *buf, int32_t *num):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         Py_UCS4 *p
+ */
+
+static Py_UCS4 *__pyx_f_7asyncpg_8protocol_8protocol_apg_parse_int32(Py_UCS4 *__pyx_v_buf, int32_t *__pyx_v_num) {
+  Py_UCS4 *__pyx_v_p;
+  int32_t __pyx_v_n;
+  int32_t __pyx_v_neg;
+  Py_UCS4 *__pyx_r;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  __Pyx_RefNannySetupContext("apg_parse_int32", 0);
+
+  /* "asyncpg/protocol/codecs/textutils.pyx":50
+ *     cdef:
+ *         Py_UCS4 *p
+ *         int32_t n = 0             # <<<<<<<<<<<<<<
+ *         int32_t neg = 0
+ * 
+ */
+  __pyx_v_n = 0;
+
+  /* "asyncpg/protocol/codecs/textutils.pyx":51
+ *         Py_UCS4 *p
+ *         int32_t n = 0
+ *         int32_t neg = 0             # <<<<<<<<<<<<<<
+ * 
+ *     if buf[0] == '-':
+ */
+  __pyx_v_neg = 0;
+
+  /* "asyncpg/protocol/codecs/textutils.pyx":53
+ *         int32_t neg = 0
+ * 
+ *     if buf[0] == '-':             # <<<<<<<<<<<<<<
+ *         neg = 1
+ *         buf += 1
+ */
+  __pyx_t_1 = (((__pyx_v_buf[0]) == 45) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/textutils.pyx":54
+ * 
+ *     if buf[0] == '-':
+ *         neg = 1             # <<<<<<<<<<<<<<
+ *         buf += 1
+ *     elif buf[0] == '+':
+ */
+    __pyx_v_neg = 1;
+
+    /* "asyncpg/protocol/codecs/textutils.pyx":55
+ *     if buf[0] == '-':
+ *         neg = 1
+ *         buf += 1             # <<<<<<<<<<<<<<
+ *     elif buf[0] == '+':
+ *         buf += 1
+ */
+    __pyx_v_buf = (__pyx_v_buf + 1);
+
+    /* "asyncpg/protocol/codecs/textutils.pyx":53
+ *         int32_t neg = 0
+ * 
+ *     if buf[0] == '-':             # <<<<<<<<<<<<<<
+ *         neg = 1
+ *         buf += 1
+ */
+    goto __pyx_L3;
+  }
+
+  /* "asyncpg/protocol/codecs/textutils.pyx":56
+ *         neg = 1
+ *         buf += 1
+ *     elif buf[0] == '+':             # <<<<<<<<<<<<<<
+ *         buf += 1
+ * 
+ */
+  __pyx_t_1 = (((__pyx_v_buf[0]) == 43) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/textutils.pyx":57
+ *         buf += 1
+ *     elif buf[0] == '+':
+ *         buf += 1             # <<<<<<<<<<<<<<
+ * 
+ *     p = buf
+ */
+    __pyx_v_buf = (__pyx_v_buf + 1);
+
+    /* "asyncpg/protocol/codecs/textutils.pyx":56
+ *         neg = 1
+ *         buf += 1
+ *     elif buf[0] == '+':             # <<<<<<<<<<<<<<
+ *         buf += 1
+ * 
+ */
+  }
+  __pyx_L3:;
+
+  /* "asyncpg/protocol/codecs/textutils.pyx":59
+ *         buf += 1
+ * 
+ *     p = buf             # <<<<<<<<<<<<<<
+ *     while <int>p[0] >= <int><Py_UCS4>'0' and <int>p[0] <= <int><Py_UCS4>'9':
+ *         n = 10 * n - (<int>p[0] - <int32_t><Py_UCS4>'0')
+ */
+  __pyx_v_p = __pyx_v_buf;
+
+  /* "asyncpg/protocol/codecs/textutils.pyx":60
+ * 
+ *     p = buf
+ *     while <int>p[0] >= <int><Py_UCS4>'0' and <int>p[0] <= <int><Py_UCS4>'9':             # <<<<<<<<<<<<<<
+ *         n = 10 * n - (<int>p[0] - <int32_t><Py_UCS4>'0')
+ *         p += 1
+ */
+  while (1) {
+    __pyx_t_2 = ((((int)(__pyx_v_p[0])) >= ((int)((Py_UCS4)48))) != 0);
+    if (__pyx_t_2) {
+    } else {
+      __pyx_t_1 = __pyx_t_2;
+      goto __pyx_L6_bool_binop_done;
+    }
+    __pyx_t_2 = ((((int)(__pyx_v_p[0])) <= ((int)((Py_UCS4)57))) != 0);
+    __pyx_t_1 = __pyx_t_2;
+    __pyx_L6_bool_binop_done:;
+    if (!__pyx_t_1) break;
+
+    /* "asyncpg/protocol/codecs/textutils.pyx":61
+ *     p = buf
+ *     while <int>p[0] >= <int><Py_UCS4>'0' and <int>p[0] <= <int><Py_UCS4>'9':
+ *         n = 10 * n - (<int>p[0] - <int32_t><Py_UCS4>'0')             # <<<<<<<<<<<<<<
+ *         p += 1
+ * 
+ */
+    __pyx_v_n = ((10 * __pyx_v_n) - (((int)(__pyx_v_p[0])) - ((int32_t)((Py_UCS4)48))));
+
+    /* "asyncpg/protocol/codecs/textutils.pyx":62
+ *     while <int>p[0] >= <int><Py_UCS4>'0' and <int>p[0] <= <int><Py_UCS4>'9':
+ *         n = 10 * n - (<int>p[0] - <int32_t><Py_UCS4>'0')
+ *         p += 1             # <<<<<<<<<<<<<<
+ * 
+ *     if p == buf:
+ */
+    __pyx_v_p = (__pyx_v_p + 1);
+  }
+
+  /* "asyncpg/protocol/codecs/textutils.pyx":64
+ *         p += 1
+ * 
+ *     if p == buf:             # <<<<<<<<<<<<<<
+ *         return NULL
+ * 
+ */
+  __pyx_t_1 = ((__pyx_v_p == __pyx_v_buf) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/textutils.pyx":65
+ * 
+ *     if p == buf:
+ *         return NULL             # <<<<<<<<<<<<<<
+ * 
+ *     if not neg:
+ */
+    __pyx_r = NULL;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/codecs/textutils.pyx":64
+ *         p += 1
+ * 
+ *     if p == buf:             # <<<<<<<<<<<<<<
+ *         return NULL
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/textutils.pyx":67
+ *         return NULL
+ * 
+ *     if not neg:             # <<<<<<<<<<<<<<
+ *         n = -n
+ * 
+ */
+  __pyx_t_1 = ((!(__pyx_v_neg != 0)) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/textutils.pyx":68
+ * 
+ *     if not neg:
+ *         n = -n             # <<<<<<<<<<<<<<
+ * 
+ *     num[0] = n
+ */
+    __pyx_v_n = (-__pyx_v_n);
+
+    /* "asyncpg/protocol/codecs/textutils.pyx":67
+ *         return NULL
+ * 
+ *     if not neg:             # <<<<<<<<<<<<<<
+ *         n = -n
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/textutils.pyx":70
+ *         n = -n
+ * 
+ *     num[0] = n             # <<<<<<<<<<<<<<
+ * 
+ *     return p
+ */
+  (__pyx_v_num[0]) = __pyx_v_n;
+
+  /* "asyncpg/protocol/codecs/textutils.pyx":72
+ *     num[0] = n
+ * 
+ *     return p             # <<<<<<<<<<<<<<
+ */
+  __pyx_r = __pyx_v_p;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/textutils.pyx":47
+ * 
+ * 
+ * cdef Py_UCS4 *apg_parse_int32(Py_UCS4 *buf, int32_t *num):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         Py_UCS4 *p
+ */
+
+  /* function exit code */
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/bytea.pyx":8
+ * 
+ * 
+ * cdef bytea_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         Py_buffer pybuf
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_bytea_encode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_wbuf, PyObject *__pyx_v_obj) {
+  Py_buffer __pyx_v_pybuf;
+  int __pyx_v_pybuf_used;
+  char *__pyx_v_buf;
+  Py_ssize_t __pyx_v_len;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  Py_ssize_t __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  int __pyx_t_5;
+  char const *__pyx_t_6;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  PyObject *__pyx_t_10 = NULL;
+  PyObject *__pyx_t_11 = NULL;
+  PyObject *__pyx_t_12 = NULL;
+  __Pyx_RefNannySetupContext("bytea_encode", 0);
+
+  /* "asyncpg/protocol/codecs/bytea.pyx":11
+ *     cdef:
+ *         Py_buffer pybuf
+ *         bint pybuf_used = False             # <<<<<<<<<<<<<<
+ *         char *buf
+ *         ssize_t len
+ */
+  __pyx_v_pybuf_used = 0;
+
+  /* "asyncpg/protocol/codecs/bytea.pyx":15
+ *         ssize_t len
+ * 
+ *     if cpython.PyBytes_CheckExact(obj):             # <<<<<<<<<<<<<<
+ *         buf = cpython.PyBytes_AS_STRING(obj)
+ *         len = cpython.Py_SIZE(obj)
+ */
+  __pyx_t_1 = (PyBytes_CheckExact(__pyx_v_obj) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/bytea.pyx":16
+ * 
+ *     if cpython.PyBytes_CheckExact(obj):
+ *         buf = cpython.PyBytes_AS_STRING(obj)             # <<<<<<<<<<<<<<
+ *         len = cpython.Py_SIZE(obj)
+ *     else:
+ */
+    __pyx_v_buf = PyBytes_AS_STRING(__pyx_v_obj);
+
+    /* "asyncpg/protocol/codecs/bytea.pyx":17
+ *     if cpython.PyBytes_CheckExact(obj):
+ *         buf = cpython.PyBytes_AS_STRING(obj)
+ *         len = cpython.Py_SIZE(obj)             # <<<<<<<<<<<<<<
+ *     else:
+ *         cpython.PyObject_GetBuffer(obj, &pybuf, cpython.PyBUF_SIMPLE)
+ */
+    __pyx_v_len = Py_SIZE(__pyx_v_obj);
+
+    /* "asyncpg/protocol/codecs/bytea.pyx":15
+ *         ssize_t len
+ * 
+ *     if cpython.PyBytes_CheckExact(obj):             # <<<<<<<<<<<<<<
+ *         buf = cpython.PyBytes_AS_STRING(obj)
+ *         len = cpython.Py_SIZE(obj)
+ */
+    goto __pyx_L3;
+  }
+
+  /* "asyncpg/protocol/codecs/bytea.pyx":19
+ *         len = cpython.Py_SIZE(obj)
+ *     else:
+ *         cpython.PyObject_GetBuffer(obj, &pybuf, cpython.PyBUF_SIMPLE)             # <<<<<<<<<<<<<<
+ *         pybuf_used = True
+ *         buf = <char*>pybuf.buf
+ */
+  /*else*/ {
+    __pyx_t_2 = PyObject_GetBuffer(__pyx_v_obj, (&__pyx_v_pybuf), PyBUF_SIMPLE); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(6, 19, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/bytea.pyx":20
+ *     else:
+ *         cpython.PyObject_GetBuffer(obj, &pybuf, cpython.PyBUF_SIMPLE)
+ *         pybuf_used = True             # <<<<<<<<<<<<<<
+ *         buf = <char*>pybuf.buf
+ *         len = pybuf.len
+ */
+    __pyx_v_pybuf_used = 1;
+
+    /* "asyncpg/protocol/codecs/bytea.pyx":21
+ *         cpython.PyObject_GetBuffer(obj, &pybuf, cpython.PyBUF_SIMPLE)
+ *         pybuf_used = True
+ *         buf = <char*>pybuf.buf             # <<<<<<<<<<<<<<
+ *         len = pybuf.len
+ * 
+ */
+    __pyx_v_buf = ((char *)__pyx_v_pybuf.buf);
+
+    /* "asyncpg/protocol/codecs/bytea.pyx":22
+ *         pybuf_used = True
+ *         buf = <char*>pybuf.buf
+ *         len = pybuf.len             # <<<<<<<<<<<<<<
+ * 
+ *     try:
+ */
+    __pyx_t_3 = __pyx_v_pybuf.len;
+    __pyx_v_len = __pyx_t_3;
+  }
+  __pyx_L3:;
+
+  /* "asyncpg/protocol/codecs/bytea.pyx":24
+ *         len = pybuf.len
+ * 
+ *     try:             # <<<<<<<<<<<<<<
+ *         wbuf.write_int32(<int32_t>len)
+ *         wbuf.write_cstr(buf, len)
+ */
+  /*try:*/ {
+
+    /* "asyncpg/protocol/codecs/bytea.pyx":25
+ * 
+ *     try:
+ *         wbuf.write_int32(<int32_t>len)             # <<<<<<<<<<<<<<
+ *         wbuf.write_cstr(buf, len)
+ *     finally:
+ */
+    __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_wbuf, ((int32_t)__pyx_v_len)); if (unlikely(!__pyx_t_4)) __PYX_ERR(6, 25, __pyx_L5_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/codecs/bytea.pyx":26
+ *     try:
+ *         wbuf.write_int32(<int32_t>len)
+ *         wbuf.write_cstr(buf, len)             # <<<<<<<<<<<<<<
+ *     finally:
+ *         if pybuf_used:
+ */
+    __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_cstr(__pyx_v_wbuf, __pyx_v_buf, __pyx_v_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(6, 26, __pyx_L5_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  }
+
+  /* "asyncpg/protocol/codecs/bytea.pyx":28
+ *         wbuf.write_cstr(buf, len)
+ *     finally:
+ *         if pybuf_used:             # <<<<<<<<<<<<<<
+ *             cpython.PyBuffer_Release(&pybuf)
+ * 
+ */
+  /*finally:*/ {
+    /*normal exit:*/{
+      __pyx_t_1 = (__pyx_v_pybuf_used != 0);
+      if (__pyx_t_1) {
+
+        /* "asyncpg/protocol/codecs/bytea.pyx":29
+ *     finally:
+ *         if pybuf_used:
+ *             cpython.PyBuffer_Release(&pybuf)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+        PyBuffer_Release((&__pyx_v_pybuf));
+
+        /* "asyncpg/protocol/codecs/bytea.pyx":28
+ *         wbuf.write_cstr(buf, len)
+ *     finally:
+ *         if pybuf_used:             # <<<<<<<<<<<<<<
+ *             cpython.PyBuffer_Release(&pybuf)
+ * 
+ */
+      }
+      goto __pyx_L6;
+    }
+    /*exception exit:*/{
+      __Pyx_PyThreadState_declare
+      __pyx_L5_error:;
+      __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
+      __Pyx_PyThreadState_assign
+      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
+      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
+      __Pyx_XGOTREF(__pyx_t_7);
+      __Pyx_XGOTREF(__pyx_t_8);
+      __Pyx_XGOTREF(__pyx_t_9);
+      __Pyx_XGOTREF(__pyx_t_10);
+      __Pyx_XGOTREF(__pyx_t_11);
+      __Pyx_XGOTREF(__pyx_t_12);
+      __pyx_t_2 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_6 = __pyx_filename;
+      {
+        __pyx_t_1 = (__pyx_v_pybuf_used != 0);
+        if (__pyx_t_1) {
+
+          /* "asyncpg/protocol/codecs/bytea.pyx":29
+ *     finally:
+ *         if pybuf_used:
+ *             cpython.PyBuffer_Release(&pybuf)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+          PyBuffer_Release((&__pyx_v_pybuf));
+
+          /* "asyncpg/protocol/codecs/bytea.pyx":28
+ *         wbuf.write_cstr(buf, len)
+ *     finally:
+ *         if pybuf_used:             # <<<<<<<<<<<<<<
+ *             cpython.PyBuffer_Release(&pybuf)
+ * 
+ */
+        }
+      }
+      __Pyx_PyThreadState_assign
+      if (PY_MAJOR_VERSION >= 3) {
+        __Pyx_XGIVEREF(__pyx_t_10);
+        __Pyx_XGIVEREF(__pyx_t_11);
+        __Pyx_XGIVEREF(__pyx_t_12);
+        __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
+      }
+      __Pyx_XGIVEREF(__pyx_t_7);
+      __Pyx_XGIVEREF(__pyx_t_8);
+      __Pyx_XGIVEREF(__pyx_t_9);
+      __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
+      __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
+      __pyx_lineno = __pyx_t_2; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_6;
+      goto __pyx_L1_error;
+    }
+    __pyx_L6:;
+  }
+
+  /* "asyncpg/protocol/codecs/bytea.pyx":8
+ * 
+ * 
+ * cdef bytea_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         Py_buffer pybuf
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.bytea_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/bytea.pyx":32
+ * 
+ * 
+ * cdef bytea_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef ssize_t buf_len = buf.len
+ *     return cpython.PyBytes_FromStringAndSize(buf.read_all(), buf_len)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_bytea_decode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  Py_ssize_t __pyx_v_buf_len;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  Py_ssize_t __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("bytea_decode", 0);
+
+  /* "asyncpg/protocol/codecs/bytea.pyx":33
+ * 
+ * cdef bytea_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     cdef ssize_t buf_len = buf.len             # <<<<<<<<<<<<<<
+ *     return cpython.PyBytes_FromStringAndSize(buf.read_all(), buf_len)
+ * 
+ */
+  __pyx_t_1 = __pyx_v_buf->len;
+  __pyx_v_buf_len = __pyx_t_1;
+
+  /* "asyncpg/protocol/codecs/bytea.pyx":34
+ * cdef bytea_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     cdef ssize_t buf_len = buf.len
+ *     return cpython.PyBytes_FromStringAndSize(buf.read_all(), buf_len)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_2 = PyBytes_FromStringAndSize(__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read_all(__pyx_v_buf), __pyx_v_buf_len); if (unlikely(!__pyx_t_2)) __PYX_ERR(6, 34, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_r = __pyx_t_2;
+  __pyx_t_2 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/bytea.pyx":32
+ * 
+ * 
+ * cdef bytea_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef ssize_t buf_len = buf.len
+ *     return cpython.PyBytes_FromStringAndSize(buf.read_all(), buf_len)
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.bytea_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/bytea.pyx":37
+ * 
+ * 
+ * cdef init_bytea_codecs():             # <<<<<<<<<<<<<<
+ *     register_core_codec(BYTEAOID,
+ *                         <encode_func>&bytea_encode,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_bytea_codecs(void) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("init_bytea_codecs", 0);
+
+  /* "asyncpg/protocol/codecs/bytea.pyx":38
+ * 
+ * cdef init_bytea_codecs():
+ *     register_core_codec(BYTEAOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&bytea_encode,
+ *                         <decode_func>&bytea_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(17, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_bytea_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_bytea_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 38, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/bytea.pyx":43
+ *                         PG_FORMAT_BINARY)
+ * 
+ *     register_core_codec(CHAROID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&bytea_encode,
+ *                         <decode_func>&bytea_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(18, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_bytea_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_bytea_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 43, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/bytea.pyx":37
+ * 
+ * 
+ * cdef init_bytea_codecs():             # <<<<<<<<<<<<<<
+ *     register_core_codec(BYTEAOID,
+ *                         <encode_func>&bytea_encode,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.init_bytea_codecs", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/text.pyx":8
+ * 
+ * 
+ * cdef inline as_pg_string_and_size(             # <<<<<<<<<<<<<<
+ *         ConnectionSettings settings, obj, char **cstr, ssize_t *size):
+ * 
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_as_pg_string_and_size(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, PyObject *__pyx_v_obj, char **__pyx_v_cstr, Py_ssize_t *__pyx_v_size) {
+  PyObject *__pyx_v_encoded = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  char *__pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  int __pyx_t_7;
+  __Pyx_RefNannySetupContext("as_pg_string_and_size", 0);
+  __Pyx_INCREF(__pyx_v_obj);
+
+  /* "asyncpg/protocol/codecs/text.pyx":11
+ *         ConnectionSettings settings, obj, char **cstr, ssize_t *size):
+ * 
+ *     if not cpython.PyUnicode_Check(obj):             # <<<<<<<<<<<<<<
+ *         obj = str(obj)
+ * 
+ */
+  __pyx_t_1 = ((!(PyUnicode_Check(__pyx_v_obj) != 0)) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/text.pyx":12
+ * 
+ *     if not cpython.PyUnicode_Check(obj):
+ *         obj = str(obj)             # <<<<<<<<<<<<<<
+ * 
+ *     if settings.is_encoding_utf8():
+ */
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 12, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(__pyx_v_obj);
+    __Pyx_GIVEREF(__pyx_v_obj);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_obj);
+    __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&PyUnicode_Type)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 12, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_DECREF_SET(__pyx_v_obj, __pyx_t_3);
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/codecs/text.pyx":11
+ *         ConnectionSettings settings, obj, char **cstr, ssize_t *size):
+ * 
+ *     if not cpython.PyUnicode_Check(obj):             # <<<<<<<<<<<<<<
+ *         obj = str(obj)
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/text.pyx":14
+ *         obj = str(obj)
+ * 
+ *     if settings.is_encoding_utf8():             # <<<<<<<<<<<<<<
+ *         cstr[0] = PyUnicode_AsUTF8AndSize(obj, size)
+ *     else:
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_is_encoding_utf8(__pyx_v_settings); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 14, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(7, 14, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/text.pyx":15
+ * 
+ *     if settings.is_encoding_utf8():
+ *         cstr[0] = PyUnicode_AsUTF8AndSize(obj, size)             # <<<<<<<<<<<<<<
+ *     else:
+ *         encoded = settings.get_text_codec().encode(obj)
+ */
+    __pyx_t_4 = PyUnicode_AsUTF8AndSize(__pyx_v_obj, __pyx_v_size); if (unlikely(__pyx_t_4 == NULL)) __PYX_ERR(7, 15, __pyx_L1_error)
+    (__pyx_v_cstr[0]) = __pyx_t_4;
+
+    /* "asyncpg/protocol/codecs/text.pyx":14
+ *         obj = str(obj)
+ * 
+ *     if settings.is_encoding_utf8():             # <<<<<<<<<<<<<<
+ *         cstr[0] = PyUnicode_AsUTF8AndSize(obj, size)
+ *     else:
+ */
+    goto __pyx_L4;
+  }
+
+  /* "asyncpg/protocol/codecs/text.pyx":17
+ *         cstr[0] = PyUnicode_AsUTF8AndSize(obj, size)
+ *     else:
+ *         encoded = settings.get_text_codec().encode(obj)             # <<<<<<<<<<<<<<
+ *         cpython.PyBytes_AsStringAndSize(encoded, cstr, size)
+ * 
+ */
+  /*else*/ {
+    __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_text_codec(__pyx_v_settings, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 17, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_encode); if (unlikely(!__pyx_t_5)) __PYX_ERR(7, 17, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_2 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
+      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
+      if (likely(__pyx_t_2)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+        __Pyx_INCREF(__pyx_t_2);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_5, function);
+      }
+    }
+    if (!__pyx_t_2) {
+      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_obj); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 17, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_5)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_obj};
+        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 17, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_obj};
+        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 17, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+      } else
+      #endif
+      {
+        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(7, 17, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_6);
+        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __pyx_t_2 = NULL;
+        __Pyx_INCREF(__pyx_v_obj);
+        __Pyx_GIVEREF(__pyx_v_obj);
+        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_obj);
+        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 17, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_v_encoded = __pyx_t_3;
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/codecs/text.pyx":18
+ *     else:
+ *         encoded = settings.get_text_codec().encode(obj)
+ *         cpython.PyBytes_AsStringAndSize(encoded, cstr, size)             # <<<<<<<<<<<<<<
+ * 
+ *     if size[0] > 0x7fffffff:
+ */
+    __pyx_t_7 = PyBytes_AsStringAndSize(__pyx_v_encoded, __pyx_v_cstr, ((Py_ssize_t *)__pyx_v_size)); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(7, 18, __pyx_L1_error)
+  }
+  __pyx_L4:;
+
+  /* "asyncpg/protocol/codecs/text.pyx":20
+ *         cpython.PyBytes_AsStringAndSize(encoded, cstr, size)
+ * 
+ *     if size[0] > 0x7fffffff:             # <<<<<<<<<<<<<<
+ *         raise ValueError('string too long')
+ * 
+ */
+  __pyx_t_1 = (((__pyx_v_size[0]) > 0x7fffffff) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/text.pyx":21
+ * 
+ *     if size[0] > 0x7fffffff:
+ *         raise ValueError('string too long')             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 21, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __PYX_ERR(7, 21, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/text.pyx":20
+ *         cpython.PyBytes_AsStringAndSize(encoded, cstr, size)
+ * 
+ *     if size[0] > 0x7fffffff:             # <<<<<<<<<<<<<<
+ *         raise ValueError('string too long')
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/text.pyx":8
+ * 
+ * 
+ * cdef inline as_pg_string_and_size(             # <<<<<<<<<<<<<<
+ *         ConnectionSettings settings, obj, char **cstr, ssize_t *size):
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.as_pg_string_and_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_encoded);
+  __Pyx_XDECREF(__pyx_v_obj);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/text.pyx":24
+ * 
+ * 
+ * cdef text_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         char *str
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_text_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
+  char *__pyx_v_str;
+  Py_ssize_t __pyx_v_size;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("text_encode", 0);
+
+  /* "asyncpg/protocol/codecs/text.pyx":29
+ *         ssize_t size
+ * 
+ *     as_pg_string_and_size(settings, obj, &str, &size)             # <<<<<<<<<<<<<<
+ * 
+ *     buf.write_int32(<int32_t>size)
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_as_pg_string_and_size(__pyx_v_settings, __pyx_v_obj, (&__pyx_v_str), (&__pyx_v_size)); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 29, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/text.pyx":31
+ *     as_pg_string_and_size(settings, obj, &str, &size)
+ * 
+ *     buf.write_int32(<int32_t>size)             # <<<<<<<<<<<<<<
+ *     buf.write_cstr(str, size)
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, ((int32_t)__pyx_v_size)); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 31, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/text.pyx":32
+ * 
+ *     buf.write_int32(<int32_t>size)
+ *     buf.write_cstr(str, size)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_cstr(__pyx_v_buf, __pyx_v_str, __pyx_v_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 32, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/text.pyx":24
+ * 
+ * 
+ * cdef text_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         char *str
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.text_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/text.pyx":35
+ * 
+ * 
+ * cdef inline decode_pg_string(ConnectionSettings settings, const char* data,             # <<<<<<<<<<<<<<
+ *                              ssize_t len):
+ * 
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_decode_pg_string(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, char const *__pyx_v_data, Py_ssize_t __pyx_v_len) {
+  PyObject *__pyx_v_bytes = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  __Pyx_RefNannySetupContext("decode_pg_string", 0);
+
+  /* "asyncpg/protocol/codecs/text.pyx":38
+ *                              ssize_t len):
+ * 
+ *     if settings.is_encoding_utf8():             # <<<<<<<<<<<<<<
+ *         # decode UTF-8 in strict mode
+ *         return cpython.PyUnicode_DecodeUTF8(data, len, NULL)
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_is_encoding_utf8(__pyx_v_settings); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 38, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(7, 38, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/codecs/text.pyx":40
+ *     if settings.is_encoding_utf8():
+ *         # decode UTF-8 in strict mode
+ *         return cpython.PyUnicode_DecodeUTF8(data, len, NULL)             # <<<<<<<<<<<<<<
+ *     else:
+ *         bytes = cpython.PyBytes_FromStringAndSize(data, len)
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_1 = PyUnicode_DecodeUTF8(__pyx_v_data, __pyx_v_len, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 40, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_r = __pyx_t_1;
+    __pyx_t_1 = 0;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/codecs/text.pyx":38
+ *                              ssize_t len):
+ * 
+ *     if settings.is_encoding_utf8():             # <<<<<<<<<<<<<<
+ *         # decode UTF-8 in strict mode
+ *         return cpython.PyUnicode_DecodeUTF8(data, len, NULL)
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/text.pyx":42
+ *         return cpython.PyUnicode_DecodeUTF8(data, len, NULL)
+ *     else:
+ *         bytes = cpython.PyBytes_FromStringAndSize(data, len)             # <<<<<<<<<<<<<<
+ *         return settings.get_text_codec().decode(bytes)
+ * 
+ */
+  /*else*/ {
+    __pyx_t_1 = PyBytes_FromStringAndSize(__pyx_v_data, __pyx_v_len); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 42, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_v_bytes = ((PyObject*)__pyx_t_1);
+    __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/codecs/text.pyx":43
+ *     else:
+ *         bytes = cpython.PyBytes_FromStringAndSize(data, len)
+ *         return settings.get_text_codec().decode(bytes)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_text_codec(__pyx_v_settings, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 43, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_decode); if (unlikely(!__pyx_t_4)) __PYX_ERR(7, 43, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_3 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
+      if (likely(__pyx_t_3)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+        __Pyx_INCREF(__pyx_t_3);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_4, function);
+      }
+    }
+    if (!__pyx_t_3) {
+      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_bytes); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 43, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_4)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_bytes};
+        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 43, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __Pyx_GOTREF(__pyx_t_1);
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_bytes};
+        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 43, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __Pyx_GOTREF(__pyx_t_1);
+      } else
+      #endif
+      {
+        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(7, 43, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
+        __Pyx_INCREF(__pyx_v_bytes);
+        __Pyx_GIVEREF(__pyx_v_bytes);
+        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_bytes);
+        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 43, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_r = __pyx_t_1;
+    __pyx_t_1 = 0;
+    goto __pyx_L0;
+  }
+
+  /* "asyncpg/protocol/codecs/text.pyx":35
+ * 
+ * 
+ * cdef inline decode_pg_string(ConnectionSettings settings, const char* data,             # <<<<<<<<<<<<<<
+ *                              ssize_t len):
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.decode_pg_string", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_bytes);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/text.pyx":46
+ * 
+ * 
+ * cdef text_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef ssize_t buf_len = buf.len
+ *     return decode_pg_string(settings, buf.read_all(), buf_len)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_text_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  Py_ssize_t __pyx_v_buf_len;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  Py_ssize_t __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("text_decode", 0);
+
+  /* "asyncpg/protocol/codecs/text.pyx":47
+ * 
+ * cdef text_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     cdef ssize_t buf_len = buf.len             # <<<<<<<<<<<<<<
+ *     return decode_pg_string(settings, buf.read_all(), buf_len)
+ * 
+ */
+  __pyx_t_1 = __pyx_v_buf->len;
+  __pyx_v_buf_len = __pyx_t_1;
+
+  /* "asyncpg/protocol/codecs/text.pyx":48
+ * cdef text_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     cdef ssize_t buf_len = buf.len
+ *     return decode_pg_string(settings, buf.read_all(), buf_len)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_decode_pg_string(__pyx_v_settings, __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read_all(__pyx_v_buf), __pyx_v_buf_len); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 48, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_r = __pyx_t_2;
+  __pyx_t_2 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/text.pyx":46
+ * 
+ * 
+ * cdef text_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef ssize_t buf_len = buf.len
+ *     return decode_pg_string(settings, buf.read_all(), buf_len)
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.text_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/text.pyx":51
+ * 
+ * 
+ * cdef init_text_codecs():             # <<<<<<<<<<<<<<
+ *     textoids = [
+ *         NAMEOID,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_text_codecs(void) {
+  PyObject *__pyx_v_textoids = NULL;
+  PyObject *__pyx_v_oid = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  Py_ssize_t __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  uint32_t __pyx_t_4;
+  __Pyx_RefNannySetupContext("init_text_codecs", 0);
+
+  /* "asyncpg/protocol/codecs/text.pyx":52
+ * 
+ * cdef init_text_codecs():
+ *     textoids = [             # <<<<<<<<<<<<<<
+ *         NAMEOID,
+ *         BPCHAROID,
+ */
+  __pyx_t_1 = PyList_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 52, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(__pyx_int_19);
+  __Pyx_GIVEREF(__pyx_int_19);
+  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_int_19);
+  __Pyx_INCREF(__pyx_int_1042);
+  __Pyx_GIVEREF(__pyx_int_1042);
+  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_int_1042);
+  __Pyx_INCREF(__pyx_int_1043);
+  __Pyx_GIVEREF(__pyx_int_1043);
+  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_int_1043);
+  __Pyx_INCREF(__pyx_int_25);
+  __Pyx_GIVEREF(__pyx_int_25);
+  PyList_SET_ITEM(__pyx_t_1, 3, __pyx_int_25);
+  __Pyx_INCREF(__pyx_int_142);
+  __Pyx_GIVEREF(__pyx_int_142);
+  PyList_SET_ITEM(__pyx_t_1, 4, __pyx_int_142);
+  __pyx_v_textoids = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/text.pyx":60
+ *     ]
+ * 
+ *     for oid in textoids:             # <<<<<<<<<<<<<<
+ *         register_core_codec(oid,
+ *                             <encode_func>&text_encode,
+ */
+  __pyx_t_1 = __pyx_v_textoids; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
+  for (;;) {
+    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
+    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(7, 60, __pyx_L1_error)
+    #else
+    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 60, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    #endif
+    __Pyx_XDECREF_SET(__pyx_v_oid, __pyx_t_3);
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/codecs/text.pyx":61
+ * 
+ *     for oid in textoids:
+ *         register_core_codec(oid,             # <<<<<<<<<<<<<<
+ *                             <encode_func>&text_encode,
+ *                             <decode_func>&text_decode,
+ */
+    __pyx_t_4 = __Pyx_PyInt_As_uint32_t(__pyx_v_oid); if (unlikely((__pyx_t_4 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(7, 61, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/text.pyx":64
+ *                             <encode_func>&text_encode,
+ *                             <decode_func>&text_decode,
+ *                             PG_FORMAT_BINARY)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+    __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(__pyx_t_4, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 61, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/codecs/text.pyx":60
+ *     ]
+ * 
+ *     for oid in textoids:             # <<<<<<<<<<<<<<
+ *         register_core_codec(oid,
+ *                             <encode_func>&text_encode,
+ */
+  }
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/text.pyx":51
+ * 
+ * 
+ * cdef init_text_codecs():             # <<<<<<<<<<<<<<
+ *     textoids = [
+ *         NAMEOID,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.init_text_codecs", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_textoids);
+  __Pyx_XDECREF(__pyx_v_oid);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/bits.pyx":11
+ * 
+ * 
+ * cdef bits_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         Py_buffer pybuf
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_bits_encode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_wbuf, PyObject *__pyx_v_obj) {
+  Py_buffer __pyx_v_pybuf;
+  int __pyx_v_pybuf_used;
+  char *__pyx_v_buf;
+  Py_ssize_t __pyx_v_len;
+  Py_ssize_t __pyx_v_bitlen;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_3;
+  int __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  Py_ssize_t __pyx_t_7;
+  Py_ssize_t __pyx_t_8;
+  int __pyx_t_9;
+  char const *__pyx_t_10;
+  PyObject *__pyx_t_11 = NULL;
+  PyObject *__pyx_t_12 = NULL;
+  PyObject *__pyx_t_13 = NULL;
+  PyObject *__pyx_t_14 = NULL;
+  PyObject *__pyx_t_15 = NULL;
+  PyObject *__pyx_t_16 = NULL;
+  __Pyx_RefNannySetupContext("bits_encode", 0);
+
+  /* "asyncpg/protocol/codecs/bits.pyx":14
+ *     cdef:
+ *         Py_buffer pybuf
+ *         bint pybuf_used = False             # <<<<<<<<<<<<<<
+ *         char *buf
+ *         ssize_t len
+ */
+  __pyx_v_pybuf_used = 0;
+
+  /* "asyncpg/protocol/codecs/bits.pyx":19
+ *         ssize_t bitlen
+ * 
+ *     if cpython.PyBytes_CheckExact(obj):             # <<<<<<<<<<<<<<
+ *         buf = cpython.PyBytes_AS_STRING(obj)
+ *         len = cpython.Py_SIZE(obj)
+ */
+  __pyx_t_1 = (PyBytes_CheckExact(__pyx_v_obj) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/bits.pyx":20
+ * 
+ *     if cpython.PyBytes_CheckExact(obj):
+ *         buf = cpython.PyBytes_AS_STRING(obj)             # <<<<<<<<<<<<<<
+ *         len = cpython.Py_SIZE(obj)
+ *         bitlen = len * 8
+ */
+    __pyx_v_buf = PyBytes_AS_STRING(__pyx_v_obj);
+
+    /* "asyncpg/protocol/codecs/bits.pyx":21
+ *     if cpython.PyBytes_CheckExact(obj):
+ *         buf = cpython.PyBytes_AS_STRING(obj)
+ *         len = cpython.Py_SIZE(obj)             # <<<<<<<<<<<<<<
+ *         bitlen = len * 8
+ *     elif isinstance(obj, BitString):
+ */
+    __pyx_v_len = Py_SIZE(__pyx_v_obj);
+
+    /* "asyncpg/protocol/codecs/bits.pyx":22
+ *         buf = cpython.PyBytes_AS_STRING(obj)
+ *         len = cpython.Py_SIZE(obj)
+ *         bitlen = len * 8             # <<<<<<<<<<<<<<
+ *     elif isinstance(obj, BitString):
+ *         cpython.PyBytes_AsStringAndSize(obj.bytes, &buf, &len)
+ */
+    __pyx_v_bitlen = (__pyx_v_len * 8);
+
+    /* "asyncpg/protocol/codecs/bits.pyx":19
+ *         ssize_t bitlen
+ * 
+ *     if cpython.PyBytes_CheckExact(obj):             # <<<<<<<<<<<<<<
+ *         buf = cpython.PyBytes_AS_STRING(obj)
+ *         len = cpython.Py_SIZE(obj)
+ */
+    goto __pyx_L3;
+  }
+
+  /* "asyncpg/protocol/codecs/bits.pyx":23
+ *         len = cpython.Py_SIZE(obj)
+ *         bitlen = len * 8
+ *     elif isinstance(obj, BitString):             # <<<<<<<<<<<<<<
+ *         cpython.PyBytes_AsStringAndSize(obj.bytes, &buf, &len)
+ *         bitlen = obj.__len__()
+ */
+  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_BitString); if (unlikely(!__pyx_t_2)) __PYX_ERR(8, 23, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_1 = PyObject_IsInstance(__pyx_v_obj, __pyx_t_2); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(8, 23, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_3 = (__pyx_t_1 != 0);
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/codecs/bits.pyx":24
+ *         bitlen = len * 8
+ *     elif isinstance(obj, BitString):
+ *         cpython.PyBytes_AsStringAndSize(obj.bytes, &buf, &len)             # <<<<<<<<<<<<<<
+ *         bitlen = obj.__len__()
+ *     else:
+ */
+    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_bytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(8, 24, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_4 = PyBytes_AsStringAndSize(__pyx_t_2, (&__pyx_v_buf), ((Py_ssize_t *)(&__pyx_v_len))); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(8, 24, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "asyncpg/protocol/codecs/bits.pyx":25
+ *     elif isinstance(obj, BitString):
+ *         cpython.PyBytes_AsStringAndSize(obj.bytes, &buf, &len)
+ *         bitlen = obj.__len__()             # <<<<<<<<<<<<<<
+ *     else:
+ *         cpython.PyObject_GetBuffer(obj, &pybuf, cpython.PyBUF_SIMPLE)
+ */
+    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_len); if (unlikely(!__pyx_t_5)) __PYX_ERR(8, 25, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
+      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
+      if (likely(__pyx_t_6)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+        __Pyx_INCREF(__pyx_t_6);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_5, function);
+      }
+    }
+    if (__pyx_t_6) {
+      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(8, 25, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    } else {
+      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(8, 25, __pyx_L1_error)
+    }
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_7 = PyInt_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(8, 25, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_v_bitlen = __pyx_t_7;
+
+    /* "asyncpg/protocol/codecs/bits.pyx":23
+ *         len = cpython.Py_SIZE(obj)
+ *         bitlen = len * 8
+ *     elif isinstance(obj, BitString):             # <<<<<<<<<<<<<<
+ *         cpython.PyBytes_AsStringAndSize(obj.bytes, &buf, &len)
+ *         bitlen = obj.__len__()
+ */
+    goto __pyx_L3;
+  }
+
+  /* "asyncpg/protocol/codecs/bits.pyx":27
+ *         bitlen = obj.__len__()
+ *     else:
+ *         cpython.PyObject_GetBuffer(obj, &pybuf, cpython.PyBUF_SIMPLE)             # <<<<<<<<<<<<<<
+ *         pybuf_used = True
+ *         buf = <char*>pybuf.buf
+ */
+  /*else*/ {
+    __pyx_t_4 = PyObject_GetBuffer(__pyx_v_obj, (&__pyx_v_pybuf), PyBUF_SIMPLE); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(8, 27, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/bits.pyx":28
+ *     else:
+ *         cpython.PyObject_GetBuffer(obj, &pybuf, cpython.PyBUF_SIMPLE)
+ *         pybuf_used = True             # <<<<<<<<<<<<<<
+ *         buf = <char*>pybuf.buf
+ *         len = pybuf.len
+ */
+    __pyx_v_pybuf_used = 1;
+
+    /* "asyncpg/protocol/codecs/bits.pyx":29
+ *         cpython.PyObject_GetBuffer(obj, &pybuf, cpython.PyBUF_SIMPLE)
+ *         pybuf_used = True
+ *         buf = <char*>pybuf.buf             # <<<<<<<<<<<<<<
+ *         len = pybuf.len
+ *         bitlen = len * 8
+ */
+    __pyx_v_buf = ((char *)__pyx_v_pybuf.buf);
+
+    /* "asyncpg/protocol/codecs/bits.pyx":30
+ *         pybuf_used = True
+ *         buf = <char*>pybuf.buf
+ *         len = pybuf.len             # <<<<<<<<<<<<<<
+ *         bitlen = len * 8
+ * 
+ */
+    __pyx_t_8 = __pyx_v_pybuf.len;
+    __pyx_v_len = __pyx_t_8;
+
+    /* "asyncpg/protocol/codecs/bits.pyx":31
+ *         buf = <char*>pybuf.buf
+ *         len = pybuf.len
+ *         bitlen = len * 8             # <<<<<<<<<<<<<<
+ * 
+ *     try:
+ */
+    __pyx_v_bitlen = (__pyx_v_len * 8);
+  }
+  __pyx_L3:;
+
+  /* "asyncpg/protocol/codecs/bits.pyx":33
+ *         bitlen = len * 8
+ * 
+ *     try:             # <<<<<<<<<<<<<<
+ *         if bitlen > _MAXINT32:
+ *             raise ValueError('bit value too long')
+ */
+  /*try:*/ {
+
+    /* "asyncpg/protocol/codecs/bits.pyx":34
+ * 
+ *     try:
+ *         if bitlen > _MAXINT32:             # <<<<<<<<<<<<<<
+ *             raise ValueError('bit value too long')
+ *         wbuf.write_int32(4 + <int32_t>len)
+ */
+    __pyx_t_3 = ((__pyx_v_bitlen > 0x7FFFFFFF) != 0);
+    if (__pyx_t_3) {
+
+      /* "asyncpg/protocol/codecs/bits.pyx":35
+ *     try:
+ *         if bitlen > _MAXINT32:
+ *             raise ValueError('bit value too long')             # <<<<<<<<<<<<<<
+ *         wbuf.write_int32(4 + <int32_t>len)
+ *         wbuf.write_int32(<int32_t>bitlen)
+ */
+      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(8, 35, __pyx_L5_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __PYX_ERR(8, 35, __pyx_L5_error)
+
+      /* "asyncpg/protocol/codecs/bits.pyx":34
+ * 
+ *     try:
+ *         if bitlen > _MAXINT32:             # <<<<<<<<<<<<<<
+ *             raise ValueError('bit value too long')
+ *         wbuf.write_int32(4 + <int32_t>len)
+ */
+    }
+
+    /* "asyncpg/protocol/codecs/bits.pyx":36
+ *         if bitlen > _MAXINT32:
+ *             raise ValueError('bit value too long')
+ *         wbuf.write_int32(4 + <int32_t>len)             # <<<<<<<<<<<<<<
+ *         wbuf.write_int32(<int32_t>bitlen)
+ *         wbuf.write_cstr(buf, len)
+ */
+    __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_wbuf, (4 + ((int32_t)__pyx_v_len))); if (unlikely(!__pyx_t_2)) __PYX_ERR(8, 36, __pyx_L5_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "asyncpg/protocol/codecs/bits.pyx":37
+ *             raise ValueError('bit value too long')
+ *         wbuf.write_int32(4 + <int32_t>len)
+ *         wbuf.write_int32(<int32_t>bitlen)             # <<<<<<<<<<<<<<
+ *         wbuf.write_cstr(buf, len)
+ *     finally:
+ */
+    __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_wbuf, ((int32_t)__pyx_v_bitlen)); if (unlikely(!__pyx_t_2)) __PYX_ERR(8, 37, __pyx_L5_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "asyncpg/protocol/codecs/bits.pyx":38
+ *         wbuf.write_int32(4 + <int32_t>len)
+ *         wbuf.write_int32(<int32_t>bitlen)
+ *         wbuf.write_cstr(buf, len)             # <<<<<<<<<<<<<<
+ *     finally:
+ *         if pybuf_used:
+ */
+    __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_cstr(__pyx_v_wbuf, __pyx_v_buf, __pyx_v_len); if (unlikely(!__pyx_t_2)) __PYX_ERR(8, 38, __pyx_L5_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  }
+
+  /* "asyncpg/protocol/codecs/bits.pyx":40
+ *         wbuf.write_cstr(buf, len)
+ *     finally:
+ *         if pybuf_used:             # <<<<<<<<<<<<<<
+ *             cpython.PyBuffer_Release(&pybuf)
+ * 
+ */
+  /*finally:*/ {
+    /*normal exit:*/{
+      __pyx_t_3 = (__pyx_v_pybuf_used != 0);
+      if (__pyx_t_3) {
+
+        /* "asyncpg/protocol/codecs/bits.pyx":41
+ *     finally:
+ *         if pybuf_used:
+ *             cpython.PyBuffer_Release(&pybuf)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+        PyBuffer_Release((&__pyx_v_pybuf));
+
+        /* "asyncpg/protocol/codecs/bits.pyx":40
+ *         wbuf.write_cstr(buf, len)
+ *     finally:
+ *         if pybuf_used:             # <<<<<<<<<<<<<<
+ *             cpython.PyBuffer_Release(&pybuf)
+ * 
+ */
+      }
+      goto __pyx_L6;
+    }
+    /*exception exit:*/{
+      __Pyx_PyThreadState_declare
+      __pyx_L5_error:;
+      __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
+      __Pyx_PyThreadState_assign
+      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
+      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13) < 0)) __Pyx_ErrFetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
+      __Pyx_XGOTREF(__pyx_t_11);
+      __Pyx_XGOTREF(__pyx_t_12);
+      __Pyx_XGOTREF(__pyx_t_13);
+      __Pyx_XGOTREF(__pyx_t_14);
+      __Pyx_XGOTREF(__pyx_t_15);
+      __Pyx_XGOTREF(__pyx_t_16);
+      __pyx_t_4 = __pyx_lineno; __pyx_t_9 = __pyx_clineno; __pyx_t_10 = __pyx_filename;
+      {
+        __pyx_t_3 = (__pyx_v_pybuf_used != 0);
+        if (__pyx_t_3) {
+
+          /* "asyncpg/protocol/codecs/bits.pyx":41
+ *     finally:
+ *         if pybuf_used:
+ *             cpython.PyBuffer_Release(&pybuf)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+          PyBuffer_Release((&__pyx_v_pybuf));
+
+          /* "asyncpg/protocol/codecs/bits.pyx":40
+ *         wbuf.write_cstr(buf, len)
+ *     finally:
+ *         if pybuf_used:             # <<<<<<<<<<<<<<
+ *             cpython.PyBuffer_Release(&pybuf)
+ * 
+ */
+        }
+      }
+      __Pyx_PyThreadState_assign
+      if (PY_MAJOR_VERSION >= 3) {
+        __Pyx_XGIVEREF(__pyx_t_14);
+        __Pyx_XGIVEREF(__pyx_t_15);
+        __Pyx_XGIVEREF(__pyx_t_16);
+        __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
+      }
+      __Pyx_XGIVEREF(__pyx_t_11);
+      __Pyx_XGIVEREF(__pyx_t_12);
+      __Pyx_XGIVEREF(__pyx_t_13);
+      __Pyx_ErrRestore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
+      __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
+      __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_9; __pyx_filename = __pyx_t_10;
+      goto __pyx_L1_error;
+    }
+    __pyx_L6:;
+  }
+
+  /* "asyncpg/protocol/codecs/bits.pyx":11
+ * 
+ * 
+ * cdef bits_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         Py_buffer pybuf
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.bits_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/bits.pyx":44
+ * 
+ * 
+ * cdef bits_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int32_t bitlen = hton.unpack_int32(buf.read(4))
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_bits_decode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  int32_t __pyx_v_bitlen;
+  Py_ssize_t __pyx_v_buf_len;
+  PyObject *__pyx_v_bytes_ = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  char const *__pyx_t_1;
+  Py_ssize_t __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  int __pyx_t_7;
+  PyObject *__pyx_t_8 = NULL;
+  __Pyx_RefNannySetupContext("bits_decode", 0);
+
+  /* "asyncpg/protocol/codecs/bits.pyx":46
+ * cdef bits_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     cdef:
+ *         int32_t bitlen = hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ *         ssize_t buf_len = buf.len
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(8, 46, __pyx_L1_error)
+  __pyx_v_bitlen = __pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/bits.pyx":47
+ *     cdef:
+ *         int32_t bitlen = hton.unpack_int32(buf.read(4))
+ *         ssize_t buf_len = buf.len             # <<<<<<<<<<<<<<
+ * 
+ *     bytes_ = cpython.PyBytes_FromStringAndSize(buf.read_all(), buf_len)
+ */
+  __pyx_t_2 = __pyx_v_buf->len;
+  __pyx_v_buf_len = __pyx_t_2;
+
+  /* "asyncpg/protocol/codecs/bits.pyx":49
+ *         ssize_t buf_len = buf.len
+ * 
+ *     bytes_ = cpython.PyBytes_FromStringAndSize(buf.read_all(), buf_len)             # <<<<<<<<<<<<<<
+ *     return BitString.frombytes(bytes_, bitlen)
+ * 
+ */
+  __pyx_t_3 = PyBytes_FromStringAndSize(__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read_all(__pyx_v_buf), __pyx_v_buf_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(8, 49, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_v_bytes_ = ((PyObject*)__pyx_t_3);
+  __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/bits.pyx":50
+ * 
+ *     bytes_ = cpython.PyBytes_FromStringAndSize(buf.read_all(), buf_len)
+ *     return BitString.frombytes(bytes_, bitlen)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_BitString); if (unlikely(!__pyx_t_4)) __PYX_ERR(8, 50, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_frombytes); if (unlikely(!__pyx_t_5)) __PYX_ERR(8, 50, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = __Pyx_PyInt_From_int32_t(__pyx_v_bitlen); if (unlikely(!__pyx_t_4)) __PYX_ERR(8, 50, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_6 = NULL;
+  __pyx_t_7 = 0;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
+    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
+    if (likely(__pyx_t_6)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+      __Pyx_INCREF(__pyx_t_6);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_5, function);
+      __pyx_t_7 = 1;
+    }
+  }
+  #if CYTHON_FAST_PYCALL
+  if (PyFunction_Check(__pyx_t_5)) {
+    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_bytes_, __pyx_t_4};
+    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(8, 50, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  } else
+  #endif
+  #if CYTHON_FAST_PYCCALL
+  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
+    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_bytes_, __pyx_t_4};
+    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(8, 50, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  } else
+  #endif
+  {
+    __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(8, 50, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_8);
+    if (__pyx_t_6) {
+      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
+    }
+    __Pyx_INCREF(__pyx_v_bytes_);
+    __Pyx_GIVEREF(__pyx_v_bytes_);
+    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_v_bytes_);
+    __Pyx_GIVEREF(__pyx_t_4);
+    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4);
+    __pyx_t_4 = 0;
+    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(8, 50, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __pyx_r = __pyx_t_3;
+  __pyx_t_3 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/bits.pyx":44
+ * 
+ * 
+ * cdef bits_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int32_t bitlen = hton.unpack_int32(buf.read(4))
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.bits_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_bytes_);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/bits.pyx":53
+ * 
+ * 
+ * cdef init_bits_codecs():             # <<<<<<<<<<<<<<
+ *     register_core_codec(BITOID,
+ *                         <encode_func>&bits_encode,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_bits_codecs(void) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("init_bits_codecs", 0);
+
+  /* "asyncpg/protocol/codecs/bits.pyx":54
+ * 
+ * cdef init_bits_codecs():
+ *     register_core_codec(BITOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&bits_encode,
+ *                         <decode_func>&bits_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x618, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_bits_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_bits_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 54, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/bits.pyx":59
+ *                         PG_FORMAT_BINARY)
+ * 
+ *     register_core_codec(VARBITOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&bits_encode,
+ *                         <decode_func>&bits_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x61A, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_bits_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_bits_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 59, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/bits.pyx":53
+ * 
+ * 
+ * cdef init_bits_codecs():             # <<<<<<<<<<<<<<
+ *     register_core_codec(BITOID,
+ *                         <encode_func>&bits_encode,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.init_bits_codecs", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/datetime.pyx":59
+ * 
+ * 
+ * cdef inline _encode_time(WriteBuffer buf, int64_t seconds,             # <<<<<<<<<<<<<<
+ *                          int32_t microseconds):
+ *     # XXX: add support for double timestamps
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol__encode_time(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, int64_t __pyx_v_seconds, int32_t __pyx_v_microseconds) {
+  int64_t __pyx_v_ts;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("_encode_time", 0);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":63
+ *     # XXX: add support for double timestamps
+ *     # int64 timestamps,
+ *     cdef int64_t ts = seconds * 1000000 + microseconds             # <<<<<<<<<<<<<<
+ * 
+ *     if ts == infinity_datetime_ts:
+ */
+  __pyx_v_ts = ((__pyx_v_seconds * 0xF4240) + __pyx_v_microseconds);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":65
+ *     cdef int64_t ts = seconds * 1000000 + microseconds
+ * 
+ *     if ts == infinity_datetime_ts:             # <<<<<<<<<<<<<<
+ *         buf.write_int64(pg_time64_infinity)
+ *     elif ts == negative_infinity_datetime_ts:
+ */
+  __pyx_t_1 = ((__pyx_v_ts == __pyx_v_7asyncpg_8protocol_8protocol_infinity_datetime_ts) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":66
+ * 
+ *     if ts == infinity_datetime_ts:
+ *         buf.write_int64(pg_time64_infinity)             # <<<<<<<<<<<<<<
+ *     elif ts == negative_infinity_datetime_ts:
+ *         buf.write_int64(pg_time64_negative_infinity)
+ */
+    __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int64(__pyx_v_buf, __pyx_v_7asyncpg_8protocol_8protocol_pg_time64_infinity); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 66, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":65
+ *     cdef int64_t ts = seconds * 1000000 + microseconds
+ * 
+ *     if ts == infinity_datetime_ts:             # <<<<<<<<<<<<<<
+ *         buf.write_int64(pg_time64_infinity)
+ *     elif ts == negative_infinity_datetime_ts:
+ */
+    goto __pyx_L3;
+  }
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":67
+ *     if ts == infinity_datetime_ts:
+ *         buf.write_int64(pg_time64_infinity)
+ *     elif ts == negative_infinity_datetime_ts:             # <<<<<<<<<<<<<<
+ *         buf.write_int64(pg_time64_negative_infinity)
+ *     else:
+ */
+  __pyx_t_1 = ((__pyx_v_ts == __pyx_v_7asyncpg_8protocol_8protocol_negative_infinity_datetime_ts) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":68
+ *         buf.write_int64(pg_time64_infinity)
+ *     elif ts == negative_infinity_datetime_ts:
+ *         buf.write_int64(pg_time64_negative_infinity)             # <<<<<<<<<<<<<<
+ *     else:
+ *         buf.write_int64(ts)
+ */
+    __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int64(__pyx_v_buf, __pyx_v_7asyncpg_8protocol_8protocol_pg_time64_negative_infinity); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 68, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":67
+ *     if ts == infinity_datetime_ts:
+ *         buf.write_int64(pg_time64_infinity)
+ *     elif ts == negative_infinity_datetime_ts:             # <<<<<<<<<<<<<<
+ *         buf.write_int64(pg_time64_negative_infinity)
+ *     else:
+ */
+    goto __pyx_L3;
+  }
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":70
+ *         buf.write_int64(pg_time64_negative_infinity)
+ *     else:
+ *         buf.write_int64(ts)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  /*else*/ {
+    __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int64(__pyx_v_buf, __pyx_v_ts); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 70, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  }
+  __pyx_L3:;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":59
+ * 
+ * 
+ * cdef inline _encode_time(WriteBuffer buf, int64_t seconds,             # <<<<<<<<<<<<<<
+ *                          int32_t microseconds):
+ *     # XXX: add support for double timestamps
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol._encode_time", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/datetime.pyx":73
+ * 
+ * 
+ * cdef inline int32_t _decode_time(FastReadBuffer buf, int64_t *seconds,             # <<<<<<<<<<<<<<
+ *                                  uint32_t *microseconds):
+ *     # XXX: add support for double timestamps
+ */
+
+static CYTHON_INLINE int32_t __pyx_f_7asyncpg_8protocol_8protocol__decode_time(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf, int64_t *__pyx_v_seconds, uint32_t *__pyx_v_microseconds) {
+  int64_t __pyx_v_ts;
+  int32_t __pyx_r;
+  __Pyx_RefNannyDeclarations
+  char const *__pyx_t_1;
+  int __pyx_t_2;
+  __Pyx_RefNannySetupContext("_decode_time", 0);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":77
+ *     # XXX: add support for double timestamps
+ *     # int64 timestamps,
+ *     cdef int64_t ts = hton.unpack_int64(buf.read(8))             # <<<<<<<<<<<<<<
+ * 
+ *     if ts == pg_time64_infinity:
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(9, 77, __pyx_L1_error)
+  __pyx_v_ts = __pyx_f_7asyncpg_8protocol_4hton_unpack_int64(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":79
+ *     cdef int64_t ts = hton.unpack_int64(buf.read(8))
+ * 
+ *     if ts == pg_time64_infinity:             # <<<<<<<<<<<<<<
+ *         return 1
+ *     elif ts == pg_time64_negative_infinity:
+ */
+  __pyx_t_2 = ((__pyx_v_ts == __pyx_v_7asyncpg_8protocol_8protocol_pg_time64_infinity) != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":80
+ * 
+ *     if ts == pg_time64_infinity:
+ *         return 1             # <<<<<<<<<<<<<<
+ *     elif ts == pg_time64_negative_infinity:
+ *         return -1
+ */
+    __pyx_r = 1;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":79
+ *     cdef int64_t ts = hton.unpack_int64(buf.read(8))
+ * 
+ *     if ts == pg_time64_infinity:             # <<<<<<<<<<<<<<
+ *         return 1
+ *     elif ts == pg_time64_negative_infinity:
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":81
+ *     if ts == pg_time64_infinity:
+ *         return 1
+ *     elif ts == pg_time64_negative_infinity:             # <<<<<<<<<<<<<<
+ *         return -1
+ * 
+ */
+  __pyx_t_2 = ((__pyx_v_ts == __pyx_v_7asyncpg_8protocol_8protocol_pg_time64_negative_infinity) != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":82
+ *         return 1
+ *     elif ts == pg_time64_negative_infinity:
+ *         return -1             # <<<<<<<<<<<<<<
+ * 
+ *     seconds[0] = <int64_t>(ts / 1000000)
+ */
+    __pyx_r = -1;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":81
+ *     if ts == pg_time64_infinity:
+ *         return 1
+ *     elif ts == pg_time64_negative_infinity:             # <<<<<<<<<<<<<<
+ *         return -1
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":84
+ *         return -1
+ * 
+ *     seconds[0] = <int64_t>(ts / 1000000)             # <<<<<<<<<<<<<<
+ *     microseconds[0] = <uint32_t>(ts % 1000000)
+ * 
+ */
+  (__pyx_v_seconds[0]) = ((int64_t)(((double)__pyx_v_ts) / 1000000.0));
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":85
+ * 
+ *     seconds[0] = <int64_t>(ts / 1000000)
+ *     microseconds[0] = <uint32_t>(ts % 1000000)             # <<<<<<<<<<<<<<
+ * 
+ *     return 0
+ */
+  (__pyx_v_microseconds[0]) = ((uint32_t)__Pyx_mod_int64_t(__pyx_v_ts, 0xF4240));
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":87
+ *     microseconds[0] = <uint32_t>(ts % 1000000)
+ * 
+ *     return 0             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_r = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":73
+ * 
+ * 
+ * cdef inline int32_t _decode_time(FastReadBuffer buf, int64_t *seconds,             # <<<<<<<<<<<<<<
+ *                                  uint32_t *microseconds):
+ *     # XXX: add support for double timestamps
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_WriteUnraisable("asyncpg.protocol.protocol._decode_time", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/datetime.pyx":90
+ * 
+ * 
+ * cdef date_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int32_t ordinal = <int32_t>cpython.PyLong_AsLong(obj.toordinal())
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_date_encode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
+  int32_t __pyx_v_ordinal;
+  int32_t __pyx_v_pg_ordinal;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  long __pyx_t_4;
+  int __pyx_t_5;
+  __Pyx_RefNannySetupContext("date_encode", 0);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":92
+ * cdef date_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+ *     cdef:
+ *         int32_t ordinal = <int32_t>cpython.PyLong_AsLong(obj.toordinal())             # <<<<<<<<<<<<<<
+ *         int32_t pg_ordinal
+ * 
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_toordinal); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 92, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (__pyx_t_3) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 92, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  } else {
+    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 92, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_4 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_4 == -1L && PyErr_Occurred())) __PYX_ERR(9, 92, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_ordinal = ((int32_t)__pyx_t_4);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":95
+ *         int32_t pg_ordinal
+ * 
+ *     if ordinal == infinity_date_ord:             # <<<<<<<<<<<<<<
+ *         pg_ordinal = pg_date_infinity
+ *     elif ordinal == negative_infinity_date_ord:
+ */
+  __pyx_t_5 = ((__pyx_v_ordinal == __pyx_v_7asyncpg_8protocol_8protocol_infinity_date_ord) != 0);
+  if (__pyx_t_5) {
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":96
+ * 
+ *     if ordinal == infinity_date_ord:
+ *         pg_ordinal = pg_date_infinity             # <<<<<<<<<<<<<<
+ *     elif ordinal == negative_infinity_date_ord:
+ *         pg_ordinal = pg_date_negative_infinity
+ */
+    __pyx_v_pg_ordinal = __pyx_v_7asyncpg_8protocol_8protocol_pg_date_infinity;
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":95
+ *         int32_t pg_ordinal
+ * 
+ *     if ordinal == infinity_date_ord:             # <<<<<<<<<<<<<<
+ *         pg_ordinal = pg_date_infinity
+ *     elif ordinal == negative_infinity_date_ord:
+ */
+    goto __pyx_L3;
+  }
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":97
+ *     if ordinal == infinity_date_ord:
+ *         pg_ordinal = pg_date_infinity
+ *     elif ordinal == negative_infinity_date_ord:             # <<<<<<<<<<<<<<
+ *         pg_ordinal = pg_date_negative_infinity
+ *     else:
+ */
+  __pyx_t_5 = ((__pyx_v_ordinal == __pyx_v_7asyncpg_8protocol_8protocol_negative_infinity_date_ord) != 0);
+  if (__pyx_t_5) {
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":98
+ *         pg_ordinal = pg_date_infinity
+ *     elif ordinal == negative_infinity_date_ord:
+ *         pg_ordinal = pg_date_negative_infinity             # <<<<<<<<<<<<<<
+ *     else:
+ *         pg_ordinal = ordinal - pg_date_offset_ord
+ */
+    __pyx_v_pg_ordinal = __pyx_v_7asyncpg_8protocol_8protocol_pg_date_negative_infinity;
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":97
+ *     if ordinal == infinity_date_ord:
+ *         pg_ordinal = pg_date_infinity
+ *     elif ordinal == negative_infinity_date_ord:             # <<<<<<<<<<<<<<
+ *         pg_ordinal = pg_date_negative_infinity
+ *     else:
+ */
+    goto __pyx_L3;
+  }
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":100
+ *         pg_ordinal = pg_date_negative_infinity
+ *     else:
+ *         pg_ordinal = ordinal - pg_date_offset_ord             # <<<<<<<<<<<<<<
+ * 
+ *     buf.write_int32(4)
+ */
+  /*else*/ {
+    __pyx_v_pg_ordinal = (__pyx_v_ordinal - __pyx_v_7asyncpg_8protocol_8protocol_pg_date_offset_ord);
+  }
+  __pyx_L3:;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":102
+ *         pg_ordinal = ordinal - pg_date_offset_ord
+ * 
+ *     buf.write_int32(4)             # <<<<<<<<<<<<<<
+ *     buf.write_int32(pg_ordinal)
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, 4); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 102, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":103
+ * 
+ *     buf.write_int32(4)
+ *     buf.write_int32(pg_ordinal)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, __pyx_v_pg_ordinal); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 103, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":90
+ * 
+ * 
+ * cdef date_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int32_t ordinal = <int32_t>cpython.PyLong_AsLong(obj.toordinal())
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.date_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/datetime.pyx":106
+ * 
+ * 
+ * cdef date_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef int32_t pg_ordinal = hton.unpack_int32(buf.read(4))
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_date_decode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  int32_t __pyx_v_pg_ordinal;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  char const *__pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  __Pyx_RefNannySetupContext("date_decode", 0);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":107
+ * 
+ * cdef date_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     cdef int32_t pg_ordinal = hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ * 
+ *     if pg_ordinal == pg_date_infinity:
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(9, 107, __pyx_L1_error)
+  __pyx_v_pg_ordinal = __pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":109
+ *     cdef int32_t pg_ordinal = hton.unpack_int32(buf.read(4))
+ * 
+ *     if pg_ordinal == pg_date_infinity:             # <<<<<<<<<<<<<<
+ *         return infinity_date
+ *     elif pg_ordinal == pg_date_negative_infinity:
+ */
+  __pyx_t_2 = ((__pyx_v_pg_ordinal == __pyx_v_7asyncpg_8protocol_8protocol_pg_date_infinity) != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":110
+ * 
+ *     if pg_ordinal == pg_date_infinity:
+ *         return infinity_date             # <<<<<<<<<<<<<<
+ *     elif pg_ordinal == pg_date_negative_infinity:
+ *         return negative_infinity_date
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_infinity_date); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 110, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_r = __pyx_t_3;
+    __pyx_t_3 = 0;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":109
+ *     cdef int32_t pg_ordinal = hton.unpack_int32(buf.read(4))
+ * 
+ *     if pg_ordinal == pg_date_infinity:             # <<<<<<<<<<<<<<
+ *         return infinity_date
+ *     elif pg_ordinal == pg_date_negative_infinity:
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":111
+ *     if pg_ordinal == pg_date_infinity:
+ *         return infinity_date
+ *     elif pg_ordinal == pg_date_negative_infinity:             # <<<<<<<<<<<<<<
+ *         return negative_infinity_date
+ *     else:
+ */
+  __pyx_t_2 = ((__pyx_v_pg_ordinal == __pyx_v_7asyncpg_8protocol_8protocol_pg_date_negative_infinity) != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":112
+ *         return infinity_date
+ *     elif pg_ordinal == pg_date_negative_infinity:
+ *         return negative_infinity_date             # <<<<<<<<<<<<<<
+ *     else:
+ *         return date_from_ordinal(pg_ordinal + pg_date_offset_ord)
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_negative_infinity_date); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 112, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_r = __pyx_t_3;
+    __pyx_t_3 = 0;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":111
+ *     if pg_ordinal == pg_date_infinity:
+ *         return infinity_date
+ *     elif pg_ordinal == pg_date_negative_infinity:             # <<<<<<<<<<<<<<
+ *         return negative_infinity_date
+ *     else:
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":114
+ *         return negative_infinity_date
+ *     else:
+ *         return date_from_ordinal(pg_ordinal + pg_date_offset_ord)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  /*else*/ {
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_date_from_ordinal); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 114, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = __Pyx_PyInt_From_int32_t((__pyx_v_pg_ordinal + __pyx_v_7asyncpg_8protocol_8protocol_pg_date_offset_ord)); if (unlikely(!__pyx_t_5)) __PYX_ERR(9, 114, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = NULL;
+    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
+      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
+      if (likely(__pyx_t_6)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+        __Pyx_INCREF(__pyx_t_6);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_4, function);
+      }
+    }
+    if (!__pyx_t_6) {
+      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 114, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_4)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
+        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 114, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
+        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 114, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(9, 114, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
+        __Pyx_GIVEREF(__pyx_t_5);
+        PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5);
+        __pyx_t_5 = 0;
+        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 114, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_r = __pyx_t_3;
+    __pyx_t_3 = 0;
+    goto __pyx_L0;
+  }
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":106
+ * 
+ * 
+ * cdef date_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef int32_t pg_ordinal = hton.unpack_int32(buf.read(4))
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.date_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/datetime.pyx":117
+ * 
+ * 
+ * cdef timestamp_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     delta = obj - pg_epoch_datetime
+ *     cdef:
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_timestamp_encode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
+  PyObject *__pyx_v_delta = NULL;
+  int64_t __pyx_v_seconds;
+  int32_t __pyx_v_microseconds;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PY_LONG_LONG __pyx_t_3;
+  long __pyx_t_4;
+  __Pyx_RefNannySetupContext("timestamp_encode", 0);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":118
+ * 
+ * cdef timestamp_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+ *     delta = obj - pg_epoch_datetime             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int64_t seconds = cpython.PyLong_AsLongLong(delta.days) * 86400 + \
+ */
+  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_pg_epoch_datetime); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 118, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyNumber_Subtract(__pyx_v_obj, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 118, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_delta = __pyx_t_2;
+  __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":120
+ *     delta = obj - pg_epoch_datetime
+ *     cdef:
+ *         int64_t seconds = cpython.PyLong_AsLongLong(delta.days) * 86400 + \             # <<<<<<<<<<<<<<
+ *                                 cpython.PyLong_AsLong(delta.seconds)
+ *         int32_t microseconds = <int32_t>cpython.PyLong_AsLong(
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_delta, __pyx_n_s_days); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 120, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyLong_AsLongLong(__pyx_t_2); if (unlikely(__pyx_t_3 == -1LL && PyErr_Occurred())) __PYX_ERR(9, 120, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":121
+ *     cdef:
+ *         int64_t seconds = cpython.PyLong_AsLongLong(delta.days) * 86400 + \
+ *                                 cpython.PyLong_AsLong(delta.seconds)             # <<<<<<<<<<<<<<
+ *         int32_t microseconds = <int32_t>cpython.PyLong_AsLong(
+ *                                     delta.microseconds)
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_delta, __pyx_n_s_seconds); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 121, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = PyLong_AsLong(__pyx_t_2); if (unlikely(__pyx_t_4 == -1L && PyErr_Occurred())) __PYX_ERR(9, 121, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":120
+ *     delta = obj - pg_epoch_datetime
+ *     cdef:
+ *         int64_t seconds = cpython.PyLong_AsLongLong(delta.days) * 86400 + \             # <<<<<<<<<<<<<<
+ *                                 cpython.PyLong_AsLong(delta.seconds)
+ *         int32_t microseconds = <int32_t>cpython.PyLong_AsLong(
+ */
+  __pyx_v_seconds = ((__pyx_t_3 * 0x15180) + __pyx_t_4);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":123
+ *                                 cpython.PyLong_AsLong(delta.seconds)
+ *         int32_t microseconds = <int32_t>cpython.PyLong_AsLong(
+ *                                     delta.microseconds)             # <<<<<<<<<<<<<<
+ * 
+ *     buf.write_int32(8)
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_delta, __pyx_n_s_microseconds); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 123, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":122
+ *         int64_t seconds = cpython.PyLong_AsLongLong(delta.days) * 86400 + \
+ *                                 cpython.PyLong_AsLong(delta.seconds)
+ *         int32_t microseconds = <int32_t>cpython.PyLong_AsLong(             # <<<<<<<<<<<<<<
+ *                                     delta.microseconds)
+ * 
+ */
+  __pyx_t_4 = PyLong_AsLong(__pyx_t_2); if (unlikely(__pyx_t_4 == -1L && PyErr_Occurred())) __PYX_ERR(9, 122, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_v_microseconds = ((int32_t)__pyx_t_4);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":125
+ *                                     delta.microseconds)
+ * 
+ *     buf.write_int32(8)             # <<<<<<<<<<<<<<
+ *     _encode_time(buf, seconds, microseconds)
+ * 
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, 8); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 125, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":126
+ * 
+ *     buf.write_int32(8)
+ *     _encode_time(buf, seconds, microseconds)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol__encode_time(__pyx_v_buf, __pyx_v_seconds, __pyx_v_microseconds); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 126, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":117
+ * 
+ * 
+ * cdef timestamp_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     delta = obj - pg_epoch_datetime
+ *     cdef:
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.timestamp_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_delta);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/datetime.pyx":129
+ * 
+ * 
+ * cdef timestamp_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int64_t seconds = 0
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_timestamp_decode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  int64_t __pyx_v_seconds;
+  uint32_t __pyx_v_microseconds;
+  int32_t __pyx_v_inf;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  int __pyx_t_9;
+  PyObject *__pyx_t_10 = NULL;
+  __Pyx_RefNannySetupContext("timestamp_decode", 0);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":131
+ * cdef timestamp_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     cdef:
+ *         int64_t seconds = 0             # <<<<<<<<<<<<<<
+ *         uint32_t microseconds = 0
+ *         int32_t inf = _decode_time(buf, &seconds, &microseconds)
+ */
+  __pyx_v_seconds = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":132
+ *     cdef:
+ *         int64_t seconds = 0
+ *         uint32_t microseconds = 0             # <<<<<<<<<<<<<<
+ *         int32_t inf = _decode_time(buf, &seconds, &microseconds)
+ * 
+ */
+  __pyx_v_microseconds = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":133
+ *         int64_t seconds = 0
+ *         uint32_t microseconds = 0
+ *         int32_t inf = _decode_time(buf, &seconds, &microseconds)             # <<<<<<<<<<<<<<
+ * 
+ *     if inf > 0:
+ */
+  __pyx_v_inf = __pyx_f_7asyncpg_8protocol_8protocol__decode_time(__pyx_v_buf, (&__pyx_v_seconds), (&__pyx_v_microseconds));
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":135
+ *         int32_t inf = _decode_time(buf, &seconds, &microseconds)
+ * 
+ *     if inf > 0:             # <<<<<<<<<<<<<<
+ *         # positive infinity
+ *         return infinity_datetime
+ */
+  __pyx_t_1 = ((__pyx_v_inf > 0) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":137
+ *     if inf > 0:
+ *         # positive infinity
+ *         return infinity_datetime             # <<<<<<<<<<<<<<
+ *     elif inf < 0:
+ *         # negative infinity
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_infinity_datetime); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 137, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_r = __pyx_t_2;
+    __pyx_t_2 = 0;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":135
+ *         int32_t inf = _decode_time(buf, &seconds, &microseconds)
+ * 
+ *     if inf > 0:             # <<<<<<<<<<<<<<
+ *         # positive infinity
+ *         return infinity_datetime
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":138
+ *         # positive infinity
+ *         return infinity_datetime
+ *     elif inf < 0:             # <<<<<<<<<<<<<<
+ *         # negative infinity
+ *         return negative_infinity_datetime
+ */
+  __pyx_t_1 = ((__pyx_v_inf < 0) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":140
+ *     elif inf < 0:
+ *         # negative infinity
+ *         return negative_infinity_datetime             # <<<<<<<<<<<<<<
+ *     else:
+ *         return pg_epoch_datetime.__add__(
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_negative_infinity_datetime); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 140, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_r = __pyx_t_2;
+    __pyx_t_2 = 0;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":138
+ *         # positive infinity
+ *         return infinity_datetime
+ *     elif inf < 0:             # <<<<<<<<<<<<<<
+ *         # negative infinity
+ *         return negative_infinity_datetime
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":142
+ *         return negative_infinity_datetime
+ *     else:
+ *         return pg_epoch_datetime.__add__(             # <<<<<<<<<<<<<<
+ *             timedelta(0, seconds, microseconds))
+ * 
+ */
+  /*else*/ {
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_pg_epoch_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 142, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_add); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 142, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":143
+ *     else:
+ *         return pg_epoch_datetime.__add__(
+ *             timedelta(0, seconds, microseconds))             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_timedelta); if (unlikely(!__pyx_t_5)) __PYX_ERR(9, 143, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = __Pyx_PyInt_From_int64_t(__pyx_v_seconds); if (unlikely(!__pyx_t_6)) __PYX_ERR(9, 143, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_7 = __Pyx_PyInt_From_uint32_t(__pyx_v_microseconds); if (unlikely(!__pyx_t_7)) __PYX_ERR(9, 143, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_7);
+    __pyx_t_8 = NULL;
+    __pyx_t_9 = 0;
+    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
+      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5);
+      if (likely(__pyx_t_8)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+        __Pyx_INCREF(__pyx_t_8);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_5, function);
+        __pyx_t_9 = 1;
+      }
+    }
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_5)) {
+      PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_int_0, __pyx_t_6, __pyx_t_7};
+      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 143, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
+      PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_int_0, __pyx_t_6, __pyx_t_7};
+      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 143, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    } else
+    #endif
+    {
+      __pyx_t_10 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(9, 143, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_10);
+      if (__pyx_t_8) {
+        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
+      }
+      __Pyx_INCREF(__pyx_int_0);
+      __Pyx_GIVEREF(__pyx_int_0);
+      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_int_0);
+      __Pyx_GIVEREF(__pyx_t_6);
+      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_6);
+      __Pyx_GIVEREF(__pyx_t_7);
+      PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_7);
+      __pyx_t_6 = 0;
+      __pyx_t_7 = 0;
+      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 143, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_5 = NULL;
+    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
+      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
+      if (likely(__pyx_t_5)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+        __Pyx_INCREF(__pyx_t_5);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_4, function);
+      }
+    }
+    if (!__pyx_t_5) {
+      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 142, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_GOTREF(__pyx_t_2);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_4)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
+        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 142, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
+        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 142, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(9, 142, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_10);
+        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5); __pyx_t_5 = NULL;
+        __Pyx_GIVEREF(__pyx_t_3);
+        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_3);
+        __pyx_t_3 = 0;
+        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 142, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_r = __pyx_t_2;
+    __pyx_t_2 = 0;
+    goto __pyx_L0;
+  }
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":129
+ * 
+ * 
+ * cdef timestamp_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int64_t seconds = 0
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.timestamp_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/datetime.pyx":146
+ * 
+ * 
+ * cdef timestamptz_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     buf.write_int32(8)
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_timestamptz_encode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
+  PyObject *__pyx_v_delta = NULL;
+  int64_t __pyx_v_seconds;
+  int32_t __pyx_v_microseconds;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PY_LONG_LONG __pyx_t_7;
+  long __pyx_t_8;
+  __Pyx_RefNannySetupContext("timestamptz_encode", 0);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":147
+ * 
+ * cdef timestamptz_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+ *     buf.write_int32(8)             # <<<<<<<<<<<<<<
+ * 
+ *     if obj == infinity_datetime:
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, 8); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 147, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":149
+ *     buf.write_int32(8)
+ * 
+ *     if obj == infinity_datetime:             # <<<<<<<<<<<<<<
+ *         buf.write_int64(pg_time64_infinity)
+ *         return
+ */
+  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_infinity_datetime); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 149, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_RichCompare(__pyx_v_obj, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 149, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(9, 149, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":150
+ * 
+ *     if obj == infinity_datetime:
+ *         buf.write_int64(pg_time64_infinity)             # <<<<<<<<<<<<<<
+ *         return
+ *     elif obj == negative_infinity_datetime:
+ */
+    __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int64(__pyx_v_buf, __pyx_v_7asyncpg_8protocol_8protocol_pg_time64_infinity); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 150, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":151
+ *     if obj == infinity_datetime:
+ *         buf.write_int64(pg_time64_infinity)
+ *         return             # <<<<<<<<<<<<<<
+ *     elif obj == negative_infinity_datetime:
+ *         buf.write_int64(pg_time64_negative_infinity)
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":149
+ *     buf.write_int32(8)
+ * 
+ *     if obj == infinity_datetime:             # <<<<<<<<<<<<<<
+ *         buf.write_int64(pg_time64_infinity)
+ *         return
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":152
+ *         buf.write_int64(pg_time64_infinity)
+ *         return
+ *     elif obj == negative_infinity_datetime:             # <<<<<<<<<<<<<<
+ *         buf.write_int64(pg_time64_negative_infinity)
+ *         return
+ */
+  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_negative_infinity_datetime); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 152, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_obj, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 152, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(9, 152, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":153
+ *         return
+ *     elif obj == negative_infinity_datetime:
+ *         buf.write_int64(pg_time64_negative_infinity)             # <<<<<<<<<<<<<<
+ *         return
+ * 
+ */
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int64(__pyx_v_buf, __pyx_v_7asyncpg_8protocol_8protocol_pg_time64_negative_infinity); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 153, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":154
+ *     elif obj == negative_infinity_datetime:
+ *         buf.write_int64(pg_time64_negative_infinity)
+ *         return             # <<<<<<<<<<<<<<
+ * 
+ *     delta = obj.astimezone(utc) - pg_epoch_datetime_utc
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":152
+ *         buf.write_int64(pg_time64_infinity)
+ *         return
+ *     elif obj == negative_infinity_datetime:             # <<<<<<<<<<<<<<
+ *         buf.write_int64(pg_time64_negative_infinity)
+ *         return
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":156
+ *         return
+ * 
+ *     delta = obj.astimezone(utc) - pg_epoch_datetime_utc             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int64_t seconds = cpython.PyLong_AsLongLong(delta.days) * 86400 + \
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_astimezone); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 156, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_utc); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 156, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_5 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_5)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_5);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (!__pyx_t_5) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 156, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
+      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 156, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
+      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 156, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    } else
+    #endif
+    {
+      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(9, 156, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
+      __Pyx_GIVEREF(__pyx_t_4);
+      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
+      __pyx_t_4 = 0;
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 156, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_pg_epoch_datetime_utc); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 156, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_6 = PyNumber_Subtract(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(9, 156, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_6);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_v_delta = __pyx_t_6;
+  __pyx_t_6 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":158
+ *     delta = obj.astimezone(utc) - pg_epoch_datetime_utc
+ *     cdef:
+ *         int64_t seconds = cpython.PyLong_AsLongLong(delta.days) * 86400 + \             # <<<<<<<<<<<<<<
+ *                                 cpython.PyLong_AsLong(delta.seconds)
+ *         int32_t microseconds = <int32_t>cpython.PyLong_AsLong(
+ */
+  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_delta, __pyx_n_s_days); if (unlikely(!__pyx_t_6)) __PYX_ERR(9, 158, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_6);
+  __pyx_t_7 = PyLong_AsLongLong(__pyx_t_6); if (unlikely(__pyx_t_7 == -1LL && PyErr_Occurred())) __PYX_ERR(9, 158, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":159
+ *     cdef:
+ *         int64_t seconds = cpython.PyLong_AsLongLong(delta.days) * 86400 + \
+ *                                 cpython.PyLong_AsLong(delta.seconds)             # <<<<<<<<<<<<<<
+ *         int32_t microseconds = <int32_t>cpython.PyLong_AsLong(
+ *                                     delta.microseconds)
+ */
+  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_delta, __pyx_n_s_seconds); if (unlikely(!__pyx_t_6)) __PYX_ERR(9, 159, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_6);
+  __pyx_t_8 = PyLong_AsLong(__pyx_t_6); if (unlikely(__pyx_t_8 == -1L && PyErr_Occurred())) __PYX_ERR(9, 159, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":158
+ *     delta = obj.astimezone(utc) - pg_epoch_datetime_utc
+ *     cdef:
+ *         int64_t seconds = cpython.PyLong_AsLongLong(delta.days) * 86400 + \             # <<<<<<<<<<<<<<
+ *                                 cpython.PyLong_AsLong(delta.seconds)
+ *         int32_t microseconds = <int32_t>cpython.PyLong_AsLong(
+ */
+  __pyx_v_seconds = ((__pyx_t_7 * 0x15180) + __pyx_t_8);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":161
+ *                                 cpython.PyLong_AsLong(delta.seconds)
+ *         int32_t microseconds = <int32_t>cpython.PyLong_AsLong(
+ *                                     delta.microseconds)             # <<<<<<<<<<<<<<
+ * 
+ *     _encode_time(buf, seconds, microseconds)
+ */
+  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_delta, __pyx_n_s_microseconds); if (unlikely(!__pyx_t_6)) __PYX_ERR(9, 161, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_6);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":160
+ *         int64_t seconds = cpython.PyLong_AsLongLong(delta.days) * 86400 + \
+ *                                 cpython.PyLong_AsLong(delta.seconds)
+ *         int32_t microseconds = <int32_t>cpython.PyLong_AsLong(             # <<<<<<<<<<<<<<
+ *                                     delta.microseconds)
+ * 
+ */
+  __pyx_t_8 = PyLong_AsLong(__pyx_t_6); if (unlikely(__pyx_t_8 == -1L && PyErr_Occurred())) __PYX_ERR(9, 160, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  __pyx_v_microseconds = ((int32_t)__pyx_t_8);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":163
+ *                                     delta.microseconds)
+ * 
+ *     _encode_time(buf, seconds, microseconds)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_6 = __pyx_f_7asyncpg_8protocol_8protocol__encode_time(__pyx_v_buf, __pyx_v_seconds, __pyx_v_microseconds); if (unlikely(!__pyx_t_6)) __PYX_ERR(9, 163, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_6);
+  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":146
+ * 
+ * 
+ * cdef timestamptz_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     buf.write_int32(8)
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.timestamptz_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_delta);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/datetime.pyx":166
+ * 
+ * 
+ * cdef timestamptz_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int64_t seconds = 0
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_timestamptz_decode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  int64_t __pyx_v_seconds;
+  uint32_t __pyx_v_microseconds;
+  int32_t __pyx_v_inf;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  int __pyx_t_9;
+  PyObject *__pyx_t_10 = NULL;
+  __Pyx_RefNannySetupContext("timestamptz_decode", 0);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":168
+ * cdef timestamptz_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     cdef:
+ *         int64_t seconds = 0             # <<<<<<<<<<<<<<
+ *         uint32_t microseconds = 0
+ *         int32_t inf = _decode_time(buf, &seconds, &microseconds)
+ */
+  __pyx_v_seconds = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":169
+ *     cdef:
+ *         int64_t seconds = 0
+ *         uint32_t microseconds = 0             # <<<<<<<<<<<<<<
+ *         int32_t inf = _decode_time(buf, &seconds, &microseconds)
+ * 
+ */
+  __pyx_v_microseconds = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":170
+ *         int64_t seconds = 0
+ *         uint32_t microseconds = 0
+ *         int32_t inf = _decode_time(buf, &seconds, &microseconds)             # <<<<<<<<<<<<<<
+ * 
+ *     if inf > 0:
+ */
+  __pyx_v_inf = __pyx_f_7asyncpg_8protocol_8protocol__decode_time(__pyx_v_buf, (&__pyx_v_seconds), (&__pyx_v_microseconds));
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":172
+ *         int32_t inf = _decode_time(buf, &seconds, &microseconds)
+ * 
+ *     if inf > 0:             # <<<<<<<<<<<<<<
+ *         # positive infinity
+ *         return infinity_datetime
+ */
+  __pyx_t_1 = ((__pyx_v_inf > 0) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":174
+ *     if inf > 0:
+ *         # positive infinity
+ *         return infinity_datetime             # <<<<<<<<<<<<<<
+ *     elif inf < 0:
+ *         # negative infinity
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_infinity_datetime); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 174, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_r = __pyx_t_2;
+    __pyx_t_2 = 0;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":172
+ *         int32_t inf = _decode_time(buf, &seconds, &microseconds)
+ * 
+ *     if inf > 0:             # <<<<<<<<<<<<<<
+ *         # positive infinity
+ *         return infinity_datetime
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":175
+ *         # positive infinity
+ *         return infinity_datetime
+ *     elif inf < 0:             # <<<<<<<<<<<<<<
+ *         # negative infinity
+ *         return negative_infinity_datetime
+ */
+  __pyx_t_1 = ((__pyx_v_inf < 0) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":177
+ *     elif inf < 0:
+ *         # negative infinity
+ *         return negative_infinity_datetime             # <<<<<<<<<<<<<<
+ *     else:
+ *         return pg_epoch_datetime_utc.__add__(
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_negative_infinity_datetime); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 177, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_r = __pyx_t_2;
+    __pyx_t_2 = 0;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":175
+ *         # positive infinity
+ *         return infinity_datetime
+ *     elif inf < 0:             # <<<<<<<<<<<<<<
+ *         # negative infinity
+ *         return negative_infinity_datetime
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":179
+ *         return negative_infinity_datetime
+ *     else:
+ *         return pg_epoch_datetime_utc.__add__(             # <<<<<<<<<<<<<<
+ *             timedelta(0, seconds, microseconds))
+ * 
+ */
+  /*else*/ {
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_pg_epoch_datetime_utc); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 179, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_add); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 179, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/codecs/datetime.pyx":180
+ *     else:
+ *         return pg_epoch_datetime_utc.__add__(
+ *             timedelta(0, seconds, microseconds))             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_timedelta); if (unlikely(!__pyx_t_5)) __PYX_ERR(9, 180, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = __Pyx_PyInt_From_int64_t(__pyx_v_seconds); if (unlikely(!__pyx_t_6)) __PYX_ERR(9, 180, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_7 = __Pyx_PyInt_From_uint32_t(__pyx_v_microseconds); if (unlikely(!__pyx_t_7)) __PYX_ERR(9, 180, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_7);
+    __pyx_t_8 = NULL;
+    __pyx_t_9 = 0;
+    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
+      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5);
+      if (likely(__pyx_t_8)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+        __Pyx_INCREF(__pyx_t_8);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_5, function);
+        __pyx_t_9 = 1;
+      }
+    }
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_5)) {
+      PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_int_0, __pyx_t_6, __pyx_t_7};
+      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 180, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
+      PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_int_0, __pyx_t_6, __pyx_t_7};
+      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 180, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    } else
+    #endif
+    {
+      __pyx_t_10 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(9, 180, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_10);
+      if (__pyx_t_8) {
+        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
+      }
+      __Pyx_INCREF(__pyx_int_0);
+      __Pyx_GIVEREF(__pyx_int_0);
+      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_int_0);
+      __Pyx_GIVEREF(__pyx_t_6);
+      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_6);
+      __Pyx_GIVEREF(__pyx_t_7);
+      PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_7);
+      __pyx_t_6 = 0;
+      __pyx_t_7 = 0;
+      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 180, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_5 = NULL;
+    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
+      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
+      if (likely(__pyx_t_5)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+        __Pyx_INCREF(__pyx_t_5);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_4, function);
+      }
+    }
+    if (!__pyx_t_5) {
+      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 179, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_GOTREF(__pyx_t_2);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_4)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
+        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 179, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
+        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 179, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(9, 179, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_10);
+        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5); __pyx_t_5 = NULL;
+        __Pyx_GIVEREF(__pyx_t_3);
+        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_3);
+        __pyx_t_3 = 0;
+        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 179, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_r = __pyx_t_2;
+    __pyx_t_2 = 0;
+    goto __pyx_L0;
+  }
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":166
+ * 
+ * 
+ * cdef timestamptz_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int64_t seconds = 0
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.timestamptz_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/datetime.pyx":183
+ * 
+ * 
+ * cdef time_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int64_t seconds = cpython.PyLong_AsLong(obj.hour) * 3600 + \
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_time_encode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
+  int64_t __pyx_v_seconds;
+  int32_t __pyx_v_microseconds;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  long __pyx_t_2;
+  long __pyx_t_3;
+  long __pyx_t_4;
+  __Pyx_RefNannySetupContext("time_encode", 0);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":185
+ * cdef time_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+ *     cdef:
+ *         int64_t seconds = cpython.PyLong_AsLong(obj.hour) * 3600 + \             # <<<<<<<<<<<<<<
+ *                             cpython.PyLong_AsLong(obj.minute) * 60 + \
+ *                             cpython.PyLong_AsLong(obj.second)
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_hour); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 185, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_2 == -1L && PyErr_Occurred())) __PYX_ERR(9, 185, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":186
+ *     cdef:
+ *         int64_t seconds = cpython.PyLong_AsLong(obj.hour) * 3600 + \
+ *                             cpython.PyLong_AsLong(obj.minute) * 60 + \             # <<<<<<<<<<<<<<
+ *                             cpython.PyLong_AsLong(obj.second)
+ *         int32_t microseconds = <int32_t>cpython.PyLong_AsLong(obj.microsecond)
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_minute); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 186, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_3 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_3 == -1L && PyErr_Occurred())) __PYX_ERR(9, 186, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":187
+ *         int64_t seconds = cpython.PyLong_AsLong(obj.hour) * 3600 + \
+ *                             cpython.PyLong_AsLong(obj.minute) * 60 + \
+ *                             cpython.PyLong_AsLong(obj.second)             # <<<<<<<<<<<<<<
+ *         int32_t microseconds = <int32_t>cpython.PyLong_AsLong(obj.microsecond)
+ * 
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_second); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 187, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_4 == -1L && PyErr_Occurred())) __PYX_ERR(9, 187, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":186
+ *     cdef:
+ *         int64_t seconds = cpython.PyLong_AsLong(obj.hour) * 3600 + \
+ *                             cpython.PyLong_AsLong(obj.minute) * 60 + \             # <<<<<<<<<<<<<<
+ *                             cpython.PyLong_AsLong(obj.second)
+ *         int32_t microseconds = <int32_t>cpython.PyLong_AsLong(obj.microsecond)
+ */
+  __pyx_v_seconds = (((__pyx_t_2 * 0xE10) + (__pyx_t_3 * 60)) + __pyx_t_4);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":188
+ *                             cpython.PyLong_AsLong(obj.minute) * 60 + \
+ *                             cpython.PyLong_AsLong(obj.second)
+ *         int32_t microseconds = <int32_t>cpython.PyLong_AsLong(obj.microsecond)             # <<<<<<<<<<<<<<
+ * 
+ *     buf.write_int32(8)
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_microsecond); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 188, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_4 == -1L && PyErr_Occurred())) __PYX_ERR(9, 188, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_microseconds = ((int32_t)__pyx_t_4);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":190
+ *         int32_t microseconds = <int32_t>cpython.PyLong_AsLong(obj.microsecond)
+ * 
+ *     buf.write_int32(8)             # <<<<<<<<<<<<<<
+ *     _encode_time(buf, seconds, microseconds)
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, 8); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 190, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":191
+ * 
+ *     buf.write_int32(8)
+ *     _encode_time(buf, seconds, microseconds)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol__encode_time(__pyx_v_buf, __pyx_v_seconds, __pyx_v_microseconds); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 191, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":183
+ * 
+ * 
+ * cdef time_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int64_t seconds = cpython.PyLong_AsLong(obj.hour) * 3600 + \
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.time_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/datetime.pyx":194
+ * 
+ * 
+ * cdef time_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int64_t seconds = 0
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_time_decode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  int64_t __pyx_v_seconds;
+  uint32_t __pyx_v_microseconds;
+  int64_t __pyx_v_minutes;
+  int64_t __pyx_v_sec;
+  int64_t __pyx_v_hours;
+  int64_t __pyx_v_min;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  int __pyx_t_8;
+  PyObject *__pyx_t_9 = NULL;
+  __Pyx_RefNannySetupContext("time_decode", 0);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":196
+ * cdef time_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     cdef:
+ *         int64_t seconds = 0             # <<<<<<<<<<<<<<
+ *         uint32_t microseconds = 0
+ * 
+ */
+  __pyx_v_seconds = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":197
+ *     cdef:
+ *         int64_t seconds = 0
+ *         uint32_t microseconds = 0             # <<<<<<<<<<<<<<
+ * 
+ *     _decode_time(buf, &seconds, &microseconds)
+ */
+  __pyx_v_microseconds = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":199
+ *         uint32_t microseconds = 0
+ * 
+ *     _decode_time(buf, &seconds, &microseconds)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef:
+ */
+  __pyx_f_7asyncpg_8protocol_8protocol__decode_time(__pyx_v_buf, (&__pyx_v_seconds), (&__pyx_v_microseconds));
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":202
+ * 
+ *     cdef:
+ *         int64_t minutes = <int64_t>(seconds / 60)             # <<<<<<<<<<<<<<
+ *         int64_t sec = seconds % 60
+ *         int64_t hours = <int64_t>(minutes / 60)
+ */
+  __pyx_v_minutes = ((int64_t)(((double)__pyx_v_seconds) / 60.0));
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":203
+ *     cdef:
+ *         int64_t minutes = <int64_t>(seconds / 60)
+ *         int64_t sec = seconds % 60             # <<<<<<<<<<<<<<
+ *         int64_t hours = <int64_t>(minutes / 60)
+ *         int64_t min = minutes % 60
+ */
+  __pyx_v_sec = __Pyx_mod_int64_t(__pyx_v_seconds, 60);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":204
+ *         int64_t minutes = <int64_t>(seconds / 60)
+ *         int64_t sec = seconds % 60
+ *         int64_t hours = <int64_t>(minutes / 60)             # <<<<<<<<<<<<<<
+ *         int64_t min = minutes % 60
+ * 
+ */
+  __pyx_v_hours = ((int64_t)(((double)__pyx_v_minutes) / 60.0));
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":205
+ *         int64_t sec = seconds % 60
+ *         int64_t hours = <int64_t>(minutes / 60)
+ *         int64_t min = minutes % 60             # <<<<<<<<<<<<<<
+ * 
+ *     return datetime.time(hours, min, sec, microseconds)
+ */
+  __pyx_v_min = __Pyx_mod_int64_t(__pyx_v_minutes, 60);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":207
+ *         int64_t min = minutes % 60
+ * 
+ *     return datetime.time(hours, min, sec, microseconds)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_datetime); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 207, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_time); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 207, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_PyInt_From_int64_t(__pyx_v_hours); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 207, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = __Pyx_PyInt_From_int64_t(__pyx_v_min); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 207, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_5 = __Pyx_PyInt_From_int64_t(__pyx_v_sec); if (unlikely(!__pyx_t_5)) __PYX_ERR(9, 207, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_6 = __Pyx_PyInt_From_uint32_t(__pyx_v_microseconds); if (unlikely(!__pyx_t_6)) __PYX_ERR(9, 207, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_6);
+  __pyx_t_7 = NULL;
+  __pyx_t_8 = 0;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
+    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
+    if (likely(__pyx_t_7)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+      __Pyx_INCREF(__pyx_t_7);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_3, function);
+      __pyx_t_8 = 1;
+    }
+  }
+  #if CYTHON_FAST_PYCALL
+  if (PyFunction_Check(__pyx_t_3)) {
+    PyObject *__pyx_temp[5] = {__pyx_t_7, __pyx_t_2, __pyx_t_4, __pyx_t_5, __pyx_t_6};
+    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 4+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 207, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  } else
+  #endif
+  #if CYTHON_FAST_PYCCALL
+  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
+    PyObject *__pyx_temp[5] = {__pyx_t_7, __pyx_t_2, __pyx_t_4, __pyx_t_5, __pyx_t_6};
+    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 4+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 207, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  } else
+  #endif
+  {
+    __pyx_t_9 = PyTuple_New(4+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(9, 207, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_9);
+    if (__pyx_t_7) {
+      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
+    }
+    __Pyx_GIVEREF(__pyx_t_2);
+    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_2);
+    __Pyx_GIVEREF(__pyx_t_4);
+    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_5);
+    PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_5);
+    __Pyx_GIVEREF(__pyx_t_6);
+    PyTuple_SET_ITEM(__pyx_t_9, 3+__pyx_t_8, __pyx_t_6);
+    __pyx_t_2 = 0;
+    __pyx_t_4 = 0;
+    __pyx_t_5 = 0;
+    __pyx_t_6 = 0;
+    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 207, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":194
+ * 
+ * 
+ * cdef time_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int64_t seconds = 0
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.time_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/datetime.pyx":210
+ * 
+ * 
+ * cdef timetz_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     offset = obj.tzinfo.utcoffset(None)
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_timetz_encode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
+  PyObject *__pyx_v_offset = NULL;
+  int32_t __pyx_v_offset_sec;
+  int64_t __pyx_v_seconds;
+  int32_t __pyx_v_microseconds;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  long __pyx_t_3;
+  long __pyx_t_4;
+  long __pyx_t_5;
+  __Pyx_RefNannySetupContext("timetz_encode", 0);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":211
+ * 
+ * cdef timetz_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+ *     offset = obj.tzinfo.utcoffset(None)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef:
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_tzinfo); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 211, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_utcoffset); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 211, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 211, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_v_offset = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":215
+ *     cdef:
+ *         int32_t offset_sec = \
+ *             <int32_t>cpython.PyLong_AsLong(offset.days) * 24 * 60 * 60 + \             # <<<<<<<<<<<<<<
+ *             <int32_t>cpython.PyLong_AsLong(offset.seconds)
+ * 
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_offset, __pyx_n_s_days); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 215, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_3 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_3 == -1L && PyErr_Occurred())) __PYX_ERR(9, 215, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":216
+ *         int32_t offset_sec = \
+ *             <int32_t>cpython.PyLong_AsLong(offset.days) * 24 * 60 * 60 + \
+ *             <int32_t>cpython.PyLong_AsLong(offset.seconds)             # <<<<<<<<<<<<<<
+ * 
+ *         int64_t seconds = cpython.PyLong_AsLong(obj.hour) * 3600 + \
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_offset, __pyx_n_s_seconds); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 216, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_4 == -1L && PyErr_Occurred())) __PYX_ERR(9, 216, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":215
+ *     cdef:
+ *         int32_t offset_sec = \
+ *             <int32_t>cpython.PyLong_AsLong(offset.days) * 24 * 60 * 60 + \             # <<<<<<<<<<<<<<
+ *             <int32_t>cpython.PyLong_AsLong(offset.seconds)
+ * 
+ */
+  __pyx_v_offset_sec = ((((((int32_t)__pyx_t_3) * 24) * 60) * 60) + ((int32_t)__pyx_t_4));
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":218
+ *             <int32_t>cpython.PyLong_AsLong(offset.seconds)
+ * 
+ *         int64_t seconds = cpython.PyLong_AsLong(obj.hour) * 3600 + \             # <<<<<<<<<<<<<<
+ *                             cpython.PyLong_AsLong(obj.minute) * 60 + \
+ *                             cpython.PyLong_AsLong(obj.second)
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_hour); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 218, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_4 == -1L && PyErr_Occurred())) __PYX_ERR(9, 218, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":219
+ * 
+ *         int64_t seconds = cpython.PyLong_AsLong(obj.hour) * 3600 + \
+ *                             cpython.PyLong_AsLong(obj.minute) * 60 + \             # <<<<<<<<<<<<<<
+ *                             cpython.PyLong_AsLong(obj.second)
+ * 
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_minute); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 219, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_3 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_3 == -1L && PyErr_Occurred())) __PYX_ERR(9, 219, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":220
+ *         int64_t seconds = cpython.PyLong_AsLong(obj.hour) * 3600 + \
+ *                             cpython.PyLong_AsLong(obj.minute) * 60 + \
+ *                             cpython.PyLong_AsLong(obj.second)             # <<<<<<<<<<<<<<
+ * 
+ *         int32_t microseconds = <int32_t>cpython.PyLong_AsLong(obj.microsecond)
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_second); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 220, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_5 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_5 == -1L && PyErr_Occurred())) __PYX_ERR(9, 220, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":219
+ * 
+ *         int64_t seconds = cpython.PyLong_AsLong(obj.hour) * 3600 + \
+ *                             cpython.PyLong_AsLong(obj.minute) * 60 + \             # <<<<<<<<<<<<<<
+ *                             cpython.PyLong_AsLong(obj.second)
+ * 
+ */
+  __pyx_v_seconds = (((__pyx_t_4 * 0xE10) + (__pyx_t_3 * 60)) + __pyx_t_5);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":222
+ *                             cpython.PyLong_AsLong(obj.second)
+ * 
+ *         int32_t microseconds = <int32_t>cpython.PyLong_AsLong(obj.microsecond)             # <<<<<<<<<<<<<<
+ * 
+ *     buf.write_int32(12)
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_microsecond); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 222, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_5 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_5 == -1L && PyErr_Occurred())) __PYX_ERR(9, 222, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_microseconds = ((int32_t)__pyx_t_5);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":224
+ *         int32_t microseconds = <int32_t>cpython.PyLong_AsLong(obj.microsecond)
+ * 
+ *     buf.write_int32(12)             # <<<<<<<<<<<<<<
+ *     _encode_time(buf, seconds, microseconds)
+ *     buf.write_int32(offset_sec)
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, 12); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 224, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":225
+ * 
+ *     buf.write_int32(12)
+ *     _encode_time(buf, seconds, microseconds)             # <<<<<<<<<<<<<<
+ *     buf.write_int32(offset_sec)
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol__encode_time(__pyx_v_buf, __pyx_v_seconds, __pyx_v_microseconds); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 225, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":226
+ *     buf.write_int32(12)
+ *     _encode_time(buf, seconds, microseconds)
+ *     buf.write_int32(offset_sec)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, __pyx_v_offset_sec); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 226, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":210
+ * 
+ * 
+ * cdef timetz_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     offset = obj.tzinfo.utcoffset(None)
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.timetz_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_offset);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/datetime.pyx":229
+ * 
+ * 
+ * cdef timetz_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     time = time_decode(settings, buf)
+ *     cdef int32_t offset = <int32_t>(hton.unpack_int32(buf.read(4)) / 60)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_timetz_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  PyObject *__pyx_v_time = NULL;
+  int32_t __pyx_v_offset;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  char const *__pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  __Pyx_RefNannySetupContext("timetz_decode", 0);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":230
+ * 
+ * cdef timetz_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     time = time_decode(settings, buf)             # <<<<<<<<<<<<<<
+ *     cdef int32_t offset = <int32_t>(hton.unpack_int32(buf.read(4)) / 60)
+ *     return time.replace(tzinfo=datetime.timezone(timedelta(minutes=offset)))
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_time_decode(__pyx_v_settings, __pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 230, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_time = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":231
+ * cdef timetz_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     time = time_decode(settings, buf)
+ *     cdef int32_t offset = <int32_t>(hton.unpack_int32(buf.read(4)) / 60)             # <<<<<<<<<<<<<<
+ *     return time.replace(tzinfo=datetime.timezone(timedelta(minutes=offset)))
+ * 
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_2 == NULL)) __PYX_ERR(9, 231, __pyx_L1_error)
+  __pyx_v_offset = ((int32_t)(((double)__pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_2)) / 60.0));
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":232
+ *     time = time_decode(settings, buf)
+ *     cdef int32_t offset = <int32_t>(hton.unpack_int32(buf.read(4)) / 60)
+ *     return time.replace(tzinfo=datetime.timezone(timedelta(minutes=offset)))             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_time, __pyx_n_s_replace); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 232, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 232, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_datetime); if (unlikely(!__pyx_t_5)) __PYX_ERR(9, 232, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_timezone); if (unlikely(!__pyx_t_6)) __PYX_ERR(9, 232, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_6);
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_timedelta); if (unlikely(!__pyx_t_5)) __PYX_ERR(9, 232, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(9, 232, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_7);
+  __pyx_t_8 = __Pyx_PyInt_From_int32_t(__pyx_v_offset); if (unlikely(!__pyx_t_8)) __PYX_ERR(9, 232, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_8);
+  if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_minutes, __pyx_t_8) < 0) __PYX_ERR(9, 232, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_empty_tuple, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(9, 232, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_8);
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+  __pyx_t_7 = NULL;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
+    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
+    if (likely(__pyx_t_7)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
+      __Pyx_INCREF(__pyx_t_7);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_6, function);
+    }
+  }
+  if (!__pyx_t_7) {
+    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 232, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+    __Pyx_GOTREF(__pyx_t_4);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_6)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_8};
+      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 232, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_8};
+      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 232, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+    } else
+    #endif
+    {
+      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(9, 232, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL;
+      __Pyx_GIVEREF(__pyx_t_8);
+      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_8);
+      __pyx_t_8 = 0;
+      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 232, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_tzinfo, __pyx_t_4) < 0) __PYX_ERR(9, 232, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 232, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_r = __pyx_t_4;
+  __pyx_t_4 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":229
+ * 
+ * 
+ * cdef timetz_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     time = time_decode(settings, buf)
+ *     cdef int32_t offset = <int32_t>(hton.unpack_int32(buf.read(4)) / 60)
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.timetz_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_time);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/datetime.pyx":235
+ * 
+ * 
+ * cdef interval_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int32_t days = <int32_t>cpython.PyLong_AsLong(obj.days)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_interval_encode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
+  int32_t __pyx_v_days;
+  int64_t __pyx_v_seconds;
+  int32_t __pyx_v_microseconds;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  long __pyx_t_2;
+  PY_LONG_LONG __pyx_t_3;
+  __Pyx_RefNannySetupContext("interval_encode", 0);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":237
+ * cdef interval_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+ *     cdef:
+ *         int32_t days = <int32_t>cpython.PyLong_AsLong(obj.days)             # <<<<<<<<<<<<<<
+ *         int64_t seconds = cpython.PyLong_AsLongLong(obj.seconds)
+ *         int32_t microseconds = <int32_t>cpython.PyLong_AsLong(obj.microseconds)
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_days); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 237, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_2 == -1L && PyErr_Occurred())) __PYX_ERR(9, 237, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_days = ((int32_t)__pyx_t_2);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":238
+ *     cdef:
+ *         int32_t days = <int32_t>cpython.PyLong_AsLong(obj.days)
+ *         int64_t seconds = cpython.PyLong_AsLongLong(obj.seconds)             # <<<<<<<<<<<<<<
+ *         int32_t microseconds = <int32_t>cpython.PyLong_AsLong(obj.microseconds)
+ * 
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_seconds); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 238, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_3 = PyLong_AsLongLong(__pyx_t_1); if (unlikely(__pyx_t_3 == -1LL && PyErr_Occurred())) __PYX_ERR(9, 238, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_seconds = __pyx_t_3;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":239
+ *         int32_t days = <int32_t>cpython.PyLong_AsLong(obj.days)
+ *         int64_t seconds = cpython.PyLong_AsLongLong(obj.seconds)
+ *         int32_t microseconds = <int32_t>cpython.PyLong_AsLong(obj.microseconds)             # <<<<<<<<<<<<<<
+ * 
+ *     buf.write_int32(16)
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_microseconds); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 239, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_2 == -1L && PyErr_Occurred())) __PYX_ERR(9, 239, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_microseconds = ((int32_t)__pyx_t_2);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":241
+ *         int32_t microseconds = <int32_t>cpython.PyLong_AsLong(obj.microseconds)
+ * 
+ *     buf.write_int32(16)             # <<<<<<<<<<<<<<
+ *     _encode_time(buf, seconds, microseconds)
+ *     buf.write_int32(days)
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, 16); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 241, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":242
+ * 
+ *     buf.write_int32(16)
+ *     _encode_time(buf, seconds, microseconds)             # <<<<<<<<<<<<<<
+ *     buf.write_int32(days)
+ *     buf.write_int32(0) # Months
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol__encode_time(__pyx_v_buf, __pyx_v_seconds, __pyx_v_microseconds); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 242, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":243
+ *     buf.write_int32(16)
+ *     _encode_time(buf, seconds, microseconds)
+ *     buf.write_int32(days)             # <<<<<<<<<<<<<<
+ *     buf.write_int32(0) # Months
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, __pyx_v_days); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 243, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":244
+ *     _encode_time(buf, seconds, microseconds)
+ *     buf.write_int32(days)
+ *     buf.write_int32(0) # Months             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 244, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":235
+ * 
+ * 
+ * cdef interval_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int32_t days = <int32_t>cpython.PyLong_AsLong(obj.days)
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.interval_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/datetime.pyx":247
+ * 
+ * 
+ * cdef interval_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int32_t days
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_interval_decode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  int32_t __pyx_v_days;
+  int32_t __pyx_v_months;
+  int64_t __pyx_v_seconds;
+  uint32_t __pyx_v_microseconds;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  char const *__pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  __Pyx_RefNannySetupContext("interval_decode", 0);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":251
+ *         int32_t days
+ *         int32_t months
+ *         int64_t seconds = 0             # <<<<<<<<<<<<<<
+ *         uint32_t microseconds = 0
+ * 
+ */
+  __pyx_v_seconds = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":252
+ *         int32_t months
+ *         int64_t seconds = 0
+ *         uint32_t microseconds = 0             # <<<<<<<<<<<<<<
+ * 
+ *     _decode_time(buf, &seconds, &microseconds)
+ */
+  __pyx_v_microseconds = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":254
+ *         uint32_t microseconds = 0
+ * 
+ *     _decode_time(buf, &seconds, &microseconds)             # <<<<<<<<<<<<<<
+ *     days = hton.unpack_int32(buf.read(4))
+ *     months = hton.unpack_int32(buf.read(4))
+ */
+  __pyx_f_7asyncpg_8protocol_8protocol__decode_time(__pyx_v_buf, (&__pyx_v_seconds), (&__pyx_v_microseconds));
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":255
+ * 
+ *     _decode_time(buf, &seconds, &microseconds)
+ *     days = hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ *     months = hton.unpack_int32(buf.read(4))
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(9, 255, __pyx_L1_error)
+  __pyx_v_days = __pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":256
+ *     _decode_time(buf, &seconds, &microseconds)
+ *     days = hton.unpack_int32(buf.read(4))
+ *     months = hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ * 
+ *     return datetime.timedelta(days=days + months * 30, seconds=seconds,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(9, 256, __pyx_L1_error)
+  __pyx_v_months = __pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":258
+ *     months = hton.unpack_int32(buf.read(4))
+ * 
+ *     return datetime.timedelta(days=days + months * 30, seconds=seconds,             # <<<<<<<<<<<<<<
+ *                               microseconds=microseconds)
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_datetime); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 258, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_timedelta); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 258, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 258, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = __Pyx_PyInt_From_long((__pyx_v_days + (__pyx_v_months * 30))); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 258, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_days, __pyx_t_4) < 0) __PYX_ERR(9, 258, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = __Pyx_PyInt_From_int64_t(__pyx_v_seconds); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 258, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_seconds, __pyx_t_4) < 0) __PYX_ERR(9, 258, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":259
+ * 
+ *     return datetime.timedelta(days=days + months * 30, seconds=seconds,
+ *                               microseconds=microseconds)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_4 = __Pyx_PyInt_From_uint32_t(__pyx_v_microseconds); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 259, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_microseconds, __pyx_t_4) < 0) __PYX_ERR(9, 258, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":258
+ *     months = hton.unpack_int32(buf.read(4))
+ * 
+ *     return datetime.timedelta(days=days + months * 30, seconds=seconds,             # <<<<<<<<<<<<<<
+ *                               microseconds=microseconds)
+ * 
+ */
+  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 258, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_r = __pyx_t_4;
+  __pyx_t_4 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":247
+ * 
+ * 
+ * cdef interval_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int32_t days
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.interval_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/datetime.pyx":262
+ * 
+ * 
+ * cdef init_datetime_codecs():             # <<<<<<<<<<<<<<
+ *     register_core_codec(DATEOID,
+ *                         <encode_func>&date_encode,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_datetime_codecs(void) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("init_datetime_codecs", 0);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":263
+ * 
+ * cdef init_datetime_codecs():
+ *     register_core_codec(DATEOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&date_encode,
+ *                         <decode_func>&date_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x43A, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_date_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_date_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 263, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":268
+ *                         PG_FORMAT_BINARY)
+ * 
+ *     register_core_codec(TIMEOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&time_encode,
+ *                         <decode_func>&time_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x43B, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_time_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_time_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 268, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":273
+ *                         PG_FORMAT_BINARY)
+ * 
+ *     register_core_codec(TIMETZOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&timetz_encode,
+ *                         <decode_func>&timetz_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x4F2, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_timetz_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_timetz_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 273, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":278
+ *                         PG_FORMAT_BINARY)
+ * 
+ *     register_core_codec(TIMESTAMPOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&timestamp_encode,
+ *                         <decode_func>&timestamp_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x45A, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_timestamp_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_timestamp_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 278, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":283
+ *                         PG_FORMAT_BINARY)
+ * 
+ *     register_core_codec(TIMESTAMPTZOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&timestamptz_encode,
+ *                         <decode_func>&timestamptz_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x4A0, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_timestamptz_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_timestamptz_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 283, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":288
+ *                         PG_FORMAT_BINARY)
+ * 
+ *     register_core_codec(INTERVALOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&interval_encode,
+ *                         <decode_func>&interval_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x4A2, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_interval_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_interval_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 288, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":296
+ *     # interpret the value, and simply return and pass it as text.
+ *     #
+ *     register_core_codec(ABSTIMEOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&text_encode,
+ *                         <decode_func>&text_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x2BE, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 296, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":301
+ *                         PG_FORMAT_TEXT)
+ * 
+ *     register_core_codec(RELTIMEOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&text_encode,
+ *                         <decode_func>&text_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x2BF, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 301, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":306
+ *                         PG_FORMAT_TEXT)
+ * 
+ *     register_core_codec(TINTERVALOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&text_encode,
+ *                         <decode_func>&text_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x2C0, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 306, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":262
+ * 
+ * 
+ * cdef init_datetime_codecs():             # <<<<<<<<<<<<<<
+ *     register_core_codec(DATEOID,
+ *                         <encode_func>&date_encode,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.init_datetime_codecs", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/float.pyx":11
+ * 
+ * 
+ * cdef float4_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef double dval = cpython.PyFloat_AsDouble(obj)
+ *     cdef float fval = <float>dval
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_float4_encode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
+  double __pyx_v_dval;
+  float __pyx_v_fval;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  double __pyx_t_1;
+  int __pyx_t_2;
+  int __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  __Pyx_RefNannySetupContext("float4_encode", 0);
+
+  /* "asyncpg/protocol/codecs/float.pyx":12
+ * 
+ * cdef float4_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+ *     cdef double dval = cpython.PyFloat_AsDouble(obj)             # <<<<<<<<<<<<<<
+ *     cdef float fval = <float>dval
+ *     if math.isinf(fval) and not math.isinf(dval):
+ */
+  __pyx_t_1 = PyFloat_AsDouble(__pyx_v_obj); if (unlikely(__pyx_t_1 == -1.0 && PyErr_Occurred())) __PYX_ERR(10, 12, __pyx_L1_error)
+  __pyx_v_dval = __pyx_t_1;
+
+  /* "asyncpg/protocol/codecs/float.pyx":13
+ * cdef float4_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+ *     cdef double dval = cpython.PyFloat_AsDouble(obj)
+ *     cdef float fval = <float>dval             # <<<<<<<<<<<<<<
+ *     if math.isinf(fval) and not math.isinf(dval):
+ *         raise ValueError('float value too large to be encoded as FLOAT4')
+ */
+  __pyx_v_fval = ((float)__pyx_v_dval);
+
+  /* "asyncpg/protocol/codecs/float.pyx":14
+ *     cdef double dval = cpython.PyFloat_AsDouble(obj)
+ *     cdef float fval = <float>dval
+ *     if math.isinf(fval) and not math.isinf(dval):             # <<<<<<<<<<<<<<
+ *         raise ValueError('float value too large to be encoded as FLOAT4')
+ * 
+ */
+  __pyx_t_3 = (isinf(__pyx_v_fval) != 0);
+  if (__pyx_t_3) {
+  } else {
+    __pyx_t_2 = __pyx_t_3;
+    goto __pyx_L4_bool_binop_done;
+  }
+  __pyx_t_3 = ((!(isinf(__pyx_v_dval) != 0)) != 0);
+  __pyx_t_2 = __pyx_t_3;
+  __pyx_L4_bool_binop_done:;
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/codecs/float.pyx":15
+ *     cdef float fval = <float>dval
+ *     if math.isinf(fval) and not math.isinf(dval):
+ *         raise ValueError('float value too large to be encoded as FLOAT4')             # <<<<<<<<<<<<<<
+ * 
+ *     buf.write_int32(4)
+ */
+    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__33, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(10, 15, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __PYX_ERR(10, 15, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/float.pyx":14
+ *     cdef double dval = cpython.PyFloat_AsDouble(obj)
+ *     cdef float fval = <float>dval
+ *     if math.isinf(fval) and not math.isinf(dval):             # <<<<<<<<<<<<<<
+ *         raise ValueError('float value too large to be encoded as FLOAT4')
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/float.pyx":17
+ *         raise ValueError('float value too large to be encoded as FLOAT4')
+ * 
+ *     buf.write_int32(4)             # <<<<<<<<<<<<<<
+ *     buf.write_float(fval)
+ * 
+ */
+  __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, 4); if (unlikely(!__pyx_t_4)) __PYX_ERR(10, 17, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "asyncpg/protocol/codecs/float.pyx":18
+ * 
+ *     buf.write_int32(4)
+ *     buf.write_float(fval)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_float(__pyx_v_buf, __pyx_v_fval); if (unlikely(!__pyx_t_4)) __PYX_ERR(10, 18, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "asyncpg/protocol/codecs/float.pyx":11
+ * 
+ * 
+ * cdef float4_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef double dval = cpython.PyFloat_AsDouble(obj)
+ *     cdef float fval = <float>dval
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.float4_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/float.pyx":21
+ * 
+ * 
+ * cdef float4_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef float f = hton.unpack_float(buf.read(4))
+ *     return cpython.PyFloat_FromDouble(f)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_float4_decode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  float __pyx_v_f;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  char const *__pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("float4_decode", 0);
+
+  /* "asyncpg/protocol/codecs/float.pyx":22
+ * 
+ * cdef float4_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     cdef float f = hton.unpack_float(buf.read(4))             # <<<<<<<<<<<<<<
+ *     return cpython.PyFloat_FromDouble(f)
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(10, 22, __pyx_L1_error)
+  __pyx_v_f = __pyx_f_7asyncpg_8protocol_4hton_unpack_float(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/float.pyx":23
+ * cdef float4_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     cdef float f = hton.unpack_float(buf.read(4))
+ *     return cpython.PyFloat_FromDouble(f)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_f); if (unlikely(!__pyx_t_2)) __PYX_ERR(10, 23, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_r = __pyx_t_2;
+  __pyx_t_2 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/float.pyx":21
+ * 
+ * 
+ * cdef float4_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef float f = hton.unpack_float(buf.read(4))
+ *     return cpython.PyFloat_FromDouble(f)
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.float4_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/float.pyx":26
+ * 
+ * 
+ * cdef float8_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef double dval = cpython.PyFloat_AsDouble(obj)
+ *     buf.write_int32(8)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_float8_encode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
+  double __pyx_v_dval;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  double __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("float8_encode", 0);
+
+  /* "asyncpg/protocol/codecs/float.pyx":27
+ * 
+ * cdef float8_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+ *     cdef double dval = cpython.PyFloat_AsDouble(obj)             # <<<<<<<<<<<<<<
+ *     buf.write_int32(8)
+ *     buf.write_double(dval)
+ */
+  __pyx_t_1 = PyFloat_AsDouble(__pyx_v_obj); if (unlikely(__pyx_t_1 == -1.0 && PyErr_Occurred())) __PYX_ERR(10, 27, __pyx_L1_error)
+  __pyx_v_dval = __pyx_t_1;
+
+  /* "asyncpg/protocol/codecs/float.pyx":28
+ * cdef float8_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+ *     cdef double dval = cpython.PyFloat_AsDouble(obj)
+ *     buf.write_int32(8)             # <<<<<<<<<<<<<<
+ *     buf.write_double(dval)
+ * 
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, 8); if (unlikely(!__pyx_t_2)) __PYX_ERR(10, 28, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/float.pyx":29
+ *     cdef double dval = cpython.PyFloat_AsDouble(obj)
+ *     buf.write_int32(8)
+ *     buf.write_double(dval)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_double(__pyx_v_buf, __pyx_v_dval); if (unlikely(!__pyx_t_2)) __PYX_ERR(10, 29, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/float.pyx":26
+ * 
+ * 
+ * cdef float8_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef double dval = cpython.PyFloat_AsDouble(obj)
+ *     buf.write_int32(8)
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.float8_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/float.pyx":32
+ * 
+ * 
+ * cdef float8_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef double f = hton.unpack_double(buf.read(8))
+ *     return cpython.PyFloat_FromDouble(f)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_float8_decode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  double __pyx_v_f;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  char const *__pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("float8_decode", 0);
+
+  /* "asyncpg/protocol/codecs/float.pyx":33
+ * 
+ * cdef float8_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     cdef double f = hton.unpack_double(buf.read(8))             # <<<<<<<<<<<<<<
+ *     return cpython.PyFloat_FromDouble(f)
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(10, 33, __pyx_L1_error)
+  __pyx_v_f = __pyx_f_7asyncpg_8protocol_4hton_unpack_double(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/float.pyx":34
+ * cdef float8_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     cdef double f = hton.unpack_double(buf.read(8))
+ *     return cpython.PyFloat_FromDouble(f)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_f); if (unlikely(!__pyx_t_2)) __PYX_ERR(10, 34, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_r = __pyx_t_2;
+  __pyx_t_2 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/float.pyx":32
+ * 
+ * 
+ * cdef float8_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef double f = hton.unpack_double(buf.read(8))
+ *     return cpython.PyFloat_FromDouble(f)
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.float8_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/float.pyx":37
+ * 
+ * 
+ * cdef init_float_codecs():             # <<<<<<<<<<<<<<
+ *     register_core_codec(FLOAT4OID,
+ *                         <encode_func>&float4_encode,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_float_codecs(void) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("init_float_codecs", 0);
+
+  /* "asyncpg/protocol/codecs/float.pyx":38
+ * 
+ * cdef init_float_codecs():
+ *     register_core_codec(FLOAT4OID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&float4_encode,
+ *                         <decode_func>&float4_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x2BC, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_float4_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_float4_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(10, 38, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/float.pyx":43
+ *                         PG_FORMAT_BINARY)
+ * 
+ *     register_core_codec(FLOAT8OID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&float8_encode,
+ *                         <decode_func>&float8_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x2BD, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_float8_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_float8_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(10, 43, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/float.pyx":37
+ * 
+ * 
+ * cdef init_float_codecs():             # <<<<<<<<<<<<<<
+ *     register_core_codec(FLOAT4OID,
+ *                         <encode_func>&float4_encode,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.init_float_codecs", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/geometry.pyx":11
+ * 
+ * 
+ * cdef inline _encode_points(WriteBuffer wbuf, object points):             # <<<<<<<<<<<<<<
+ *     cdef object point
+ * 
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol__encode_points(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_wbuf, PyObject *__pyx_v_points) {
+  PyObject *__pyx_v_point = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  Py_ssize_t __pyx_t_2;
+  PyObject *(*__pyx_t_3)(PyObject *);
+  PyObject *__pyx_t_4 = NULL;
+  double __pyx_t_5;
+  __Pyx_RefNannySetupContext("_encode_points", 0);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":14
+ *     cdef object point
+ * 
+ *     for point in points:             # <<<<<<<<<<<<<<
+ *         wbuf.write_double(point[0])
+ *         wbuf.write_double(point[1])
+ */
+  if (likely(PyList_CheckExact(__pyx_v_points)) || PyTuple_CheckExact(__pyx_v_points)) {
+    __pyx_t_1 = __pyx_v_points; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
+    __pyx_t_3 = NULL;
+  } else {
+    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_points); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 14, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(11, 14, __pyx_L1_error)
+  }
+  for (;;) {
+    if (likely(!__pyx_t_3)) {
+      if (likely(PyList_CheckExact(__pyx_t_1))) {
+        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
+        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(11, 14, __pyx_L1_error)
+        #else
+        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(11, 14, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        #endif
+      } else {
+        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(11, 14, __pyx_L1_error)
+        #else
+        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(11, 14, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        #endif
+      }
+    } else {
+      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
+      if (unlikely(!__pyx_t_4)) {
+        PyObject* exc_type = PyErr_Occurred();
+        if (exc_type) {
+          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+          else __PYX_ERR(11, 14, __pyx_L1_error)
+        }
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_4);
+    }
+    __Pyx_XDECREF_SET(__pyx_v_point, __pyx_t_4);
+    __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/codecs/geometry.pyx":15
+ * 
+ *     for point in points:
+ *         wbuf.write_double(point[0])             # <<<<<<<<<<<<<<
+ *         wbuf.write_double(point[1])
+ * 
+ */
+    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_point, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(11, 15, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(11, 15, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_double(__pyx_v_wbuf, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(11, 15, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/codecs/geometry.pyx":16
+ *     for point in points:
+ *         wbuf.write_double(point[0])
+ *         wbuf.write_double(point[1])             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_point, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(11, 16, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(11, 16, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_double(__pyx_v_wbuf, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(11, 16, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/codecs/geometry.pyx":14
+ *     cdef object point
+ * 
+ *     for point in points:             # <<<<<<<<<<<<<<
+ *         wbuf.write_double(point[0])
+ *         wbuf.write_double(point[1])
+ */
+  }
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":11
+ * 
+ * 
+ * cdef inline _encode_points(WriteBuffer wbuf, object points):             # <<<<<<<<<<<<<<
+ *     cdef object point
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol._encode_points", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_point);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/geometry.pyx":19
+ * 
+ * 
+ * cdef inline _decode_points(FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int32_t npts = hton.unpack_int32(buf.read(4))
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol__decode_points(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  int32_t __pyx_v_npts;
+  PyObject *__pyx_v_pts = 0;
+  int32_t __pyx_v_i;
+  PyObject *__pyx_v_point = 0;
+  double __pyx_v_x;
+  double __pyx_v_y;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  char const *__pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  int32_t __pyx_t_3;
+  int32_t __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  int __pyx_t_9;
+  PyObject *__pyx_t_10 = NULL;
+  __Pyx_RefNannySetupContext("_decode_points", 0);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":21
+ * cdef inline _decode_points(FastReadBuffer buf):
+ *     cdef:
+ *         int32_t npts = hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ *         pts = cpython.PyTuple_New(npts)
+ *         int32_t i
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(11, 21, __pyx_L1_error)
+  __pyx_v_npts = __pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":22
+ *     cdef:
+ *         int32_t npts = hton.unpack_int32(buf.read(4))
+ *         pts = cpython.PyTuple_New(npts)             # <<<<<<<<<<<<<<
+ *         int32_t i
+ *         object point
+ */
+  __pyx_t_2 = PyTuple_New(__pyx_v_npts); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 22, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_v_pts = __pyx_t_2;
+  __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":28
+ *         double y
+ * 
+ *     for i in range(npts):             # <<<<<<<<<<<<<<
+ *         x = hton.unpack_double(buf.read(8))
+ *         y = hton.unpack_double(buf.read(8))
+ */
+  __pyx_t_3 = __pyx_v_npts;
+  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
+    __pyx_v_i = __pyx_t_4;
+
+    /* "asyncpg/protocol/codecs/geometry.pyx":29
+ * 
+ *     for i in range(npts):
+ *         x = hton.unpack_double(buf.read(8))             # <<<<<<<<<<<<<<
+ *         y = hton.unpack_double(buf.read(8))
+ *         point = Point(x, y)
+ */
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(11, 29, __pyx_L1_error)
+    __pyx_v_x = __pyx_f_7asyncpg_8protocol_4hton_unpack_double(__pyx_t_1);
+
+    /* "asyncpg/protocol/codecs/geometry.pyx":30
+ *     for i in range(npts):
+ *         x = hton.unpack_double(buf.read(8))
+ *         y = hton.unpack_double(buf.read(8))             # <<<<<<<<<<<<<<
+ *         point = Point(x, y)
+ *         cpython.Py_INCREF(point)
+ */
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(11, 30, __pyx_L1_error)
+    __pyx_v_y = __pyx_f_7asyncpg_8protocol_4hton_unpack_double(__pyx_t_1);
+
+    /* "asyncpg/protocol/codecs/geometry.pyx":31
+ *         x = hton.unpack_double(buf.read(8))
+ *         y = hton.unpack_double(buf.read(8))
+ *         point = Point(x, y)             # <<<<<<<<<<<<<<
+ *         cpython.Py_INCREF(point)
+ *         cpython.PyTuple_SET_ITEM(pts, i, point)
+ */
+    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_Point); if (unlikely(!__pyx_t_5)) __PYX_ERR(11, 31, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = PyFloat_FromDouble(__pyx_v_x); if (unlikely(!__pyx_t_6)) __PYX_ERR(11, 31, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_7 = PyFloat_FromDouble(__pyx_v_y); if (unlikely(!__pyx_t_7)) __PYX_ERR(11, 31, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_7);
+    __pyx_t_8 = NULL;
+    __pyx_t_9 = 0;
+    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
+      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5);
+      if (likely(__pyx_t_8)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+        __Pyx_INCREF(__pyx_t_8);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_5, function);
+        __pyx_t_9 = 1;
+      }
+    }
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_5)) {
+      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_6, __pyx_t_7};
+      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 31, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
+      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_6, __pyx_t_7};
+      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 31, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    } else
+    #endif
+    {
+      __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(11, 31, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_10);
+      if (__pyx_t_8) {
+        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
+      }
+      __Pyx_GIVEREF(__pyx_t_6);
+      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_6);
+      __Pyx_GIVEREF(__pyx_t_7);
+      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_7);
+      __pyx_t_6 = 0;
+      __pyx_t_7 = 0;
+      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 31, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_XDECREF_SET(__pyx_v_point, __pyx_t_2);
+    __pyx_t_2 = 0;
+
+    /* "asyncpg/protocol/codecs/geometry.pyx":32
+ *         y = hton.unpack_double(buf.read(8))
+ *         point = Point(x, y)
+ *         cpython.Py_INCREF(point)             # <<<<<<<<<<<<<<
+ *         cpython.PyTuple_SET_ITEM(pts, i, point)
+ * 
+ */
+    Py_INCREF(__pyx_v_point);
+
+    /* "asyncpg/protocol/codecs/geometry.pyx":33
+ *         point = Point(x, y)
+ *         cpython.Py_INCREF(point)
+ *         cpython.PyTuple_SET_ITEM(pts, i, point)             # <<<<<<<<<<<<<<
+ * 
+ *     return pts
+ */
+    PyTuple_SET_ITEM(__pyx_v_pts, __pyx_v_i, __pyx_v_point);
+  }
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":35
+ *         cpython.PyTuple_SET_ITEM(pts, i, point)
+ * 
+ *     return pts             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_pts);
+  __pyx_r = __pyx_v_pts;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":19
+ * 
+ * 
+ * cdef inline _decode_points(FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int32_t npts = hton.unpack_int32(buf.read(4))
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol._decode_points", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_pts);
+  __Pyx_XDECREF(__pyx_v_point);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/geometry.pyx":38
+ * 
+ * 
+ * cdef box_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):             # <<<<<<<<<<<<<<
+ *     wbuf.write_int32(32)
+ *     _encode_points(wbuf, (obj[0], obj[1]))
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_box_encode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_wbuf, PyObject *__pyx_v_obj) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("box_encode", 0);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":39
+ * 
+ * cdef box_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):
+ *     wbuf.write_int32(32)             # <<<<<<<<<<<<<<
+ *     _encode_points(wbuf, (obj[0], obj[1]))
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_wbuf, 32); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 39, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":40
+ * cdef box_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):
+ *     wbuf.write_int32(32)
+ *     _encode_points(wbuf, (obj[0], obj[1]))             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_obj, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 40, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_obj, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 40, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(11, 40, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_2);
+  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
+  __pyx_t_1 = 0;
+  __pyx_t_2 = 0;
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol__encode_points(__pyx_v_wbuf, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 40, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":38
+ * 
+ * 
+ * cdef box_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):             # <<<<<<<<<<<<<<
+ *     wbuf.write_int32(32)
+ *     _encode_points(wbuf, (obj[0], obj[1]))
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.box_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/geometry.pyx":43
+ * 
+ * 
+ * cdef box_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         double high_x = hton.unpack_double(buf.read(8))
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_box_decode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  double __pyx_v_high_x;
+  double __pyx_v_high_y;
+  double __pyx_v_low_x;
+  double __pyx_v_low_y;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  char const *__pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  int __pyx_t_9;
+  PyObject *__pyx_t_10 = NULL;
+  PyObject *__pyx_t_11 = NULL;
+  __Pyx_RefNannySetupContext("box_decode", 0);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":45
+ * cdef box_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     cdef:
+ *         double high_x = hton.unpack_double(buf.read(8))             # <<<<<<<<<<<<<<
+ *         double high_y = hton.unpack_double(buf.read(8))
+ *         double low_x = hton.unpack_double(buf.read(8))
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(11, 45, __pyx_L1_error)
+  __pyx_v_high_x = __pyx_f_7asyncpg_8protocol_4hton_unpack_double(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":46
+ *     cdef:
+ *         double high_x = hton.unpack_double(buf.read(8))
+ *         double high_y = hton.unpack_double(buf.read(8))             # <<<<<<<<<<<<<<
+ *         double low_x = hton.unpack_double(buf.read(8))
+ *         double low_y = hton.unpack_double(buf.read(8))
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(11, 46, __pyx_L1_error)
+  __pyx_v_high_y = __pyx_f_7asyncpg_8protocol_4hton_unpack_double(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":47
+ *         double high_x = hton.unpack_double(buf.read(8))
+ *         double high_y = hton.unpack_double(buf.read(8))
+ *         double low_x = hton.unpack_double(buf.read(8))             # <<<<<<<<<<<<<<
+ *         double low_y = hton.unpack_double(buf.read(8))
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(11, 47, __pyx_L1_error)
+  __pyx_v_low_x = __pyx_f_7asyncpg_8protocol_4hton_unpack_double(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":48
+ *         double high_y = hton.unpack_double(buf.read(8))
+ *         double low_x = hton.unpack_double(buf.read(8))
+ *         double low_y = hton.unpack_double(buf.read(8))             # <<<<<<<<<<<<<<
+ * 
+ *     return Box(Point(high_x, high_y), Point(low_x, low_y))
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(11, 48, __pyx_L1_error)
+  __pyx_v_low_y = __pyx_f_7asyncpg_8protocol_4hton_unpack_double(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":50
+ *         double low_y = hton.unpack_double(buf.read(8))
+ * 
+ *     return Box(Point(high_x, high_y), Point(low_x, low_y))             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_Box); if (unlikely(!__pyx_t_3)) __PYX_ERR(11, 50, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_Point); if (unlikely(!__pyx_t_5)) __PYX_ERR(11, 50, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_high_x); if (unlikely(!__pyx_t_6)) __PYX_ERR(11, 50, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_6);
+  __pyx_t_7 = PyFloat_FromDouble(__pyx_v_high_y); if (unlikely(!__pyx_t_7)) __PYX_ERR(11, 50, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_7);
+  __pyx_t_8 = NULL;
+  __pyx_t_9 = 0;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
+    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5);
+    if (likely(__pyx_t_8)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+      __Pyx_INCREF(__pyx_t_8);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_5, function);
+      __pyx_t_9 = 1;
+    }
+  }
+  #if CYTHON_FAST_PYCALL
+  if (PyFunction_Check(__pyx_t_5)) {
+    PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_6, __pyx_t_7};
+    __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(11, 50, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+  } else
+  #endif
+  #if CYTHON_FAST_PYCCALL
+  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
+    PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_6, __pyx_t_7};
+    __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(11, 50, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+  } else
+  #endif
+  {
+    __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(11, 50, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_10);
+    if (__pyx_t_8) {
+      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
+    }
+    __Pyx_GIVEREF(__pyx_t_6);
+    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_6);
+    __Pyx_GIVEREF(__pyx_t_7);
+    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_7);
+    __pyx_t_6 = 0;
+    __pyx_t_7 = 0;
+    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(11, 50, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_Point); if (unlikely(!__pyx_t_10)) __PYX_ERR(11, 50, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_10);
+  __pyx_t_7 = PyFloat_FromDouble(__pyx_v_low_x); if (unlikely(!__pyx_t_7)) __PYX_ERR(11, 50, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_7);
+  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_low_y); if (unlikely(!__pyx_t_6)) __PYX_ERR(11, 50, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_6);
+  __pyx_t_8 = NULL;
+  __pyx_t_9 = 0;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
+    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_10);
+    if (likely(__pyx_t_8)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
+      __Pyx_INCREF(__pyx_t_8);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_10, function);
+      __pyx_t_9 = 1;
+    }
+  }
+  #if CYTHON_FAST_PYCALL
+  if (PyFunction_Check(__pyx_t_10)) {
+    PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_7, __pyx_t_6};
+    __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(11, 50, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  } else
+  #endif
+  #if CYTHON_FAST_PYCCALL
+  if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
+    PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_7, __pyx_t_6};
+    __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(11, 50, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  } else
+  #endif
+  {
+    __pyx_t_11 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(11, 50, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_11);
+    if (__pyx_t_8) {
+      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_8); __pyx_t_8 = NULL;
+    }
+    __Pyx_GIVEREF(__pyx_t_7);
+    PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_9, __pyx_t_7);
+    __Pyx_GIVEREF(__pyx_t_6);
+    PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_9, __pyx_t_6);
+    __pyx_t_7 = 0;
+    __pyx_t_6 = 0;
+    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(11, 50, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+  __pyx_t_10 = NULL;
+  __pyx_t_9 = 0;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
+    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_3);
+    if (likely(__pyx_t_10)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+      __Pyx_INCREF(__pyx_t_10);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_3, function);
+      __pyx_t_9 = 1;
+    }
+  }
+  #if CYTHON_FAST_PYCALL
+  if (PyFunction_Check(__pyx_t_3)) {
+    PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_4, __pyx_t_5};
+    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 50, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  } else
+  #endif
+  #if CYTHON_FAST_PYCCALL
+  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
+    PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_4, __pyx_t_5};
+    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 50, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  } else
+  #endif
+  {
+    __pyx_t_11 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(11, 50, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_11);
+    if (__pyx_t_10) {
+      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
+    }
+    __Pyx_GIVEREF(__pyx_t_4);
+    PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_9, __pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_5);
+    PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_9, __pyx_t_5);
+    __pyx_t_4 = 0;
+    __pyx_t_5 = 0;
+    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 50, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_r = __pyx_t_2;
+  __pyx_t_2 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":43
+ * 
+ * 
+ * cdef box_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         double high_x = hton.unpack_double(buf.read(8))
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_XDECREF(__pyx_t_11);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.box_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/geometry.pyx":53
+ * 
+ * 
+ * cdef line_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):             # <<<<<<<<<<<<<<
+ *     wbuf.write_int32(24)
+ *     wbuf.write_double(obj[0])
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_line_encode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_wbuf, PyObject *__pyx_v_obj) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  double __pyx_t_2;
+  __Pyx_RefNannySetupContext("line_encode", 0);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":54
+ * 
+ * cdef line_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):
+ *     wbuf.write_int32(24)             # <<<<<<<<<<<<<<
+ *     wbuf.write_double(obj[0])
+ *     wbuf.write_double(obj[1])
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_wbuf, 24); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 54, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":55
+ * cdef line_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):
+ *     wbuf.write_int32(24)
+ *     wbuf.write_double(obj[0])             # <<<<<<<<<<<<<<
+ *     wbuf.write_double(obj[1])
+ *     wbuf.write_double(obj[2])
+ */
+  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_obj, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 55, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) __PYX_ERR(11, 55, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_double(__pyx_v_wbuf, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 55, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":56
+ *     wbuf.write_int32(24)
+ *     wbuf.write_double(obj[0])
+ *     wbuf.write_double(obj[1])             # <<<<<<<<<<<<<<
+ *     wbuf.write_double(obj[2])
+ * 
+ */
+  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_obj, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 56, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) __PYX_ERR(11, 56, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_double(__pyx_v_wbuf, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 56, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":57
+ *     wbuf.write_double(obj[0])
+ *     wbuf.write_double(obj[1])
+ *     wbuf.write_double(obj[2])             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_obj, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 57, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) __PYX_ERR(11, 57, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_double(__pyx_v_wbuf, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 57, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":53
+ * 
+ * 
+ * cdef line_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):             # <<<<<<<<<<<<<<
+ *     wbuf.write_int32(24)
+ *     wbuf.write_double(obj[0])
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.line_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/geometry.pyx":60
+ * 
+ * 
+ * cdef line_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         double A = hton.unpack_double(buf.read(8))
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_line_decode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  double __pyx_v_A;
+  double __pyx_v_B;
+  double __pyx_v_C;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  char const *__pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  int __pyx_t_8;
+  PyObject *__pyx_t_9 = NULL;
+  __Pyx_RefNannySetupContext("line_decode", 0);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":62
+ * cdef line_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     cdef:
+ *         double A = hton.unpack_double(buf.read(8))             # <<<<<<<<<<<<<<
+ *         double B = hton.unpack_double(buf.read(8))
+ *         double C = hton.unpack_double(buf.read(8))
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(11, 62, __pyx_L1_error)
+  __pyx_v_A = __pyx_f_7asyncpg_8protocol_4hton_unpack_double(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":63
+ *     cdef:
+ *         double A = hton.unpack_double(buf.read(8))
+ *         double B = hton.unpack_double(buf.read(8))             # <<<<<<<<<<<<<<
+ *         double C = hton.unpack_double(buf.read(8))
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(11, 63, __pyx_L1_error)
+  __pyx_v_B = __pyx_f_7asyncpg_8protocol_4hton_unpack_double(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":64
+ *         double A = hton.unpack_double(buf.read(8))
+ *         double B = hton.unpack_double(buf.read(8))
+ *         double C = hton.unpack_double(buf.read(8))             # <<<<<<<<<<<<<<
+ * 
+ *     return Line(A, B, C)
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(11, 64, __pyx_L1_error)
+  __pyx_v_C = __pyx_f_7asyncpg_8protocol_4hton_unpack_double(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":66
+ *         double C = hton.unpack_double(buf.read(8))
+ * 
+ *     return Line(A, B, C)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_Line); if (unlikely(!__pyx_t_3)) __PYX_ERR(11, 66, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_A); if (unlikely(!__pyx_t_4)) __PYX_ERR(11, 66, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_B); if (unlikely(!__pyx_t_5)) __PYX_ERR(11, 66, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_C); if (unlikely(!__pyx_t_6)) __PYX_ERR(11, 66, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_6);
+  __pyx_t_7 = NULL;
+  __pyx_t_8 = 0;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
+    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
+    if (likely(__pyx_t_7)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+      __Pyx_INCREF(__pyx_t_7);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_3, function);
+      __pyx_t_8 = 1;
+    }
+  }
+  #if CYTHON_FAST_PYCALL
+  if (PyFunction_Check(__pyx_t_3)) {
+    PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_4, __pyx_t_5, __pyx_t_6};
+    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 66, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  } else
+  #endif
+  #if CYTHON_FAST_PYCCALL
+  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
+    PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_4, __pyx_t_5, __pyx_t_6};
+    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 66, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  } else
+  #endif
+  {
+    __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(11, 66, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_9);
+    if (__pyx_t_7) {
+      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
+    }
+    __Pyx_GIVEREF(__pyx_t_4);
+    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_5);
+    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_5);
+    __Pyx_GIVEREF(__pyx_t_6);
+    PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_6);
+    __pyx_t_4 = 0;
+    __pyx_t_5 = 0;
+    __pyx_t_6 = 0;
+    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 66, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_r = __pyx_t_2;
+  __pyx_t_2 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":60
+ * 
+ * 
+ * cdef line_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         double A = hton.unpack_double(buf.read(8))
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.line_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/geometry.pyx":69
+ * 
+ * 
+ * cdef lseg_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):             # <<<<<<<<<<<<<<
+ *     wbuf.write_int32(32)
+ *     _encode_points(wbuf, (obj[0], obj[1]))
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_lseg_encode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_wbuf, PyObject *__pyx_v_obj) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("lseg_encode", 0);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":70
+ * 
+ * cdef lseg_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):
+ *     wbuf.write_int32(32)             # <<<<<<<<<<<<<<
+ *     _encode_points(wbuf, (obj[0], obj[1]))
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_wbuf, 32); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 70, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":71
+ * cdef lseg_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):
+ *     wbuf.write_int32(32)
+ *     _encode_points(wbuf, (obj[0], obj[1]))             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_obj, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 71, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_obj, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 71, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(11, 71, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_2);
+  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
+  __pyx_t_1 = 0;
+  __pyx_t_2 = 0;
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol__encode_points(__pyx_v_wbuf, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 71, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":69
+ * 
+ * 
+ * cdef lseg_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):             # <<<<<<<<<<<<<<
+ *     wbuf.write_int32(32)
+ *     _encode_points(wbuf, (obj[0], obj[1]))
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.lseg_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/geometry.pyx":74
+ * 
+ * 
+ * cdef lseg_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         double p1_x = hton.unpack_double(buf.read(8))
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_lseg_decode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  double __pyx_v_p1_x;
+  double __pyx_v_p1_y;
+  double __pyx_v_p2_x;
+  double __pyx_v_p2_y;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  char const *__pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  int __pyx_t_8;
+  __Pyx_RefNannySetupContext("lseg_decode", 0);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":76
+ * cdef lseg_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     cdef:
+ *         double p1_x = hton.unpack_double(buf.read(8))             # <<<<<<<<<<<<<<
+ *         double p1_y = hton.unpack_double(buf.read(8))
+ *         double p2_x = hton.unpack_double(buf.read(8))
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(11, 76, __pyx_L1_error)
+  __pyx_v_p1_x = __pyx_f_7asyncpg_8protocol_4hton_unpack_double(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":77
+ *     cdef:
+ *         double p1_x = hton.unpack_double(buf.read(8))
+ *         double p1_y = hton.unpack_double(buf.read(8))             # <<<<<<<<<<<<<<
+ *         double p2_x = hton.unpack_double(buf.read(8))
+ *         double p2_y = hton.unpack_double(buf.read(8))
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(11, 77, __pyx_L1_error)
+  __pyx_v_p1_y = __pyx_f_7asyncpg_8protocol_4hton_unpack_double(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":78
+ *         double p1_x = hton.unpack_double(buf.read(8))
+ *         double p1_y = hton.unpack_double(buf.read(8))
+ *         double p2_x = hton.unpack_double(buf.read(8))             # <<<<<<<<<<<<<<
+ *         double p2_y = hton.unpack_double(buf.read(8))
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(11, 78, __pyx_L1_error)
+  __pyx_v_p2_x = __pyx_f_7asyncpg_8protocol_4hton_unpack_double(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":79
+ *         double p1_y = hton.unpack_double(buf.read(8))
+ *         double p2_x = hton.unpack_double(buf.read(8))
+ *         double p2_y = hton.unpack_double(buf.read(8))             # <<<<<<<<<<<<<<
+ * 
+ *     return LineSegment((p1_x, p1_y), (p2_x, p2_y))
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(11, 79, __pyx_L1_error)
+  __pyx_v_p2_y = __pyx_f_7asyncpg_8protocol_4hton_unpack_double(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":81
+ *         double p2_y = hton.unpack_double(buf.read(8))
+ * 
+ *     return LineSegment((p1_x, p1_y), (p2_x, p2_y))             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_LineSegment); if (unlikely(!__pyx_t_3)) __PYX_ERR(11, 81, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_p1_x); if (unlikely(!__pyx_t_4)) __PYX_ERR(11, 81, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_p1_y); if (unlikely(!__pyx_t_5)) __PYX_ERR(11, 81, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(11, 81, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_6);
+  __Pyx_GIVEREF(__pyx_t_4);
+  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
+  __Pyx_GIVEREF(__pyx_t_5);
+  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
+  __pyx_t_4 = 0;
+  __pyx_t_5 = 0;
+  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_p2_x); if (unlikely(!__pyx_t_5)) __PYX_ERR(11, 81, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_p2_y); if (unlikely(!__pyx_t_4)) __PYX_ERR(11, 81, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(11, 81, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_7);
+  __Pyx_GIVEREF(__pyx_t_5);
+  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5);
+  __Pyx_GIVEREF(__pyx_t_4);
+  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4);
+  __pyx_t_5 = 0;
+  __pyx_t_4 = 0;
+  __pyx_t_4 = NULL;
+  __pyx_t_8 = 0;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
+    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
+    if (likely(__pyx_t_4)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+      __Pyx_INCREF(__pyx_t_4);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_3, function);
+      __pyx_t_8 = 1;
+    }
+  }
+  #if CYTHON_FAST_PYCALL
+  if (PyFunction_Check(__pyx_t_3)) {
+    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_6, __pyx_t_7};
+    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 81, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+  } else
+  #endif
+  #if CYTHON_FAST_PYCCALL
+  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
+    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_6, __pyx_t_7};
+    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 81, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+  } else
+  #endif
+  {
+    __pyx_t_5 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(11, 81, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    if (__pyx_t_4) {
+      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
+    }
+    __Pyx_GIVEREF(__pyx_t_6);
+    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_8, __pyx_t_6);
+    __Pyx_GIVEREF(__pyx_t_7);
+    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_8, __pyx_t_7);
+    __pyx_t_6 = 0;
+    __pyx_t_7 = 0;
+    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 81, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_r = __pyx_t_2;
+  __pyx_t_2 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":74
+ * 
+ * 
+ * cdef lseg_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         double p1_x = hton.unpack_double(buf.read(8))
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.lseg_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/geometry.pyx":84
+ * 
+ * 
+ * cdef point_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):             # <<<<<<<<<<<<<<
+ *     wbuf.write_int32(16)
+ *     wbuf.write_double(obj[0])
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_point_encode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_wbuf, PyObject *__pyx_v_obj) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  double __pyx_t_2;
+  __Pyx_RefNannySetupContext("point_encode", 0);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":85
+ * 
+ * cdef point_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):
+ *     wbuf.write_int32(16)             # <<<<<<<<<<<<<<
+ *     wbuf.write_double(obj[0])
+ *     wbuf.write_double(obj[1])
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_wbuf, 16); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 85, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":86
+ * cdef point_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):
+ *     wbuf.write_int32(16)
+ *     wbuf.write_double(obj[0])             # <<<<<<<<<<<<<<
+ *     wbuf.write_double(obj[1])
+ * 
+ */
+  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_obj, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 86, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) __PYX_ERR(11, 86, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_double(__pyx_v_wbuf, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 86, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":87
+ *     wbuf.write_int32(16)
+ *     wbuf.write_double(obj[0])
+ *     wbuf.write_double(obj[1])             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_obj, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 87, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) __PYX_ERR(11, 87, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_double(__pyx_v_wbuf, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 87, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":84
+ * 
+ * 
+ * cdef point_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):             # <<<<<<<<<<<<<<
+ *     wbuf.write_int32(16)
+ *     wbuf.write_double(obj[0])
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.point_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/geometry.pyx":90
+ * 
+ * 
+ * cdef point_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         double x = hton.unpack_double(buf.read(8))
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_point_decode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  double __pyx_v_x;
+  double __pyx_v_y;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  char const *__pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  int __pyx_t_7;
+  PyObject *__pyx_t_8 = NULL;
+  __Pyx_RefNannySetupContext("point_decode", 0);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":92
+ * cdef point_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     cdef:
+ *         double x = hton.unpack_double(buf.read(8))             # <<<<<<<<<<<<<<
+ *         double y = hton.unpack_double(buf.read(8))
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(11, 92, __pyx_L1_error)
+  __pyx_v_x = __pyx_f_7asyncpg_8protocol_4hton_unpack_double(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":93
+ *     cdef:
+ *         double x = hton.unpack_double(buf.read(8))
+ *         double y = hton.unpack_double(buf.read(8))             # <<<<<<<<<<<<<<
+ * 
+ *     return Point(x, y)
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(11, 93, __pyx_L1_error)
+  __pyx_v_y = __pyx_f_7asyncpg_8protocol_4hton_unpack_double(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":95
+ *         double y = hton.unpack_double(buf.read(8))
+ * 
+ *     return Point(x, y)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_Point); if (unlikely(!__pyx_t_3)) __PYX_ERR(11, 95, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_x); if (unlikely(!__pyx_t_4)) __PYX_ERR(11, 95, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_y); if (unlikely(!__pyx_t_5)) __PYX_ERR(11, 95, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_6 = NULL;
+  __pyx_t_7 = 0;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
+    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
+    if (likely(__pyx_t_6)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+      __Pyx_INCREF(__pyx_t_6);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_3, function);
+      __pyx_t_7 = 1;
+    }
+  }
+  #if CYTHON_FAST_PYCALL
+  if (PyFunction_Check(__pyx_t_3)) {
+    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_4, __pyx_t_5};
+    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 95, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  } else
+  #endif
+  #if CYTHON_FAST_PYCCALL
+  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
+    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_4, __pyx_t_5};
+    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 95, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  } else
+  #endif
+  {
+    __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(11, 95, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_8);
+    if (__pyx_t_6) {
+      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
+    }
+    __Pyx_GIVEREF(__pyx_t_4);
+    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_5);
+    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_5);
+    __pyx_t_4 = 0;
+    __pyx_t_5 = 0;
+    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 95, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_r = __pyx_t_2;
+  __pyx_t_2 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":90
+ * 
+ * 
+ * cdef point_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         double x = hton.unpack_double(buf.read(8))
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.point_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/geometry.pyx":98
+ * 
+ * 
+ * cdef path_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int8_t is_closed = 0
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_path_encode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_wbuf, PyObject *__pyx_v_obj) {
+  int8_t __pyx_v_is_closed;
+  Py_ssize_t __pyx_v_npts;
+  Py_ssize_t __pyx_v_encoded_len;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_3;
+  int8_t __pyx_t_4;
+  Py_ssize_t __pyx_t_5;
+  __Pyx_RefNannySetupContext("path_encode", 0);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":100
+ * cdef path_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):
+ *     cdef:
+ *         int8_t is_closed = 0             # <<<<<<<<<<<<<<
+ *         ssize_t npts
+ *         ssize_t encoded_len
+ */
+  __pyx_v_is_closed = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":105
+ *         int32_t i
+ * 
+ *     if cpython.PyTuple_Check(obj):             # <<<<<<<<<<<<<<
+ *         is_closed = 1
+ *     elif cpython.PyList_Check(obj):
+ */
+  __pyx_t_1 = (PyTuple_Check(__pyx_v_obj) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/geometry.pyx":106
+ * 
+ *     if cpython.PyTuple_Check(obj):
+ *         is_closed = 1             # <<<<<<<<<<<<<<
+ *     elif cpython.PyList_Check(obj):
+ *         is_closed = 0
+ */
+    __pyx_v_is_closed = 1;
+
+    /* "asyncpg/protocol/codecs/geometry.pyx":105
+ *         int32_t i
+ * 
+ *     if cpython.PyTuple_Check(obj):             # <<<<<<<<<<<<<<
+ *         is_closed = 1
+ *     elif cpython.PyList_Check(obj):
+ */
+    goto __pyx_L3;
+  }
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":107
+ *     if cpython.PyTuple_Check(obj):
+ *         is_closed = 1
+ *     elif cpython.PyList_Check(obj):             # <<<<<<<<<<<<<<
+ *         is_closed = 0
+ *     elif isinstance(obj, Path):
+ */
+  __pyx_t_1 = (PyList_Check(__pyx_v_obj) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/geometry.pyx":108
+ *         is_closed = 1
+ *     elif cpython.PyList_Check(obj):
+ *         is_closed = 0             # <<<<<<<<<<<<<<
+ *     elif isinstance(obj, Path):
+ *         is_closed = obj.is_closed
+ */
+    __pyx_v_is_closed = 0;
+
+    /* "asyncpg/protocol/codecs/geometry.pyx":107
+ *     if cpython.PyTuple_Check(obj):
+ *         is_closed = 1
+ *     elif cpython.PyList_Check(obj):             # <<<<<<<<<<<<<<
+ *         is_closed = 0
+ *     elif isinstance(obj, Path):
+ */
+    goto __pyx_L3;
+  }
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":109
+ *     elif cpython.PyList_Check(obj):
+ *         is_closed = 0
+ *     elif isinstance(obj, Path):             # <<<<<<<<<<<<<<
+ *         is_closed = obj.is_closed
+ * 
+ */
+  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_Path); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 109, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_1 = PyObject_IsInstance(__pyx_v_obj, __pyx_t_2); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(11, 109, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_3 = (__pyx_t_1 != 0);
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/codecs/geometry.pyx":110
+ *         is_closed = 0
+ *     elif isinstance(obj, Path):
+ *         is_closed = obj.is_closed             # <<<<<<<<<<<<<<
+ * 
+ *     npts = len(obj)
+ */
+    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_is_closed); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 110, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_4 = __Pyx_PyInt_As_int8_t(__pyx_t_2); if (unlikely((__pyx_t_4 == ((int8_t)-1)) && PyErr_Occurred())) __PYX_ERR(11, 110, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_v_is_closed = __pyx_t_4;
+
+    /* "asyncpg/protocol/codecs/geometry.pyx":109
+ *     elif cpython.PyList_Check(obj):
+ *         is_closed = 0
+ *     elif isinstance(obj, Path):             # <<<<<<<<<<<<<<
+ *         is_closed = obj.is_closed
+ * 
+ */
+  }
+  __pyx_L3:;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":112
+ *         is_closed = obj.is_closed
+ * 
+ *     npts = len(obj)             # <<<<<<<<<<<<<<
+ *     encoded_len = 1 + 4 + 16 * npts
+ *     if encoded_len > _MAXINT32:
+ */
+  __pyx_t_5 = PyObject_Length(__pyx_v_obj); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(11, 112, __pyx_L1_error)
+  __pyx_v_npts = __pyx_t_5;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":113
+ * 
+ *     npts = len(obj)
+ *     encoded_len = 1 + 4 + 16 * npts             # <<<<<<<<<<<<<<
+ *     if encoded_len > _MAXINT32:
+ *         raise ValueError('path value too long')
+ */
+  __pyx_v_encoded_len = (5 + (16 * __pyx_v_npts));
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":114
+ *     npts = len(obj)
+ *     encoded_len = 1 + 4 + 16 * npts
+ *     if encoded_len > _MAXINT32:             # <<<<<<<<<<<<<<
+ *         raise ValueError('path value too long')
+ * 
+ */
+  __pyx_t_3 = ((__pyx_v_encoded_len > 0x7FFFFFFF) != 0);
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/codecs/geometry.pyx":115
+ *     encoded_len = 1 + 4 + 16 * npts
+ *     if encoded_len > _MAXINT32:
+ *         raise ValueError('path value too long')             # <<<<<<<<<<<<<<
+ * 
+ *     wbuf.write_int32(<int32_t>encoded_len)
+ */
+    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 115, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __PYX_ERR(11, 115, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/geometry.pyx":114
+ *     npts = len(obj)
+ *     encoded_len = 1 + 4 + 16 * npts
+ *     if encoded_len > _MAXINT32:             # <<<<<<<<<<<<<<
+ *         raise ValueError('path value too long')
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":117
+ *         raise ValueError('path value too long')
+ * 
+ *     wbuf.write_int32(<int32_t>encoded_len)             # <<<<<<<<<<<<<<
+ *     wbuf.write_byte(is_closed)
+ *     wbuf.write_int32(<int32_t>npts)
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_wbuf, ((int32_t)__pyx_v_encoded_len)); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 117, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":118
+ * 
+ *     wbuf.write_int32(<int32_t>encoded_len)
+ *     wbuf.write_byte(is_closed)             # <<<<<<<<<<<<<<
+ *     wbuf.write_int32(<int32_t>npts)
+ * 
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(__pyx_v_wbuf, __pyx_v_is_closed); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 118, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":119
+ *     wbuf.write_int32(<int32_t>encoded_len)
+ *     wbuf.write_byte(is_closed)
+ *     wbuf.write_int32(<int32_t>npts)             # <<<<<<<<<<<<<<
+ * 
+ *     _encode_points(wbuf, obj)
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_wbuf, ((int32_t)__pyx_v_npts)); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 119, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":121
+ *     wbuf.write_int32(<int32_t>npts)
+ * 
+ *     _encode_points(wbuf, obj)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol__encode_points(__pyx_v_wbuf, __pyx_v_obj); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 121, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":98
+ * 
+ * 
+ * cdef path_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int8_t is_closed = 0
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.path_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/geometry.pyx":124
+ * 
+ * 
+ * cdef path_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int8_t is_closed = <int8_t>buf.read(1)[0]
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_path_decode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  int8_t __pyx_v_is_closed;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  char const *__pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  __Pyx_RefNannySetupContext("path_decode", 0);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":126
+ * cdef path_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     cdef:
+ *         int8_t is_closed = <int8_t>buf.read(1)[0]             # <<<<<<<<<<<<<<
+ * 
+ *     return Path(*_decode_points(buf), is_closed=is_closed == 1)
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 1); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(11, 126, __pyx_L1_error)
+  __pyx_v_is_closed = ((int8_t)(__pyx_t_1[0]));
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":128
+ *         int8_t is_closed = <int8_t>buf.read(1)[0]
+ * 
+ *     return Path(*_decode_points(buf), is_closed=is_closed == 1)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_Path); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 128, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol__decode_points(__pyx_v_buf); if (unlikely(!__pyx_t_3)) __PYX_ERR(11, 128, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(11, 128, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(11, 128, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_5 = __Pyx_PyBool_FromLong((__pyx_v_is_closed == 1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(11, 128, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_is_closed, __pyx_t_5) < 0) __PYX_ERR(11, 128, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(11, 128, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_r = __pyx_t_5;
+  __pyx_t_5 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":124
+ * 
+ * 
+ * cdef path_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int8_t is_closed = <int8_t>buf.read(1)[0]
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.path_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/geometry.pyx":131
+ * 
+ * 
+ * cdef poly_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         bint is_closed
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_poly_encode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_wbuf, PyObject *__pyx_v_obj) {
+  Py_ssize_t __pyx_v_npts;
+  Py_ssize_t __pyx_v_encoded_len;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  Py_ssize_t __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("poly_encode", 0);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":138
+ *         int32_t i
+ * 
+ *     npts = len(obj)             # <<<<<<<<<<<<<<
+ *     encoded_len = 4 + 16 * npts
+ *     if encoded_len > _MAXINT32:
+ */
+  __pyx_t_1 = PyObject_Length(__pyx_v_obj); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(11, 138, __pyx_L1_error)
+  __pyx_v_npts = __pyx_t_1;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":139
+ * 
+ *     npts = len(obj)
+ *     encoded_len = 4 + 16 * npts             # <<<<<<<<<<<<<<
+ *     if encoded_len > _MAXINT32:
+ *         raise ValueError('polygon value too long')
+ */
+  __pyx_v_encoded_len = (4 + (16 * __pyx_v_npts));
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":140
+ *     npts = len(obj)
+ *     encoded_len = 4 + 16 * npts
+ *     if encoded_len > _MAXINT32:             # <<<<<<<<<<<<<<
+ *         raise ValueError('polygon value too long')
+ * 
+ */
+  __pyx_t_2 = ((__pyx_v_encoded_len > 0x7FFFFFFF) != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/codecs/geometry.pyx":141
+ *     encoded_len = 4 + 16 * npts
+ *     if encoded_len > _MAXINT32:
+ *         raise ValueError('polygon value too long')             # <<<<<<<<<<<<<<
+ * 
+ *     wbuf.write_int32(<int32_t>encoded_len)
+ */
+    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__35, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(11, 141, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __PYX_ERR(11, 141, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/geometry.pyx":140
+ *     npts = len(obj)
+ *     encoded_len = 4 + 16 * npts
+ *     if encoded_len > _MAXINT32:             # <<<<<<<<<<<<<<
+ *         raise ValueError('polygon value too long')
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":143
+ *         raise ValueError('polygon value too long')
+ * 
+ *     wbuf.write_int32(<int32_t>encoded_len)             # <<<<<<<<<<<<<<
+ *     wbuf.write_int32(<int32_t>npts)
+ *     _encode_points(wbuf, obj)
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_wbuf, ((int32_t)__pyx_v_encoded_len)); if (unlikely(!__pyx_t_3)) __PYX_ERR(11, 143, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":144
+ * 
+ *     wbuf.write_int32(<int32_t>encoded_len)
+ *     wbuf.write_int32(<int32_t>npts)             # <<<<<<<<<<<<<<
+ *     _encode_points(wbuf, obj)
+ * 
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_wbuf, ((int32_t)__pyx_v_npts)); if (unlikely(!__pyx_t_3)) __PYX_ERR(11, 144, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":145
+ *     wbuf.write_int32(<int32_t>encoded_len)
+ *     wbuf.write_int32(<int32_t>npts)
+ *     _encode_points(wbuf, obj)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol__encode_points(__pyx_v_wbuf, __pyx_v_obj); if (unlikely(!__pyx_t_3)) __PYX_ERR(11, 145, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":131
+ * 
+ * 
+ * cdef poly_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         bint is_closed
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.poly_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/geometry.pyx":148
+ * 
+ * 
+ * cdef poly_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     return Polygon(*_decode_points(buf))
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_poly_decode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("poly_decode", 0);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":149
+ * 
+ * cdef poly_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     return Polygon(*_decode_points(buf))             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Polygon); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 149, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol__decode_points(__pyx_v_buf); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 149, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PySequence_Tuple(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(11, 149, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 149, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_r = __pyx_t_2;
+  __pyx_t_2 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":148
+ * 
+ * 
+ * cdef poly_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     return Polygon(*_decode_points(buf))
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.poly_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/geometry.pyx":152
+ * 
+ * 
+ * cdef circle_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):             # <<<<<<<<<<<<<<
+ *     wbuf.write_int32(24)
+ *     wbuf.write_double(obj[0][0])
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_circle_encode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_wbuf, PyObject *__pyx_v_obj) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  double __pyx_t_3;
+  __Pyx_RefNannySetupContext("circle_encode", 0);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":153
+ * 
+ * cdef circle_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):
+ *     wbuf.write_int32(24)             # <<<<<<<<<<<<<<
+ *     wbuf.write_double(obj[0][0])
+ *     wbuf.write_double(obj[0][1])
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_wbuf, 24); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 153, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":154
+ * cdef circle_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):
+ *     wbuf.write_int32(24)
+ *     wbuf.write_double(obj[0][0])             # <<<<<<<<<<<<<<
+ *     wbuf.write_double(obj[0][1])
+ *     wbuf.write_double(obj[1])
+ */
+  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_obj, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 154, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 154, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_3 == (double)-1) && PyErr_Occurred())) __PYX_ERR(11, 154, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_double(__pyx_v_wbuf, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 154, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":155
+ *     wbuf.write_int32(24)
+ *     wbuf.write_double(obj[0][0])
+ *     wbuf.write_double(obj[0][1])             # <<<<<<<<<<<<<<
+ *     wbuf.write_double(obj[1])
+ * 
+ */
+  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_obj, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 155, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 155, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_3 == (double)-1) && PyErr_Occurred())) __PYX_ERR(11, 155, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_double(__pyx_v_wbuf, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 155, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":156
+ *     wbuf.write_double(obj[0][0])
+ *     wbuf.write_double(obj[0][1])
+ *     wbuf.write_double(obj[1])             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_obj, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 156, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_3 == (double)-1) && PyErr_Occurred())) __PYX_ERR(11, 156, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_double(__pyx_v_wbuf, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 156, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":152
+ * 
+ * 
+ * cdef circle_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):             # <<<<<<<<<<<<<<
+ *     wbuf.write_int32(24)
+ *     wbuf.write_double(obj[0][0])
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.circle_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/geometry.pyx":159
+ * 
+ * 
+ * cdef circle_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         double center_x = hton.unpack_double(buf.read(8))
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_circle_decode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  double __pyx_v_center_x;
+  double __pyx_v_center_y;
+  double __pyx_v_radius;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  char const *__pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  int __pyx_t_7;
+  PyObject *__pyx_t_8 = NULL;
+  __Pyx_RefNannySetupContext("circle_decode", 0);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":161
+ * cdef circle_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     cdef:
+ *         double center_x = hton.unpack_double(buf.read(8))             # <<<<<<<<<<<<<<
+ *         double center_y = hton.unpack_double(buf.read(8))
+ *         double radius = hton.unpack_double(buf.read(8))
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(11, 161, __pyx_L1_error)
+  __pyx_v_center_x = __pyx_f_7asyncpg_8protocol_4hton_unpack_double(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":162
+ *     cdef:
+ *         double center_x = hton.unpack_double(buf.read(8))
+ *         double center_y = hton.unpack_double(buf.read(8))             # <<<<<<<<<<<<<<
+ *         double radius = hton.unpack_double(buf.read(8))
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(11, 162, __pyx_L1_error)
+  __pyx_v_center_y = __pyx_f_7asyncpg_8protocol_4hton_unpack_double(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":163
+ *         double center_x = hton.unpack_double(buf.read(8))
+ *         double center_y = hton.unpack_double(buf.read(8))
+ *         double radius = hton.unpack_double(buf.read(8))             # <<<<<<<<<<<<<<
+ * 
+ *     return Circle((center_x, center_y), radius)
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(11, 163, __pyx_L1_error)
+  __pyx_v_radius = __pyx_f_7asyncpg_8protocol_4hton_unpack_double(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":165
+ *         double radius = hton.unpack_double(buf.read(8))
+ * 
+ *     return Circle((center_x, center_y), radius)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_Circle); if (unlikely(!__pyx_t_3)) __PYX_ERR(11, 165, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_center_x); if (unlikely(!__pyx_t_4)) __PYX_ERR(11, 165, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_center_y); if (unlikely(!__pyx_t_5)) __PYX_ERR(11, 165, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(11, 165, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_6);
+  __Pyx_GIVEREF(__pyx_t_4);
+  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
+  __Pyx_GIVEREF(__pyx_t_5);
+  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
+  __pyx_t_4 = 0;
+  __pyx_t_5 = 0;
+  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_radius); if (unlikely(!__pyx_t_5)) __PYX_ERR(11, 165, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_4 = NULL;
+  __pyx_t_7 = 0;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
+    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
+    if (likely(__pyx_t_4)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+      __Pyx_INCREF(__pyx_t_4);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_3, function);
+      __pyx_t_7 = 1;
+    }
+  }
+  #if CYTHON_FAST_PYCALL
+  if (PyFunction_Check(__pyx_t_3)) {
+    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_6, __pyx_t_5};
+    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 165, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  } else
+  #endif
+  #if CYTHON_FAST_PYCCALL
+  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
+    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_6, __pyx_t_5};
+    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 165, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  } else
+  #endif
+  {
+    __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(11, 165, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_8);
+    if (__pyx_t_4) {
+      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); __pyx_t_4 = NULL;
+    }
+    __Pyx_GIVEREF(__pyx_t_6);
+    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_6);
+    __Pyx_GIVEREF(__pyx_t_5);
+    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_5);
+    __pyx_t_6 = 0;
+    __pyx_t_5 = 0;
+    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 165, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_r = __pyx_t_2;
+  __pyx_t_2 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":159
+ * 
+ * 
+ * cdef circle_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         double center_x = hton.unpack_double(buf.read(8))
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.circle_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/geometry.pyx":168
+ * 
+ * 
+ * cdef init_geometry_codecs():             # <<<<<<<<<<<<<<
+ *     register_core_codec(BOXOID,
+ *                         <encode_func>&box_encode,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_geometry_codecs(void) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("init_geometry_codecs", 0);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":169
+ * 
+ * cdef init_geometry_codecs():
+ *     register_core_codec(BOXOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&box_encode,
+ *                         <decode_func>&box_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x25B, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_box_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_box_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 169, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":174
+ *                         PG_FORMAT_BINARY)
+ * 
+ *     register_core_codec(LINEOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&line_encode,
+ *                         <decode_func>&line_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x274, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_line_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_line_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 174, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":179
+ *                         PG_FORMAT_BINARY)
+ * 
+ *     register_core_codec(LSEGOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&lseg_encode,
+ *                         <decode_func>&lseg_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x259, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_lseg_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_lseg_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 179, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":184
+ *                         PG_FORMAT_BINARY)
+ * 
+ *     register_core_codec(POINTOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&point_encode,
+ *                         <decode_func>&point_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x258, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_point_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_point_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 184, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":189
+ *                         PG_FORMAT_BINARY)
+ * 
+ *     register_core_codec(PATHOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&path_encode,
+ *                         <decode_func>&path_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x25A, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_path_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_path_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 189, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":194
+ *                         PG_FORMAT_BINARY)
+ * 
+ *     register_core_codec(POLYGONOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&poly_encode,
+ *                         <decode_func>&poly_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x25C, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_poly_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_poly_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 194, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":199
+ *                         PG_FORMAT_BINARY)
+ * 
+ *     register_core_codec(CIRCLEOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&circle_encode,
+ *                         <decode_func>&circle_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x2CE, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_circle_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_circle_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 199, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":168
+ * 
+ * 
+ * cdef init_geometry_codecs():             # <<<<<<<<<<<<<<
+ *     register_core_codec(BOXOID,
+ *                         <encode_func>&box_encode,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.init_geometry_codecs", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/int.pyx":8
+ * 
+ * 
+ * cdef bool_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     if not cpython.PyBool_Check(obj):
+ *         raise TypeError('a boolean is required (got type {})'.format(
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_bool_encode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  char __pyx_t_7;
+  __Pyx_RefNannySetupContext("bool_encode", 0);
+
+  /* "asyncpg/protocol/codecs/int.pyx":9
+ * 
+ * cdef bool_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+ *     if not cpython.PyBool_Check(obj):             # <<<<<<<<<<<<<<
+ *         raise TypeError('a boolean is required (got type {})'.format(
+ *             type(obj).__name__))
+ */
+  __pyx_t_1 = ((!(PyBool_Check(__pyx_v_obj) != 0)) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/int.pyx":10
+ * cdef bool_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+ *     if not cpython.PyBool_Check(obj):
+ *         raise TypeError('a boolean is required (got type {})'.format(             # <<<<<<<<<<<<<<
+ *             type(obj).__name__))
+ * 
+ */
+    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_a_boolean_is_required_got_type, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 10, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+
+    /* "asyncpg/protocol/codecs/int.pyx":11
+ *     if not cpython.PyBool_Check(obj):
+ *         raise TypeError('a boolean is required (got type {})'.format(
+ *             type(obj).__name__))             # <<<<<<<<<<<<<<
+ * 
+ *     buf.write_int32(1)
+ */
+    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_obj)), __pyx_n_s_name_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 11, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
+      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
+      if (likely(__pyx_t_5)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+        __Pyx_INCREF(__pyx_t_5);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_3, function);
+      }
+    }
+    if (!__pyx_t_5) {
+      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 10, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_GOTREF(__pyx_t_2);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_3)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
+        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 10, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
+        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 10, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 10, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_6);
+        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
+        __Pyx_GIVEREF(__pyx_t_4);
+        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
+        __pyx_t_4 = 0;
+        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 10, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/codecs/int.pyx":10
+ * cdef bool_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+ *     if not cpython.PyBool_Check(obj):
+ *         raise TypeError('a boolean is required (got type {})'.format(             # <<<<<<<<<<<<<<
+ *             type(obj).__name__))
+ * 
+ */
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 10, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_GIVEREF(__pyx_t_2);
+    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
+    __pyx_t_2 = 0;
+    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 10, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __PYX_ERR(3, 10, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/int.pyx":9
+ * 
+ * cdef bool_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+ *     if not cpython.PyBool_Check(obj):             # <<<<<<<<<<<<<<
+ *         raise TypeError('a boolean is required (got type {})'.format(
+ *             type(obj).__name__))
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/int.pyx":13
+ *             type(obj).__name__))
+ * 
+ *     buf.write_int32(1)             # <<<<<<<<<<<<<<
+ *     buf.write_byte(b'\x01' if obj is True else b'\x00')
+ * 
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 13, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/int.pyx":14
+ * 
+ *     buf.write_int32(1)
+ *     buf.write_byte(b'\x01' if obj is True else b'\x00')             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_1 = (__pyx_v_obj == Py_True);
+  if ((__pyx_t_1 != 0)) {
+    __pyx_t_7 = '\x01';
+  } else {
+    __pyx_t_7 = '\x00';
+  }
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(__pyx_v_buf, __pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 14, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/int.pyx":8
+ * 
+ * 
+ * cdef bool_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     if not cpython.PyBool_Check(obj):
+ *         raise TypeError('a boolean is required (got type {})'.format(
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.bool_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/int.pyx":17
+ * 
+ * 
+ * cdef bool_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     return buf.read(1)[0] is b'\x01'
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_bool_decode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  char const *__pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("bool_decode", 0);
+
+  /* "asyncpg/protocol/codecs/int.pyx":18
+ * 
+ * cdef bool_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     return buf.read(1)[0] is b'\x01'             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 1); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(3, 18, __pyx_L1_error)
+  __pyx_t_2 = __Pyx_PyBool_FromLong(((__pyx_t_1[0]) == '\x01')); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 18, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_r = __pyx_t_2;
+  __pyx_t_2 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/int.pyx":17
+ * 
+ * 
+ * cdef bool_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     return buf.read(1)[0] is b'\x01'
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.bool_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/int.pyx":21
+ * 
+ * 
+ * cdef int2_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef long val = cpython.PyLong_AsLong(obj)
+ *     if val < -32767 or val > 32767:
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_int2_encode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
+  long __pyx_v_val;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  long __pyx_t_1;
+  int __pyx_t_2;
+  int __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  __Pyx_RefNannySetupContext("int2_encode", 0);
+
+  /* "asyncpg/protocol/codecs/int.pyx":22
+ * 
+ * cdef int2_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+ *     cdef long val = cpython.PyLong_AsLong(obj)             # <<<<<<<<<<<<<<
+ *     if val < -32767 or val > 32767:
+ *         raise ValueError(
+ */
+  __pyx_t_1 = PyLong_AsLong(__pyx_v_obj); if (unlikely(__pyx_t_1 == -1L && PyErr_Occurred())) __PYX_ERR(3, 22, __pyx_L1_error)
+  __pyx_v_val = __pyx_t_1;
+
+  /* "asyncpg/protocol/codecs/int.pyx":23
+ * cdef int2_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+ *     cdef long val = cpython.PyLong_AsLong(obj)
+ *     if val < -32767 or val > 32767:             # <<<<<<<<<<<<<<
+ *         raise ValueError(
+ *             'integer too large to be encoded as INT2: {!r}'.format(val))
+ */
+  __pyx_t_3 = ((__pyx_v_val < -32767L) != 0);
+  if (!__pyx_t_3) {
+  } else {
+    __pyx_t_2 = __pyx_t_3;
+    goto __pyx_L4_bool_binop_done;
+  }
+  __pyx_t_3 = ((__pyx_v_val > 0x7FFF) != 0);
+  __pyx_t_2 = __pyx_t_3;
+  __pyx_L4_bool_binop_done:;
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/codecs/int.pyx":25
+ *     if val < -32767 or val > 32767:
+ *         raise ValueError(
+ *             'integer too large to be encoded as INT2: {!r}'.format(val))             # <<<<<<<<<<<<<<
+ * 
+ *     buf.write_int32(2)
+ */
+    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_integer_too_large_to_be_encoded, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 25, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = __Pyx_PyInt_From_long(__pyx_v_val); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 25, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_7 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
+      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
+      if (likely(__pyx_t_7)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+        __Pyx_INCREF(__pyx_t_7);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_5, function);
+      }
+    }
+    if (!__pyx_t_7) {
+      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 25, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_GOTREF(__pyx_t_4);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_5)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
+        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 25, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
+        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 25, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(3, 25, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_8);
+        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
+        __Pyx_GIVEREF(__pyx_t_6);
+        PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_6);
+        __pyx_t_6 = 0;
+        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 25, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+    /* "asyncpg/protocol/codecs/int.pyx":24
+ *     cdef long val = cpython.PyLong_AsLong(obj)
+ *     if val < -32767 or val > 32767:
+ *         raise ValueError(             # <<<<<<<<<<<<<<
+ *             'integer too large to be encoded as INT2: {!r}'.format(val))
+ * 
+ */
+    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 24, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_GIVEREF(__pyx_t_4);
+    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
+    __pyx_t_4 = 0;
+    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 24, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __PYX_ERR(3, 24, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/int.pyx":23
+ * cdef int2_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+ *     cdef long val = cpython.PyLong_AsLong(obj)
+ *     if val < -32767 or val > 32767:             # <<<<<<<<<<<<<<
+ *         raise ValueError(
+ *             'integer too large to be encoded as INT2: {!r}'.format(val))
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/int.pyx":27
+ *             'integer too large to be encoded as INT2: {!r}'.format(val))
+ * 
+ *     buf.write_int32(2)             # <<<<<<<<<<<<<<
+ *     buf.write_int16(<int16_t>val)
+ * 
+ */
+  __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, 2); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 27, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "asyncpg/protocol/codecs/int.pyx":28
+ * 
+ *     buf.write_int32(2)
+ *     buf.write_int16(<int16_t>val)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int16(__pyx_v_buf, ((int16_t)__pyx_v_val)); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 28, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "asyncpg/protocol/codecs/int.pyx":21
+ * 
+ * 
+ * cdef int2_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef long val = cpython.PyLong_AsLong(obj)
+ *     if val < -32767 or val > 32767:
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.int2_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/int.pyx":31
+ * 
+ * 
+ * cdef int2_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     return cpython.PyLong_FromLong(hton.unpack_int16(buf.read(2)))
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_int2_decode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  char const *__pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("int2_decode", 0);
+
+  /* "asyncpg/protocol/codecs/int.pyx":32
+ * 
+ * cdef int2_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     return cpython.PyLong_FromLong(hton.unpack_int16(buf.read(2)))             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 2); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(3, 32, __pyx_L1_error)
+  __pyx_t_2 = PyLong_FromLong(__pyx_f_7asyncpg_8protocol_4hton_unpack_int16(__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 32, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_r = __pyx_t_2;
+  __pyx_t_2 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/int.pyx":31
+ * 
+ * 
+ * cdef int2_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     return cpython.PyLong_FromLong(hton.unpack_int16(buf.read(2)))
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.int2_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/int.pyx":35
+ * 
+ * 
+ * cdef int4_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef int32_t val = <int32_t>cpython.PyLong_AsLong(obj)
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_int4_encode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
+  int32_t __pyx_v_val;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  long __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("int4_encode", 0);
+
+  /* "asyncpg/protocol/codecs/int.pyx":36
+ * 
+ * cdef int4_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+ *     cdef int32_t val = <int32_t>cpython.PyLong_AsLong(obj)             # <<<<<<<<<<<<<<
+ * 
+ *     buf.write_int32(4)
+ */
+  __pyx_t_1 = PyLong_AsLong(__pyx_v_obj); if (unlikely(__pyx_t_1 == -1L && PyErr_Occurred())) __PYX_ERR(3, 36, __pyx_L1_error)
+  __pyx_v_val = ((int32_t)__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/int.pyx":38
+ *     cdef int32_t val = <int32_t>cpython.PyLong_AsLong(obj)
+ * 
+ *     buf.write_int32(4)             # <<<<<<<<<<<<<<
+ *     buf.write_int32(val)
+ * 
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, 4); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 38, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/int.pyx":39
+ * 
+ *     buf.write_int32(4)
+ *     buf.write_int32(val)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, __pyx_v_val); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 39, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/int.pyx":35
+ * 
+ * 
+ * cdef int4_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef int32_t val = <int32_t>cpython.PyLong_AsLong(obj)
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.int4_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/int.pyx":42
+ * 
+ * 
+ * cdef int4_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     return cpython.PyLong_FromLong(hton.unpack_int32(buf.read(4)))
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_int4_decode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  char const *__pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("int4_decode", 0);
+
+  /* "asyncpg/protocol/codecs/int.pyx":43
+ * 
+ * cdef int4_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     return cpython.PyLong_FromLong(hton.unpack_int32(buf.read(4)))             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(3, 43, __pyx_L1_error)
+  __pyx_t_2 = PyLong_FromLong(__pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 43, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_r = __pyx_t_2;
+  __pyx_t_2 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/int.pyx":42
+ * 
+ * 
+ * cdef int4_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     return cpython.PyLong_FromLong(hton.unpack_int32(buf.read(4)))
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.int4_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/int.pyx":46
+ * 
+ * 
+ * cdef int8_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef int64_t val = cpython.PyLong_AsLongLong(obj)
+ *     buf.write_int32(8)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_int8_encode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
+  int64_t __pyx_v_val;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PY_LONG_LONG __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("int8_encode", 0);
+
+  /* "asyncpg/protocol/codecs/int.pyx":47
+ * 
+ * cdef int8_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+ *     cdef int64_t val = cpython.PyLong_AsLongLong(obj)             # <<<<<<<<<<<<<<
+ *     buf.write_int32(8)
+ *     buf.write_int64(val)
+ */
+  __pyx_t_1 = PyLong_AsLongLong(__pyx_v_obj); if (unlikely(__pyx_t_1 == -1LL && PyErr_Occurred())) __PYX_ERR(3, 47, __pyx_L1_error)
+  __pyx_v_val = __pyx_t_1;
+
+  /* "asyncpg/protocol/codecs/int.pyx":48
+ * cdef int8_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+ *     cdef int64_t val = cpython.PyLong_AsLongLong(obj)
+ *     buf.write_int32(8)             # <<<<<<<<<<<<<<
+ *     buf.write_int64(val)
+ * 
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, 8); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 48, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/int.pyx":49
+ *     cdef int64_t val = cpython.PyLong_AsLongLong(obj)
+ *     buf.write_int32(8)
+ *     buf.write_int64(val)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int64(__pyx_v_buf, __pyx_v_val); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 49, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/int.pyx":46
+ * 
+ * 
+ * cdef int8_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef int64_t val = cpython.PyLong_AsLongLong(obj)
+ *     buf.write_int32(8)
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.int8_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/int.pyx":52
+ * 
+ * 
+ * cdef int8_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     return cpython.PyLong_FromLongLong(hton.unpack_int64(buf.read(8)))
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_int8_decode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  char const *__pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("int8_decode", 0);
+
+  /* "asyncpg/protocol/codecs/int.pyx":53
+ * 
+ * cdef int8_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     return cpython.PyLong_FromLongLong(hton.unpack_int64(buf.read(8)))             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(3, 53, __pyx_L1_error)
+  __pyx_t_2 = PyLong_FromLongLong(__pyx_f_7asyncpg_8protocol_4hton_unpack_int64(__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 53, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_r = __pyx_t_2;
+  __pyx_t_2 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/int.pyx":52
+ * 
+ * 
+ * cdef int8_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     return cpython.PyLong_FromLongLong(hton.unpack_int64(buf.read(8)))
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.int8_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/int.pyx":56
+ * 
+ * 
+ * cdef init_int_codecs():             # <<<<<<<<<<<<<<
+ * 
+ *     register_core_codec(BOOLOID,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_int_codecs(void) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("init_int_codecs", 0);
+
+  /* "asyncpg/protocol/codecs/int.pyx":58
+ * cdef init_int_codecs():
+ * 
+ *     register_core_codec(BOOLOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&bool_encode,
+ *                         <decode_func>&bool_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(16, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_bool_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_bool_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 58, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/int.pyx":63
+ *                         PG_FORMAT_BINARY)
+ * 
+ *     register_core_codec(INT2OID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&int2_encode,
+ *                         <decode_func>&int2_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(21, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_int2_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_int2_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 63, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/int.pyx":68
+ *                         PG_FORMAT_BINARY)
+ * 
+ *     register_core_codec(INT4OID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&int4_encode,
+ *                         <decode_func>&int4_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(23, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_int4_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_int4_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 68, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/int.pyx":73
+ *                         PG_FORMAT_BINARY)
+ * 
+ *     register_core_codec(INT8OID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&int8_encode,
+ *                         <decode_func>&int8_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(20, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_int8_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_int8_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 73, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/int.pyx":56
+ * 
+ * 
+ * cdef init_int_codecs():             # <<<<<<<<<<<<<<
+ * 
+ *     register_core_codec(BOOLOID,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.init_int_codecs", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/json.pyx":8
+ * 
+ * 
+ * cdef jsonb_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         char *str
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_jsonb_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
+  char *__pyx_v_str;
+  Py_ssize_t __pyx_v_size;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  __Pyx_RefNannySetupContext("jsonb_encode", 0);
+
+  /* "asyncpg/protocol/codecs/json.pyx":13
+ *         ssize_t size
+ * 
+ *     as_pg_string_and_size(settings, obj, &str, &size)             # <<<<<<<<<<<<<<
+ * 
+ *     if size > 0x7fffffff - 1:
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_as_pg_string_and_size(__pyx_v_settings, __pyx_v_obj, (&__pyx_v_str), (&__pyx_v_size)); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 13, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/json.pyx":15
+ *     as_pg_string_and_size(settings, obj, &str, &size)
+ * 
+ *     if size > 0x7fffffff - 1:             # <<<<<<<<<<<<<<
+ *         raise ValueError('string too long')
+ * 
+ */
+  __pyx_t_2 = ((__pyx_v_size > 0x7FFFFFFE) != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/codecs/json.pyx":16
+ * 
+ *     if size > 0x7fffffff - 1:
+ *         raise ValueError('string too long')             # <<<<<<<<<<<<<<
+ * 
+ *     buf.write_int32(<int32_t>size + 1)
+ */
+    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__36, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 16, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __PYX_ERR(12, 16, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/json.pyx":15
+ *     as_pg_string_and_size(settings, obj, &str, &size)
+ * 
+ *     if size > 0x7fffffff - 1:             # <<<<<<<<<<<<<<
+ *         raise ValueError('string too long')
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/json.pyx":18
+ *         raise ValueError('string too long')
+ * 
+ *     buf.write_int32(<int32_t>size + 1)             # <<<<<<<<<<<<<<
+ *     buf.write_byte(1)  # JSONB format version
+ *     buf.write_cstr(str, size)
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, (((int32_t)__pyx_v_size) + 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 18, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/json.pyx":19
+ * 
+ *     buf.write_int32(<int32_t>size + 1)
+ *     buf.write_byte(1)  # JSONB format version             # <<<<<<<<<<<<<<
+ *     buf.write_cstr(str, size)
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(__pyx_v_buf, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 19, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/json.pyx":20
+ *     buf.write_int32(<int32_t>size + 1)
+ *     buf.write_byte(1)  # JSONB format version
+ *     buf.write_cstr(str, size)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_cstr(__pyx_v_buf, __pyx_v_str, __pyx_v_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 20, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/json.pyx":8
+ * 
+ * 
+ * cdef jsonb_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         char *str
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.jsonb_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/json.pyx":23
+ * 
+ * 
+ * cdef jsonb_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef uint8_t format = <uint8_t>buf.read(1)[0]
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_jsonb_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  uint8_t __pyx_v_format;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  char const *__pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  __Pyx_RefNannySetupContext("jsonb_decode", 0);
+
+  /* "asyncpg/protocol/codecs/json.pyx":24
+ * 
+ * cdef jsonb_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     cdef uint8_t format = <uint8_t>buf.read(1)[0]             # <<<<<<<<<<<<<<
+ * 
+ *     if format != 1:
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 1); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(12, 24, __pyx_L1_error)
+  __pyx_v_format = ((uint8_t)(__pyx_t_1[0]));
+
+  /* "asyncpg/protocol/codecs/json.pyx":26
+ *     cdef uint8_t format = <uint8_t>buf.read(1)[0]
+ * 
+ *     if format != 1:             # <<<<<<<<<<<<<<
+ *         raise ValueError('unexpected JSONB format: {}'.format(format))
+ * 
+ */
+  __pyx_t_2 = ((__pyx_v_format != 1) != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/codecs/json.pyx":27
+ * 
+ *     if format != 1:
+ *         raise ValueError('unexpected JSONB format: {}'.format(format))             # <<<<<<<<<<<<<<
+ * 
+ *     return text_decode(settings, buf)
+ */
+    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_unexpected_JSONB_format, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(12, 27, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = __Pyx_PyInt_From_uint8_t(__pyx_v_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(12, 27, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
+      if (likely(__pyx_t_6)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+        __Pyx_INCREF(__pyx_t_6);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_4, function);
+      }
+    }
+    if (!__pyx_t_6) {
+      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 27, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_4)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
+        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 27, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
+        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 27, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(12, 27, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
+        __Pyx_GIVEREF(__pyx_t_5);
+        PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5);
+        __pyx_t_5 = 0;
+        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 27, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(12, 27, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_3);
+    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
+    __pyx_t_3 = 0;
+    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 27, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __PYX_ERR(12, 27, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/json.pyx":26
+ *     cdef uint8_t format = <uint8_t>buf.read(1)[0]
+ * 
+ *     if format != 1:             # <<<<<<<<<<<<<<
+ *         raise ValueError('unexpected JSONB format: {}'.format(format))
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/json.pyx":29
+ *         raise ValueError('unexpected JSONB format: {}'.format(format))
+ * 
+ *     return text_decode(settings, buf)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_text_decode(__pyx_v_settings, __pyx_v_buf); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 29, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_r = __pyx_t_3;
+  __pyx_t_3 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/json.pyx":23
+ * 
+ * 
+ * cdef jsonb_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef uint8_t format = <uint8_t>buf.read(1)[0]
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.jsonb_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/json.pyx":32
+ * 
+ * 
+ * cdef init_json_codecs():             # <<<<<<<<<<<<<<
+ *     register_core_codec(JSONOID,
+ *                         <encode_func>&text_encode,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_json_codecs(void) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("init_json_codecs", 0);
+
+  /* "asyncpg/protocol/codecs/json.pyx":33
+ * 
+ * cdef init_json_codecs():
+ *     register_core_codec(JSONOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&text_encode,
+ *                         <decode_func>&text_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x72, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 33, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/json.pyx":37
+ *                         <decode_func>&text_decode,
+ *                         PG_FORMAT_BINARY)
+ *     register_core_codec(JSONBOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&jsonb_encode,
+ *                         <decode_func>&jsonb_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0xEDA, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_jsonb_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_jsonb_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 37, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/json.pyx":32
+ * 
+ * 
+ * cdef init_json_codecs():             # <<<<<<<<<<<<<<
+ *     register_core_codec(JSONOID,
+ *                         <encode_func>&text_encode,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.init_json_codecs", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/money.pyx":8
+ * 
+ * 
+ * cdef init_monetary_codecs():             # <<<<<<<<<<<<<<
+ *     moneyoids = [
+ *         MONEYOID,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_monetary_codecs(void) {
+  PyObject *__pyx_v_moneyoids = NULL;
+  PyObject *__pyx_v_oid = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  Py_ssize_t __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  uint32_t __pyx_t_4;
+  __Pyx_RefNannySetupContext("init_monetary_codecs", 0);
+
+  /* "asyncpg/protocol/codecs/money.pyx":9
+ * 
+ * cdef init_monetary_codecs():
+ *     moneyoids = [             # <<<<<<<<<<<<<<
+ *         MONEYOID,
+ *     ]
+ */
+  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(13, 9, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(__pyx_int_790);
+  __Pyx_GIVEREF(__pyx_int_790);
+  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_int_790);
+  __pyx_v_moneyoids = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/money.pyx":13
+ *     ]
+ * 
+ *     for oid in moneyoids:             # <<<<<<<<<<<<<<
+ *         register_core_codec(oid,
+ *                             <encode_func>&text_encode,
+ */
+  __pyx_t_1 = __pyx_v_moneyoids; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
+  for (;;) {
+    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
+    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(13, 13, __pyx_L1_error)
+    #else
+    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(13, 13, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    #endif
+    __Pyx_XDECREF_SET(__pyx_v_oid, __pyx_t_3);
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/codecs/money.pyx":14
+ * 
+ *     for oid in moneyoids:
+ *         register_core_codec(oid,             # <<<<<<<<<<<<<<
+ *                             <encode_func>&text_encode,
+ *                             <decode_func>&text_decode,
+ */
+    __pyx_t_4 = __Pyx_PyInt_As_uint32_t(__pyx_v_oid); if (unlikely((__pyx_t_4 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(13, 14, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/money.pyx":17
+ *                             <encode_func>&text_encode,
+ *                             <decode_func>&text_decode,
+ *                             PG_FORMAT_TEXT)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+    __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(__pyx_t_4, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT); if (unlikely(!__pyx_t_3)) __PYX_ERR(13, 14, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/codecs/money.pyx":13
+ *     ]
+ * 
+ *     for oid in moneyoids:             # <<<<<<<<<<<<<<
+ *         register_core_codec(oid,
+ *                             <encode_func>&text_encode,
+ */
+  }
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/money.pyx":8
+ * 
+ * 
+ * cdef init_monetary_codecs():             # <<<<<<<<<<<<<<
+ *     moneyoids = [
+ *         MONEYOID,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.init_monetary_codecs", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_moneyoids);
+  __Pyx_XDECREF(__pyx_v_oid);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/network.pyx":21
+ * 
+ * 
+ * cdef inline _net_encode(WriteBuffer buf, int32_t version, uint8_t bits,             # <<<<<<<<<<<<<<
+ *                         int8_t is_cidr, bytes addr):
+ * 
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol__net_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, int32_t __pyx_v_version, uint8_t __pyx_v_bits, int8_t __pyx_v_is_cidr, PyObject *__pyx_v_addr) {
+  char *__pyx_v_addrbytes;
+  Py_ssize_t __pyx_v_addrlen;
+  int8_t __pyx_v_family;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int8_t __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("_net_encode", 0);
+
+  /* "asyncpg/protocol/codecs/network.pyx":29
+ *         int8_t family
+ * 
+ *     family = PGSQL_AF_INET if version == 4 else PGSQL_AF_INET6             # <<<<<<<<<<<<<<
+ *     cpython.PyBytes_AsStringAndSize(addr, &addrbytes, &addrlen)
+ * 
+ */
+  if (((__pyx_v_version == 4) != 0)) {
+    __pyx_t_1 = 2;
+  } else {
+    __pyx_t_1 = 3;
+  }
+  __pyx_v_family = __pyx_t_1;
+
+  /* "asyncpg/protocol/codecs/network.pyx":30
+ * 
+ *     family = PGSQL_AF_INET if version == 4 else PGSQL_AF_INET6
+ *     cpython.PyBytes_AsStringAndSize(addr, &addrbytes, &addrlen)             # <<<<<<<<<<<<<<
+ * 
+ *     buf.write_int32(4 + <int32_t>addrlen)
+ */
+  __pyx_t_2 = PyBytes_AsStringAndSize(__pyx_v_addr, (&__pyx_v_addrbytes), ((Py_ssize_t *)(&__pyx_v_addrlen))); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(14, 30, __pyx_L1_error)
+
+  /* "asyncpg/protocol/codecs/network.pyx":32
+ *     cpython.PyBytes_AsStringAndSize(addr, &addrbytes, &addrlen)
+ * 
+ *     buf.write_int32(4 + <int32_t>addrlen)             # <<<<<<<<<<<<<<
+ *     buf.write_byte(family)
+ *     buf.write_byte(<int8_t>bits)
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, (4 + ((int32_t)__pyx_v_addrlen))); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 32, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/network.pyx":33
+ * 
+ *     buf.write_int32(4 + <int32_t>addrlen)
+ *     buf.write_byte(family)             # <<<<<<<<<<<<<<
+ *     buf.write_byte(<int8_t>bits)
+ *     buf.write_byte(is_cidr)
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(__pyx_v_buf, __pyx_v_family); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 33, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/network.pyx":34
+ *     buf.write_int32(4 + <int32_t>addrlen)
+ *     buf.write_byte(family)
+ *     buf.write_byte(<int8_t>bits)             # <<<<<<<<<<<<<<
+ *     buf.write_byte(is_cidr)
+ *     buf.write_byte(<int8_t>addrlen)
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(__pyx_v_buf, ((int8_t)__pyx_v_bits)); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 34, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/network.pyx":35
+ *     buf.write_byte(family)
+ *     buf.write_byte(<int8_t>bits)
+ *     buf.write_byte(is_cidr)             # <<<<<<<<<<<<<<
+ *     buf.write_byte(<int8_t>addrlen)
+ *     buf.write_cstr(addrbytes, addrlen)
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(__pyx_v_buf, __pyx_v_is_cidr); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 35, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/network.pyx":36
+ *     buf.write_byte(<int8_t>bits)
+ *     buf.write_byte(is_cidr)
+ *     buf.write_byte(<int8_t>addrlen)             # <<<<<<<<<<<<<<
+ *     buf.write_cstr(addrbytes, addrlen)
+ * 
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(__pyx_v_buf, ((int8_t)__pyx_v_addrlen)); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 36, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/network.pyx":37
+ *     buf.write_byte(is_cidr)
+ *     buf.write_byte(<int8_t>addrlen)
+ *     buf.write_cstr(addrbytes, addrlen)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_cstr(__pyx_v_buf, __pyx_v_addrbytes, __pyx_v_addrlen); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 37, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/network.pyx":21
+ * 
+ * 
+ * cdef inline _net_encode(WriteBuffer buf, int32_t version, uint8_t bits,             # <<<<<<<<<<<<<<
+ *                         int8_t is_cidr, bytes addr):
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol._net_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/network.pyx":40
+ * 
+ * 
+ * cdef net_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int32_t family = <int32_t>buf.read(1)[0]
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_net_decode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  int32_t __pyx_v_family;
+  uint8_t __pyx_v_bits;
+  uint32_t __pyx_v_is_cidr;
+  uint32_t __pyx_v_addrlen;
+  PyObject *__pyx_v_addr = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  char const *__pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  long __pyx_t_8;
+  int __pyx_t_9;
+  __Pyx_RefNannySetupContext("net_decode", 0);
+
+  /* "asyncpg/protocol/codecs/network.pyx":42
+ * cdef net_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     cdef:
+ *         int32_t family = <int32_t>buf.read(1)[0]             # <<<<<<<<<<<<<<
+ *         uint8_t bits = <uint8_t>buf.read(1)[0]
+ *         uint32_t is_cidr = <uint32_t>buf.read(1)[0]
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 1); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(14, 42, __pyx_L1_error)
+  __pyx_v_family = ((int32_t)(__pyx_t_1[0]));
+
+  /* "asyncpg/protocol/codecs/network.pyx":43
+ *     cdef:
+ *         int32_t family = <int32_t>buf.read(1)[0]
+ *         uint8_t bits = <uint8_t>buf.read(1)[0]             # <<<<<<<<<<<<<<
+ *         uint32_t is_cidr = <uint32_t>buf.read(1)[0]
+ *         uint32_t addrlen = <uint32_t>buf.read(1)[0]
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 1); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(14, 43, __pyx_L1_error)
+  __pyx_v_bits = ((uint8_t)(__pyx_t_1[0]));
+
+  /* "asyncpg/protocol/codecs/network.pyx":44
+ *         int32_t family = <int32_t>buf.read(1)[0]
+ *         uint8_t bits = <uint8_t>buf.read(1)[0]
+ *         uint32_t is_cidr = <uint32_t>buf.read(1)[0]             # <<<<<<<<<<<<<<
+ *         uint32_t addrlen = <uint32_t>buf.read(1)[0]
+ *         bytes addr
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 1); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(14, 44, __pyx_L1_error)
+  __pyx_v_is_cidr = ((uint32_t)(__pyx_t_1[0]));
+
+  /* "asyncpg/protocol/codecs/network.pyx":45
+ *         uint8_t bits = <uint8_t>buf.read(1)[0]
+ *         uint32_t is_cidr = <uint32_t>buf.read(1)[0]
+ *         uint32_t addrlen = <uint32_t>buf.read(1)[0]             # <<<<<<<<<<<<<<
+ *         bytes addr
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 1); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(14, 45, __pyx_L1_error)
+  __pyx_v_addrlen = ((uint32_t)(__pyx_t_1[0]));
+
+  /* "asyncpg/protocol/codecs/network.pyx":48
+ *         bytes addr
+ * 
+ *     if family != PGSQL_AF_INET and family != PGSQL_AF_INET6:             # <<<<<<<<<<<<<<
+ *         raise ValueError('invalid address family in "{}" value'.format(
+ *             'cidr' if is_cidr else 'inet'
+ */
+  switch (__pyx_v_family) {
+    case 2:
+    case 3:
+    __pyx_t_2 = 0;
+    break;
+    default:
+    __pyx_t_2 = 1;
+    break;
+  }
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/codecs/network.pyx":49
+ * 
+ *     if family != PGSQL_AF_INET and family != PGSQL_AF_INET6:
+ *         raise ValueError('invalid address family in "{}" value'.format(             # <<<<<<<<<<<<<<
+ *             'cidr' if is_cidr else 'inet'
+ *         ))
+ */
+    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_invalid_address_family_in_value, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(14, 49, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+
+    /* "asyncpg/protocol/codecs/network.pyx":50
+ *     if family != PGSQL_AF_INET and family != PGSQL_AF_INET6:
+ *         raise ValueError('invalid address family in "{}" value'.format(
+ *             'cidr' if is_cidr else 'inet'             # <<<<<<<<<<<<<<
+ *         ))
+ * 
+ */
+    if ((__pyx_v_is_cidr != 0)) {
+      __Pyx_INCREF(__pyx_n_u_cidr);
+      __pyx_t_5 = __pyx_n_u_cidr;
+    } else {
+      __Pyx_INCREF(__pyx_n_u_inet);
+      __pyx_t_5 = __pyx_n_u_inet;
+    }
+    __pyx_t_6 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
+      if (likely(__pyx_t_6)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+        __Pyx_INCREF(__pyx_t_6);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_4, function);
+      }
+    }
+    if (!__pyx_t_6) {
+      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 49, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_4)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
+        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 49, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
+        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 49, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(14, 49, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
+        __Pyx_GIVEREF(__pyx_t_5);
+        PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5);
+        __pyx_t_5 = 0;
+        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 49, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/codecs/network.pyx":49
+ * 
+ *     if family != PGSQL_AF_INET and family != PGSQL_AF_INET6:
+ *         raise ValueError('invalid address family in "{}" value'.format(             # <<<<<<<<<<<<<<
+ *             'cidr' if is_cidr else 'inet'
+ *         ))
+ */
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(14, 49, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_3);
+    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
+    __pyx_t_3 = 0;
+    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 49, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __PYX_ERR(14, 49, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/network.pyx":48
+ *         bytes addr
+ * 
+ *     if family != PGSQL_AF_INET and family != PGSQL_AF_INET6:             # <<<<<<<<<<<<<<
+ *         raise ValueError('invalid address family in "{}" value'.format(
+ *             'cidr' if is_cidr else 'inet'
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/network.pyx":53
+ *         ))
+ * 
+ *     if bits > (32 if family == PGSQL_AF_INET else 128):             # <<<<<<<<<<<<<<
+ *         raise ValueError('invalid bits in "{}" value'.format(
+ *             'cidr' if is_cidr else 'inet'
+ */
+  if (((__pyx_v_family == 2) != 0)) {
+    __pyx_t_8 = 32;
+  } else {
+    __pyx_t_8 = 0x80;
+  }
+  __pyx_t_2 = ((__pyx_v_bits > __pyx_t_8) != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/codecs/network.pyx":54
+ * 
+ *     if bits > (32 if family == PGSQL_AF_INET else 128):
+ *         raise ValueError('invalid bits in "{}" value'.format(             # <<<<<<<<<<<<<<
+ *             'cidr' if is_cidr else 'inet'
+ *         ))
+ */
+    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_invalid_bits_in_value, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(14, 54, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+
+    /* "asyncpg/protocol/codecs/network.pyx":55
+ *     if bits > (32 if family == PGSQL_AF_INET else 128):
+ *         raise ValueError('invalid bits in "{}" value'.format(
+ *             'cidr' if is_cidr else 'inet'             # <<<<<<<<<<<<<<
+ *         ))
+ * 
+ */
+    if ((__pyx_v_is_cidr != 0)) {
+      __Pyx_INCREF(__pyx_n_u_cidr);
+      __pyx_t_7 = __pyx_n_u_cidr;
+    } else {
+      __Pyx_INCREF(__pyx_n_u_inet);
+      __pyx_t_7 = __pyx_n_u_inet;
+    }
+    __pyx_t_5 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
+      if (likely(__pyx_t_5)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+        __Pyx_INCREF(__pyx_t_5);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_4, function);
+      }
+    }
+    if (!__pyx_t_5) {
+      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 54, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_4)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_7};
+        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 54, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_7};
+        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 54, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(14, 54, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_6);
+        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
+        __Pyx_GIVEREF(__pyx_t_7);
+        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_7);
+        __pyx_t_7 = 0;
+        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 54, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/codecs/network.pyx":54
+ * 
+ *     if bits > (32 if family == PGSQL_AF_INET else 128):
+ *         raise ValueError('invalid bits in "{}" value'.format(             # <<<<<<<<<<<<<<
+ *             'cidr' if is_cidr else 'inet'
+ *         ))
+ */
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(14, 54, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_3);
+    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
+    __pyx_t_3 = 0;
+    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 54, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __PYX_ERR(14, 54, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/network.pyx":53
+ *         ))
+ * 
+ *     if bits > (32 if family == PGSQL_AF_INET else 128):             # <<<<<<<<<<<<<<
+ *         raise ValueError('invalid bits in "{}" value'.format(
+ *             'cidr' if is_cidr else 'inet'
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/network.pyx":58
+ *         ))
+ * 
+ *     if addrlen != (4 if family == PGSQL_AF_INET else 16):             # <<<<<<<<<<<<<<
+ *         raise ValueError('invalid length in "{}" value'.format(
+ *             'cidr' if is_cidr else 'inet'
+ */
+  if (((__pyx_v_family == 2) != 0)) {
+    __pyx_t_8 = 4;
+  } else {
+    __pyx_t_8 = 16;
+  }
+  __pyx_t_2 = ((__pyx_v_addrlen != __pyx_t_8) != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/codecs/network.pyx":59
+ * 
+ *     if addrlen != (4 if family == PGSQL_AF_INET else 16):
+ *         raise ValueError('invalid length in "{}" value'.format(             # <<<<<<<<<<<<<<
+ *             'cidr' if is_cidr else 'inet'
+ *         ))
+ */
+    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_invalid_length_in_value, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(14, 59, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+
+    /* "asyncpg/protocol/codecs/network.pyx":60
+ *     if addrlen != (4 if family == PGSQL_AF_INET else 16):
+ *         raise ValueError('invalid length in "{}" value'.format(
+ *             'cidr' if is_cidr else 'inet'             # <<<<<<<<<<<<<<
+ *         ))
+ * 
+ */
+    if ((__pyx_v_is_cidr != 0)) {
+      __Pyx_INCREF(__pyx_n_u_cidr);
+      __pyx_t_6 = __pyx_n_u_cidr;
+    } else {
+      __Pyx_INCREF(__pyx_n_u_inet);
+      __pyx_t_6 = __pyx_n_u_inet;
+    }
+    __pyx_t_7 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
+      if (likely(__pyx_t_7)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+        __Pyx_INCREF(__pyx_t_7);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_4, function);
+      }
+    }
+    if (!__pyx_t_7) {
+      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 59, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_4)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
+        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 59, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
+        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 59, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(14, 59, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL;
+        __Pyx_GIVEREF(__pyx_t_6);
+        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_6);
+        __pyx_t_6 = 0;
+        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 59, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/codecs/network.pyx":59
+ * 
+ *     if addrlen != (4 if family == PGSQL_AF_INET else 16):
+ *         raise ValueError('invalid length in "{}" value'.format(             # <<<<<<<<<<<<<<
+ *             'cidr' if is_cidr else 'inet'
+ *         ))
+ */
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(14, 59, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_3);
+    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
+    __pyx_t_3 = 0;
+    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 59, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __PYX_ERR(14, 59, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/network.pyx":58
+ *         ))
+ * 
+ *     if addrlen != (4 if family == PGSQL_AF_INET else 16):             # <<<<<<<<<<<<<<
+ *         raise ValueError('invalid length in "{}" value'.format(
+ *             'cidr' if is_cidr else 'inet'
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/network.pyx":63
+ *         ))
+ * 
+ *     addr = cpython.PyBytes_FromStringAndSize(buf.read(addrlen), addrlen)             # <<<<<<<<<<<<<<
+ * 
+ *     if is_cidr or bits > 0:
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, __pyx_v_addrlen); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(14, 63, __pyx_L1_error)
+  __pyx_t_3 = PyBytes_FromStringAndSize(__pyx_t_1, __pyx_v_addrlen); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 63, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_v_addr = ((PyObject*)__pyx_t_3);
+  __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/network.pyx":65
+ *     addr = cpython.PyBytes_FromStringAndSize(buf.read(addrlen), addrlen)
+ * 
+ *     if is_cidr or bits > 0:             # <<<<<<<<<<<<<<
+ *         return _ipnet(addr).supernet(new_prefix=cpython.PyLong_FromLong(bits))
+ *     else:
+ */
+  __pyx_t_9 = (__pyx_v_is_cidr != 0);
+  if (!__pyx_t_9) {
+  } else {
+    __pyx_t_2 = __pyx_t_9;
+    goto __pyx_L7_bool_binop_done;
+  }
+  __pyx_t_9 = ((__pyx_v_bits > 0) != 0);
+  __pyx_t_2 = __pyx_t_9;
+  __pyx_L7_bool_binop_done:;
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/codecs/network.pyx":66
+ * 
+ *     if is_cidr or bits > 0:
+ *         return _ipnet(addr).supernet(new_prefix=cpython.PyLong_FromLong(bits))             # <<<<<<<<<<<<<<
+ *     else:
+ *         return _ipaddr(addr)
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_ipnet); if (unlikely(!__pyx_t_4)) __PYX_ERR(14, 66, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = NULL;
+    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
+      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
+      if (likely(__pyx_t_5)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+        __Pyx_INCREF(__pyx_t_5);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_4, function);
+      }
+    }
+    if (!__pyx_t_5) {
+      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_addr); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 66, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_4)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_addr};
+        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 66, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_addr};
+        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 66, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+      } else
+      #endif
+      {
+        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(14, 66, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_6);
+        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
+        __Pyx_INCREF(__pyx_v_addr);
+        __Pyx_GIVEREF(__pyx_v_addr);
+        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_addr);
+        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 66, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_supernet); if (unlikely(!__pyx_t_4)) __PYX_ERR(14, 66, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 66, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_6 = PyLong_FromLong(__pyx_v_bits); if (unlikely(!__pyx_t_6)) __PYX_ERR(14, 66, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_6);
+    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_new_prefix, __pyx_t_6) < 0) __PYX_ERR(14, 66, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(14, 66, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_r = __pyx_t_6;
+    __pyx_t_6 = 0;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/codecs/network.pyx":65
+ *     addr = cpython.PyBytes_FromStringAndSize(buf.read(addrlen), addrlen)
+ * 
+ *     if is_cidr or bits > 0:             # <<<<<<<<<<<<<<
+ *         return _ipnet(addr).supernet(new_prefix=cpython.PyLong_FromLong(bits))
+ *     else:
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/network.pyx":68
+ *         return _ipnet(addr).supernet(new_prefix=cpython.PyLong_FromLong(bits))
+ *     else:
+ *         return _ipaddr(addr)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  /*else*/ {
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_ipaddr); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 68, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_4 = NULL;
+    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
+      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
+      if (likely(__pyx_t_4)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+        __Pyx_INCREF(__pyx_t_4);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_3, function);
+      }
+    }
+    if (!__pyx_t_4) {
+      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_addr); if (unlikely(!__pyx_t_6)) __PYX_ERR(14, 68, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_6);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_3)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_addr};
+        __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(14, 68, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_GOTREF(__pyx_t_6);
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_addr};
+        __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(14, 68, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_GOTREF(__pyx_t_6);
+      } else
+      #endif
+      {
+        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(14, 68, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
+        __Pyx_INCREF(__pyx_v_addr);
+        __Pyx_GIVEREF(__pyx_v_addr);
+        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_addr);
+        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(14, 68, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_6);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_r = __pyx_t_6;
+    __pyx_t_6 = 0;
+    goto __pyx_L0;
+  }
+
+  /* "asyncpg/protocol/codecs/network.pyx":40
+ * 
+ * 
+ * cdef net_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int32_t family = <int32_t>buf.read(1)[0]
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.net_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_addr);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/network.pyx":71
+ * 
+ * 
+ * cdef cidr_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         object ipnet
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_cidr_encode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
+  PyObject *__pyx_v_ipnet = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  int32_t __pyx_t_5;
+  uint8_t __pyx_t_6;
+  __Pyx_RefNannySetupContext("cidr_encode", 0);
+
+  /* "asyncpg/protocol/codecs/network.pyx":75
+ *         object ipnet
+ * 
+ *     ipnet = _ipnet(obj)             # <<<<<<<<<<<<<<
+ *     _net_encode(buf, ipnet.version, ipnet.prefixlen, 1,
+ *                 ipnet.network_address.packed)
+ */
+  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_ipnet); if (unlikely(!__pyx_t_2)) __PYX_ERR(14, 75, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = NULL;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (!__pyx_t_3) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(14, 75, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_obj};
+      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(14, 75, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_obj};
+      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(14, 75, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else
+    #endif
+    {
+      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(14, 75, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
+      __Pyx_INCREF(__pyx_v_obj);
+      __Pyx_GIVEREF(__pyx_v_obj);
+      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_obj);
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(14, 75, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_v_ipnet = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/network.pyx":76
+ * 
+ *     ipnet = _ipnet(obj)
+ *     _net_encode(buf, ipnet.version, ipnet.prefixlen, 1,             # <<<<<<<<<<<<<<
+ *                 ipnet.network_address.packed)
+ * 
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_ipnet, __pyx_n_s_version); if (unlikely(!__pyx_t_1)) __PYX_ERR(14, 76, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_5 = __Pyx_PyInt_As_int32_t(__pyx_t_1); if (unlikely((__pyx_t_5 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(14, 76, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_ipnet, __pyx_n_s_prefixlen); if (unlikely(!__pyx_t_1)) __PYX_ERR(14, 76, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_6 = __Pyx_PyInt_As_uint8_t(__pyx_t_1); if (unlikely((__pyx_t_6 == ((uint8_t)-1)) && PyErr_Occurred())) __PYX_ERR(14, 76, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/network.pyx":77
+ *     ipnet = _ipnet(obj)
+ *     _net_encode(buf, ipnet.version, ipnet.prefixlen, 1,
+ *                 ipnet.network_address.packed)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_ipnet, __pyx_n_s_network_address); if (unlikely(!__pyx_t_1)) __PYX_ERR(14, 77, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_packed); if (unlikely(!__pyx_t_2)) __PYX_ERR(14, 77, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(14, 77, __pyx_L1_error)
+
+  /* "asyncpg/protocol/codecs/network.pyx":76
+ * 
+ *     ipnet = _ipnet(obj)
+ *     _net_encode(buf, ipnet.version, ipnet.prefixlen, 1,             # <<<<<<<<<<<<<<
+ *                 ipnet.network_address.packed)
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol__net_encode(__pyx_v_buf, __pyx_t_5, __pyx_t_6, 1, ((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(14, 76, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/network.pyx":71
+ * 
+ * 
+ * cdef cidr_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         object ipnet
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.cidr_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_ipnet);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/network.pyx":80
+ * 
+ * 
+ * cdef inet_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         object ipaddr
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_inet_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
+  PyObject *__pyx_v_ipaddr = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  int32_t __pyx_t_8;
+  int __pyx_t_9;
+  __Pyx_RefNannySetupContext("inet_encode", 0);
+
+  /* "asyncpg/protocol/codecs/network.pyx":84
+ *         object ipaddr
+ * 
+ *     try:             # <<<<<<<<<<<<<<
+ *         ipaddr = _ipaddr(obj)
+ *     except ValueError:
+ */
+  {
+    __Pyx_PyThreadState_declare
+    __Pyx_PyThreadState_assign
+    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
+    __Pyx_XGOTREF(__pyx_t_1);
+    __Pyx_XGOTREF(__pyx_t_2);
+    __Pyx_XGOTREF(__pyx_t_3);
+    /*try:*/ {
+
+      /* "asyncpg/protocol/codecs/network.pyx":85
+ * 
+ *     try:
+ *         ipaddr = _ipaddr(obj)             # <<<<<<<<<<<<<<
+ *     except ValueError:
+ *         # PostgreSQL accepts *both* CIDR and host values
+ */
+      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_ipaddr); if (unlikely(!__pyx_t_5)) __PYX_ERR(14, 85, __pyx_L3_error)
+      __Pyx_GOTREF(__pyx_t_5);
+      __pyx_t_6 = NULL;
+      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
+        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
+        if (likely(__pyx_t_6)) {
+          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+          __Pyx_INCREF(__pyx_t_6);
+          __Pyx_INCREF(function);
+          __Pyx_DECREF_SET(__pyx_t_5, function);
+        }
+      }
+      if (!__pyx_t_6) {
+        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_obj); if (unlikely(!__pyx_t_4)) __PYX_ERR(14, 85, __pyx_L3_error)
+        __Pyx_GOTREF(__pyx_t_4);
+      } else {
+        #if CYTHON_FAST_PYCALL
+        if (PyFunction_Check(__pyx_t_5)) {
+          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_obj};
+          __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(14, 85, __pyx_L3_error)
+          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+          __Pyx_GOTREF(__pyx_t_4);
+        } else
+        #endif
+        #if CYTHON_FAST_PYCCALL
+        if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
+          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_obj};
+          __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(14, 85, __pyx_L3_error)
+          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+          __Pyx_GOTREF(__pyx_t_4);
+        } else
+        #endif
+        {
+          __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(14, 85, __pyx_L3_error)
+          __Pyx_GOTREF(__pyx_t_7);
+          __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
+          __Pyx_INCREF(__pyx_v_obj);
+          __Pyx_GIVEREF(__pyx_v_obj);
+          PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_obj);
+          __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(14, 85, __pyx_L3_error)
+          __Pyx_GOTREF(__pyx_t_4);
+          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        }
+      }
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __pyx_v_ipaddr = __pyx_t_4;
+      __pyx_t_4 = 0;
+
+      /* "asyncpg/protocol/codecs/network.pyx":84
+ *         object ipaddr
+ * 
+ *     try:             # <<<<<<<<<<<<<<
+ *         ipaddr = _ipaddr(obj)
+ *     except ValueError:
+ */
+    }
+
+    /* "asyncpg/protocol/codecs/network.pyx":91
+ *         cidr_encode(settings, buf, obj)
+ *     else:
+ *         _net_encode(buf, ipaddr.version, 0, 0, ipaddr.packed)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+    /*else:*/ {
+      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_ipaddr, __pyx_n_s_version); if (unlikely(!__pyx_t_4)) __PYX_ERR(14, 91, __pyx_L5_except_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_8 = __Pyx_PyInt_As_int32_t(__pyx_t_4); if (unlikely((__pyx_t_8 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(14, 91, __pyx_L5_except_error)
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_ipaddr, __pyx_n_s_packed); if (unlikely(!__pyx_t_4)) __PYX_ERR(14, 91, __pyx_L5_except_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(14, 91, __pyx_L5_except_error)
+      __pyx_t_5 = __pyx_f_7asyncpg_8protocol_8protocol__net_encode(__pyx_v_buf, __pyx_t_8, 0, 0, ((PyObject*)__pyx_t_4)); if (unlikely(!__pyx_t_5)) __PYX_ERR(14, 91, __pyx_L5_except_error)
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    }
+    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+    goto __pyx_L10_try_end;
+    __pyx_L3_error:;
+    __Pyx_PyThreadState_assign
+    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/codecs/network.pyx":86
+ *     try:
+ *         ipaddr = _ipaddr(obj)
+ *     except ValueError:             # <<<<<<<<<<<<<<
+ *         # PostgreSQL accepts *both* CIDR and host values
+ *         # for the host datatype.
+ */
+    __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError);
+    if (__pyx_t_9) {
+      __Pyx_AddTraceback("asyncpg.protocol.protocol.inet_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_4, &__pyx_t_7) < 0) __PYX_ERR(14, 86, __pyx_L5_except_error)
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_GOTREF(__pyx_t_7);
+
+      /* "asyncpg/protocol/codecs/network.pyx":89
+ *         # PostgreSQL accepts *both* CIDR and host values
+ *         # for the host datatype.
+ *         cidr_encode(settings, buf, obj)             # <<<<<<<<<<<<<<
+ *     else:
+ *         _net_encode(buf, ipaddr.version, 0, 0, ipaddr.packed)
+ */
+      __pyx_t_6 = __pyx_f_7asyncpg_8protocol_8protocol_cidr_encode(__pyx_v_settings, __pyx_v_buf, __pyx_v_obj); if (unlikely(!__pyx_t_6)) __PYX_ERR(14, 89, __pyx_L5_except_error)
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      goto __pyx_L4_exception_handled;
+    }
+    goto __pyx_L5_except_error;
+    __pyx_L5_except_error:;
+
+    /* "asyncpg/protocol/codecs/network.pyx":84
+ *         object ipaddr
+ * 
+ *     try:             # <<<<<<<<<<<<<<
+ *         ipaddr = _ipaddr(obj)
+ *     except ValueError:
+ */
+    __Pyx_PyThreadState_assign
+    __Pyx_XGIVEREF(__pyx_t_1);
+    __Pyx_XGIVEREF(__pyx_t_2);
+    __Pyx_XGIVEREF(__pyx_t_3);
+    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
+    goto __pyx_L1_error;
+    __pyx_L4_exception_handled:;
+    __Pyx_PyThreadState_assign
+    __Pyx_XGIVEREF(__pyx_t_1);
+    __Pyx_XGIVEREF(__pyx_t_2);
+    __Pyx_XGIVEREF(__pyx_t_3);
+    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
+    __pyx_L10_try_end:;
+  }
+
+  /* "asyncpg/protocol/codecs/network.pyx":80
+ * 
+ * 
+ * cdef inet_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         object ipaddr
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.inet_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_ipaddr);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/network.pyx":94
+ * 
+ * 
+ * cdef init_network_codecs():             # <<<<<<<<<<<<<<
+ *     register_core_codec(CIDROID,
+ *                         <encode_func>&cidr_encode,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_network_codecs(void) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("init_network_codecs", 0);
+
+  /* "asyncpg/protocol/codecs/network.pyx":95
+ * 
+ * cdef init_network_codecs():
+ *     register_core_codec(CIDROID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&cidr_encode,
+ *                         <decode_func>&net_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x28A, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_cidr_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_net_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(14, 95, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/network.pyx":100
+ *                         PG_FORMAT_BINARY)
+ * 
+ *     register_core_codec(INETOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&inet_encode,
+ *                         <decode_func>&net_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x365, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_inet_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_net_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(14, 100, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/network.pyx":105
+ *                         PG_FORMAT_BINARY)
+ * 
+ *     register_core_codec(MACADDROID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&text_encode,
+ *                         <decode_func>&text_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x33D, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT); if (unlikely(!__pyx_t_1)) __PYX_ERR(14, 105, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/network.pyx":94
+ * 
+ * 
+ * cdef init_network_codecs():             # <<<<<<<<<<<<<<
+ *     register_core_codec(CIDROID,
+ *                         <encode_func>&cidr_encode,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.init_network_codecs", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/numeric.pyx":14
+ * 
+ * 
+ * cdef numeric_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     text_encode(settings, buf, str(obj))
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_numeric_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("numeric_encode", 0);
+
+  /* "asyncpg/protocol/codecs/numeric.pyx":15
+ * 
+ * cdef numeric_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+ *     text_encode(settings, buf, str(obj))             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(15, 15, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(__pyx_v_obj);
+  __Pyx_GIVEREF(__pyx_v_obj);
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_obj);
+  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)(&PyUnicode_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(15, 15, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_text_encode(__pyx_v_settings, __pyx_v_buf, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(15, 15, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/numeric.pyx":14
+ * 
+ * 
+ * cdef numeric_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     text_encode(settings, buf, str(obj))
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.numeric_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/numeric.pyx":18
+ * 
+ * 
+ * cdef numeric_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     return _Dec(text_decode(settings, buf))
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_numeric_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  __Pyx_RefNannySetupContext("numeric_decode", 0);
+
+  /* "asyncpg/protocol/codecs/numeric.pyx":19
+ * 
+ * cdef numeric_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     return _Dec(text_decode(settings, buf))             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_Dec); if (unlikely(!__pyx_t_2)) __PYX_ERR(15, 19, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_text_decode(__pyx_v_settings, __pyx_v_buf); if (unlikely(!__pyx_t_3)) __PYX_ERR(15, 19, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = NULL;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_4)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_4);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (!__pyx_t_4) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(15, 19, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
+      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(15, 19, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
+      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(15, 19, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    } else
+    #endif
+    {
+      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(15, 19, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
+      __Pyx_GIVEREF(__pyx_t_3);
+      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_3);
+      __pyx_t_3 = 0;
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(15, 19, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/numeric.pyx":18
+ * 
+ * 
+ * cdef numeric_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     return _Dec(text_decode(settings, buf))
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.numeric_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/numeric.pyx":22
+ * 
+ * 
+ * cdef init_numeric_codecs():             # <<<<<<<<<<<<<<
+ *     register_core_codec(NUMERICOID,
+ *                         <encode_func>&numeric_encode,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_numeric_codecs(void) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("init_numeric_codecs", 0);
+
+  /* "asyncpg/protocol/codecs/numeric.pyx":23
+ * 
+ * cdef init_numeric_codecs():
+ *     register_core_codec(NUMERICOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&numeric_encode,
+ *                         <decode_func>&numeric_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x6A4, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_numeric_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_numeric_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT); if (unlikely(!__pyx_t_1)) __PYX_ERR(15, 23, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/numeric.pyx":22
+ * 
+ * 
+ * cdef init_numeric_codecs():             # <<<<<<<<<<<<<<
+ *     register_core_codec(NUMERICOID,
+ *                         <encode_func>&numeric_encode,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.init_numeric_codecs", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/tsearch.pyx":8
+ * 
+ * 
+ * cdef init_tsearch_codecs():             # <<<<<<<<<<<<<<
+ *     ts_oids = [
+ *         TSQUERYOID,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_tsearch_codecs(void) {
+  PyObject *__pyx_v_ts_oids = NULL;
+  PyObject *__pyx_v_oid = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  Py_ssize_t __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  uint32_t __pyx_t_4;
+  __Pyx_RefNannySetupContext("init_tsearch_codecs", 0);
+
+  /* "asyncpg/protocol/codecs/tsearch.pyx":9
+ * 
+ * cdef init_tsearch_codecs():
+ *     ts_oids = [             # <<<<<<<<<<<<<<
+ *         TSQUERYOID,
+ *         TSVECTOROID,
+ */
+  __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(16, 9, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(__pyx_int_3615);
+  __Pyx_GIVEREF(__pyx_int_3615);
+  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_int_3615);
+  __Pyx_INCREF(__pyx_int_3614);
+  __Pyx_GIVEREF(__pyx_int_3614);
+  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_int_3614);
+  __pyx_v_ts_oids = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/tsearch.pyx":14
+ *     ]
+ * 
+ *     for oid in ts_oids:             # <<<<<<<<<<<<<<
+ *         register_core_codec(oid,
+ *                             <encode_func>&text_encode,
+ */
+  __pyx_t_1 = __pyx_v_ts_oids; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
+  for (;;) {
+    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
+    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(16, 14, __pyx_L1_error)
+    #else
+    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(16, 14, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    #endif
+    __Pyx_XDECREF_SET(__pyx_v_oid, __pyx_t_3);
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/codecs/tsearch.pyx":15
+ * 
+ *     for oid in ts_oids:
+ *         register_core_codec(oid,             # <<<<<<<<<<<<<<
+ *                             <encode_func>&text_encode,
+ *                             <decode_func>&text_decode,
+ */
+    __pyx_t_4 = __Pyx_PyInt_As_uint32_t(__pyx_v_oid); if (unlikely((__pyx_t_4 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(16, 15, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/tsearch.pyx":18
+ *                             <encode_func>&text_encode,
+ *                             <decode_func>&text_decode,
+ *                             PG_FORMAT_TEXT)             # <<<<<<<<<<<<<<
+ * 
+ *     register_core_codec(GTSVECTOROID,
+ */
+    __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(__pyx_t_4, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT); if (unlikely(!__pyx_t_3)) __PYX_ERR(16, 15, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/codecs/tsearch.pyx":14
+ *     ]
+ * 
+ *     for oid in ts_oids:             # <<<<<<<<<<<<<<
+ *         register_core_codec(oid,
+ *                             <encode_func>&text_encode,
+ */
+  }
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/tsearch.pyx":20
+ *                             PG_FORMAT_TEXT)
+ * 
+ *     register_core_codec(GTSVECTOROID,             # <<<<<<<<<<<<<<
+ *                         NULL,
+ *                         <decode_func>&text_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0xE3A, NULL, ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT); if (unlikely(!__pyx_t_1)) __PYX_ERR(16, 20, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/tsearch.pyx":8
+ * 
+ * 
+ * cdef init_tsearch_codecs():             # <<<<<<<<<<<<<<
+ *     ts_oids = [
+ *         TSQUERYOID,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.init_tsearch_codecs", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_ts_oids);
+  __Pyx_XDECREF(__pyx_v_oid);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/txid.pyx":8
+ * 
+ * 
+ * cdef txid_snapshot_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         ssize_t nxip
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_txid_snapshot_encode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
+  Py_ssize_t __pyx_v_nxip;
+  CYTHON_UNUSED int64_t __pyx_v_xmin;
+  CYTHON_UNUSED int64_t __pyx_v_xmax;
+  int __pyx_v_i;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_xip_buf = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  int __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  Py_ssize_t __pyx_t_7;
+  int64_t __pyx_t_8;
+  Py_ssize_t __pyx_t_9;
+  int __pyx_t_10;
+  int32_t __pyx_t_11;
+  __Pyx_RefNannySetupContext("txid_snapshot_encode", 0);
+
+  /* "asyncpg/protocol/codecs/txid.pyx":14
+ *         int64_t xmax
+ *         int i
+ *         WriteBuffer xip_buf = WriteBuffer.new()             # <<<<<<<<<<<<<<
+ * 
+ *     if not (cpython.PyTuple_Check(obj) or cpython.PyList_Check(obj)):
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new()); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 14, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_xip_buf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/txid.pyx":16
+ *         WriteBuffer xip_buf = WriteBuffer.new()
+ * 
+ *     if not (cpython.PyTuple_Check(obj) or cpython.PyList_Check(obj)):             # <<<<<<<<<<<<<<
+ *         raise TypeError(
+ *             'list or tuple expected (got type {})'.format(type(obj)))
+ */
+  __pyx_t_3 = (PyTuple_Check(__pyx_v_obj) != 0);
+  if (!__pyx_t_3) {
+  } else {
+    __pyx_t_2 = __pyx_t_3;
+    goto __pyx_L4_bool_binop_done;
+  }
+  __pyx_t_3 = (PyList_Check(__pyx_v_obj) != 0);
+  __pyx_t_2 = __pyx_t_3;
+  __pyx_L4_bool_binop_done:;
+  __pyx_t_3 = ((!__pyx_t_2) != 0);
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/codecs/txid.pyx":18
+ *     if not (cpython.PyTuple_Check(obj) or cpython.PyList_Check(obj)):
+ *         raise TypeError(
+ *             'list or tuple expected (got type {})'.format(type(obj)))             # <<<<<<<<<<<<<<
+ * 
+ *     if len(obj) != 3:
+ */
+    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_list_or_tuple_expected_got_type, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(17, 18, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
+      if (likely(__pyx_t_5)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+        __Pyx_INCREF(__pyx_t_5);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_4, function);
+      }
+    }
+    if (!__pyx_t_5) {
+      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)Py_TYPE(__pyx_v_obj))); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 18, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_4)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_5, ((PyObject *)Py_TYPE(__pyx_v_obj))};
+        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 18, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_GOTREF(__pyx_t_1);
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_5, ((PyObject *)Py_TYPE(__pyx_v_obj))};
+        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 18, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_GOTREF(__pyx_t_1);
+      } else
+      #endif
+      {
+        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(17, 18, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_6);
+        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
+        __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_obj)));
+        __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_obj)));
+        PyTuple_SET_ITEM(__pyx_t_6, 0+1, ((PyObject *)Py_TYPE(__pyx_v_obj)));
+        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 18, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/codecs/txid.pyx":17
+ * 
+ *     if not (cpython.PyTuple_Check(obj) or cpython.PyList_Check(obj)):
+ *         raise TypeError(             # <<<<<<<<<<<<<<
+ *             'list or tuple expected (got type {})'.format(type(obj)))
+ * 
+ */
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(17, 17, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_1);
+    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
+    __pyx_t_1 = 0;
+    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 17, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __PYX_ERR(17, 17, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/txid.pyx":16
+ *         WriteBuffer xip_buf = WriteBuffer.new()
+ * 
+ *     if not (cpython.PyTuple_Check(obj) or cpython.PyList_Check(obj)):             # <<<<<<<<<<<<<<
+ *         raise TypeError(
+ *             'list or tuple expected (got type {})'.format(type(obj)))
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/txid.pyx":20
+ *             'list or tuple expected (got type {})'.format(type(obj)))
+ * 
+ *     if len(obj) != 3:             # <<<<<<<<<<<<<<
+ *         raise ValueError(
+ *             'invalid number of elements in txid_snapshot tuple, expecting 4')
+ */
+  __pyx_t_7 = PyObject_Length(__pyx_v_obj); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(17, 20, __pyx_L1_error)
+  __pyx_t_3 = ((__pyx_t_7 != 3) != 0);
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/codecs/txid.pyx":21
+ * 
+ *     if len(obj) != 3:
+ *         raise ValueError(             # <<<<<<<<<<<<<<
+ *             'invalid number of elements in txid_snapshot tuple, expecting 4')
+ * 
+ */
+    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__37, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 21, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __PYX_ERR(17, 21, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/txid.pyx":20
+ *             'list or tuple expected (got type {})'.format(type(obj)))
+ * 
+ *     if len(obj) != 3:             # <<<<<<<<<<<<<<
+ *         raise ValueError(
+ *             'invalid number of elements in txid_snapshot tuple, expecting 4')
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/txid.pyx":24
+ *             'invalid number of elements in txid_snapshot tuple, expecting 4')
+ * 
+ *     nxip = len(obj[2])             # <<<<<<<<<<<<<<
+ *     if nxip > _MAXINT32:
+ *         raise ValueError('txid_snapshot value is too long')
+ */
+  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_obj, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 24, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_7 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(17, 24, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_nxip = __pyx_t_7;
+
+  /* "asyncpg/protocol/codecs/txid.pyx":25
+ * 
+ *     nxip = len(obj[2])
+ *     if nxip > _MAXINT32:             # <<<<<<<<<<<<<<
+ *         raise ValueError('txid_snapshot value is too long')
+ * 
+ */
+  __pyx_t_3 = ((__pyx_v_nxip > 0x7FFFFFFF) != 0);
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/codecs/txid.pyx":26
+ *     nxip = len(obj[2])
+ *     if nxip > _MAXINT32:
+ *         raise ValueError('txid_snapshot value is too long')             # <<<<<<<<<<<<<<
+ * 
+ *     xmin = obj[0]
+ */
+    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__38, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 26, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __PYX_ERR(17, 26, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/txid.pyx":25
+ * 
+ *     nxip = len(obj[2])
+ *     if nxip > _MAXINT32:             # <<<<<<<<<<<<<<
+ *         raise ValueError('txid_snapshot value is too long')
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/txid.pyx":28
+ *         raise ValueError('txid_snapshot value is too long')
+ * 
+ *     xmin = obj[0]             # <<<<<<<<<<<<<<
+ *     xmax = obj[1]
+ * 
+ */
+  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_obj, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 28, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_8 = __Pyx_PyInt_As_int64_t(__pyx_t_1); if (unlikely((__pyx_t_8 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(17, 28, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_xmin = __pyx_t_8;
+
+  /* "asyncpg/protocol/codecs/txid.pyx":29
+ * 
+ *     xmin = obj[0]
+ *     xmax = obj[1]             # <<<<<<<<<<<<<<
+ * 
+ *     for i in range(nxip):
+ */
+  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_obj, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 29, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_8 = __Pyx_PyInt_As_int64_t(__pyx_t_1); if (unlikely((__pyx_t_8 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(17, 29, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_xmax = __pyx_t_8;
+
+  /* "asyncpg/protocol/codecs/txid.pyx":31
+ *     xmax = obj[1]
+ * 
+ *     for i in range(nxip):             # <<<<<<<<<<<<<<
+ *         xip_buf.write_int64(obj[2][i])
+ * 
+ */
+  __pyx_t_9 = __pyx_v_nxip;
+  for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
+    __pyx_v_i = __pyx_t_10;
+
+    /* "asyncpg/protocol/codecs/txid.pyx":32
+ * 
+ *     for i in range(nxip):
+ *         xip_buf.write_int64(obj[2][i])             # <<<<<<<<<<<<<<
+ * 
+ *     buf.write_int32(20 + xip_buf.len())
+ */
+    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_obj, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 32, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(17, 32, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_8 = __Pyx_PyInt_As_int64_t(__pyx_t_4); if (unlikely((__pyx_t_8 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(17, 32, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int64(__pyx_v_xip_buf, __pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(17, 32, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  }
+
+  /* "asyncpg/protocol/codecs/txid.pyx":34
+ *         xip_buf.write_int64(obj[2][i])
+ * 
+ *     buf.write_int32(20 + xip_buf.len())             # <<<<<<<<<<<<<<
+ * 
+ *     buf.write_int32(<int32_t>nxip)
+ */
+  __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_len(__pyx_v_xip_buf); if (unlikely(!__pyx_t_4)) __PYX_ERR(17, 34, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_1 = __Pyx_PyInt_AddCObj(__pyx_int_20, __pyx_t_4, 20, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 34, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_11 = __Pyx_PyInt_As_int32_t(__pyx_t_1); if (unlikely((__pyx_t_11 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(17, 34, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 34, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/txid.pyx":36
+ *     buf.write_int32(20 + xip_buf.len())
+ * 
+ *     buf.write_int32(<int32_t>nxip)             # <<<<<<<<<<<<<<
+ *     buf.write_int64(obj[0])
+ *     buf.write_int64(obj[1])
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, ((int32_t)__pyx_v_nxip)); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 36, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/txid.pyx":37
+ * 
+ *     buf.write_int32(<int32_t>nxip)
+ *     buf.write_int64(obj[0])             # <<<<<<<<<<<<<<
+ *     buf.write_int64(obj[1])
+ *     buf.write_buffer(xip_buf)
+ */
+  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_obj, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 37, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_8 = __Pyx_PyInt_As_int64_t(__pyx_t_1); if (unlikely((__pyx_t_8 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(17, 37, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int64(__pyx_v_buf, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 37, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/txid.pyx":38
+ *     buf.write_int32(<int32_t>nxip)
+ *     buf.write_int64(obj[0])
+ *     buf.write_int64(obj[1])             # <<<<<<<<<<<<<<
+ *     buf.write_buffer(xip_buf)
+ * 
+ */
+  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_obj, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 38, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_8 = __Pyx_PyInt_As_int64_t(__pyx_t_1); if (unlikely((__pyx_t_8 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(17, 38, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int64(__pyx_v_buf, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 38, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/txid.pyx":39
+ *     buf.write_int64(obj[0])
+ *     buf.write_int64(obj[1])
+ *     buf.write_buffer(xip_buf)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_buffer(__pyx_v_buf, __pyx_v_xip_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 39, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/txid.pyx":8
+ * 
+ * 
+ * cdef txid_snapshot_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         ssize_t nxip
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.txid_snapshot_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_xip_buf);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/txid.pyx":42
+ * 
+ * 
+ * cdef txid_snapshot_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int32_t nxip
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_txid_snapshot_decode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  int32_t __pyx_v_nxip;
+  int64_t __pyx_v_xmin;
+  int64_t __pyx_v_xmax;
+  PyObject *__pyx_v_xip_tup = 0;
+  int32_t __pyx_v_i;
+  PyObject *__pyx_v_xip = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  char const *__pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  int32_t __pyx_t_3;
+  int32_t __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  __Pyx_RefNannySetupContext("txid_snapshot_decode", 0);
+
+  /* "asyncpg/protocol/codecs/txid.pyx":51
+ *         object xip
+ * 
+ *     nxip = hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ *     xmin = hton.unpack_int64(buf.read(8))
+ *     xmax = hton.unpack_int64(buf.read(8))
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(17, 51, __pyx_L1_error)
+  __pyx_v_nxip = __pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/txid.pyx":52
+ * 
+ *     nxip = hton.unpack_int32(buf.read(4))
+ *     xmin = hton.unpack_int64(buf.read(8))             # <<<<<<<<<<<<<<
+ *     xmax = hton.unpack_int64(buf.read(8))
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(17, 52, __pyx_L1_error)
+  __pyx_v_xmin = __pyx_f_7asyncpg_8protocol_4hton_unpack_int64(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/txid.pyx":53
+ *     nxip = hton.unpack_int32(buf.read(4))
+ *     xmin = hton.unpack_int64(buf.read(8))
+ *     xmax = hton.unpack_int64(buf.read(8))             # <<<<<<<<<<<<<<
+ * 
+ *     xip_tup = cpython.PyTuple_New(nxip)
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(17, 53, __pyx_L1_error)
+  __pyx_v_xmax = __pyx_f_7asyncpg_8protocol_4hton_unpack_int64(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/txid.pyx":55
+ *     xmax = hton.unpack_int64(buf.read(8))
+ * 
+ *     xip_tup = cpython.PyTuple_New(nxip)             # <<<<<<<<<<<<<<
+ *     for i in range(nxip):
+ *         xip = cpython.PyLong_FromLongLong(hton.unpack_int64(buf.read(8)))
+ */
+  __pyx_t_2 = PyTuple_New(__pyx_v_nxip); if (unlikely(!__pyx_t_2)) __PYX_ERR(17, 55, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_v_xip_tup = ((PyObject*)__pyx_t_2);
+  __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/txid.pyx":56
+ * 
+ *     xip_tup = cpython.PyTuple_New(nxip)
+ *     for i in range(nxip):             # <<<<<<<<<<<<<<
+ *         xip = cpython.PyLong_FromLongLong(hton.unpack_int64(buf.read(8)))
+ *         cpython.Py_INCREF(xip)
+ */
+  __pyx_t_3 = __pyx_v_nxip;
+  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
+    __pyx_v_i = __pyx_t_4;
+
+    /* "asyncpg/protocol/codecs/txid.pyx":57
+ *     xip_tup = cpython.PyTuple_New(nxip)
+ *     for i in range(nxip):
+ *         xip = cpython.PyLong_FromLongLong(hton.unpack_int64(buf.read(8)))             # <<<<<<<<<<<<<<
+ *         cpython.Py_INCREF(xip)
+ *         cpython.PyTuple_SET_ITEM(xip_tup, i, xip)
+ */
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(17, 57, __pyx_L1_error)
+    __pyx_t_2 = PyLong_FromLongLong(__pyx_f_7asyncpg_8protocol_4hton_unpack_int64(__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(17, 57, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_XDECREF_SET(__pyx_v_xip, __pyx_t_2);
+    __pyx_t_2 = 0;
+
+    /* "asyncpg/protocol/codecs/txid.pyx":58
+ *     for i in range(nxip):
+ *         xip = cpython.PyLong_FromLongLong(hton.unpack_int64(buf.read(8)))
+ *         cpython.Py_INCREF(xip)             # <<<<<<<<<<<<<<
+ *         cpython.PyTuple_SET_ITEM(xip_tup, i, xip)
+ * 
+ */
+    Py_INCREF(__pyx_v_xip);
+
+    /* "asyncpg/protocol/codecs/txid.pyx":59
+ *         xip = cpython.PyLong_FromLongLong(hton.unpack_int64(buf.read(8)))
+ *         cpython.Py_INCREF(xip)
+ *         cpython.PyTuple_SET_ITEM(xip_tup, i, xip)             # <<<<<<<<<<<<<<
+ * 
+ *     return (xmin, xmax, xip_tup)
+ */
+    PyTuple_SET_ITEM(__pyx_v_xip_tup, __pyx_v_i, __pyx_v_xip);
+  }
+
+  /* "asyncpg/protocol/codecs/txid.pyx":61
+ *         cpython.PyTuple_SET_ITEM(xip_tup, i, xip)
+ * 
+ *     return (xmin, xmax, xip_tup)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_2 = __Pyx_PyInt_From_int64_t(__pyx_v_xmin); if (unlikely(!__pyx_t_2)) __PYX_ERR(17, 61, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_5 = __Pyx_PyInt_From_int64_t(__pyx_v_xmax); if (unlikely(!__pyx_t_5)) __PYX_ERR(17, 61, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(17, 61, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_6);
+  __Pyx_GIVEREF(__pyx_t_2);
+  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_5);
+  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
+  __Pyx_INCREF(__pyx_v_xip_tup);
+  __Pyx_GIVEREF(__pyx_v_xip_tup);
+  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_xip_tup);
+  __pyx_t_2 = 0;
+  __pyx_t_5 = 0;
+  __pyx_r = __pyx_t_6;
+  __pyx_t_6 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/txid.pyx":42
+ * 
+ * 
+ * cdef txid_snapshot_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         int32_t nxip
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.txid_snapshot_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_xip_tup);
+  __Pyx_XDECREF(__pyx_v_xip);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/txid.pyx":64
+ * 
+ * 
+ * cdef init_txid_codecs():             # <<<<<<<<<<<<<<
+ *     register_core_codec(TXID_SNAPSHOTOID,
+ *                         <encode_func>&txid_snapshot_encode,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_txid_codecs(void) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("init_txid_codecs", 0);
+
+  /* "asyncpg/protocol/codecs/txid.pyx":65
+ * 
+ * cdef init_txid_codecs():
+ *     register_core_codec(TXID_SNAPSHOTOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&txid_snapshot_encode,
+ *                         <decode_func>&txid_snapshot_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0xB9A, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_txid_snapshot_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_txid_snapshot_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 65, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/txid.pyx":64
+ * 
+ * 
+ * cdef init_txid_codecs():             # <<<<<<<<<<<<<<
+ *     register_core_codec(TXID_SNAPSHOTOID,
+ *                         <encode_func>&txid_snapshot_encode,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.init_txid_codecs", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/uuid.pyx":14
+ * 
+ * 
+ * cdef uuid_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):             # <<<<<<<<<<<<<<
+ *     if cpython.PyUnicode_Check(obj):
+ *         obj = _UUID(obj)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_uuid_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_wbuf, PyObject *__pyx_v_obj) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  __Pyx_RefNannySetupContext("uuid_encode", 0);
+  __Pyx_INCREF(__pyx_v_obj);
+
+  /* "asyncpg/protocol/codecs/uuid.pyx":15
+ * 
+ * cdef uuid_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):
+ *     if cpython.PyUnicode_Check(obj):             # <<<<<<<<<<<<<<
+ *         obj = _UUID(obj)
+ * 
+ */
+  __pyx_t_1 = (PyUnicode_Check(__pyx_v_obj) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/uuid.pyx":16
+ * cdef uuid_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):
+ *     if cpython.PyUnicode_Check(obj):
+ *         obj = _UUID(obj)             # <<<<<<<<<<<<<<
+ * 
+ *     bytea_encode(settings, wbuf, obj.bytes)
+ */
+    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(18, 16, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_4 = NULL;
+    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
+      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
+      if (likely(__pyx_t_4)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+        __Pyx_INCREF(__pyx_t_4);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_3, function);
+      }
+    }
+    if (!__pyx_t_4) {
+      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_obj); if (unlikely(!__pyx_t_2)) __PYX_ERR(18, 16, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_3)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_obj};
+        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(18, 16, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_GOTREF(__pyx_t_2);
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_obj};
+        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(18, 16, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_GOTREF(__pyx_t_2);
+      } else
+      #endif
+      {
+        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(18, 16, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
+        __Pyx_INCREF(__pyx_v_obj);
+        __Pyx_GIVEREF(__pyx_v_obj);
+        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_obj);
+        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(18, 16, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF_SET(__pyx_v_obj, __pyx_t_2);
+    __pyx_t_2 = 0;
+
+    /* "asyncpg/protocol/codecs/uuid.pyx":15
+ * 
+ * cdef uuid_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):
+ *     if cpython.PyUnicode_Check(obj):             # <<<<<<<<<<<<<<
+ *         obj = _UUID(obj)
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/uuid.pyx":18
+ *         obj = _UUID(obj)
+ * 
+ *     bytea_encode(settings, wbuf, obj.bytes)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_bytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(18, 18, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_bytea_encode(__pyx_v_settings, __pyx_v_wbuf, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(18, 18, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/uuid.pyx":14
+ * 
+ * 
+ * cdef uuid_encode(ConnectionSettings settings, WriteBuffer wbuf, obj):             # <<<<<<<<<<<<<<
+ *     if cpython.PyUnicode_Check(obj):
+ *         obj = _UUID(obj)
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.uuid_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_obj);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/uuid.pyx":21
+ * 
+ * 
+ * cdef uuid_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     return _UUID(bytes=bytea_decode(settings, buf))
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_uuid_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("uuid_decode", 0);
+
+  /* "asyncpg/protocol/codecs/uuid.pyx":22
+ * 
+ * cdef uuid_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     return _UUID(bytes=bytea_decode(settings, buf))             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_UUID); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 22, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(18, 22, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_bytea_decode(__pyx_v_settings, __pyx_v_buf); if (unlikely(!__pyx_t_3)) __PYX_ERR(18, 22, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_bytes, __pyx_t_3) < 0) __PYX_ERR(18, 22, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(18, 22, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_r = __pyx_t_3;
+  __pyx_t_3 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/uuid.pyx":21
+ * 
+ * 
+ * cdef uuid_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     return _UUID(bytes=bytea_decode(settings, buf))
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.uuid_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/uuid.pyx":25
+ * 
+ * 
+ * cdef init_uuid_codecs():             # <<<<<<<<<<<<<<
+ *     register_core_codec(UUIDOID,
+ *                         <encode_func>&uuid_encode,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_uuid_codecs(void) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("init_uuid_codecs", 0);
+
+  /* "asyncpg/protocol/codecs/uuid.pyx":26
+ * 
+ * cdef init_uuid_codecs():
+ *     register_core_codec(UUIDOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&uuid_encode,
+ *                         <decode_func>&uuid_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0xB86, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_uuid_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_uuid_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 26, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/uuid.pyx":25
+ * 
+ * 
+ * cdef init_uuid_codecs():             # <<<<<<<<<<<<<<
+ *     register_core_codec(UUIDOID,
+ *                         <encode_func>&uuid_encode,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.init_uuid_codecs", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/misc.pyx":8
+ * 
+ * 
+ * cdef void_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     # Void is zero bytes
+ *     buf.write_int32(0)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_void_encode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, CYTHON_UNUSED PyObject *__pyx_v_obj) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("void_encode", 0);
+
+  /* "asyncpg/protocol/codecs/misc.pyx":10
+ * cdef void_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+ *     # Void is zero bytes
+ *     buf.write_int32(0)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(19, 10, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/misc.pyx":8
+ * 
+ * 
+ * cdef void_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     # Void is zero bytes
+ *     buf.write_int32(0)
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.void_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/misc.pyx":13
+ * 
+ * 
+ * cdef void_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     # Do nothing; void will be passed as NULL so this function
+ *     # will never be called.
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_void_decode(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("void_decode", 0);
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/misc.pyx":19
+ * 
+ * 
+ * cdef init_pseudo_codecs():             # <<<<<<<<<<<<<<
+ *     # Void type is returned by SELECT void_returning_function()
+ *     register_core_codec(VOIDOID,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_pseudo_codecs(void) {
+  PyObject *__pyx_v_oid_types = NULL;
+  PyObject *__pyx_v_oid_type = NULL;
+  PyObject *__pyx_v_reg_types = NULL;
+  PyObject *__pyx_v_reg_type = NULL;
+  PyObject *__pyx_v_no_io_types = NULL;
+  PyObject *__pyx_v_no_io_type = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  Py_ssize_t __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  uint32_t __pyx_t_4;
+  __Pyx_RefNannySetupContext("init_pseudo_codecs", 0);
+
+  /* "asyncpg/protocol/codecs/misc.pyx":21
+ * cdef init_pseudo_codecs():
+ *     # Void type is returned by SELECT void_returning_function()
+ *     register_core_codec(VOIDOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&void_encode,
+ *                         <decode_func>&void_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x8E6, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_void_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_void_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(19, 21, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/misc.pyx":27
+ * 
+ *     # Unknown type, always decoded as text
+ *     register_core_codec(UNKNOWNOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&text_encode,
+ *                         <decode_func>&text_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x2C1, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT); if (unlikely(!__pyx_t_1)) __PYX_ERR(19, 27, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/misc.pyx":33
+ * 
+ *     # OID and friends
+ *     oid_types = [             # <<<<<<<<<<<<<<
+ *         OIDOID, TIDOID, XIDOID, CIDOID
+ *     ]
+ */
+  __pyx_t_1 = PyList_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(19, 33, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(__pyx_int_26);
+  __Pyx_GIVEREF(__pyx_int_26);
+  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_int_26);
+  __Pyx_INCREF(__pyx_int_27);
+  __Pyx_GIVEREF(__pyx_int_27);
+  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_int_27);
+  __Pyx_INCREF(__pyx_int_28);
+  __Pyx_GIVEREF(__pyx_int_28);
+  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_int_28);
+  __Pyx_INCREF(__pyx_int_29);
+  __Pyx_GIVEREF(__pyx_int_29);
+  PyList_SET_ITEM(__pyx_t_1, 3, __pyx_int_29);
+  __pyx_v_oid_types = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/misc.pyx":37
+ *     ]
+ * 
+ *     for oid_type in oid_types:             # <<<<<<<<<<<<<<
+ *         register_core_codec(oid_type,
+ *                             <encode_func>&int4_encode,
+ */
+  __pyx_t_1 = __pyx_v_oid_types; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
+  for (;;) {
+    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
+    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(19, 37, __pyx_L1_error)
+    #else
+    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(19, 37, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    #endif
+    __Pyx_XDECREF_SET(__pyx_v_oid_type, __pyx_t_3);
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/codecs/misc.pyx":38
+ * 
+ *     for oid_type in oid_types:
+ *         register_core_codec(oid_type,             # <<<<<<<<<<<<<<
+ *                             <encode_func>&int4_encode,
+ *                             <decode_func>&int4_decode,
+ */
+    __pyx_t_4 = __Pyx_PyInt_As_uint32_t(__pyx_v_oid_type); if (unlikely((__pyx_t_4 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(19, 38, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/misc.pyx":41
+ *                             <encode_func>&int4_encode,
+ *                             <decode_func>&int4_decode,
+ *                             PG_FORMAT_BINARY)             # <<<<<<<<<<<<<<
+ * 
+ *     # reg* types -- these are really system catalog OIDs, but
+ */
+    __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(__pyx_t_4, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_int4_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_int4_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_3)) __PYX_ERR(19, 38, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/codecs/misc.pyx":37
+ *     ]
+ * 
+ *     for oid_type in oid_types:             # <<<<<<<<<<<<<<
+ *         register_core_codec(oid_type,
+ *                             <encode_func>&int4_encode,
+ */
+  }
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/misc.pyx":48
+ *     # useful.
+ *     #
+ *     reg_types = [             # <<<<<<<<<<<<<<
+ *         REGPROCOID, REGPROCEDUREOID, REGOPEROID, REGOPERATOROID,
+ *         REGCLASSOID, REGTYPEOID, REGCONFIGOID, REGDICTIONARYOID,
+ */
+  __pyx_t_1 = PyList_New(11); if (unlikely(!__pyx_t_1)) __PYX_ERR(19, 48, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(__pyx_int_24);
+  __Pyx_GIVEREF(__pyx_int_24);
+  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_int_24);
+  __Pyx_INCREF(__pyx_int_2202);
+  __Pyx_GIVEREF(__pyx_int_2202);
+  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_int_2202);
+  __Pyx_INCREF(__pyx_int_2203);
+  __Pyx_GIVEREF(__pyx_int_2203);
+  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_int_2203);
+  __Pyx_INCREF(__pyx_int_2204);
+  __Pyx_GIVEREF(__pyx_int_2204);
+  PyList_SET_ITEM(__pyx_t_1, 3, __pyx_int_2204);
+  __Pyx_INCREF(__pyx_int_2205);
+  __Pyx_GIVEREF(__pyx_int_2205);
+  PyList_SET_ITEM(__pyx_t_1, 4, __pyx_int_2205);
+  __Pyx_INCREF(__pyx_int_2206);
+  __Pyx_GIVEREF(__pyx_int_2206);
+  PyList_SET_ITEM(__pyx_t_1, 5, __pyx_int_2206);
+  __Pyx_INCREF(__pyx_int_3734);
+  __Pyx_GIVEREF(__pyx_int_3734);
+  PyList_SET_ITEM(__pyx_t_1, 6, __pyx_int_3734);
+  __Pyx_INCREF(__pyx_int_3769);
+  __Pyx_GIVEREF(__pyx_int_3769);
+  PyList_SET_ITEM(__pyx_t_1, 7, __pyx_int_3769);
+  __Pyx_INCREF(__pyx_int_4089);
+  __Pyx_GIVEREF(__pyx_int_4089);
+  PyList_SET_ITEM(__pyx_t_1, 8, __pyx_int_4089);
+  __Pyx_INCREF(__pyx_int_4096);
+  __Pyx_GIVEREF(__pyx_int_4096);
+  PyList_SET_ITEM(__pyx_t_1, 9, __pyx_int_4096);
+  __Pyx_INCREF(__pyx_int_1790);
+  __Pyx_GIVEREF(__pyx_int_1790);
+  PyList_SET_ITEM(__pyx_t_1, 10, __pyx_int_1790);
+  __pyx_v_reg_types = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/misc.pyx":54
+ *     ]
+ * 
+ *     for reg_type in reg_types:             # <<<<<<<<<<<<<<
+ *         register_core_codec(reg_type,
+ *                             <encode_func>&text_encode,
+ */
+  __pyx_t_1 = __pyx_v_reg_types; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
+  for (;;) {
+    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
+    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(19, 54, __pyx_L1_error)
+    #else
+    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(19, 54, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    #endif
+    __Pyx_XDECREF_SET(__pyx_v_reg_type, __pyx_t_3);
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/codecs/misc.pyx":55
+ * 
+ *     for reg_type in reg_types:
+ *         register_core_codec(reg_type,             # <<<<<<<<<<<<<<
+ *                             <encode_func>&text_encode,
+ *                             <decode_func>&text_decode,
+ */
+    __pyx_t_4 = __Pyx_PyInt_As_uint32_t(__pyx_v_reg_type); if (unlikely((__pyx_t_4 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(19, 55, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/misc.pyx":58
+ *                             <encode_func>&text_encode,
+ *                             <decode_func>&text_decode,
+ *                             PG_FORMAT_TEXT)             # <<<<<<<<<<<<<<
+ * 
+ *     # cstring type is used by Postgres' I/O functions
+ */
+    __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(__pyx_t_4, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT); if (unlikely(!__pyx_t_3)) __PYX_ERR(19, 55, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/codecs/misc.pyx":54
+ *     ]
+ * 
+ *     for reg_type in reg_types:             # <<<<<<<<<<<<<<
+ *         register_core_codec(reg_type,
+ *                             <encode_func>&text_encode,
+ */
+  }
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/misc.pyx":61
+ * 
+ *     # cstring type is used by Postgres' I/O functions
+ *     register_core_codec(CSTRINGOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&text_encode,
+ *                         <decode_func>&text_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x8E3, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(19, 61, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/misc.pyx":67
+ * 
+ *     # various system pseudotypes with no I/O
+ *     no_io_types = [             # <<<<<<<<<<<<<<
+ *         ANYOID, TRIGGEROID, EVENT_TRIGGEROID, LANGUAGE_HANDLEROID,
+ *         FDW_HANDLEROID, TSM_HANDLEROID, INTERNALOID, OPAQUEOID,
+ */
+  __pyx_t_1 = PyList_New(11); if (unlikely(!__pyx_t_1)) __PYX_ERR(19, 67, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(__pyx_int_2276);
+  __Pyx_GIVEREF(__pyx_int_2276);
+  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_int_2276);
+  __Pyx_INCREF(__pyx_int_2279);
+  __Pyx_GIVEREF(__pyx_int_2279);
+  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_int_2279);
+  __Pyx_INCREF(__pyx_int_3838);
+  __Pyx_GIVEREF(__pyx_int_3838);
+  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_int_3838);
+  __Pyx_INCREF(__pyx_int_2280);
+  __Pyx_GIVEREF(__pyx_int_2280);
+  PyList_SET_ITEM(__pyx_t_1, 3, __pyx_int_2280);
+  __Pyx_INCREF(__pyx_int_3115);
+  __Pyx_GIVEREF(__pyx_int_3115);
+  PyList_SET_ITEM(__pyx_t_1, 4, __pyx_int_3115);
+  __Pyx_INCREF(__pyx_int_3310);
+  __Pyx_GIVEREF(__pyx_int_3310);
+  PyList_SET_ITEM(__pyx_t_1, 5, __pyx_int_3310);
+  __Pyx_INCREF(__pyx_int_2281);
+  __Pyx_GIVEREF(__pyx_int_2281);
+  PyList_SET_ITEM(__pyx_t_1, 6, __pyx_int_2281);
+  __Pyx_INCREF(__pyx_int_2282);
+  __Pyx_GIVEREF(__pyx_int_2282);
+  PyList_SET_ITEM(__pyx_t_1, 7, __pyx_int_2282);
+  __Pyx_INCREF(__pyx_int_2283);
+  __Pyx_GIVEREF(__pyx_int_2283);
+  PyList_SET_ITEM(__pyx_t_1, 8, __pyx_int_2283);
+  __Pyx_INCREF(__pyx_int_2776);
+  __Pyx_GIVEREF(__pyx_int_2776);
+  PyList_SET_ITEM(__pyx_t_1, 9, __pyx_int_2776);
+  __Pyx_INCREF(__pyx_int_32);
+  __Pyx_GIVEREF(__pyx_int_32);
+  PyList_SET_ITEM(__pyx_t_1, 10, __pyx_int_32);
+  __pyx_v_no_io_types = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/misc.pyx":73
+ *     ]
+ * 
+ *     register_core_codec(ANYENUMOID,             # <<<<<<<<<<<<<<
+ *                         NULL,
+ *                         <decode_func>&text_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0xDAC, NULL, ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT); if (unlikely(!__pyx_t_1)) __PYX_ERR(19, 73, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/misc.pyx":78
+ *                         PG_FORMAT_TEXT)
+ * 
+ *     for no_io_type in no_io_types:             # <<<<<<<<<<<<<<
+ *         register_core_codec(no_io_type,
+ *                             NULL,
+ */
+  __pyx_t_1 = __pyx_v_no_io_types; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
+  for (;;) {
+    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
+    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(19, 78, __pyx_L1_error)
+    #else
+    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(19, 78, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    #endif
+    __Pyx_XDECREF_SET(__pyx_v_no_io_type, __pyx_t_3);
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/codecs/misc.pyx":79
+ * 
+ *     for no_io_type in no_io_types:
+ *         register_core_codec(no_io_type,             # <<<<<<<<<<<<<<
+ *                             NULL,
+ *                             NULL,
+ */
+    __pyx_t_4 = __Pyx_PyInt_As_uint32_t(__pyx_v_no_io_type); if (unlikely((__pyx_t_4 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(19, 79, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/misc.pyx":82
+ *                             NULL,
+ *                             NULL,
+ *                             PG_FORMAT_BINARY)             # <<<<<<<<<<<<<<
+ * 
+ *     # ACL specification string
+ */
+    __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(__pyx_t_4, NULL, NULL, __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_3)) __PYX_ERR(19, 79, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/codecs/misc.pyx":78
+ *                         PG_FORMAT_TEXT)
+ * 
+ *     for no_io_type in no_io_types:             # <<<<<<<<<<<<<<
+ *         register_core_codec(no_io_type,
+ *                             NULL,
+ */
+  }
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/misc.pyx":85
+ * 
+ *     # ACL specification string
+ *     register_core_codec(ACLITEMOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&text_encode,
+ *                         <decode_func>&text_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x409, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT); if (unlikely(!__pyx_t_1)) __PYX_ERR(19, 85, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/misc.pyx":91
+ * 
+ *     # Postgres' serialized expression tree type
+ *     register_core_codec(PG_NODE_TREEOID,             # <<<<<<<<<<<<<<
+ *                         NULL,
+ *                         <decode_func>&text_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0xC2, NULL, ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT); if (unlikely(!__pyx_t_1)) __PYX_ERR(19, 91, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/misc.pyx":97
+ * 
+ *     # pg_lsn type -- a pointer to a location in the XLOG.
+ *     register_core_codec(PG_LSNOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&int8_encode,
+ *                         <decode_func>&int8_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0xC94, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_int8_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_int8_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(19, 97, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/misc.pyx":102
+ *                         PG_FORMAT_BINARY)
+ * 
+ *     register_core_codec(SMGROID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&text_encode,
+ *                         <decode_func>&text_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0xD2, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT); if (unlikely(!__pyx_t_1)) __PYX_ERR(19, 102, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/misc.pyx":19
+ * 
+ * 
+ * cdef init_pseudo_codecs():             # <<<<<<<<<<<<<<
+ *     # Void type is returned by SELECT void_returning_function()
+ *     register_core_codec(VOIDOID,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.init_pseudo_codecs", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_oid_types);
+  __Pyx_XDECREF(__pyx_v_oid_type);
+  __Pyx_XDECREF(__pyx_v_reg_types);
+  __Pyx_XDECREF(__pyx_v_reg_type);
+  __Pyx_XDECREF(__pyx_v_no_io_types);
+  __Pyx_XDECREF(__pyx_v_no_io_type);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/array.pyx":28
+ * 
+ * 
+ * cdef inline bint _is_trivial_container(object obj):             # <<<<<<<<<<<<<<
+ *     return cpython.PyUnicode_Check(obj) or cpython.PyBytes_Check(obj) or \
+ *             PyByteArray_Check(obj) or PyMemoryView_Check(obj)
+ */
+
+static CYTHON_INLINE int __pyx_f_7asyncpg_8protocol_8protocol__is_trivial_container(PyObject *__pyx_v_obj) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  __Pyx_RefNannySetupContext("_is_trivial_container", 0);
+
+  /* "asyncpg/protocol/codecs/array.pyx":29
+ * 
+ * cdef inline bint _is_trivial_container(object obj):
+ *     return cpython.PyUnicode_Check(obj) or cpython.PyBytes_Check(obj) or \             # <<<<<<<<<<<<<<
+ *             PyByteArray_Check(obj) or PyMemoryView_Check(obj)
+ * 
+ */
+  __pyx_t_2 = (PyUnicode_Check(__pyx_v_obj) != 0);
+  if (!__pyx_t_2) {
+  } else {
+    __pyx_t_1 = __pyx_t_2;
+    goto __pyx_L3_bool_binop_done;
+  }
+  __pyx_t_2 = (PyBytes_Check(__pyx_v_obj) != 0);
+  if (!__pyx_t_2) {
+  } else {
+    __pyx_t_1 = __pyx_t_2;
+    goto __pyx_L3_bool_binop_done;
+  }
+
+  /* "asyncpg/protocol/codecs/array.pyx":30
+ * cdef inline bint _is_trivial_container(object obj):
+ *     return cpython.PyUnicode_Check(obj) or cpython.PyBytes_Check(obj) or \
+ *             PyByteArray_Check(obj) or PyMemoryView_Check(obj)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_2 = (PyByteArray_Check(__pyx_v_obj) != 0);
+  if (!__pyx_t_2) {
+  } else {
+    __pyx_t_1 = __pyx_t_2;
+    goto __pyx_L3_bool_binop_done;
+  }
+  __pyx_t_2 = (PyMemoryView_Check(__pyx_v_obj) != 0);
+  __pyx_t_1 = __pyx_t_2;
+  __pyx_L3_bool_binop_done:;
+  __pyx_r = __pyx_t_1;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":28
+ * 
+ * 
+ * cdef inline bint _is_trivial_container(object obj):             # <<<<<<<<<<<<<<
+ *     return cpython.PyUnicode_Check(obj) or cpython.PyBytes_Check(obj) or \
+ *             PyByteArray_Check(obj) or PyMemoryView_Check(obj)
+ */
+
+  /* function exit code */
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/array.pyx":33
+ * 
+ * 
+ * cdef inline _is_container(object obj):             # <<<<<<<<<<<<<<
+ *     return not _is_trivial_container(obj) and isinstance(obj, ContainerABC)
+ * 
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol__is_container(PyObject *__pyx_v_obj) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("_is_container", 0);
+
+  /* "asyncpg/protocol/codecs/array.pyx":34
+ * 
+ * cdef inline _is_container(object obj):
+ *     return not _is_trivial_container(obj) and isinstance(obj, ContainerABC)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_2 = (!(__pyx_f_7asyncpg_8protocol_8protocol__is_trivial_container(__pyx_v_obj) != 0));
+  if (__pyx_t_2) {
+  } else {
+    __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 34, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_1 = __pyx_t_3;
+    __pyx_t_3 = 0;
+    goto __pyx_L3_bool_binop_done;
+  }
+  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_ContainerABC); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 34, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = PyObject_IsInstance(__pyx_v_obj, __pyx_t_3); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(20, 34, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 34, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_1 = __pyx_t_3;
+  __pyx_t_3 = 0;
+  __pyx_L3_bool_binop_done:;
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":33
+ * 
+ * 
+ * cdef inline _is_container(object obj):             # <<<<<<<<<<<<<<
+ *     return not _is_trivial_container(obj) and isinstance(obj, ContainerABC)
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol._is_container", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/array.pyx":37
+ * 
+ * 
+ * cdef inline _is_sub_array(object obj):             # <<<<<<<<<<<<<<
+ *     return not _is_trivial_container(obj) and isinstance(obj, ContainerABC) \
+ *             and not cpython.PyTuple_Check(obj)
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol__is_sub_array(PyObject *__pyx_v_obj) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("_is_sub_array", 0);
+
+  /* "asyncpg/protocol/codecs/array.pyx":38
+ * 
+ * cdef inline _is_sub_array(object obj):
+ *     return not _is_trivial_container(obj) and isinstance(obj, ContainerABC) \             # <<<<<<<<<<<<<<
+ *             and not cpython.PyTuple_Check(obj)
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_2 = (!(__pyx_f_7asyncpg_8protocol_8protocol__is_trivial_container(__pyx_v_obj) != 0));
+  if (__pyx_t_2) {
+  } else {
+    __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 38, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_1 = __pyx_t_3;
+    __pyx_t_3 = 0;
+    goto __pyx_L3_bool_binop_done;
+  }
+
+  /* "asyncpg/protocol/codecs/array.pyx":39
+ * cdef inline _is_sub_array(object obj):
+ *     return not _is_trivial_container(obj) and isinstance(obj, ContainerABC) \
+ *             and not cpython.PyTuple_Check(obj)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_ContainerABC); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 38, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+
+  /* "asyncpg/protocol/codecs/array.pyx":38
+ * 
+ * cdef inline _is_sub_array(object obj):
+ *     return not _is_trivial_container(obj) and isinstance(obj, ContainerABC) \             # <<<<<<<<<<<<<<
+ *             and not cpython.PyTuple_Check(obj)
+ * 
+ */
+  __pyx_t_2 = PyObject_IsInstance(__pyx_v_obj, __pyx_t_3); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(20, 38, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (__pyx_t_2) {
+  } else {
+    __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 38, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_1 = __pyx_t_3;
+    __pyx_t_3 = 0;
+    goto __pyx_L3_bool_binop_done;
+  }
+
+  /* "asyncpg/protocol/codecs/array.pyx":39
+ * cdef inline _is_sub_array(object obj):
+ *     return not _is_trivial_container(obj) and isinstance(obj, ContainerABC) \
+ *             and not cpython.PyTuple_Check(obj)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_2 = (!(PyTuple_Check(__pyx_v_obj) != 0));
+  __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 39, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_1 = __pyx_t_3;
+  __pyx_t_3 = 0;
+  __pyx_L3_bool_binop_done:;
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":37
+ * 
+ * 
+ * cdef inline _is_sub_array(object obj):             # <<<<<<<<<<<<<<
+ *     return not _is_trivial_container(obj) and isinstance(obj, ContainerABC) \
+ *             and not cpython.PyTuple_Check(obj)
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol._is_sub_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/array.pyx":42
+ * 
+ * 
+ * cdef _get_array_shape(object obj, int32_t *dims, int32_t *ndims):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         ssize_t mylen = len(obj)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol__get_array_shape(PyObject *__pyx_v_obj, int32_t *__pyx_v_dims, int32_t *__pyx_v_ndims) {
+  Py_ssize_t __pyx_v_mylen;
+  Py_ssize_t __pyx_v_elemlen;
+  PyObject *__pyx_v_elem = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  Py_ssize_t __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  int __pyx_t_7;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *(*__pyx_t_9)(PyObject *);
+  Py_ssize_t __pyx_t_10;
+  long __pyx_t_11;
+  __Pyx_RefNannySetupContext("_get_array_shape", 0);
+
+  /* "asyncpg/protocol/codecs/array.pyx":44
+ * cdef _get_array_shape(object obj, int32_t *dims, int32_t *ndims):
+ *     cdef:
+ *         ssize_t mylen = len(obj)             # <<<<<<<<<<<<<<
+ *         ssize_t elemlen = -2
+ *         object it
+ */
+  __pyx_t_1 = PyObject_Length(__pyx_v_obj); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(20, 44, __pyx_L1_error)
+  __pyx_v_mylen = __pyx_t_1;
+
+  /* "asyncpg/protocol/codecs/array.pyx":45
+ *     cdef:
+ *         ssize_t mylen = len(obj)
+ *         ssize_t elemlen = -2             # <<<<<<<<<<<<<<
+ *         object it
+ * 
+ */
+  __pyx_v_elemlen = -2L;
+
+  /* "asyncpg/protocol/codecs/array.pyx":48
+ *         object it
+ * 
+ *     if mylen > _MAXINT32:             # <<<<<<<<<<<<<<
+ *         raise ValueError('too many elements in array value')
+ * 
+ */
+  __pyx_t_2 = ((__pyx_v_mylen > 0x7FFFFFFF) != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/codecs/array.pyx":49
+ * 
+ *     if mylen > _MAXINT32:
+ *         raise ValueError('too many elements in array value')             # <<<<<<<<<<<<<<
+ * 
+ *     if ndims[0] > ARRAY_MAXDIM:
+ */
+    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__39, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 49, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __PYX_ERR(20, 49, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/array.pyx":48
+ *         object it
+ * 
+ *     if mylen > _MAXINT32:             # <<<<<<<<<<<<<<
+ *         raise ValueError('too many elements in array value')
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/array.pyx":51
+ *         raise ValueError('too many elements in array value')
+ * 
+ *     if ndims[0] > ARRAY_MAXDIM:             # <<<<<<<<<<<<<<
+ *         raise ValueError(
+ *             'number of array dimensions ({}) exceed the maximum expected ({})'.
+ */
+  __pyx_t_2 = (((__pyx_v_ndims[0]) > 6) != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/codecs/array.pyx":53
+ *     if ndims[0] > ARRAY_MAXDIM:
+ *         raise ValueError(
+ *             'number of array dimensions ({}) exceed the maximum expected ({})'.             # <<<<<<<<<<<<<<
+ *                 format(ndims[0], ARRAY_MAXDIM))
+ * 
+ */
+    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_number_of_array_dimensions_excee, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(20, 53, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+
+    /* "asyncpg/protocol/codecs/array.pyx":54
+ *         raise ValueError(
+ *             'number of array dimensions ({}) exceed the maximum expected ({})'.
+ *                 format(ndims[0], ARRAY_MAXDIM))             # <<<<<<<<<<<<<<
+ * 
+ *     dims[ndims[0] - 1] = <int32_t>mylen
+ */
+    __pyx_t_5 = __Pyx_PyInt_From_int32_t((__pyx_v_ndims[0])); if (unlikely(!__pyx_t_5)) __PYX_ERR(20, 54, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = NULL;
+    __pyx_t_7 = 0;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
+      if (likely(__pyx_t_6)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+        __Pyx_INCREF(__pyx_t_6);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_4, function);
+        __pyx_t_7 = 1;
+      }
+    }
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_4)) {
+      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_5, __pyx_int_6};
+      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 54, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
+      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_5, __pyx_int_6};
+      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 54, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    } else
+    #endif
+    {
+      __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(20, 54, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_8);
+      if (__pyx_t_6) {
+        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
+      }
+      __Pyx_GIVEREF(__pyx_t_5);
+      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_5);
+      __Pyx_INCREF(__pyx_int_6);
+      __Pyx_GIVEREF(__pyx_int_6);
+      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_int_6);
+      __pyx_t_5 = 0;
+      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 54, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/codecs/array.pyx":52
+ * 
+ *     if ndims[0] > ARRAY_MAXDIM:
+ *         raise ValueError(             # <<<<<<<<<<<<<<
+ *             'number of array dimensions ({}) exceed the maximum expected ({})'.
+ *                 format(ndims[0], ARRAY_MAXDIM))
+ */
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(20, 52, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_3);
+    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
+    __pyx_t_3 = 0;
+    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 52, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __PYX_ERR(20, 52, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/array.pyx":51
+ *         raise ValueError('too many elements in array value')
+ * 
+ *     if ndims[0] > ARRAY_MAXDIM:             # <<<<<<<<<<<<<<
+ *         raise ValueError(
+ *             'number of array dimensions ({}) exceed the maximum expected ({})'.
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/array.pyx":56
+ *                 format(ndims[0], ARRAY_MAXDIM))
+ * 
+ *     dims[ndims[0] - 1] = <int32_t>mylen             # <<<<<<<<<<<<<<
+ * 
+ *     for elem in obj:
+ */
+  (__pyx_v_dims[((__pyx_v_ndims[0]) - 1)]) = ((int32_t)__pyx_v_mylen);
+
+  /* "asyncpg/protocol/codecs/array.pyx":58
+ *     dims[ndims[0] - 1] = <int32_t>mylen
+ * 
+ *     for elem in obj:             # <<<<<<<<<<<<<<
+ *         if _is_sub_array(elem):
+ *             if elemlen == -2:
+ */
+  if (likely(PyList_CheckExact(__pyx_v_obj)) || PyTuple_CheckExact(__pyx_v_obj)) {
+    __pyx_t_3 = __pyx_v_obj; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0;
+    __pyx_t_9 = NULL;
+  } else {
+    __pyx_t_1 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_obj); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 58, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_9 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(20, 58, __pyx_L1_error)
+  }
+  for (;;) {
+    if (likely(!__pyx_t_9)) {
+      if (likely(PyList_CheckExact(__pyx_t_3))) {
+        if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_3)) break;
+        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_4); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(20, 58, __pyx_L1_error)
+        #else
+        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_4)) __PYX_ERR(20, 58, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        #endif
+      } else {
+        if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
+        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_4); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(20, 58, __pyx_L1_error)
+        #else
+        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_4)) __PYX_ERR(20, 58, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        #endif
+      }
+    } else {
+      __pyx_t_4 = __pyx_t_9(__pyx_t_3);
+      if (unlikely(!__pyx_t_4)) {
+        PyObject* exc_type = PyErr_Occurred();
+        if (exc_type) {
+          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+          else __PYX_ERR(20, 58, __pyx_L1_error)
+        }
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_4);
+    }
+    __Pyx_XDECREF_SET(__pyx_v_elem, __pyx_t_4);
+    __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/codecs/array.pyx":59
+ * 
+ *     for elem in obj:
+ *         if _is_sub_array(elem):             # <<<<<<<<<<<<<<
+ *             if elemlen == -2:
+ *                 elemlen = len(elem)
+ */
+    __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol__is_sub_array(__pyx_v_elem); if (unlikely(!__pyx_t_4)) __PYX_ERR(20, 59, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(20, 59, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    if (__pyx_t_2) {
+
+      /* "asyncpg/protocol/codecs/array.pyx":60
+ *     for elem in obj:
+ *         if _is_sub_array(elem):
+ *             if elemlen == -2:             # <<<<<<<<<<<<<<
+ *                 elemlen = len(elem)
+ *                 if elemlen > _MAXINT32:
+ */
+      __pyx_t_2 = ((__pyx_v_elemlen == -2L) != 0);
+      if (__pyx_t_2) {
+
+        /* "asyncpg/protocol/codecs/array.pyx":61
+ *         if _is_sub_array(elem):
+ *             if elemlen == -2:
+ *                 elemlen = len(elem)             # <<<<<<<<<<<<<<
+ *                 if elemlen > _MAXINT32:
+ *                     raise ValueError('too many elements in array value')
+ */
+        __pyx_t_10 = PyObject_Length(__pyx_v_elem); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(20, 61, __pyx_L1_error)
+        __pyx_v_elemlen = __pyx_t_10;
+
+        /* "asyncpg/protocol/codecs/array.pyx":62
+ *             if elemlen == -2:
+ *                 elemlen = len(elem)
+ *                 if elemlen > _MAXINT32:             # <<<<<<<<<<<<<<
+ *                     raise ValueError('too many elements in array value')
+ *                 ndims[0] += 1
+ */
+        __pyx_t_2 = ((__pyx_v_elemlen > 0x7FFFFFFF) != 0);
+        if (__pyx_t_2) {
+
+          /* "asyncpg/protocol/codecs/array.pyx":63
+ *                 elemlen = len(elem)
+ *                 if elemlen > _MAXINT32:
+ *                     raise ValueError('too many elements in array value')             # <<<<<<<<<<<<<<
+ *                 ndims[0] += 1
+ *                 _get_array_shape(elem, dims, ndims)
+ */
+          __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__40, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(20, 63, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_4);
+          __Pyx_Raise(__pyx_t_4, 0, 0, 0);
+          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+          __PYX_ERR(20, 63, __pyx_L1_error)
+
+          /* "asyncpg/protocol/codecs/array.pyx":62
+ *             if elemlen == -2:
+ *                 elemlen = len(elem)
+ *                 if elemlen > _MAXINT32:             # <<<<<<<<<<<<<<
+ *                     raise ValueError('too many elements in array value')
+ *                 ndims[0] += 1
+ */
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":64
+ *                 if elemlen > _MAXINT32:
+ *                     raise ValueError('too many elements in array value')
+ *                 ndims[0] += 1             # <<<<<<<<<<<<<<
+ *                 _get_array_shape(elem, dims, ndims)
+ *             else:
+ */
+        __pyx_t_11 = 0;
+        (__pyx_v_ndims[__pyx_t_11]) = ((__pyx_v_ndims[__pyx_t_11]) + 1);
+
+        /* "asyncpg/protocol/codecs/array.pyx":65
+ *                     raise ValueError('too many elements in array value')
+ *                 ndims[0] += 1
+ *                 _get_array_shape(elem, dims, ndims)             # <<<<<<<<<<<<<<
+ *             else:
+ *                 if len(elem) != elemlen:
+ */
+        __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol__get_array_shape(__pyx_v_elem, __pyx_v_dims, __pyx_v_ndims); if (unlikely(!__pyx_t_4)) __PYX_ERR(20, 65, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+        /* "asyncpg/protocol/codecs/array.pyx":60
+ *     for elem in obj:
+ *         if _is_sub_array(elem):
+ *             if elemlen == -2:             # <<<<<<<<<<<<<<
+ *                 elemlen = len(elem)
+ *                 if elemlen > _MAXINT32:
+ */
+        goto __pyx_L8;
+      }
+
+      /* "asyncpg/protocol/codecs/array.pyx":67
+ *                 _get_array_shape(elem, dims, ndims)
+ *             else:
+ *                 if len(elem) != elemlen:             # <<<<<<<<<<<<<<
+ *                     raise ValueError('non-homogeneous array')
+ *         else:
+ */
+      /*else*/ {
+        __pyx_t_10 = PyObject_Length(__pyx_v_elem); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(20, 67, __pyx_L1_error)
+        __pyx_t_2 = ((__pyx_t_10 != __pyx_v_elemlen) != 0);
+        if (__pyx_t_2) {
+
+          /* "asyncpg/protocol/codecs/array.pyx":68
+ *             else:
+ *                 if len(elem) != elemlen:
+ *                     raise ValueError('non-homogeneous array')             # <<<<<<<<<<<<<<
+ *         else:
+ *             if elemlen >= 0:
+ */
+          __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__41, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(20, 68, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_4);
+          __Pyx_Raise(__pyx_t_4, 0, 0, 0);
+          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+          __PYX_ERR(20, 68, __pyx_L1_error)
+
+          /* "asyncpg/protocol/codecs/array.pyx":67
+ *                 _get_array_shape(elem, dims, ndims)
+ *             else:
+ *                 if len(elem) != elemlen:             # <<<<<<<<<<<<<<
+ *                     raise ValueError('non-homogeneous array')
+ *         else:
+ */
+        }
+      }
+      __pyx_L8:;
+
+      /* "asyncpg/protocol/codecs/array.pyx":59
+ * 
+ *     for elem in obj:
+ *         if _is_sub_array(elem):             # <<<<<<<<<<<<<<
+ *             if elemlen == -2:
+ *                 elemlen = len(elem)
+ */
+      goto __pyx_L7;
+    }
+
+    /* "asyncpg/protocol/codecs/array.pyx":70
+ *                     raise ValueError('non-homogeneous array')
+ *         else:
+ *             if elemlen >= 0:             # <<<<<<<<<<<<<<
+ *                 raise ValueError('non-homogeneous array')
+ *             else:
+ */
+    /*else*/ {
+      __pyx_t_2 = ((__pyx_v_elemlen >= 0) != 0);
+      if (__pyx_t_2) {
+
+        /* "asyncpg/protocol/codecs/array.pyx":71
+ *         else:
+ *             if elemlen >= 0:
+ *                 raise ValueError('non-homogeneous array')             # <<<<<<<<<<<<<<
+ *             else:
+ *                 elemlen = -1
+ */
+        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__42, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(20, 71, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __PYX_ERR(20, 71, __pyx_L1_error)
+
+        /* "asyncpg/protocol/codecs/array.pyx":70
+ *                     raise ValueError('non-homogeneous array')
+ *         else:
+ *             if elemlen >= 0:             # <<<<<<<<<<<<<<
+ *                 raise ValueError('non-homogeneous array')
+ *             else:
+ */
+      }
+
+      /* "asyncpg/protocol/codecs/array.pyx":73
+ *                 raise ValueError('non-homogeneous array')
+ *             else:
+ *                 elemlen = -1             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+      /*else*/ {
+        __pyx_v_elemlen = -1L;
+      }
+    }
+    __pyx_L7:;
+
+    /* "asyncpg/protocol/codecs/array.pyx":58
+ *     dims[ndims[0] - 1] = <int32_t>mylen
+ * 
+ *     for elem in obj:             # <<<<<<<<<<<<<<
+ *         if _is_sub_array(elem):
+ *             if elemlen == -2:
+ */
+  }
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":42
+ * 
+ * 
+ * cdef _get_array_shape(object obj, int32_t *dims, int32_t *ndims):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         ssize_t mylen = len(obj)
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol._get_array_shape", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_elem);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/array.pyx":76
+ * 
+ * 
+ * cdef _write_array_data(ConnectionSettings settings, object obj, int32_t ndims,             # <<<<<<<<<<<<<<
+ *                        int32_t dim, WriteBuffer elem_data,
+ *                        encode_func_ex encoder, const void *encoder_arg):
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol__write_array_data(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, PyObject *__pyx_v_obj, int32_t __pyx_v_ndims, int32_t __pyx_v_dim, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_elem_data, __pyx_t_7asyncpg_8protocol_8protocol_encode_func_ex __pyx_v_encoder, void const *__pyx_v_encoder_arg) {
+  PyObject *__pyx_v_item = NULL;
+  PyObject *__pyx_v_e = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  Py_ssize_t __pyx_t_3;
+  PyObject *(*__pyx_t_4)(PyObject *);
+  PyObject *__pyx_t_5 = NULL;
+  int __pyx_t_6;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  int __pyx_t_10;
+  PyObject *__pyx_t_11 = NULL;
+  PyObject *__pyx_t_12 = NULL;
+  PyObject *__pyx_t_13 = NULL;
+  PyObject *__pyx_t_14 = NULL;
+  PyObject *__pyx_t_15 = NULL;
+  PyObject *__pyx_t_16 = NULL;
+  PyObject *__pyx_t_17 = NULL;
+  int __pyx_t_18;
+  char const *__pyx_t_19;
+  PyObject *__pyx_t_20 = NULL;
+  PyObject *__pyx_t_21 = NULL;
+  PyObject *__pyx_t_22 = NULL;
+  PyObject *__pyx_t_23 = NULL;
+  PyObject *__pyx_t_24 = NULL;
+  PyObject *__pyx_t_25 = NULL;
+  __Pyx_RefNannySetupContext("_write_array_data", 0);
+
+  /* "asyncpg/protocol/codecs/array.pyx":79
+ *                        int32_t dim, WriteBuffer elem_data,
+ *                        encode_func_ex encoder, const void *encoder_arg):
+ *     if dim < ndims - 1:             # <<<<<<<<<<<<<<
+ *         for item in obj:
+ *             _write_array_data(settings, item, ndims, dim + 1, elem_data,
+ */
+  __pyx_t_1 = ((__pyx_v_dim < (__pyx_v_ndims - 1)) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/array.pyx":80
+ *                        encode_func_ex encoder, const void *encoder_arg):
+ *     if dim < ndims - 1:
+ *         for item in obj:             # <<<<<<<<<<<<<<
+ *             _write_array_data(settings, item, ndims, dim + 1, elem_data,
+ *                               encoder, encoder_arg)
+ */
+    if (likely(PyList_CheckExact(__pyx_v_obj)) || PyTuple_CheckExact(__pyx_v_obj)) {
+      __pyx_t_2 = __pyx_v_obj; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
+      __pyx_t_4 = NULL;
+    } else {
+      __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_obj); if (unlikely(!__pyx_t_2)) __PYX_ERR(20, 80, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(20, 80, __pyx_L1_error)
+    }
+    for (;;) {
+      if (likely(!__pyx_t_4)) {
+        if (likely(PyList_CheckExact(__pyx_t_2))) {
+          if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
+          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+          __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(20, 80, __pyx_L1_error)
+          #else
+          __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(20, 80, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_5);
+          #endif
+        } else {
+          if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+          __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(20, 80, __pyx_L1_error)
+          #else
+          __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(20, 80, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_5);
+          #endif
+        }
+      } else {
+        __pyx_t_5 = __pyx_t_4(__pyx_t_2);
+        if (unlikely(!__pyx_t_5)) {
+          PyObject* exc_type = PyErr_Occurred();
+          if (exc_type) {
+            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+            else __PYX_ERR(20, 80, __pyx_L1_error)
+          }
+          break;
+        }
+        __Pyx_GOTREF(__pyx_t_5);
+      }
+      __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_5);
+      __pyx_t_5 = 0;
+
+      /* "asyncpg/protocol/codecs/array.pyx":81
+ *     if dim < ndims - 1:
+ *         for item in obj:
+ *             _write_array_data(settings, item, ndims, dim + 1, elem_data,             # <<<<<<<<<<<<<<
+ *                               encoder, encoder_arg)
+ *     else:
+ */
+      __pyx_t_5 = __pyx_f_7asyncpg_8protocol_8protocol__write_array_data(__pyx_v_settings, __pyx_v_item, __pyx_v_ndims, (__pyx_v_dim + 1), __pyx_v_elem_data, __pyx_v_encoder, __pyx_v_encoder_arg); if (unlikely(!__pyx_t_5)) __PYX_ERR(20, 81, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+      /* "asyncpg/protocol/codecs/array.pyx":80
+ *                        encode_func_ex encoder, const void *encoder_arg):
+ *     if dim < ndims - 1:
+ *         for item in obj:             # <<<<<<<<<<<<<<
+ *             _write_array_data(settings, item, ndims, dim + 1, elem_data,
+ *                               encoder, encoder_arg)
+ */
+    }
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "asyncpg/protocol/codecs/array.pyx":79
+ *                        int32_t dim, WriteBuffer elem_data,
+ *                        encode_func_ex encoder, const void *encoder_arg):
+ *     if dim < ndims - 1:             # <<<<<<<<<<<<<<
+ *         for item in obj:
+ *             _write_array_data(settings, item, ndims, dim + 1, elem_data,
+ */
+    goto __pyx_L3;
+  }
+
+  /* "asyncpg/protocol/codecs/array.pyx":84
+ *                               encoder, encoder_arg)
+ *     else:
+ *         for item in obj:             # <<<<<<<<<<<<<<
+ *             if item is None:
+ *                 elem_data.write_int32(-1)
+ */
+  /*else*/ {
+    if (likely(PyList_CheckExact(__pyx_v_obj)) || PyTuple_CheckExact(__pyx_v_obj)) {
+      __pyx_t_2 = __pyx_v_obj; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
+      __pyx_t_4 = NULL;
+    } else {
+      __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_obj); if (unlikely(!__pyx_t_2)) __PYX_ERR(20, 84, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(20, 84, __pyx_L1_error)
+    }
+    for (;;) {
+      if (likely(!__pyx_t_4)) {
+        if (likely(PyList_CheckExact(__pyx_t_2))) {
+          if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
+          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+          __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(20, 84, __pyx_L1_error)
+          #else
+          __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(20, 84, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_5);
+          #endif
+        } else {
+          if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+          __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(20, 84, __pyx_L1_error)
+          #else
+          __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(20, 84, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_5);
+          #endif
+        }
+      } else {
+        __pyx_t_5 = __pyx_t_4(__pyx_t_2);
+        if (unlikely(!__pyx_t_5)) {
+          PyObject* exc_type = PyErr_Occurred();
+          if (exc_type) {
+            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+            else __PYX_ERR(20, 84, __pyx_L1_error)
+          }
+          break;
+        }
+        __Pyx_GOTREF(__pyx_t_5);
+      }
+      __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_5);
+      __pyx_t_5 = 0;
+
+      /* "asyncpg/protocol/codecs/array.pyx":85
+ *     else:
+ *         for item in obj:
+ *             if item is None:             # <<<<<<<<<<<<<<
+ *                 elem_data.write_int32(-1)
+ *             else:
+ */
+      __pyx_t_1 = (__pyx_v_item == Py_None);
+      __pyx_t_6 = (__pyx_t_1 != 0);
+      if (__pyx_t_6) {
+
+        /* "asyncpg/protocol/codecs/array.pyx":86
+ *         for item in obj:
+ *             if item is None:
+ *                 elem_data.write_int32(-1)             # <<<<<<<<<<<<<<
+ *             else:
+ *                 try:
+ */
+        __pyx_t_5 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_elem_data, -1); if (unlikely(!__pyx_t_5)) __PYX_ERR(20, 86, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+        /* "asyncpg/protocol/codecs/array.pyx":85
+ *     else:
+ *         for item in obj:
+ *             if item is None:             # <<<<<<<<<<<<<<
+ *                 elem_data.write_int32(-1)
+ *             else:
+ */
+        goto __pyx_L8;
+      }
+
+      /* "asyncpg/protocol/codecs/array.pyx":88
+ *                 elem_data.write_int32(-1)
+ *             else:
+ *                 try:             # <<<<<<<<<<<<<<
+ *                     encoder(settings, elem_data, item, encoder_arg)
+ *                 except TypeError as e:
+ */
+      /*else*/ {
+        {
+          __Pyx_PyThreadState_declare
+          __Pyx_PyThreadState_assign
+          __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
+          __Pyx_XGOTREF(__pyx_t_7);
+          __Pyx_XGOTREF(__pyx_t_8);
+          __Pyx_XGOTREF(__pyx_t_9);
+          /*try:*/ {
+
+            /* "asyncpg/protocol/codecs/array.pyx":89
+ *             else:
+ *                 try:
+ *                     encoder(settings, elem_data, item, encoder_arg)             # <<<<<<<<<<<<<<
+ *                 except TypeError as e:
+ *                     raise ValueError(
+ */
+            __pyx_t_5 = __pyx_v_encoder(__pyx_v_settings, __pyx_v_elem_data, __pyx_v_item, __pyx_v_encoder_arg); if (unlikely(!__pyx_t_5)) __PYX_ERR(20, 89, __pyx_L9_error)
+            __Pyx_GOTREF(__pyx_t_5);
+            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+            /* "asyncpg/protocol/codecs/array.pyx":88
+ *                 elem_data.write_int32(-1)
+ *             else:
+ *                 try:             # <<<<<<<<<<<<<<
+ *                     encoder(settings, elem_data, item, encoder_arg)
+ *                 except TypeError as e:
+ */
+          }
+          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
+          goto __pyx_L16_try_end;
+          __pyx_L9_error:;
+          __Pyx_PyThreadState_assign
+          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+          /* "asyncpg/protocol/codecs/array.pyx":90
+ *                 try:
+ *                     encoder(settings, elem_data, item, encoder_arg)
+ *                 except TypeError as e:             # <<<<<<<<<<<<<<
+ *                     raise ValueError(
+ *                         'invalid array element: {}'.format(e.args[0])) from None
+ */
+          __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError);
+          if (__pyx_t_10) {
+            __Pyx_AddTraceback("asyncpg.protocol.protocol._write_array_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
+            if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_11, &__pyx_t_12) < 0) __PYX_ERR(20, 90, __pyx_L11_except_error)
+            __Pyx_GOTREF(__pyx_t_5);
+            __Pyx_GOTREF(__pyx_t_11);
+            __Pyx_GOTREF(__pyx_t_12);
+            __Pyx_INCREF(__pyx_t_11);
+            __pyx_v_e = __pyx_t_11;
+            /*try:*/ {
+
+              /* "asyncpg/protocol/codecs/array.pyx":92
+ *                 except TypeError as e:
+ *                     raise ValueError(
+ *                         'invalid array element: {}'.format(e.args[0])) from None             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+              __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_invalid_array_element, __pyx_n_s_format); if (unlikely(!__pyx_t_14)) __PYX_ERR(20, 92, __pyx_L22_error)
+              __Pyx_GOTREF(__pyx_t_14);
+              __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_e, __pyx_n_s_args); if (unlikely(!__pyx_t_15)) __PYX_ERR(20, 92, __pyx_L22_error)
+              __Pyx_GOTREF(__pyx_t_15);
+              __pyx_t_16 = __Pyx_GetItemInt(__pyx_t_15, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_16)) __PYX_ERR(20, 92, __pyx_L22_error)
+              __Pyx_GOTREF(__pyx_t_16);
+              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+              __pyx_t_15 = NULL;
+              if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_14))) {
+                __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_14);
+                if (likely(__pyx_t_15)) {
+                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
+                  __Pyx_INCREF(__pyx_t_15);
+                  __Pyx_INCREF(function);
+                  __Pyx_DECREF_SET(__pyx_t_14, function);
+                }
+              }
+              if (!__pyx_t_15) {
+                __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_t_16); if (unlikely(!__pyx_t_13)) __PYX_ERR(20, 92, __pyx_L22_error)
+                __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
+                __Pyx_GOTREF(__pyx_t_13);
+              } else {
+                #if CYTHON_FAST_PYCALL
+                if (PyFunction_Check(__pyx_t_14)) {
+                  PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_t_16};
+                  __pyx_t_13 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(20, 92, __pyx_L22_error)
+                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
+                  __Pyx_GOTREF(__pyx_t_13);
+                  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
+                } else
+                #endif
+                #if CYTHON_FAST_PYCCALL
+                if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) {
+                  PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_t_16};
+                  __pyx_t_13 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(20, 92, __pyx_L22_error)
+                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
+                  __Pyx_GOTREF(__pyx_t_13);
+                  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
+                } else
+                #endif
+                {
+                  __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(20, 92, __pyx_L22_error)
+                  __Pyx_GOTREF(__pyx_t_17);
+                  __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_15); __pyx_t_15 = NULL;
+                  __Pyx_GIVEREF(__pyx_t_16);
+                  PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_t_16);
+                  __pyx_t_16 = 0;
+                  __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_17, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(20, 92, __pyx_L22_error)
+                  __Pyx_GOTREF(__pyx_t_13);
+                  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
+                }
+              }
+              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+
+              /* "asyncpg/protocol/codecs/array.pyx":91
+ *                     encoder(settings, elem_data, item, encoder_arg)
+ *                 except TypeError as e:
+ *                     raise ValueError(             # <<<<<<<<<<<<<<
+ *                         'invalid array element: {}'.format(e.args[0])) from None
+ * 
+ */
+              __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) __PYX_ERR(20, 91, __pyx_L22_error)
+              __Pyx_GOTREF(__pyx_t_14);
+              __Pyx_GIVEREF(__pyx_t_13);
+              PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13);
+              __pyx_t_13 = 0;
+              __pyx_t_13 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_14, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(20, 91, __pyx_L22_error)
+              __Pyx_GOTREF(__pyx_t_13);
+              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+
+              /* "asyncpg/protocol/codecs/array.pyx":92
+ *                 except TypeError as e:
+ *                     raise ValueError(
+ *                         'invalid array element: {}'.format(e.args[0])) from None             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+              __Pyx_Raise(__pyx_t_13, 0, 0, Py_None);
+              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+              __PYX_ERR(20, 91, __pyx_L22_error)
+            }
+
+            /* "asyncpg/protocol/codecs/array.pyx":90
+ *                 try:
+ *                     encoder(settings, elem_data, item, encoder_arg)
+ *                 except TypeError as e:             # <<<<<<<<<<<<<<
+ *                     raise ValueError(
+ *                         'invalid array element: {}'.format(e.args[0])) from None
+ */
+            /*finally:*/ {
+              /*exception exit:*/{
+                __Pyx_PyThreadState_declare
+                __pyx_L22_error:;
+                __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0;
+                __Pyx_PyThreadState_assign
+                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
+                __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
+                __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
+                __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
+                __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
+                if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25);
+                if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22) < 0)) __Pyx_ErrFetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
+                __Pyx_XGOTREF(__pyx_t_20);
+                __Pyx_XGOTREF(__pyx_t_21);
+                __Pyx_XGOTREF(__pyx_t_22);
+                __Pyx_XGOTREF(__pyx_t_23);
+                __Pyx_XGOTREF(__pyx_t_24);
+                __Pyx_XGOTREF(__pyx_t_25);
+                __pyx_t_10 = __pyx_lineno; __pyx_t_18 = __pyx_clineno; __pyx_t_19 = __pyx_filename;
+                {
+                  __Pyx_DECREF(__pyx_v_e);
+                  __pyx_v_e = NULL;
+                }
+                __Pyx_PyThreadState_assign
+                if (PY_MAJOR_VERSION >= 3) {
+                  __Pyx_XGIVEREF(__pyx_t_23);
+                  __Pyx_XGIVEREF(__pyx_t_24);
+                  __Pyx_XGIVEREF(__pyx_t_25);
+                  __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_24, __pyx_t_25);
+                }
+                __Pyx_XGIVEREF(__pyx_t_20);
+                __Pyx_XGIVEREF(__pyx_t_21);
+                __Pyx_XGIVEREF(__pyx_t_22);
+                __Pyx_ErrRestore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
+                __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0;
+                __pyx_lineno = __pyx_t_10; __pyx_clineno = __pyx_t_18; __pyx_filename = __pyx_t_19;
+                goto __pyx_L11_except_error;
+              }
+            }
+          }
+          goto __pyx_L11_except_error;
+          __pyx_L11_except_error:;
+
+          /* "asyncpg/protocol/codecs/array.pyx":88
+ *                 elem_data.write_int32(-1)
+ *             else:
+ *                 try:             # <<<<<<<<<<<<<<
+ *                     encoder(settings, elem_data, item, encoder_arg)
+ *                 except TypeError as e:
+ */
+          __Pyx_PyThreadState_assign
+          __Pyx_XGIVEREF(__pyx_t_7);
+          __Pyx_XGIVEREF(__pyx_t_8);
+          __Pyx_XGIVEREF(__pyx_t_9);
+          __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
+          goto __pyx_L1_error;
+          __pyx_L16_try_end:;
+        }
+      }
+      __pyx_L8:;
+
+      /* "asyncpg/protocol/codecs/array.pyx":84
+ *                               encoder, encoder_arg)
+ *     else:
+ *         for item in obj:             # <<<<<<<<<<<<<<
+ *             if item is None:
+ *                 elem_data.write_int32(-1)
+ */
+    }
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  }
+  __pyx_L3:;
+
+  /* "asyncpg/protocol/codecs/array.pyx":76
+ * 
+ * 
+ * cdef _write_array_data(ConnectionSettings settings, object obj, int32_t ndims,             # <<<<<<<<<<<<<<
+ *                        int32_t dim, WriteBuffer elem_data,
+ *                        encode_func_ex encoder, const void *encoder_arg):
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_11);
+  __Pyx_XDECREF(__pyx_t_12);
+  __Pyx_XDECREF(__pyx_t_13);
+  __Pyx_XDECREF(__pyx_t_14);
+  __Pyx_XDECREF(__pyx_t_15);
+  __Pyx_XDECREF(__pyx_t_16);
+  __Pyx_XDECREF(__pyx_t_17);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol._write_array_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_item);
+  __Pyx_XDECREF(__pyx_v_e);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/array.pyx":95
+ * 
+ * 
+ * cdef inline array_encode(ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
+ *                          object obj, uint32_t elem_oid,
+ *                          encode_func_ex encoder, const void *encoder_arg):
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_array_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj, uint32_t __pyx_v_elem_oid, __pyx_t_7asyncpg_8protocol_8protocol_encode_func_ex __pyx_v_encoder, void const *__pyx_v_encoder_arg) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_elem_data = 0;
+  int32_t __pyx_v_dims[6];
+  int32_t __pyx_v_ndims;
+  int32_t __pyx_v_i;
+  PyObject *__pyx_v_item = NULL;
+  PyObject *__pyx_v_e = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  int __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  int32_t __pyx_t_8;
+  Py_ssize_t __pyx_t_9;
+  PyObject *(*__pyx_t_10)(PyObject *);
+  PyObject *__pyx_t_11 = NULL;
+  PyObject *__pyx_t_12 = NULL;
+  PyObject *__pyx_t_13 = NULL;
+  int __pyx_t_14;
+  PyObject *__pyx_t_15 = NULL;
+  PyObject *__pyx_t_16 = NULL;
+  PyObject *__pyx_t_17 = NULL;
+  PyObject *__pyx_t_18 = NULL;
+  PyObject *__pyx_t_19 = NULL;
+  int __pyx_t_20;
+  char const *__pyx_t_21;
+  PyObject *__pyx_t_22 = NULL;
+  PyObject *__pyx_t_23 = NULL;
+  PyObject *__pyx_t_24 = NULL;
+  PyObject *__pyx_t_25 = NULL;
+  PyObject *__pyx_t_26 = NULL;
+  PyObject *__pyx_t_27 = NULL;
+  int32_t __pyx_t_28;
+  __Pyx_RefNannySetupContext("array_encode", 0);
+
+  /* "asyncpg/protocol/codecs/array.pyx":101
+ *         WriteBuffer elem_data
+ *         int32_t dims[ARRAY_MAXDIM]
+ *         int32_t ndims = 1             # <<<<<<<<<<<<<<
+ *         int32_t i
+ * 
+ */
+  __pyx_v_ndims = 1;
+
+  /* "asyncpg/protocol/codecs/array.pyx":104
+ *         int32_t i
+ * 
+ *     if not _is_container(obj):             # <<<<<<<<<<<<<<
+ *         raise TypeError(
+ *             'a non-trivial iterable expected (got type {!r})'.format(
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol__is_container(__pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 104, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(20, 104, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_3 = ((!__pyx_t_2) != 0);
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/codecs/array.pyx":106
+ *     if not _is_container(obj):
+ *         raise TypeError(
+ *             'a non-trivial iterable expected (got type {!r})'.format(             # <<<<<<<<<<<<<<
+ *                 type(obj).__name__))
+ * 
+ */
+    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_a_non_trivial_iterable_expected, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(20, 106, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+
+    /* "asyncpg/protocol/codecs/array.pyx":107
+ *         raise TypeError(
+ *             'a non-trivial iterable expected (got type {!r})'.format(
+ *                 type(obj).__name__))             # <<<<<<<<<<<<<<
+ * 
+ *     _get_array_shape(obj, dims, &ndims)
+ */
+    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_obj)), __pyx_n_s_name_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(20, 107, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
+      if (likely(__pyx_t_6)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+        __Pyx_INCREF(__pyx_t_6);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_4, function);
+      }
+    }
+    if (!__pyx_t_6) {
+      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 106, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_4)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
+        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 106, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
+        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 106, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(20, 106, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
+        __Pyx_GIVEREF(__pyx_t_5);
+        PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5);
+        __pyx_t_5 = 0;
+        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 106, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/codecs/array.pyx":105
+ * 
+ *     if not _is_container(obj):
+ *         raise TypeError(             # <<<<<<<<<<<<<<
+ *             'a non-trivial iterable expected (got type {!r})'.format(
+ *                 type(obj).__name__))
+ */
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(20, 105, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_1);
+    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
+    __pyx_t_1 = 0;
+    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 105, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __PYX_ERR(20, 105, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/array.pyx":104
+ *         int32_t i
+ * 
+ *     if not _is_container(obj):             # <<<<<<<<<<<<<<
+ *         raise TypeError(
+ *             'a non-trivial iterable expected (got type {!r})'.format(
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/array.pyx":109
+ *                 type(obj).__name__))
+ * 
+ *     _get_array_shape(obj, dims, &ndims)             # <<<<<<<<<<<<<<
+ * 
+ *     elem_data = WriteBuffer.new()
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol__get_array_shape(__pyx_v_obj, __pyx_v_dims, (&__pyx_v_ndims)); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 109, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":111
+ *     _get_array_shape(obj, dims, &ndims)
+ * 
+ *     elem_data = WriteBuffer.new()             # <<<<<<<<<<<<<<
+ * 
+ *     if ndims > 1:
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new()); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 111, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_elem_data = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":113
+ *     elem_data = WriteBuffer.new()
+ * 
+ *     if ndims > 1:             # <<<<<<<<<<<<<<
+ *         _write_array_data(settings, obj, ndims, 0, elem_data,
+ *                           encoder, encoder_arg)
+ */
+  __pyx_t_3 = ((__pyx_v_ndims > 1) != 0);
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/codecs/array.pyx":114
+ * 
+ *     if ndims > 1:
+ *         _write_array_data(settings, obj, ndims, 0, elem_data,             # <<<<<<<<<<<<<<
+ *                           encoder, encoder_arg)
+ *     else:
+ */
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol__write_array_data(__pyx_v_settings, __pyx_v_obj, __pyx_v_ndims, 0, __pyx_v_elem_data, __pyx_v_encoder, __pyx_v_encoder_arg); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 114, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/codecs/array.pyx":113
+ *     elem_data = WriteBuffer.new()
+ * 
+ *     if ndims > 1:             # <<<<<<<<<<<<<<
+ *         _write_array_data(settings, obj, ndims, 0, elem_data,
+ *                           encoder, encoder_arg)
+ */
+    goto __pyx_L4;
+  }
+
+  /* "asyncpg/protocol/codecs/array.pyx":117
+ *                           encoder, encoder_arg)
+ *     else:
+ *         for i, item in enumerate(obj):             # <<<<<<<<<<<<<<
+ *             if item is None:
+ *                 elem_data.write_int32(-1)
+ */
+  /*else*/ {
+    __pyx_t_8 = 0;
+    if (likely(PyList_CheckExact(__pyx_v_obj)) || PyTuple_CheckExact(__pyx_v_obj)) {
+      __pyx_t_1 = __pyx_v_obj; __Pyx_INCREF(__pyx_t_1); __pyx_t_9 = 0;
+      __pyx_t_10 = NULL;
+    } else {
+      __pyx_t_9 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 117, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_10 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(20, 117, __pyx_L1_error)
+    }
+    for (;;) {
+      if (likely(!__pyx_t_10)) {
+        if (likely(PyList_CheckExact(__pyx_t_1))) {
+          if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_1)) break;
+          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+          __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_4); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(20, 117, __pyx_L1_error)
+          #else
+          __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_4)) __PYX_ERR(20, 117, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_4);
+          #endif
+        } else {
+          if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+          __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_4); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(20, 117, __pyx_L1_error)
+          #else
+          __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_4)) __PYX_ERR(20, 117, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_4);
+          #endif
+        }
+      } else {
+        __pyx_t_4 = __pyx_t_10(__pyx_t_1);
+        if (unlikely(!__pyx_t_4)) {
+          PyObject* exc_type = PyErr_Occurred();
+          if (exc_type) {
+            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+            else __PYX_ERR(20, 117, __pyx_L1_error)
+          }
+          break;
+        }
+        __Pyx_GOTREF(__pyx_t_4);
+      }
+      __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_4);
+      __pyx_t_4 = 0;
+      __pyx_v_i = __pyx_t_8;
+      __pyx_t_8 = (__pyx_t_8 + 1);
+
+      /* "asyncpg/protocol/codecs/array.pyx":118
+ *     else:
+ *         for i, item in enumerate(obj):
+ *             if item is None:             # <<<<<<<<<<<<<<
+ *                 elem_data.write_int32(-1)
+ *             else:
+ */
+      __pyx_t_3 = (__pyx_v_item == Py_None);
+      __pyx_t_2 = (__pyx_t_3 != 0);
+      if (__pyx_t_2) {
+
+        /* "asyncpg/protocol/codecs/array.pyx":119
+ *         for i, item in enumerate(obj):
+ *             if item is None:
+ *                 elem_data.write_int32(-1)             # <<<<<<<<<<<<<<
+ *             else:
+ *                 try:
+ */
+        __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_elem_data, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(20, 119, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+        /* "asyncpg/protocol/codecs/array.pyx":118
+ *     else:
+ *         for i, item in enumerate(obj):
+ *             if item is None:             # <<<<<<<<<<<<<<
+ *                 elem_data.write_int32(-1)
+ *             else:
+ */
+        goto __pyx_L7;
+      }
+
+      /* "asyncpg/protocol/codecs/array.pyx":121
+ *                 elem_data.write_int32(-1)
+ *             else:
+ *                 try:             # <<<<<<<<<<<<<<
+ *                     encoder(settings, elem_data, item, encoder_arg)
+ *                 except TypeError as e:
+ */
+      /*else*/ {
+        {
+          __Pyx_PyThreadState_declare
+          __Pyx_PyThreadState_assign
+          __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
+          __Pyx_XGOTREF(__pyx_t_11);
+          __Pyx_XGOTREF(__pyx_t_12);
+          __Pyx_XGOTREF(__pyx_t_13);
+          /*try:*/ {
+
+            /* "asyncpg/protocol/codecs/array.pyx":122
+ *             else:
+ *                 try:
+ *                     encoder(settings, elem_data, item, encoder_arg)             # <<<<<<<<<<<<<<
+ *                 except TypeError as e:
+ *                     raise ValueError(
+ */
+            __pyx_t_4 = __pyx_v_encoder(__pyx_v_settings, __pyx_v_elem_data, __pyx_v_item, __pyx_v_encoder_arg); if (unlikely(!__pyx_t_4)) __PYX_ERR(20, 122, __pyx_L8_error)
+            __Pyx_GOTREF(__pyx_t_4);
+            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+            /* "asyncpg/protocol/codecs/array.pyx":121
+ *                 elem_data.write_int32(-1)
+ *             else:
+ *                 try:             # <<<<<<<<<<<<<<
+ *                     encoder(settings, elem_data, item, encoder_arg)
+ *                 except TypeError as e:
+ */
+          }
+          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
+          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
+          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
+          goto __pyx_L15_try_end;
+          __pyx_L8_error:;
+          __Pyx_PyThreadState_assign
+          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+          /* "asyncpg/protocol/codecs/array.pyx":123
+ *                 try:
+ *                     encoder(settings, elem_data, item, encoder_arg)
+ *                 except TypeError as e:             # <<<<<<<<<<<<<<
+ *                     raise ValueError(
+ *                         'invalid array element at index {}: {}'.format(
+ */
+          __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError);
+          if (__pyx_t_14) {
+            __Pyx_AddTraceback("asyncpg.protocol.protocol.array_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+            if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_7, &__pyx_t_5) < 0) __PYX_ERR(20, 123, __pyx_L10_except_error)
+            __Pyx_GOTREF(__pyx_t_4);
+            __Pyx_GOTREF(__pyx_t_7);
+            __Pyx_GOTREF(__pyx_t_5);
+            __Pyx_INCREF(__pyx_t_7);
+            __pyx_v_e = __pyx_t_7;
+            /*try:*/ {
+
+              /* "asyncpg/protocol/codecs/array.pyx":125
+ *                 except TypeError as e:
+ *                     raise ValueError(
+ *                         'invalid array element at index {}: {}'.format(             # <<<<<<<<<<<<<<
+ *                             i, e.args[0])) from None
+ * 
+ */
+              __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_invalid_array_element_at_index, __pyx_n_s_format); if (unlikely(!__pyx_t_15)) __PYX_ERR(20, 125, __pyx_L21_error)
+              __Pyx_GOTREF(__pyx_t_15);
+
+              /* "asyncpg/protocol/codecs/array.pyx":126
+ *                     raise ValueError(
+ *                         'invalid array element at index {}: {}'.format(
+ *                             i, e.args[0])) from None             # <<<<<<<<<<<<<<
+ * 
+ *     buf.write_int32(12 + 8 * ndims + elem_data.len())
+ */
+              __pyx_t_16 = __Pyx_PyInt_From_int32_t(__pyx_v_i); if (unlikely(!__pyx_t_16)) __PYX_ERR(20, 126, __pyx_L21_error)
+              __Pyx_GOTREF(__pyx_t_16);
+              __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_v_e, __pyx_n_s_args); if (unlikely(!__pyx_t_17)) __PYX_ERR(20, 126, __pyx_L21_error)
+              __Pyx_GOTREF(__pyx_t_17);
+              __pyx_t_18 = __Pyx_GetItemInt(__pyx_t_17, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_18)) __PYX_ERR(20, 126, __pyx_L21_error)
+              __Pyx_GOTREF(__pyx_t_18);
+              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
+              __pyx_t_17 = NULL;
+              __pyx_t_14 = 0;
+              if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_15))) {
+                __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_15);
+                if (likely(__pyx_t_17)) {
+                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
+                  __Pyx_INCREF(__pyx_t_17);
+                  __Pyx_INCREF(function);
+                  __Pyx_DECREF_SET(__pyx_t_15, function);
+                  __pyx_t_14 = 1;
+                }
+              }
+              #if CYTHON_FAST_PYCALL
+              if (PyFunction_Check(__pyx_t_15)) {
+                PyObject *__pyx_temp[3] = {__pyx_t_17, __pyx_t_16, __pyx_t_18};
+                __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_15, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_6)) __PYX_ERR(20, 125, __pyx_L21_error)
+                __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
+                __Pyx_GOTREF(__pyx_t_6);
+                __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
+                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+              } else
+              #endif
+              #if CYTHON_FAST_PYCCALL
+              if (__Pyx_PyFastCFunction_Check(__pyx_t_15)) {
+                PyObject *__pyx_temp[3] = {__pyx_t_17, __pyx_t_16, __pyx_t_18};
+                __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_15, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_6)) __PYX_ERR(20, 125, __pyx_L21_error)
+                __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
+                __Pyx_GOTREF(__pyx_t_6);
+                __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
+                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+              } else
+              #endif
+              {
+                __pyx_t_19 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_19)) __PYX_ERR(20, 125, __pyx_L21_error)
+                __Pyx_GOTREF(__pyx_t_19);
+                if (__pyx_t_17) {
+                  __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_17); __pyx_t_17 = NULL;
+                }
+                __Pyx_GIVEREF(__pyx_t_16);
+                PyTuple_SET_ITEM(__pyx_t_19, 0+__pyx_t_14, __pyx_t_16);
+                __Pyx_GIVEREF(__pyx_t_18);
+                PyTuple_SET_ITEM(__pyx_t_19, 1+__pyx_t_14, __pyx_t_18);
+                __pyx_t_16 = 0;
+                __pyx_t_18 = 0;
+                __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_19, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(20, 125, __pyx_L21_error)
+                __Pyx_GOTREF(__pyx_t_6);
+                __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
+              }
+              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+
+              /* "asyncpg/protocol/codecs/array.pyx":124
+ *                     encoder(settings, elem_data, item, encoder_arg)
+ *                 except TypeError as e:
+ *                     raise ValueError(             # <<<<<<<<<<<<<<
+ *                         'invalid array element at index {}: {}'.format(
+ *                             i, e.args[0])) from None
+ */
+              __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(20, 124, __pyx_L21_error)
+              __Pyx_GOTREF(__pyx_t_15);
+              __Pyx_GIVEREF(__pyx_t_6);
+              PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_6);
+              __pyx_t_6 = 0;
+              __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_15, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(20, 124, __pyx_L21_error)
+              __Pyx_GOTREF(__pyx_t_6);
+              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+
+              /* "asyncpg/protocol/codecs/array.pyx":126
+ *                     raise ValueError(
+ *                         'invalid array element at index {}: {}'.format(
+ *                             i, e.args[0])) from None             # <<<<<<<<<<<<<<
+ * 
+ *     buf.write_int32(12 + 8 * ndims + elem_data.len())
+ */
+              __Pyx_Raise(__pyx_t_6, 0, 0, Py_None);
+              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+              __PYX_ERR(20, 124, __pyx_L21_error)
+            }
+
+            /* "asyncpg/protocol/codecs/array.pyx":123
+ *                 try:
+ *                     encoder(settings, elem_data, item, encoder_arg)
+ *                 except TypeError as e:             # <<<<<<<<<<<<<<
+ *                     raise ValueError(
+ *                         'invalid array element at index {}: {}'.format(
+ */
+            /*finally:*/ {
+              /*exception exit:*/{
+                __Pyx_PyThreadState_declare
+                __pyx_L21_error:;
+                __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0;
+                __Pyx_PyThreadState_assign
+                __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
+                __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
+                __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
+                __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
+                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
+                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+                if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_25, &__pyx_t_26, &__pyx_t_27);
+                if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24) < 0)) __Pyx_ErrFetch(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
+                __Pyx_XGOTREF(__pyx_t_22);
+                __Pyx_XGOTREF(__pyx_t_23);
+                __Pyx_XGOTREF(__pyx_t_24);
+                __Pyx_XGOTREF(__pyx_t_25);
+                __Pyx_XGOTREF(__pyx_t_26);
+                __Pyx_XGOTREF(__pyx_t_27);
+                __pyx_t_14 = __pyx_lineno; __pyx_t_20 = __pyx_clineno; __pyx_t_21 = __pyx_filename;
+                {
+                  __Pyx_DECREF(__pyx_v_e);
+                  __pyx_v_e = NULL;
+                }
+                __Pyx_PyThreadState_assign
+                if (PY_MAJOR_VERSION >= 3) {
+                  __Pyx_XGIVEREF(__pyx_t_25);
+                  __Pyx_XGIVEREF(__pyx_t_26);
+                  __Pyx_XGIVEREF(__pyx_t_27);
+                  __Pyx_ExceptionReset(__pyx_t_25, __pyx_t_26, __pyx_t_27);
+                }
+                __Pyx_XGIVEREF(__pyx_t_22);
+                __Pyx_XGIVEREF(__pyx_t_23);
+                __Pyx_XGIVEREF(__pyx_t_24);
+                __Pyx_ErrRestore(__pyx_t_22, __pyx_t_23, __pyx_t_24);
+                __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0;
+                __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_20; __pyx_filename = __pyx_t_21;
+                goto __pyx_L10_except_error;
+              }
+            }
+          }
+          goto __pyx_L10_except_error;
+          __pyx_L10_except_error:;
+
+          /* "asyncpg/protocol/codecs/array.pyx":121
+ *                 elem_data.write_int32(-1)
+ *             else:
+ *                 try:             # <<<<<<<<<<<<<<
+ *                     encoder(settings, elem_data, item, encoder_arg)
+ *                 except TypeError as e:
+ */
+          __Pyx_PyThreadState_assign
+          __Pyx_XGIVEREF(__pyx_t_11);
+          __Pyx_XGIVEREF(__pyx_t_12);
+          __Pyx_XGIVEREF(__pyx_t_13);
+          __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
+          goto __pyx_L1_error;
+          __pyx_L15_try_end:;
+        }
+      }
+      __pyx_L7:;
+
+      /* "asyncpg/protocol/codecs/array.pyx":117
+ *                           encoder, encoder_arg)
+ *     else:
+ *         for i, item in enumerate(obj):             # <<<<<<<<<<<<<<
+ *             if item is None:
+ *                 elem_data.write_int32(-1)
+ */
+    }
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  }
+  __pyx_L4:;
+
+  /* "asyncpg/protocol/codecs/array.pyx":128
+ *                             i, e.args[0])) from None
+ * 
+ *     buf.write_int32(12 + 8 * ndims + elem_data.len())             # <<<<<<<<<<<<<<
+ *     # Number of dimensions
+ *     buf.write_int32(ndims)
+ */
+  __pyx_t_1 = __Pyx_PyInt_From_long((12 + (8 * __pyx_v_ndims))); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 128, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_5 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_len(__pyx_v_elem_data); if (unlikely(!__pyx_t_5)) __PYX_ERR(20, 128, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_7 = PyNumber_Add(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(20, 128, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_7);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __pyx_t_8 = __Pyx_PyInt_As_int32_t(__pyx_t_7); if (unlikely((__pyx_t_8 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(20, 128, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+  __pyx_t_7 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(20, 128, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_7);
+  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":130
+ *     buf.write_int32(12 + 8 * ndims + elem_data.len())
+ *     # Number of dimensions
+ *     buf.write_int32(ndims)             # <<<<<<<<<<<<<<
+ *     # flags
+ *     buf.write_int32(0)
+ */
+  __pyx_t_7 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, __pyx_v_ndims); if (unlikely(!__pyx_t_7)) __PYX_ERR(20, 130, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_7);
+  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":132
+ *     buf.write_int32(ndims)
+ *     # flags
+ *     buf.write_int32(0)             # <<<<<<<<<<<<<<
+ *     # element type
+ *     buf.write_int32(<int32_t>elem_oid)
+ */
+  __pyx_t_7 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(20, 132, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_7);
+  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":134
+ *     buf.write_int32(0)
+ *     # element type
+ *     buf.write_int32(<int32_t>elem_oid)             # <<<<<<<<<<<<<<
+ *     # upper / lower bounds
+ *     for i in range(ndims):
+ */
+  __pyx_t_7 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, ((int32_t)__pyx_v_elem_oid)); if (unlikely(!__pyx_t_7)) __PYX_ERR(20, 134, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_7);
+  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":136
+ *     buf.write_int32(<int32_t>elem_oid)
+ *     # upper / lower bounds
+ *     for i in range(ndims):             # <<<<<<<<<<<<<<
+ *         buf.write_int32(dims[i])
+ *         buf.write_int32(1)
+ */
+  __pyx_t_8 = __pyx_v_ndims;
+  for (__pyx_t_28 = 0; __pyx_t_28 < __pyx_t_8; __pyx_t_28+=1) {
+    __pyx_v_i = __pyx_t_28;
+
+    /* "asyncpg/protocol/codecs/array.pyx":137
+ *     # upper / lower bounds
+ *     for i in range(ndims):
+ *         buf.write_int32(dims[i])             # <<<<<<<<<<<<<<
+ *         buf.write_int32(1)
+ *     # element data
+ */
+    __pyx_t_7 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, (__pyx_v_dims[__pyx_v_i])); if (unlikely(!__pyx_t_7)) __PYX_ERR(20, 137, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_7);
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+    /* "asyncpg/protocol/codecs/array.pyx":138
+ *     for i in range(ndims):
+ *         buf.write_int32(dims[i])
+ *         buf.write_int32(1)             # <<<<<<<<<<<<<<
+ *     # element data
+ *     buf.write_buffer(elem_data)
+ */
+    __pyx_t_7 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(20, 138, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_7);
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+  }
+
+  /* "asyncpg/protocol/codecs/array.pyx":140
+ *         buf.write_int32(1)
+ *     # element data
+ *     buf.write_buffer(elem_data)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_7 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_buffer(__pyx_v_buf, __pyx_v_elem_data); if (unlikely(!__pyx_t_7)) __PYX_ERR(20, 140, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_7);
+  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":95
+ * 
+ * 
+ * cdef inline array_encode(ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
+ *                          object obj, uint32_t elem_oid,
+ *                          encode_func_ex encoder, const void *encoder_arg):
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_15);
+  __Pyx_XDECREF(__pyx_t_16);
+  __Pyx_XDECREF(__pyx_t_17);
+  __Pyx_XDECREF(__pyx_t_18);
+  __Pyx_XDECREF(__pyx_t_19);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.array_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_elem_data);
+  __Pyx_XDECREF(__pyx_v_item);
+  __Pyx_XDECREF(__pyx_v_e);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/array.pyx":143
+ * 
+ * 
+ * cdef inline array_decode(ConnectionSettings settings, FastReadBuffer buf,             # <<<<<<<<<<<<<<
+ *                          decode_func_ex decoder, const void *decoder_arg):
+ *     cdef:
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_array_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf, __pyx_t_7asyncpg_8protocol_8protocol_decode_func_ex __pyx_v_decoder, void const *__pyx_v_decoder_arg) {
+  int32_t __pyx_v_ndims;
+  CYTHON_UNUSED int32_t __pyx_v_flags;
+  uint32_t __pyx_v_elem_oid;
+  PyObject *__pyx_v_result = 0;
+  int __pyx_v_i;
+  int32_t __pyx_v_elem_len;
+  int32_t __pyx_v_elem_count;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_elem_buf = 0;
+  int32_t __pyx_v_dims[6];
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_elem_codec = 0;
+  PyObject *__pyx_v_elem = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  char const *__pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  int __pyx_t_7;
+  PyObject *__pyx_t_8 = NULL;
+  int __pyx_t_9;
+  int __pyx_t_10;
+  int32_t __pyx_t_11;
+  __Pyx_RefNannySetupContext("array_decode", 0);
+
+  /* "asyncpg/protocol/codecs/array.pyx":146
+ *                          decode_func_ex decoder, const void *decoder_arg):
+ *     cdef:
+ *         int32_t ndims = hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ *         int32_t flags = hton.unpack_int32(buf.read(4))
+ *         uint32_t elem_oid = <uint32_t>hton.unpack_int32(buf.read(4))
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(20, 146, __pyx_L1_error)
+  __pyx_v_ndims = __pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/array.pyx":147
+ *     cdef:
+ *         int32_t ndims = hton.unpack_int32(buf.read(4))
+ *         int32_t flags = hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ *         uint32_t elem_oid = <uint32_t>hton.unpack_int32(buf.read(4))
+ *         list result
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(20, 147, __pyx_L1_error)
+  __pyx_v_flags = __pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_1);
+
+  /* "asyncpg/protocol/codecs/array.pyx":148
+ *         int32_t ndims = hton.unpack_int32(buf.read(4))
+ *         int32_t flags = hton.unpack_int32(buf.read(4))
+ *         uint32_t elem_oid = <uint32_t>hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ *         list result
+ *         int i
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(20, 148, __pyx_L1_error)
+  __pyx_v_elem_oid = ((uint32_t)__pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_1));
+
+  /* "asyncpg/protocol/codecs/array.pyx":152
+ *         int i
+ *         int32_t elem_len
+ *         int32_t elem_count = 1             # <<<<<<<<<<<<<<
+ *         FastReadBuffer elem_buf = FastReadBuffer.new()
+ *         int32_t dims[ARRAY_MAXDIM]
+ */
+  __pyx_v_elem_count = 1;
+
+  /* "asyncpg/protocol/codecs/array.pyx":153
+ *         int32_t elem_len
+ *         int32_t elem_count = 1
+ *         FastReadBuffer elem_buf = FastReadBuffer.new()             # <<<<<<<<<<<<<<
+ *         int32_t dims[ARRAY_MAXDIM]
+ *         Codec elem_codec
+ */
+  __pyx_t_2 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_new()); if (unlikely(!__pyx_t_2)) __PYX_ERR(20, 153, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_v_elem_buf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *)__pyx_t_2);
+  __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":157
+ *         Codec elem_codec
+ * 
+ *     if ndims == 0:             # <<<<<<<<<<<<<<
+ *         result = cpython.PyList_New(0)
+ *         return result
+ */
+  __pyx_t_3 = ((__pyx_v_ndims == 0) != 0);
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/codecs/array.pyx":158
+ * 
+ *     if ndims == 0:
+ *         result = cpython.PyList_New(0)             # <<<<<<<<<<<<<<
+ *         return result
+ * 
+ */
+    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(20, 158, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_v_result = ((PyObject*)__pyx_t_2);
+    __pyx_t_2 = 0;
+
+    /* "asyncpg/protocol/codecs/array.pyx":159
+ *     if ndims == 0:
+ *         result = cpython.PyList_New(0)
+ *         return result             # <<<<<<<<<<<<<<
+ * 
+ *     if ndims > ARRAY_MAXDIM:
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(__pyx_v_result);
+    __pyx_r = __pyx_v_result;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/codecs/array.pyx":157
+ *         Codec elem_codec
+ * 
+ *     if ndims == 0:             # <<<<<<<<<<<<<<
+ *         result = cpython.PyList_New(0)
+ *         return result
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/array.pyx":161
+ *         return result
+ * 
+ *     if ndims > ARRAY_MAXDIM:             # <<<<<<<<<<<<<<
+ *         raise RuntimeError(
+ *             'number of array dimensions ({}) exceed the maximum expected ({})'.
+ */
+  __pyx_t_3 = ((__pyx_v_ndims > 6) != 0);
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/codecs/array.pyx":163
+ *     if ndims > ARRAY_MAXDIM:
+ *         raise RuntimeError(
+ *             'number of array dimensions ({}) exceed the maximum expected ({})'.             # <<<<<<<<<<<<<<
+ *             format(ndims, ARRAY_MAXDIM))
+ * 
+ */
+    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_number_of_array_dimensions_excee, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(20, 163, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+
+    /* "asyncpg/protocol/codecs/array.pyx":164
+ *         raise RuntimeError(
+ *             'number of array dimensions ({}) exceed the maximum expected ({})'.
+ *             format(ndims, ARRAY_MAXDIM))             # <<<<<<<<<<<<<<
+ * 
+ *     if decoder == NULL:
+ */
+    __pyx_t_5 = __Pyx_PyInt_From_int32_t(__pyx_v_ndims); if (unlikely(!__pyx_t_5)) __PYX_ERR(20, 164, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = NULL;
+    __pyx_t_7 = 0;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
+      if (likely(__pyx_t_6)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+        __Pyx_INCREF(__pyx_t_6);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_4, function);
+        __pyx_t_7 = 1;
+      }
+    }
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_4)) {
+      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_5, __pyx_int_6};
+      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(20, 164, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
+      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_5, __pyx_int_6};
+      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(20, 164, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    } else
+    #endif
+    {
+      __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(20, 164, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_8);
+      if (__pyx_t_6) {
+        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
+      }
+      __Pyx_GIVEREF(__pyx_t_5);
+      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_5);
+      __Pyx_INCREF(__pyx_int_6);
+      __Pyx_GIVEREF(__pyx_int_6);
+      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_int_6);
+      __pyx_t_5 = 0;
+      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(20, 164, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/codecs/array.pyx":162
+ * 
+ *     if ndims > ARRAY_MAXDIM:
+ *         raise RuntimeError(             # <<<<<<<<<<<<<<
+ *             'number of array dimensions ({}) exceed the maximum expected ({})'.
+ *             format(ndims, ARRAY_MAXDIM))
+ */
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(20, 162, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_2);
+    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
+    __pyx_t_2 = 0;
+    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(20, 162, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __PYX_ERR(20, 162, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/array.pyx":161
+ *         return result
+ * 
+ *     if ndims > ARRAY_MAXDIM:             # <<<<<<<<<<<<<<
+ *         raise RuntimeError(
+ *             'number of array dimensions ({}) exceed the maximum expected ({})'.
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/array.pyx":166
+ *             format(ndims, ARRAY_MAXDIM))
+ * 
+ *     if decoder == NULL:             # <<<<<<<<<<<<<<
+ *         # No decoder is known beforehand, look it up
+ * 
+ */
+  __pyx_t_3 = ((__pyx_v_decoder == NULL) != 0);
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/codecs/array.pyx":169
+ *         # No decoder is known beforehand, look it up
+ * 
+ *         elem_codec = settings.get_data_codec(elem_oid)             # <<<<<<<<<<<<<<
+ *         if elem_codec is None or not elem_codec.has_decoder():
+ *             raise RuntimeError(
+ */
+    __pyx_t_2 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_data_codec(__pyx_v_settings, __pyx_v_elem_oid, 0, NULL)); if (unlikely(!__pyx_t_2)) __PYX_ERR(20, 169, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_v_elem_codec = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_2);
+    __pyx_t_2 = 0;
+
+    /* "asyncpg/protocol/codecs/array.pyx":170
+ * 
+ *         elem_codec = settings.get_data_codec(elem_oid)
+ *         if elem_codec is None or not elem_codec.has_decoder():             # <<<<<<<<<<<<<<
+ *             raise RuntimeError(
+ *                 'no decoder for type OID {}'.format(elem_oid))
+ */
+    __pyx_t_9 = (((PyObject *)__pyx_v_elem_codec) == Py_None);
+    __pyx_t_10 = (__pyx_t_9 != 0);
+    if (!__pyx_t_10) {
+    } else {
+      __pyx_t_3 = __pyx_t_10;
+      goto __pyx_L7_bool_binop_done;
+    }
+    __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_has_decoder(__pyx_v_elem_codec); if (unlikely(!__pyx_t_2)) __PYX_ERR(20, 170, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(20, 170, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_9 = ((!__pyx_t_10) != 0);
+    __pyx_t_3 = __pyx_t_9;
+    __pyx_L7_bool_binop_done:;
+    if (__pyx_t_3) {
+
+      /* "asyncpg/protocol/codecs/array.pyx":172
+ *         if elem_codec is None or not elem_codec.has_decoder():
+ *             raise RuntimeError(
+ *                 'no decoder for type OID {}'.format(elem_oid))             # <<<<<<<<<<<<<<
+ * 
+ *         decoder = codec_decode_func_ex
+ */
+      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_no_decoder_for_type_OID, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(20, 172, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_8 = __Pyx_PyInt_From_uint32_t(__pyx_v_elem_oid); if (unlikely(!__pyx_t_8)) __PYX_ERR(20, 172, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_8);
+      __pyx_t_5 = NULL;
+      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
+        if (likely(__pyx_t_5)) {
+          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+          __Pyx_INCREF(__pyx_t_5);
+          __Pyx_INCREF(function);
+          __Pyx_DECREF_SET(__pyx_t_4, function);
+        }
+      }
+      if (!__pyx_t_5) {
+        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(20, 172, __pyx_L1_error)
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        __Pyx_GOTREF(__pyx_t_2);
+      } else {
+        #if CYTHON_FAST_PYCALL
+        if (PyFunction_Check(__pyx_t_4)) {
+          PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_8};
+          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(20, 172, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+          __Pyx_GOTREF(__pyx_t_2);
+          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        } else
+        #endif
+        #if CYTHON_FAST_PYCCALL
+        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
+          PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_8};
+          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(20, 172, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+          __Pyx_GOTREF(__pyx_t_2);
+          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        } else
+        #endif
+        {
+          __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(20, 172, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_6);
+          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
+          __Pyx_GIVEREF(__pyx_t_8);
+          PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_8);
+          __pyx_t_8 = 0;
+          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(20, 172, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_2);
+          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+        }
+      }
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+      /* "asyncpg/protocol/codecs/array.pyx":171
+ *         elem_codec = settings.get_data_codec(elem_oid)
+ *         if elem_codec is None or not elem_codec.has_decoder():
+ *             raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                 'no decoder for type OID {}'.format(elem_oid))
+ * 
+ */
+      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(20, 171, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_GIVEREF(__pyx_t_2);
+      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
+      __pyx_t_2 = 0;
+      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(20, 171, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __PYX_ERR(20, 171, __pyx_L1_error)
+
+      /* "asyncpg/protocol/codecs/array.pyx":170
+ * 
+ *         elem_codec = settings.get_data_codec(elem_oid)
+ *         if elem_codec is None or not elem_codec.has_decoder():             # <<<<<<<<<<<<<<
+ *             raise RuntimeError(
+ *                 'no decoder for type OID {}'.format(elem_oid))
+ */
+    }
+
+    /* "asyncpg/protocol/codecs/array.pyx":174
+ *                 'no decoder for type OID {}'.format(elem_oid))
+ * 
+ *         decoder = codec_decode_func_ex             # <<<<<<<<<<<<<<
+ *         decoder_arg = <void*>(<cpython.PyObject>elem_codec)
+ * 
+ */
+    __pyx_v_decoder = __pyx_f_7asyncpg_8protocol_8protocol_codec_decode_func_ex;
+
+    /* "asyncpg/protocol/codecs/array.pyx":175
+ * 
+ *         decoder = codec_decode_func_ex
+ *         decoder_arg = <void*>(<cpython.PyObject>elem_codec)             # <<<<<<<<<<<<<<
+ * 
+ *     for i in range(ndims):
+ */
+    __pyx_v_decoder_arg = ((void *)__pyx_v_elem_codec);
+
+    /* "asyncpg/protocol/codecs/array.pyx":166
+ *             format(ndims, ARRAY_MAXDIM))
+ * 
+ *     if decoder == NULL:             # <<<<<<<<<<<<<<
+ *         # No decoder is known beforehand, look it up
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/array.pyx":177
+ *         decoder_arg = <void*>(<cpython.PyObject>elem_codec)
+ * 
+ *     for i in range(ndims):             # <<<<<<<<<<<<<<
+ *         dims[i] = hton.unpack_int32(buf.read(4))
+ *         # Ignore the lower bound information
+ */
+  __pyx_t_11 = __pyx_v_ndims;
+  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_11; __pyx_t_7+=1) {
+    __pyx_v_i = __pyx_t_7;
+
+    /* "asyncpg/protocol/codecs/array.pyx":178
+ * 
+ *     for i in range(ndims):
+ *         dims[i] = hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ *         # Ignore the lower bound information
+ *         buf.read(4)
+ */
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(20, 178, __pyx_L1_error)
+    (__pyx_v_dims[__pyx_v_i]) = __pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_1);
+
+    /* "asyncpg/protocol/codecs/array.pyx":180
+ *         dims[i] = hton.unpack_int32(buf.read(4))
+ *         # Ignore the lower bound information
+ *         buf.read(4)             # <<<<<<<<<<<<<<
+ * 
+ *     if ndims == 1:
+ */
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(20, 180, __pyx_L1_error)
+  }
+
+  /* "asyncpg/protocol/codecs/array.pyx":182
+ *         buf.read(4)
+ * 
+ *     if ndims == 1:             # <<<<<<<<<<<<<<
+ *         # Fast path for flat arrays
+ *         elem_count = dims[0]
+ */
+  __pyx_t_3 = ((__pyx_v_ndims == 1) != 0);
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/codecs/array.pyx":184
+ *     if ndims == 1:
+ *         # Fast path for flat arrays
+ *         elem_count = dims[0]             # <<<<<<<<<<<<<<
+ *         result = cpython.PyList_New(elem_count)
+ * 
+ */
+    __pyx_v_elem_count = (__pyx_v_dims[0]);
+
+    /* "asyncpg/protocol/codecs/array.pyx":185
+ *         # Fast path for flat arrays
+ *         elem_count = dims[0]
+ *         result = cpython.PyList_New(elem_count)             # <<<<<<<<<<<<<<
+ * 
+ *         for i in range(elem_count):
+ */
+    __pyx_t_2 = PyList_New(__pyx_v_elem_count); if (unlikely(!__pyx_t_2)) __PYX_ERR(20, 185, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_v_result = ((PyObject*)__pyx_t_2);
+    __pyx_t_2 = 0;
+
+    /* "asyncpg/protocol/codecs/array.pyx":187
+ *         result = cpython.PyList_New(elem_count)
+ * 
+ *         for i in range(elem_count):             # <<<<<<<<<<<<<<
+ *             elem_len = hton.unpack_int32(buf.read(4))
+ *             if elem_len == -1:
+ */
+    __pyx_t_11 = __pyx_v_elem_count;
+    for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_11; __pyx_t_7+=1) {
+      __pyx_v_i = __pyx_t_7;
+
+      /* "asyncpg/protocol/codecs/array.pyx":188
+ * 
+ *         for i in range(elem_count):
+ *             elem_len = hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ *             if elem_len == -1:
+ *                 elem = None
+ */
+      __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(20, 188, __pyx_L1_error)
+      __pyx_v_elem_len = __pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_1);
+
+      /* "asyncpg/protocol/codecs/array.pyx":189
+ *         for i in range(elem_count):
+ *             elem_len = hton.unpack_int32(buf.read(4))
+ *             if elem_len == -1:             # <<<<<<<<<<<<<<
+ *                 elem = None
+ *             else:
+ */
+      __pyx_t_3 = ((__pyx_v_elem_len == -1L) != 0);
+      if (__pyx_t_3) {
+
+        /* "asyncpg/protocol/codecs/array.pyx":190
+ *             elem_len = hton.unpack_int32(buf.read(4))
+ *             if elem_len == -1:
+ *                 elem = None             # <<<<<<<<<<<<<<
+ *             else:
+ *                 elem_buf.slice_from(buf, elem_len)
+ */
+        __Pyx_INCREF(Py_None);
+        __Pyx_XDECREF_SET(__pyx_v_elem, Py_None);
+
+        /* "asyncpg/protocol/codecs/array.pyx":189
+ *         for i in range(elem_count):
+ *             elem_len = hton.unpack_int32(buf.read(4))
+ *             if elem_len == -1:             # <<<<<<<<<<<<<<
+ *                 elem = None
+ *             else:
+ */
+        goto __pyx_L14;
+      }
+
+      /* "asyncpg/protocol/codecs/array.pyx":192
+ *                 elem = None
+ *             else:
+ *                 elem_buf.slice_from(buf, elem_len)             # <<<<<<<<<<<<<<
+ *                 elem = decoder(settings, elem_buf, decoder_arg)
+ * 
+ */
+      /*else*/ {
+        __pyx_t_2 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_slice_from(__pyx_v_elem_buf, __pyx_v_buf, __pyx_v_elem_len)); if (unlikely(!__pyx_t_2)) __PYX_ERR(20, 192, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+        /* "asyncpg/protocol/codecs/array.pyx":193
+ *             else:
+ *                 elem_buf.slice_from(buf, elem_len)
+ *                 elem = decoder(settings, elem_buf, decoder_arg)             # <<<<<<<<<<<<<<
+ * 
+ *             cpython.Py_INCREF(elem)
+ */
+        __pyx_t_2 = __pyx_v_decoder(__pyx_v_settings, __pyx_v_elem_buf, __pyx_v_decoder_arg); if (unlikely(!__pyx_t_2)) __PYX_ERR(20, 193, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_XDECREF_SET(__pyx_v_elem, __pyx_t_2);
+        __pyx_t_2 = 0;
+      }
+      __pyx_L14:;
+
+      /* "asyncpg/protocol/codecs/array.pyx":195
+ *                 elem = decoder(settings, elem_buf, decoder_arg)
+ * 
+ *             cpython.Py_INCREF(elem)             # <<<<<<<<<<<<<<
+ *             cpython.PyList_SET_ITEM(result, i, elem)
+ * 
+ */
+      Py_INCREF(__pyx_v_elem);
+
+      /* "asyncpg/protocol/codecs/array.pyx":196
+ * 
+ *             cpython.Py_INCREF(elem)
+ *             cpython.PyList_SET_ITEM(result, i, elem)             # <<<<<<<<<<<<<<
+ * 
+ *     else:
+ */
+      PyList_SET_ITEM(__pyx_v_result, __pyx_v_i, __pyx_v_elem);
+    }
+
+    /* "asyncpg/protocol/codecs/array.pyx":182
+ *         buf.read(4)
+ * 
+ *     if ndims == 1:             # <<<<<<<<<<<<<<
+ *         # Fast path for flat arrays
+ *         elem_count = dims[0]
+ */
+    goto __pyx_L11;
+  }
+
+  /* "asyncpg/protocol/codecs/array.pyx":199
+ * 
+ *     else:
+ *         result = _nested_array_decode(settings, buf,             # <<<<<<<<<<<<<<
+ *                                       decoder, decoder_arg, ndims, dims,
+ *                                       elem_buf)
+ */
+  /*else*/ {
+
+    /* "asyncpg/protocol/codecs/array.pyx":201
+ *         result = _nested_array_decode(settings, buf,
+ *                                       decoder, decoder_arg, ndims, dims,
+ *                                       elem_buf)             # <<<<<<<<<<<<<<
+ * 
+ *     return result
+ */
+    __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol__nested_array_decode(__pyx_v_settings, __pyx_v_buf, __pyx_v_decoder, __pyx_v_decoder_arg, __pyx_v_ndims, __pyx_v_dims, __pyx_v_elem_buf); if (unlikely(!__pyx_t_2)) __PYX_ERR(20, 199, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+
+    /* "asyncpg/protocol/codecs/array.pyx":199
+ * 
+ *     else:
+ *         result = _nested_array_decode(settings, buf,             # <<<<<<<<<<<<<<
+ *                                       decoder, decoder_arg, ndims, dims,
+ *                                       elem_buf)
+ */
+    if (!(likely(PyList_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(20, 199, __pyx_L1_error)
+    __pyx_v_result = ((PyObject*)__pyx_t_2);
+    __pyx_t_2 = 0;
+  }
+  __pyx_L11:;
+
+  /* "asyncpg/protocol/codecs/array.pyx":203
+ *                                       elem_buf)
+ * 
+ *     return result             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_result);
+  __pyx_r = __pyx_v_result;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":143
+ * 
+ * 
+ * cdef inline array_decode(ConnectionSettings settings, FastReadBuffer buf,             # <<<<<<<<<<<<<<
+ *                          decode_func_ex decoder, const void *decoder_arg):
+ *     cdef:
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.array_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_result);
+  __Pyx_XDECREF((PyObject *)__pyx_v_elem_buf);
+  __Pyx_XDECREF((PyObject *)__pyx_v_elem_codec);
+  __Pyx_XDECREF(__pyx_v_elem);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/array.pyx":206
+ * 
+ * 
+ * cdef inline _nested_array_decode(ConnectionSettings settings,             # <<<<<<<<<<<<<<
+ *                                  FastReadBuffer buf,
+ *                                  decode_func_ex decoder,
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol__nested_array_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf, __pyx_t_7asyncpg_8protocol_8protocol_decode_func_ex __pyx_v_decoder, void const *__pyx_v_decoder_arg, int32_t __pyx_v_ndims, int32_t *__pyx_v_dims, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_elem_buf) {
+  int32_t __pyx_v_elem_len;
+  int32_t __pyx_v_d1;
+  int32_t __pyx_v_d2;
+  int32_t __pyx_v_d3;
+  int32_t __pyx_v_d4;
+  int32_t __pyx_v_d5;
+  int32_t __pyx_v_d6;
+  PyObject *__pyx_v_result = 0;
+  PyObject *__pyx_v_elem = 0;
+  PyObject *__pyx_v_stride1 = 0;
+  PyObject *__pyx_v_stride2 = 0;
+  PyObject *__pyx_v_stride3 = 0;
+  PyObject *__pyx_v_stride4 = 0;
+  PyObject *__pyx_v_stride5 = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int32_t __pyx_t_2;
+  int32_t __pyx_t_3;
+  int32_t __pyx_t_4;
+  int32_t __pyx_t_5;
+  int __pyx_t_6;
+  char const *__pyx_t_7;
+  PyObject *__pyx_t_8 = NULL;
+  int32_t __pyx_t_9;
+  int32_t __pyx_t_10;
+  int32_t __pyx_t_11;
+  int32_t __pyx_t_12;
+  int32_t __pyx_t_13;
+  int32_t __pyx_t_14;
+  int32_t __pyx_t_15;
+  int32_t __pyx_t_16;
+  __Pyx_RefNannySetupContext("_nested_array_decode", 0);
+
+  /* "asyncpg/protocol/codecs/array.pyx":224
+ *     # Alas, Cython doesn't have preprocessor macros.
+ *     #
+ *     result = cpython.PyList_New(dims[0])             # <<<<<<<<<<<<<<
+ * 
+ *     for d1 in range(dims[0]):
+ */
+  __pyx_t_1 = PyList_New((__pyx_v_dims[0])); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 224, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_result = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":226
+ *     result = cpython.PyList_New(dims[0])
+ * 
+ *     for d1 in range(dims[0]):             # <<<<<<<<<<<<<<
+ *         stride1 = cpython.PyList_New(dims[1])
+ *         cpython.Py_INCREF(stride1)
+ */
+  __pyx_t_2 = (__pyx_v_dims[0]);
+  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
+    __pyx_v_d1 = __pyx_t_3;
+
+    /* "asyncpg/protocol/codecs/array.pyx":227
+ * 
+ *     for d1 in range(dims[0]):
+ *         stride1 = cpython.PyList_New(dims[1])             # <<<<<<<<<<<<<<
+ *         cpython.Py_INCREF(stride1)
+ *         cpython.PyList_SET_ITEM(result, d1, stride1)
+ */
+    __pyx_t_1 = PyList_New((__pyx_v_dims[1])); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 227, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_XDECREF_SET(__pyx_v_stride1, ((PyObject*)__pyx_t_1));
+    __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/codecs/array.pyx":228
+ *     for d1 in range(dims[0]):
+ *         stride1 = cpython.PyList_New(dims[1])
+ *         cpython.Py_INCREF(stride1)             # <<<<<<<<<<<<<<
+ *         cpython.PyList_SET_ITEM(result, d1, stride1)
+ * 
+ */
+    Py_INCREF(__pyx_v_stride1);
+
+    /* "asyncpg/protocol/codecs/array.pyx":229
+ *         stride1 = cpython.PyList_New(dims[1])
+ *         cpython.Py_INCREF(stride1)
+ *         cpython.PyList_SET_ITEM(result, d1, stride1)             # <<<<<<<<<<<<<<
+ * 
+ *         for d2 in range(dims[1]):
+ */
+    PyList_SET_ITEM(__pyx_v_result, __pyx_v_d1, __pyx_v_stride1);
+
+    /* "asyncpg/protocol/codecs/array.pyx":231
+ *         cpython.PyList_SET_ITEM(result, d1, stride1)
+ * 
+ *         for d2 in range(dims[1]):             # <<<<<<<<<<<<<<
+ *             if ndims == 2:
+ *                 elem_len = hton.unpack_int32(buf.read(4))
+ */
+    __pyx_t_4 = (__pyx_v_dims[1]);
+    for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
+      __pyx_v_d2 = __pyx_t_5;
+
+      /* "asyncpg/protocol/codecs/array.pyx":232
+ * 
+ *         for d2 in range(dims[1]):
+ *             if ndims == 2:             # <<<<<<<<<<<<<<
+ *                 elem_len = hton.unpack_int32(buf.read(4))
+ *                 if elem_len == -1:
+ */
+      __pyx_t_6 = ((__pyx_v_ndims == 2) != 0);
+      if (__pyx_t_6) {
+
+        /* "asyncpg/protocol/codecs/array.pyx":233
+ *         for d2 in range(dims[1]):
+ *             if ndims == 2:
+ *                 elem_len = hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ *                 if elem_len == -1:
+ *                     elem = None
+ */
+        __pyx_t_7 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_7 == NULL)) __PYX_ERR(20, 233, __pyx_L1_error)
+        __pyx_v_elem_len = __pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_7);
+
+        /* "asyncpg/protocol/codecs/array.pyx":234
+ *             if ndims == 2:
+ *                 elem_len = hton.unpack_int32(buf.read(4))
+ *                 if elem_len == -1:             # <<<<<<<<<<<<<<
+ *                     elem = None
+ *                 else:
+ */
+        __pyx_t_6 = ((__pyx_v_elem_len == -1L) != 0);
+        if (__pyx_t_6) {
+
+          /* "asyncpg/protocol/codecs/array.pyx":235
+ *                 elem_len = hton.unpack_int32(buf.read(4))
+ *                 if elem_len == -1:
+ *                     elem = None             # <<<<<<<<<<<<<<
+ *                 else:
+ *                     elem = decoder(settings,
+ */
+          __Pyx_INCREF(Py_None);
+          __Pyx_XDECREF_SET(__pyx_v_elem, Py_None);
+
+          /* "asyncpg/protocol/codecs/array.pyx":234
+ *             if ndims == 2:
+ *                 elem_len = hton.unpack_int32(buf.read(4))
+ *                 if elem_len == -1:             # <<<<<<<<<<<<<<
+ *                     elem = None
+ *                 else:
+ */
+          goto __pyx_L8;
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":237
+ *                     elem = None
+ *                 else:
+ *                     elem = decoder(settings,             # <<<<<<<<<<<<<<
+ *                                    elem_buf.slice_from(buf, elem_len),
+ *                                    decoder_arg)
+ */
+        /*else*/ {
+
+          /* "asyncpg/protocol/codecs/array.pyx":238
+ *                 else:
+ *                     elem = decoder(settings,
+ *                                    elem_buf.slice_from(buf, elem_len),             # <<<<<<<<<<<<<<
+ *                                    decoder_arg)
+ * 
+ */
+          __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_slice_from(__pyx_v_elem_buf, __pyx_v_buf, __pyx_v_elem_len)); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 238, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_1);
+
+          /* "asyncpg/protocol/codecs/array.pyx":237
+ *                     elem = None
+ *                 else:
+ *                     elem = decoder(settings,             # <<<<<<<<<<<<<<
+ *                                    elem_buf.slice_from(buf, elem_len),
+ *                                    decoder_arg)
+ */
+          __pyx_t_8 = __pyx_v_decoder(__pyx_v_settings, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *)__pyx_t_1), __pyx_v_decoder_arg); if (unlikely(!__pyx_t_8)) __PYX_ERR(20, 237, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_8);
+          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+          __Pyx_XDECREF_SET(__pyx_v_elem, __pyx_t_8);
+          __pyx_t_8 = 0;
+        }
+        __pyx_L8:;
+
+        /* "asyncpg/protocol/codecs/array.pyx":241
+ *                                    decoder_arg)
+ * 
+ *                 cpython.Py_INCREF(elem)             # <<<<<<<<<<<<<<
+ *                 cpython.PyList_SET_ITEM(stride1, d2, elem)
+ * 
+ */
+        Py_INCREF(__pyx_v_elem);
+
+        /* "asyncpg/protocol/codecs/array.pyx":242
+ * 
+ *                 cpython.Py_INCREF(elem)
+ *                 cpython.PyList_SET_ITEM(stride1, d2, elem)             # <<<<<<<<<<<<<<
+ * 
+ *             else:
+ */
+        PyList_SET_ITEM(__pyx_v_stride1, __pyx_v_d2, __pyx_v_elem);
+
+        /* "asyncpg/protocol/codecs/array.pyx":232
+ * 
+ *         for d2 in range(dims[1]):
+ *             if ndims == 2:             # <<<<<<<<<<<<<<
+ *                 elem_len = hton.unpack_int32(buf.read(4))
+ *                 if elem_len == -1:
+ */
+        goto __pyx_L7;
+      }
+
+      /* "asyncpg/protocol/codecs/array.pyx":245
+ * 
+ *             else:
+ *                 stride2 = cpython.PyList_New(dims[2])             # <<<<<<<<<<<<<<
+ *                 cpython.Py_INCREF(stride2)
+ *                 cpython.PyList_SET_ITEM(stride1, d2, stride2)
+ */
+      /*else*/ {
+        __pyx_t_8 = PyList_New((__pyx_v_dims[2])); if (unlikely(!__pyx_t_8)) __PYX_ERR(20, 245, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_8);
+        __Pyx_XDECREF_SET(__pyx_v_stride2, ((PyObject*)__pyx_t_8));
+        __pyx_t_8 = 0;
+
+        /* "asyncpg/protocol/codecs/array.pyx":246
+ *             else:
+ *                 stride2 = cpython.PyList_New(dims[2])
+ *                 cpython.Py_INCREF(stride2)             # <<<<<<<<<<<<<<
+ *                 cpython.PyList_SET_ITEM(stride1, d2, stride2)
+ * 
+ */
+        Py_INCREF(__pyx_v_stride2);
+
+        /* "asyncpg/protocol/codecs/array.pyx":247
+ *                 stride2 = cpython.PyList_New(dims[2])
+ *                 cpython.Py_INCREF(stride2)
+ *                 cpython.PyList_SET_ITEM(stride1, d2, stride2)             # <<<<<<<<<<<<<<
+ * 
+ *                 for d3 in range(dims[2]):
+ */
+        PyList_SET_ITEM(__pyx_v_stride1, __pyx_v_d2, __pyx_v_stride2);
+
+        /* "asyncpg/protocol/codecs/array.pyx":249
+ *                 cpython.PyList_SET_ITEM(stride1, d2, stride2)
+ * 
+ *                 for d3 in range(dims[2]):             # <<<<<<<<<<<<<<
+ *                     if ndims == 3:
+ *                         elem_len = hton.unpack_int32(buf.read(4))
+ */
+        __pyx_t_9 = (__pyx_v_dims[2]);
+        for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
+          __pyx_v_d3 = __pyx_t_10;
+
+          /* "asyncpg/protocol/codecs/array.pyx":250
+ * 
+ *                 for d3 in range(dims[2]):
+ *                     if ndims == 3:             # <<<<<<<<<<<<<<
+ *                         elem_len = hton.unpack_int32(buf.read(4))
+ *                         if elem_len == -1:
+ */
+          __pyx_t_6 = ((__pyx_v_ndims == 3) != 0);
+          if (__pyx_t_6) {
+
+            /* "asyncpg/protocol/codecs/array.pyx":251
+ *                 for d3 in range(dims[2]):
+ *                     if ndims == 3:
+ *                         elem_len = hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ *                         if elem_len == -1:
+ *                             elem = None
+ */
+            __pyx_t_7 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_7 == NULL)) __PYX_ERR(20, 251, __pyx_L1_error)
+            __pyx_v_elem_len = __pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_7);
+
+            /* "asyncpg/protocol/codecs/array.pyx":252
+ *                     if ndims == 3:
+ *                         elem_len = hton.unpack_int32(buf.read(4))
+ *                         if elem_len == -1:             # <<<<<<<<<<<<<<
+ *                             elem = None
+ *                         else:
+ */
+            __pyx_t_6 = ((__pyx_v_elem_len == -1L) != 0);
+            if (__pyx_t_6) {
+
+              /* "asyncpg/protocol/codecs/array.pyx":253
+ *                         elem_len = hton.unpack_int32(buf.read(4))
+ *                         if elem_len == -1:
+ *                             elem = None             # <<<<<<<<<<<<<<
+ *                         else:
+ *                             elem = decoder(settings,
+ */
+              __Pyx_INCREF(Py_None);
+              __Pyx_XDECREF_SET(__pyx_v_elem, Py_None);
+
+              /* "asyncpg/protocol/codecs/array.pyx":252
+ *                     if ndims == 3:
+ *                         elem_len = hton.unpack_int32(buf.read(4))
+ *                         if elem_len == -1:             # <<<<<<<<<<<<<<
+ *                             elem = None
+ *                         else:
+ */
+              goto __pyx_L12;
+            }
+
+            /* "asyncpg/protocol/codecs/array.pyx":255
+ *                             elem = None
+ *                         else:
+ *                             elem = decoder(settings,             # <<<<<<<<<<<<<<
+ *                                            elem_buf.slice_from(buf, elem_len),
+ *                                            decoder_arg)
+ */
+            /*else*/ {
+
+              /* "asyncpg/protocol/codecs/array.pyx":256
+ *                         else:
+ *                             elem = decoder(settings,
+ *                                            elem_buf.slice_from(buf, elem_len),             # <<<<<<<<<<<<<<
+ *                                            decoder_arg)
+ * 
+ */
+              __pyx_t_8 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_slice_from(__pyx_v_elem_buf, __pyx_v_buf, __pyx_v_elem_len)); if (unlikely(!__pyx_t_8)) __PYX_ERR(20, 256, __pyx_L1_error)
+              __Pyx_GOTREF(__pyx_t_8);
+
+              /* "asyncpg/protocol/codecs/array.pyx":255
+ *                             elem = None
+ *                         else:
+ *                             elem = decoder(settings,             # <<<<<<<<<<<<<<
+ *                                            elem_buf.slice_from(buf, elem_len),
+ *                                            decoder_arg)
+ */
+              __pyx_t_1 = __pyx_v_decoder(__pyx_v_settings, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *)__pyx_t_8), __pyx_v_decoder_arg); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 255, __pyx_L1_error)
+              __Pyx_GOTREF(__pyx_t_1);
+              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+              __Pyx_XDECREF_SET(__pyx_v_elem, __pyx_t_1);
+              __pyx_t_1 = 0;
+            }
+            __pyx_L12:;
+
+            /* "asyncpg/protocol/codecs/array.pyx":259
+ *                                            decoder_arg)
+ * 
+ *                         cpython.Py_INCREF(elem)             # <<<<<<<<<<<<<<
+ *                         cpython.PyList_SET_ITEM(stride2, d3, elem)
+ * 
+ */
+            Py_INCREF(__pyx_v_elem);
+
+            /* "asyncpg/protocol/codecs/array.pyx":260
+ * 
+ *                         cpython.Py_INCREF(elem)
+ *                         cpython.PyList_SET_ITEM(stride2, d3, elem)             # <<<<<<<<<<<<<<
+ * 
+ *                     else:
+ */
+            PyList_SET_ITEM(__pyx_v_stride2, __pyx_v_d3, __pyx_v_elem);
+
+            /* "asyncpg/protocol/codecs/array.pyx":250
+ * 
+ *                 for d3 in range(dims[2]):
+ *                     if ndims == 3:             # <<<<<<<<<<<<<<
+ *                         elem_len = hton.unpack_int32(buf.read(4))
+ *                         if elem_len == -1:
+ */
+            goto __pyx_L11;
+          }
+
+          /* "asyncpg/protocol/codecs/array.pyx":263
+ * 
+ *                     else:
+ *                         stride3 = cpython.PyList_New(dims[3])             # <<<<<<<<<<<<<<
+ *                         cpython.Py_INCREF(stride3)
+ *                         cpython.PyList_SET_ITEM(stride2, d3, stride3)
+ */
+          /*else*/ {
+            __pyx_t_1 = PyList_New((__pyx_v_dims[3])); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 263, __pyx_L1_error)
+            __Pyx_GOTREF(__pyx_t_1);
+            __Pyx_XDECREF_SET(__pyx_v_stride3, ((PyObject*)__pyx_t_1));
+            __pyx_t_1 = 0;
+
+            /* "asyncpg/protocol/codecs/array.pyx":264
+ *                     else:
+ *                         stride3 = cpython.PyList_New(dims[3])
+ *                         cpython.Py_INCREF(stride3)             # <<<<<<<<<<<<<<
+ *                         cpython.PyList_SET_ITEM(stride2, d3, stride3)
+ * 
+ */
+            Py_INCREF(__pyx_v_stride3);
+
+            /* "asyncpg/protocol/codecs/array.pyx":265
+ *                         stride3 = cpython.PyList_New(dims[3])
+ *                         cpython.Py_INCREF(stride3)
+ *                         cpython.PyList_SET_ITEM(stride2, d3, stride3)             # <<<<<<<<<<<<<<
+ * 
+ *                         for d4 in range(dims[3]):
+ */
+            PyList_SET_ITEM(__pyx_v_stride2, __pyx_v_d3, __pyx_v_stride3);
+
+            /* "asyncpg/protocol/codecs/array.pyx":267
+ *                         cpython.PyList_SET_ITEM(stride2, d3, stride3)
+ * 
+ *                         for d4 in range(dims[3]):             # <<<<<<<<<<<<<<
+ *                             if ndims == 4:
+ *                                 elem_len = hton.unpack_int32(buf.read(4))
+ */
+            __pyx_t_11 = (__pyx_v_dims[3]);
+            for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
+              __pyx_v_d4 = __pyx_t_12;
+
+              /* "asyncpg/protocol/codecs/array.pyx":268
+ * 
+ *                         for d4 in range(dims[3]):
+ *                             if ndims == 4:             # <<<<<<<<<<<<<<
+ *                                 elem_len = hton.unpack_int32(buf.read(4))
+ *                                 if elem_len == -1:
+ */
+              __pyx_t_6 = ((__pyx_v_ndims == 4) != 0);
+              if (__pyx_t_6) {
+
+                /* "asyncpg/protocol/codecs/array.pyx":269
+ *                         for d4 in range(dims[3]):
+ *                             if ndims == 4:
+ *                                 elem_len = hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ *                                 if elem_len == -1:
+ *                                     elem = None
+ */
+                __pyx_t_7 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_7 == NULL)) __PYX_ERR(20, 269, __pyx_L1_error)
+                __pyx_v_elem_len = __pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_7);
+
+                /* "asyncpg/protocol/codecs/array.pyx":270
+ *                             if ndims == 4:
+ *                                 elem_len = hton.unpack_int32(buf.read(4))
+ *                                 if elem_len == -1:             # <<<<<<<<<<<<<<
+ *                                     elem = None
+ *                                 else:
+ */
+                __pyx_t_6 = ((__pyx_v_elem_len == -1L) != 0);
+                if (__pyx_t_6) {
+
+                  /* "asyncpg/protocol/codecs/array.pyx":271
+ *                                 elem_len = hton.unpack_int32(buf.read(4))
+ *                                 if elem_len == -1:
+ *                                     elem = None             # <<<<<<<<<<<<<<
+ *                                 else:
+ *                                     elem = decoder(settings,
+ */
+                  __Pyx_INCREF(Py_None);
+                  __Pyx_XDECREF_SET(__pyx_v_elem, Py_None);
+
+                  /* "asyncpg/protocol/codecs/array.pyx":270
+ *                             if ndims == 4:
+ *                                 elem_len = hton.unpack_int32(buf.read(4))
+ *                                 if elem_len == -1:             # <<<<<<<<<<<<<<
+ *                                     elem = None
+ *                                 else:
+ */
+                  goto __pyx_L16;
+                }
+
+                /* "asyncpg/protocol/codecs/array.pyx":273
+ *                                     elem = None
+ *                                 else:
+ *                                     elem = decoder(settings,             # <<<<<<<<<<<<<<
+ *                                                    elem_buf.slice_from(buf, elem_len),
+ *                                                    decoder_arg)
+ */
+                /*else*/ {
+
+                  /* "asyncpg/protocol/codecs/array.pyx":274
+ *                                 else:
+ *                                     elem = decoder(settings,
+ *                                                    elem_buf.slice_from(buf, elem_len),             # <<<<<<<<<<<<<<
+ *                                                    decoder_arg)
+ * 
+ */
+                  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_slice_from(__pyx_v_elem_buf, __pyx_v_buf, __pyx_v_elem_len)); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 274, __pyx_L1_error)
+                  __Pyx_GOTREF(__pyx_t_1);
+
+                  /* "asyncpg/protocol/codecs/array.pyx":273
+ *                                     elem = None
+ *                                 else:
+ *                                     elem = decoder(settings,             # <<<<<<<<<<<<<<
+ *                                                    elem_buf.slice_from(buf, elem_len),
+ *                                                    decoder_arg)
+ */
+                  __pyx_t_8 = __pyx_v_decoder(__pyx_v_settings, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *)__pyx_t_1), __pyx_v_decoder_arg); if (unlikely(!__pyx_t_8)) __PYX_ERR(20, 273, __pyx_L1_error)
+                  __Pyx_GOTREF(__pyx_t_8);
+                  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+                  __Pyx_XDECREF_SET(__pyx_v_elem, __pyx_t_8);
+                  __pyx_t_8 = 0;
+                }
+                __pyx_L16:;
+
+                /* "asyncpg/protocol/codecs/array.pyx":277
+ *                                                    decoder_arg)
+ * 
+ *                                 cpython.Py_INCREF(elem)             # <<<<<<<<<<<<<<
+ *                                 cpython.PyList_SET_ITEM(stride3, d4, elem)
+ * 
+ */
+                Py_INCREF(__pyx_v_elem);
+
+                /* "asyncpg/protocol/codecs/array.pyx":278
+ * 
+ *                                 cpython.Py_INCREF(elem)
+ *                                 cpython.PyList_SET_ITEM(stride3, d4, elem)             # <<<<<<<<<<<<<<
+ * 
+ *                             else:
+ */
+                PyList_SET_ITEM(__pyx_v_stride3, __pyx_v_d4, __pyx_v_elem);
+
+                /* "asyncpg/protocol/codecs/array.pyx":268
+ * 
+ *                         for d4 in range(dims[3]):
+ *                             if ndims == 4:             # <<<<<<<<<<<<<<
+ *                                 elem_len = hton.unpack_int32(buf.read(4))
+ *                                 if elem_len == -1:
+ */
+                goto __pyx_L15;
+              }
+
+              /* "asyncpg/protocol/codecs/array.pyx":281
+ * 
+ *                             else:
+ *                                 stride4 = cpython.PyList_New(dims[4])             # <<<<<<<<<<<<<<
+ *                                 cpython.Py_INCREF(stride4)
+ *                                 cpython.PyList_SET_ITEM(stride3, d4, stride4)
+ */
+              /*else*/ {
+                __pyx_t_8 = PyList_New((__pyx_v_dims[4])); if (unlikely(!__pyx_t_8)) __PYX_ERR(20, 281, __pyx_L1_error)
+                __Pyx_GOTREF(__pyx_t_8);
+                __Pyx_XDECREF_SET(__pyx_v_stride4, ((PyObject*)__pyx_t_8));
+                __pyx_t_8 = 0;
+
+                /* "asyncpg/protocol/codecs/array.pyx":282
+ *                             else:
+ *                                 stride4 = cpython.PyList_New(dims[4])
+ *                                 cpython.Py_INCREF(stride4)             # <<<<<<<<<<<<<<
+ *                                 cpython.PyList_SET_ITEM(stride3, d4, stride4)
+ * 
+ */
+                Py_INCREF(__pyx_v_stride4);
+
+                /* "asyncpg/protocol/codecs/array.pyx":283
+ *                                 stride4 = cpython.PyList_New(dims[4])
+ *                                 cpython.Py_INCREF(stride4)
+ *                                 cpython.PyList_SET_ITEM(stride3, d4, stride4)             # <<<<<<<<<<<<<<
+ * 
+ *                                 for d5 in range(dims[4]):
+ */
+                PyList_SET_ITEM(__pyx_v_stride3, __pyx_v_d4, __pyx_v_stride4);
+
+                /* "asyncpg/protocol/codecs/array.pyx":285
+ *                                 cpython.PyList_SET_ITEM(stride3, d4, stride4)
+ * 
+ *                                 for d5 in range(dims[4]):             # <<<<<<<<<<<<<<
+ *                                     if ndims == 5:
+ *                                         elem_len = hton.unpack_int32(buf.read(4))
+ */
+                __pyx_t_13 = (__pyx_v_dims[4]);
+                for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) {
+                  __pyx_v_d5 = __pyx_t_14;
+
+                  /* "asyncpg/protocol/codecs/array.pyx":286
+ * 
+ *                                 for d5 in range(dims[4]):
+ *                                     if ndims == 5:             # <<<<<<<<<<<<<<
+ *                                         elem_len = hton.unpack_int32(buf.read(4))
+ *                                         if elem_len == -1:
+ */
+                  __pyx_t_6 = ((__pyx_v_ndims == 5) != 0);
+                  if (__pyx_t_6) {
+
+                    /* "asyncpg/protocol/codecs/array.pyx":287
+ *                                 for d5 in range(dims[4]):
+ *                                     if ndims == 5:
+ *                                         elem_len = hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ *                                         if elem_len == -1:
+ *                                             elem = None
+ */
+                    __pyx_t_7 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_7 == NULL)) __PYX_ERR(20, 287, __pyx_L1_error)
+                    __pyx_v_elem_len = __pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_7);
+
+                    /* "asyncpg/protocol/codecs/array.pyx":288
+ *                                     if ndims == 5:
+ *                                         elem_len = hton.unpack_int32(buf.read(4))
+ *                                         if elem_len == -1:             # <<<<<<<<<<<<<<
+ *                                             elem = None
+ *                                         else:
+ */
+                    __pyx_t_6 = ((__pyx_v_elem_len == -1L) != 0);
+                    if (__pyx_t_6) {
+
+                      /* "asyncpg/protocol/codecs/array.pyx":289
+ *                                         elem_len = hton.unpack_int32(buf.read(4))
+ *                                         if elem_len == -1:
+ *                                             elem = None             # <<<<<<<<<<<<<<
+ *                                         else:
+ *                                             elem = decoder(settings,
+ */
+                      __Pyx_INCREF(Py_None);
+                      __Pyx_XDECREF_SET(__pyx_v_elem, Py_None);
+
+                      /* "asyncpg/protocol/codecs/array.pyx":288
+ *                                     if ndims == 5:
+ *                                         elem_len = hton.unpack_int32(buf.read(4))
+ *                                         if elem_len == -1:             # <<<<<<<<<<<<<<
+ *                                             elem = None
+ *                                         else:
+ */
+                      goto __pyx_L20;
+                    }
+
+                    /* "asyncpg/protocol/codecs/array.pyx":291
+ *                                             elem = None
+ *                                         else:
+ *                                             elem = decoder(settings,             # <<<<<<<<<<<<<<
+ *                                                            elem_buf.slice_from(buf, elem_len),
+ *                                                            decoder_arg)
+ */
+                    /*else*/ {
+
+                      /* "asyncpg/protocol/codecs/array.pyx":292
+ *                                         else:
+ *                                             elem = decoder(settings,
+ *                                                            elem_buf.slice_from(buf, elem_len),             # <<<<<<<<<<<<<<
+ *                                                            decoder_arg)
+ * 
+ */
+                      __pyx_t_8 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_slice_from(__pyx_v_elem_buf, __pyx_v_buf, __pyx_v_elem_len)); if (unlikely(!__pyx_t_8)) __PYX_ERR(20, 292, __pyx_L1_error)
+                      __Pyx_GOTREF(__pyx_t_8);
+
+                      /* "asyncpg/protocol/codecs/array.pyx":291
+ *                                             elem = None
+ *                                         else:
+ *                                             elem = decoder(settings,             # <<<<<<<<<<<<<<
+ *                                                            elem_buf.slice_from(buf, elem_len),
+ *                                                            decoder_arg)
+ */
+                      __pyx_t_1 = __pyx_v_decoder(__pyx_v_settings, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *)__pyx_t_8), __pyx_v_decoder_arg); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 291, __pyx_L1_error)
+                      __Pyx_GOTREF(__pyx_t_1);
+                      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+                      __Pyx_XDECREF_SET(__pyx_v_elem, __pyx_t_1);
+                      __pyx_t_1 = 0;
+                    }
+                    __pyx_L20:;
+
+                    /* "asyncpg/protocol/codecs/array.pyx":295
+ *                                                            decoder_arg)
+ * 
+ *                                         cpython.Py_INCREF(elem)             # <<<<<<<<<<<<<<
+ *                                         cpython.PyList_SET_ITEM(stride4, d5, elem)
+ * 
+ */
+                    Py_INCREF(__pyx_v_elem);
+
+                    /* "asyncpg/protocol/codecs/array.pyx":296
+ * 
+ *                                         cpython.Py_INCREF(elem)
+ *                                         cpython.PyList_SET_ITEM(stride4, d5, elem)             # <<<<<<<<<<<<<<
+ * 
+ *                                     else:
+ */
+                    PyList_SET_ITEM(__pyx_v_stride4, __pyx_v_d5, __pyx_v_elem);
+
+                    /* "asyncpg/protocol/codecs/array.pyx":286
+ * 
+ *                                 for d5 in range(dims[4]):
+ *                                     if ndims == 5:             # <<<<<<<<<<<<<<
+ *                                         elem_len = hton.unpack_int32(buf.read(4))
+ *                                         if elem_len == -1:
+ */
+                    goto __pyx_L19;
+                  }
+
+                  /* "asyncpg/protocol/codecs/array.pyx":299
+ * 
+ *                                     else:
+ *                                         stride5 = cpython.PyList_New(dims[5])             # <<<<<<<<<<<<<<
+ *                                         cpython.Py_INCREF(stride5)
+ *                                         cpython.PyList_SET_ITEM(stride4, d5, stride5)
+ */
+                  /*else*/ {
+                    __pyx_t_1 = PyList_New((__pyx_v_dims[5])); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 299, __pyx_L1_error)
+                    __Pyx_GOTREF(__pyx_t_1);
+                    __Pyx_XDECREF_SET(__pyx_v_stride5, ((PyObject*)__pyx_t_1));
+                    __pyx_t_1 = 0;
+
+                    /* "asyncpg/protocol/codecs/array.pyx":300
+ *                                     else:
+ *                                         stride5 = cpython.PyList_New(dims[5])
+ *                                         cpython.Py_INCREF(stride5)             # <<<<<<<<<<<<<<
+ *                                         cpython.PyList_SET_ITEM(stride4, d5, stride5)
+ * 
+ */
+                    Py_INCREF(__pyx_v_stride5);
+
+                    /* "asyncpg/protocol/codecs/array.pyx":301
+ *                                         stride5 = cpython.PyList_New(dims[5])
+ *                                         cpython.Py_INCREF(stride5)
+ *                                         cpython.PyList_SET_ITEM(stride4, d5, stride5)             # <<<<<<<<<<<<<<
+ * 
+ *                                         for d6 in range(dims[5]):
+ */
+                    PyList_SET_ITEM(__pyx_v_stride4, __pyx_v_d5, __pyx_v_stride5);
+
+                    /* "asyncpg/protocol/codecs/array.pyx":303
+ *                                         cpython.PyList_SET_ITEM(stride4, d5, stride5)
+ * 
+ *                                         for d6 in range(dims[5]):             # <<<<<<<<<<<<<<
+ *                                             elem_len = hton.unpack_int32(buf.read(4))
+ *                                             if elem_len == -1:
+ */
+                    __pyx_t_15 = (__pyx_v_dims[5]);
+                    for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) {
+                      __pyx_v_d6 = __pyx_t_16;
+
+                      /* "asyncpg/protocol/codecs/array.pyx":304
+ * 
+ *                                         for d6 in range(dims[5]):
+ *                                             elem_len = hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ *                                             if elem_len == -1:
+ *                                                 elem = None
+ */
+                      __pyx_t_7 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_7 == NULL)) __PYX_ERR(20, 304, __pyx_L1_error)
+                      __pyx_v_elem_len = __pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_7);
+
+                      /* "asyncpg/protocol/codecs/array.pyx":305
+ *                                         for d6 in range(dims[5]):
+ *                                             elem_len = hton.unpack_int32(buf.read(4))
+ *                                             if elem_len == -1:             # <<<<<<<<<<<<<<
+ *                                                 elem = None
+ *                                             else:
+ */
+                      __pyx_t_6 = ((__pyx_v_elem_len == -1L) != 0);
+                      if (__pyx_t_6) {
+
+                        /* "asyncpg/protocol/codecs/array.pyx":306
+ *                                             elem_len = hton.unpack_int32(buf.read(4))
+ *                                             if elem_len == -1:
+ *                                                 elem = None             # <<<<<<<<<<<<<<
+ *                                             else:
+ *                                                 elem = decoder(settings,
+ */
+                        __Pyx_INCREF(Py_None);
+                        __Pyx_XDECREF_SET(__pyx_v_elem, Py_None);
+
+                        /* "asyncpg/protocol/codecs/array.pyx":305
+ *                                         for d6 in range(dims[5]):
+ *                                             elem_len = hton.unpack_int32(buf.read(4))
+ *                                             if elem_len == -1:             # <<<<<<<<<<<<<<
+ *                                                 elem = None
+ *                                             else:
+ */
+                        goto __pyx_L23;
+                      }
+
+                      /* "asyncpg/protocol/codecs/array.pyx":308
+ *                                                 elem = None
+ *                                             else:
+ *                                                 elem = decoder(settings,             # <<<<<<<<<<<<<<
+ *                                                                elem_buf.slice_from(buf, elem_len),
+ *                                                                decoder_arg)
+ */
+                      /*else*/ {
+
+                        /* "asyncpg/protocol/codecs/array.pyx":309
+ *                                             else:
+ *                                                 elem = decoder(settings,
+ *                                                                elem_buf.slice_from(buf, elem_len),             # <<<<<<<<<<<<<<
+ *                                                                decoder_arg)
+ * 
+ */
+                        __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_slice_from(__pyx_v_elem_buf, __pyx_v_buf, __pyx_v_elem_len)); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 309, __pyx_L1_error)
+                        __Pyx_GOTREF(__pyx_t_1);
+
+                        /* "asyncpg/protocol/codecs/array.pyx":308
+ *                                                 elem = None
+ *                                             else:
+ *                                                 elem = decoder(settings,             # <<<<<<<<<<<<<<
+ *                                                                elem_buf.slice_from(buf, elem_len),
+ *                                                                decoder_arg)
+ */
+                        __pyx_t_8 = __pyx_v_decoder(__pyx_v_settings, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *)__pyx_t_1), __pyx_v_decoder_arg); if (unlikely(!__pyx_t_8)) __PYX_ERR(20, 308, __pyx_L1_error)
+                        __Pyx_GOTREF(__pyx_t_8);
+                        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+                        __Pyx_XDECREF_SET(__pyx_v_elem, __pyx_t_8);
+                        __pyx_t_8 = 0;
+                      }
+                      __pyx_L23:;
+
+                      /* "asyncpg/protocol/codecs/array.pyx":312
+ *                                                                decoder_arg)
+ * 
+ *                                             cpython.Py_INCREF(elem)             # <<<<<<<<<<<<<<
+ *                                             cpython.PyList_SET_ITEM(stride5, d6, elem)
+ * 
+ */
+                      Py_INCREF(__pyx_v_elem);
+
+                      /* "asyncpg/protocol/codecs/array.pyx":313
+ * 
+ *                                             cpython.Py_INCREF(elem)
+ *                                             cpython.PyList_SET_ITEM(stride5, d6, elem)             # <<<<<<<<<<<<<<
+ * 
+ *     return result
+ */
+                      PyList_SET_ITEM(__pyx_v_stride5, __pyx_v_d6, __pyx_v_elem);
+                    }
+                  }
+                  __pyx_L19:;
+                }
+              }
+              __pyx_L15:;
+            }
+          }
+          __pyx_L11:;
+        }
+      }
+      __pyx_L7:;
+    }
+  }
+
+  /* "asyncpg/protocol/codecs/array.pyx":315
+ *                                             cpython.PyList_SET_ITEM(stride5, d6, elem)
+ * 
+ *     return result             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_result);
+  __pyx_r = __pyx_v_result;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":206
+ * 
+ * 
+ * cdef inline _nested_array_decode(ConnectionSettings settings,             # <<<<<<<<<<<<<<
+ *                                  FastReadBuffer buf,
+ *                                  decode_func_ex decoder,
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol._nested_array_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_result);
+  __Pyx_XDECREF(__pyx_v_elem);
+  __Pyx_XDECREF(__pyx_v_stride1);
+  __Pyx_XDECREF(__pyx_v_stride2);
+  __Pyx_XDECREF(__pyx_v_stride3);
+  __Pyx_XDECREF(__pyx_v_stride4);
+  __Pyx_XDECREF(__pyx_v_stride5);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/array.pyx":318
+ * 
+ * 
+ * cdef textarray_decode(ConnectionSettings settings, FastReadBuffer buf,             # <<<<<<<<<<<<<<
+ *                       decode_func_ex decoder, const void *decoder_arg,
+ *                       Py_UCS4 typdelim):
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_textarray_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf, __pyx_t_7asyncpg_8protocol_8protocol_decode_func_ex __pyx_v_decoder, void const *__pyx_v_decoder_arg, Py_UCS4 __pyx_v_typdelim) {
+  Py_UCS4 *__pyx_v_array_text;
+  PyObject *__pyx_v_s = 0;
+  PyObject *__pyx_v_e = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  int __pyx_t_5;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  PyObject *__pyx_t_10 = NULL;
+  PyObject *__pyx_t_11 = NULL;
+  PyObject *__pyx_t_12 = NULL;
+  int __pyx_t_13;
+  char const *__pyx_t_14;
+  PyObject *__pyx_t_15 = NULL;
+  PyObject *__pyx_t_16 = NULL;
+  PyObject *__pyx_t_17 = NULL;
+  PyObject *__pyx_t_18 = NULL;
+  PyObject *__pyx_t_19 = NULL;
+  PyObject *__pyx_t_20 = NULL;
+  char const *__pyx_t_21;
+  __Pyx_RefNannySetupContext("textarray_decode", 0);
+
+  /* "asyncpg/protocol/codecs/array.pyx":327
+ *     # Make a copy of array data since we will be mutating it for
+ *     # the purposes of element decoding.
+ *     s = text_decode(settings, buf)             # <<<<<<<<<<<<<<
+ *     array_text = PyUnicode_AsUCS4Copy(s)
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_text_decode(__pyx_v_settings, __pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 327, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(20, 327, __pyx_L1_error)
+  __pyx_v_s = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":328
+ *     # the purposes of element decoding.
+ *     s = text_decode(settings, buf)
+ *     array_text = PyUnicode_AsUCS4Copy(s)             # <<<<<<<<<<<<<<
+ * 
+ *     try:
+ */
+  __pyx_v_array_text = PyUnicode_AsUCS4Copy(__pyx_v_s);
+
+  /* "asyncpg/protocol/codecs/array.pyx":330
+ *     array_text = PyUnicode_AsUCS4Copy(s)
+ * 
+ *     try:             # <<<<<<<<<<<<<<
+ *         return _textarray_decode(
+ *             settings, array_text, decoder, decoder_arg, typdelim)
+ */
+  /*try:*/ {
+    {
+      __Pyx_PyThreadState_declare
+      __Pyx_PyThreadState_assign
+      __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
+      __Pyx_XGOTREF(__pyx_t_2);
+      __Pyx_XGOTREF(__pyx_t_3);
+      __Pyx_XGOTREF(__pyx_t_4);
+      /*try:*/ {
+
+        /* "asyncpg/protocol/codecs/array.pyx":331
+ * 
+ *     try:
+ *         return _textarray_decode(             # <<<<<<<<<<<<<<
+ *             settings, array_text, decoder, decoder_arg, typdelim)
+ *     except ValueError as e:
+ */
+        __Pyx_XDECREF(__pyx_r);
+
+        /* "asyncpg/protocol/codecs/array.pyx":332
+ *     try:
+ *         return _textarray_decode(
+ *             settings, array_text, decoder, decoder_arg, typdelim)             # <<<<<<<<<<<<<<
+ *     except ValueError as e:
+ *         raise ValueError(
+ */
+        __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol__textarray_decode(__pyx_v_settings, __pyx_v_array_text, __pyx_v_decoder, __pyx_v_decoder_arg, __pyx_v_typdelim); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 331, __pyx_L6_error)
+        __Pyx_GOTREF(__pyx_t_1);
+        __pyx_r = __pyx_t_1;
+        __pyx_t_1 = 0;
+        goto __pyx_L10_try_return;
+
+        /* "asyncpg/protocol/codecs/array.pyx":330
+ *     array_text = PyUnicode_AsUCS4Copy(s)
+ * 
+ *     try:             # <<<<<<<<<<<<<<
+ *         return _textarray_decode(
+ *             settings, array_text, decoder, decoder_arg, typdelim)
+ */
+      }
+      __pyx_L6_error:;
+      __Pyx_PyThreadState_assign
+      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+      /* "asyncpg/protocol/codecs/array.pyx":333
+ *         return _textarray_decode(
+ *             settings, array_text, decoder, decoder_arg, typdelim)
+ *     except ValueError as e:             # <<<<<<<<<<<<<<
+ *         raise ValueError(
+ *             'malformed array literal {!r}: {}'.format(s, e.args[0]))
+ */
+      __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError);
+      if (__pyx_t_5) {
+        __Pyx_AddTraceback("asyncpg.protocol.protocol.textarray_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+        if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(20, 333, __pyx_L8_except_error)
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_GOTREF(__pyx_t_6);
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_INCREF(__pyx_t_6);
+        __pyx_v_e = __pyx_t_6;
+        /*try:*/ {
+
+          /* "asyncpg/protocol/codecs/array.pyx":335
+ *     except ValueError as e:
+ *         raise ValueError(
+ *             'malformed array literal {!r}: {}'.format(s, e.args[0]))             # <<<<<<<<<<<<<<
+ *     finally:
+ *         PyMem_Free(array_text)
+ */
+          __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_malformed_array_literal_r, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(20, 335, __pyx_L19_error)
+          __Pyx_GOTREF(__pyx_t_9);
+          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_e, __pyx_n_s_args); if (unlikely(!__pyx_t_10)) __PYX_ERR(20, 335, __pyx_L19_error)
+          __Pyx_GOTREF(__pyx_t_10);
+          __pyx_t_11 = __Pyx_GetItemInt(__pyx_t_10, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(20, 335, __pyx_L19_error)
+          __Pyx_GOTREF(__pyx_t_11);
+          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+          __pyx_t_10 = NULL;
+          __pyx_t_5 = 0;
+          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
+            __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
+            if (likely(__pyx_t_10)) {
+              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
+              __Pyx_INCREF(__pyx_t_10);
+              __Pyx_INCREF(function);
+              __Pyx_DECREF_SET(__pyx_t_9, function);
+              __pyx_t_5 = 1;
+            }
+          }
+          #if CYTHON_FAST_PYCALL
+          if (PyFunction_Check(__pyx_t_9)) {
+            PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_s, __pyx_t_11};
+            __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(20, 335, __pyx_L19_error)
+            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
+            __Pyx_GOTREF(__pyx_t_8);
+            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+          } else
+          #endif
+          #if CYTHON_FAST_PYCCALL
+          if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
+            PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_s, __pyx_t_11};
+            __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(20, 335, __pyx_L19_error)
+            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
+            __Pyx_GOTREF(__pyx_t_8);
+            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+          } else
+          #endif
+          {
+            __pyx_t_12 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(20, 335, __pyx_L19_error)
+            __Pyx_GOTREF(__pyx_t_12);
+            if (__pyx_t_10) {
+              __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
+            }
+            __Pyx_INCREF(__pyx_v_s);
+            __Pyx_GIVEREF(__pyx_v_s);
+            PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_5, __pyx_v_s);
+            __Pyx_GIVEREF(__pyx_t_11);
+            PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_5, __pyx_t_11);
+            __pyx_t_11 = 0;
+            __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(20, 335, __pyx_L19_error)
+            __Pyx_GOTREF(__pyx_t_8);
+            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+          }
+          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+
+          /* "asyncpg/protocol/codecs/array.pyx":334
+ *             settings, array_text, decoder, decoder_arg, typdelim)
+ *     except ValueError as e:
+ *         raise ValueError(             # <<<<<<<<<<<<<<
+ *             'malformed array literal {!r}: {}'.format(s, e.args[0]))
+ *     finally:
+ */
+          __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(20, 334, __pyx_L19_error)
+          __Pyx_GOTREF(__pyx_t_9);
+          __Pyx_GIVEREF(__pyx_t_8);
+          PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8);
+          __pyx_t_8 = 0;
+          __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_9, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(20, 334, __pyx_L19_error)
+          __Pyx_GOTREF(__pyx_t_8);
+          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+          __Pyx_Raise(__pyx_t_8, 0, 0, 0);
+          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+          __PYX_ERR(20, 334, __pyx_L19_error)
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":333
+ *         return _textarray_decode(
+ *             settings, array_text, decoder, decoder_arg, typdelim)
+ *     except ValueError as e:             # <<<<<<<<<<<<<<
+ *         raise ValueError(
+ *             'malformed array literal {!r}: {}'.format(s, e.args[0]))
+ */
+        /*finally:*/ {
+          /*exception exit:*/{
+            __Pyx_PyThreadState_declare
+            __pyx_L19_error:;
+            __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
+            __Pyx_PyThreadState_assign
+            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
+            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
+            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
+            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
+            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+            if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20);
+            if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
+            __Pyx_XGOTREF(__pyx_t_15);
+            __Pyx_XGOTREF(__pyx_t_16);
+            __Pyx_XGOTREF(__pyx_t_17);
+            __Pyx_XGOTREF(__pyx_t_18);
+            __Pyx_XGOTREF(__pyx_t_19);
+            __Pyx_XGOTREF(__pyx_t_20);
+            __pyx_t_5 = __pyx_lineno; __pyx_t_13 = __pyx_clineno; __pyx_t_14 = __pyx_filename;
+            {
+              __Pyx_DECREF(__pyx_v_e);
+              __pyx_v_e = NULL;
+            }
+            __Pyx_PyThreadState_assign
+            if (PY_MAJOR_VERSION >= 3) {
+              __Pyx_XGIVEREF(__pyx_t_18);
+              __Pyx_XGIVEREF(__pyx_t_19);
+              __Pyx_XGIVEREF(__pyx_t_20);
+              __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20);
+            }
+            __Pyx_XGIVEREF(__pyx_t_15);
+            __Pyx_XGIVEREF(__pyx_t_16);
+            __Pyx_XGIVEREF(__pyx_t_17);
+            __Pyx_ErrRestore(__pyx_t_15, __pyx_t_16, __pyx_t_17);
+            __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
+            __pyx_lineno = __pyx_t_5; __pyx_clineno = __pyx_t_13; __pyx_filename = __pyx_t_14;
+            goto __pyx_L8_except_error;
+          }
+        }
+      }
+      goto __pyx_L8_except_error;
+      __pyx_L8_except_error:;
+
+      /* "asyncpg/protocol/codecs/array.pyx":330
+ *     array_text = PyUnicode_AsUCS4Copy(s)
+ * 
+ *     try:             # <<<<<<<<<<<<<<
+ *         return _textarray_decode(
+ *             settings, array_text, decoder, decoder_arg, typdelim)
+ */
+      __Pyx_PyThreadState_assign
+      __Pyx_XGIVEREF(__pyx_t_2);
+      __Pyx_XGIVEREF(__pyx_t_3);
+      __Pyx_XGIVEREF(__pyx_t_4);
+      __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
+      goto __pyx_L4_error;
+      __pyx_L10_try_return:;
+      __Pyx_PyThreadState_assign
+      __Pyx_XGIVEREF(__pyx_t_2);
+      __Pyx_XGIVEREF(__pyx_t_3);
+      __Pyx_XGIVEREF(__pyx_t_4);
+      __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
+      goto __pyx_L3_return;
+    }
+  }
+
+  /* "asyncpg/protocol/codecs/array.pyx":337
+ *             'malformed array literal {!r}: {}'.format(s, e.args[0]))
+ *     finally:
+ *         PyMem_Free(array_text)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  /*finally:*/ {
+    /*exception exit:*/{
+      __Pyx_PyThreadState_declare
+      __pyx_L4_error:;
+      __pyx_t_4 = 0; __pyx_t_3 = 0; __pyx_t_2 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0;
+      __Pyx_PyThreadState_assign
+      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
+      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
+      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
+      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_19, &__pyx_t_18);
+      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_4, &__pyx_t_3, &__pyx_t_2) < 0)) __Pyx_ErrFetch(&__pyx_t_4, &__pyx_t_3, &__pyx_t_2);
+      __Pyx_XGOTREF(__pyx_t_4);
+      __Pyx_XGOTREF(__pyx_t_3);
+      __Pyx_XGOTREF(__pyx_t_2);
+      __Pyx_XGOTREF(__pyx_t_20);
+      __Pyx_XGOTREF(__pyx_t_19);
+      __Pyx_XGOTREF(__pyx_t_18);
+      __pyx_t_13 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_21 = __pyx_filename;
+      {
+        PyMem_Free(__pyx_v_array_text);
+      }
+      __Pyx_PyThreadState_assign
+      if (PY_MAJOR_VERSION >= 3) {
+        __Pyx_XGIVEREF(__pyx_t_20);
+        __Pyx_XGIVEREF(__pyx_t_19);
+        __Pyx_XGIVEREF(__pyx_t_18);
+        __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_19, __pyx_t_18);
+      }
+      __Pyx_XGIVEREF(__pyx_t_4);
+      __Pyx_XGIVEREF(__pyx_t_3);
+      __Pyx_XGIVEREF(__pyx_t_2);
+      __Pyx_ErrRestore(__pyx_t_4, __pyx_t_3, __pyx_t_2);
+      __pyx_t_4 = 0; __pyx_t_3 = 0; __pyx_t_2 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0;
+      __pyx_lineno = __pyx_t_13; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_21;
+      goto __pyx_L1_error;
+    }
+    __pyx_L3_return: {
+      __pyx_t_18 = __pyx_r;
+      __pyx_r = 0;
+      PyMem_Free(__pyx_v_array_text);
+      __pyx_r = __pyx_t_18;
+      __pyx_t_18 = 0;
+      goto __pyx_L0;
+    }
+  }
+
+  /* "asyncpg/protocol/codecs/array.pyx":318
+ * 
+ * 
+ * cdef textarray_decode(ConnectionSettings settings, FastReadBuffer buf,             # <<<<<<<<<<<<<<
+ *                       decode_func_ex decoder, const void *decoder_arg,
+ *                       Py_UCS4 typdelim):
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_XDECREF(__pyx_t_11);
+  __Pyx_XDECREF(__pyx_t_12);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.textarray_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_s);
+  __Pyx_XDECREF(__pyx_v_e);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/array.pyx":340
+ * 
+ * 
+ * cdef _textarray_decode(ConnectionSettings settings,             # <<<<<<<<<<<<<<
+ *                        Py_UCS4 *array_text,
+ *                        decode_func_ex decoder,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol__textarray_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, Py_UCS4 *__pyx_v_array_text, __pyx_t_7asyncpg_8protocol_8protocol_decode_func_ex __pyx_v_decoder, void const *__pyx_v_decoder_arg, Py_UCS4 __pyx_v_typdelim) {
+  PyObject *__pyx_v_result = 0;
+  PyObject *__pyx_v_new_stride = 0;
+  Py_UCS4 *__pyx_v_ptr;
+  int32_t __pyx_v_ndims;
+  int32_t __pyx_v_ubound;
+  int32_t __pyx_v_lbound;
+  int32_t __pyx_v_dims[6];
+  int32_t __pyx_v_inferred_dims[6];
+  int32_t __pyx_v_inferred_ndims;
+  void *__pyx_v_strides[6];
+  int32_t __pyx_v_indexes[6];
+  int32_t __pyx_v_nest_level;
+  int32_t __pyx_v_item_level;
+  int __pyx_v_end_of_array;
+  int __pyx_v_end_of_item;
+  int __pyx_v_has_quoting;
+  int __pyx_v_strip_spaces;
+  int __pyx_v_in_quotes;
+  Py_UCS4 *__pyx_v_item_start;
+  Py_UCS4 *__pyx_v_item_ptr;
+  Py_UCS4 *__pyx_v_item_end;
+  int __pyx_v_i;
+  PyObject *__pyx_v_item = 0;
+  PyObject *__pyx_v_item_text = 0;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_item_buf = 0;
+  char *__pyx_v_pg_item_str;
+  Py_ssize_t __pyx_v_pg_item_len;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  int __pyx_t_6;
+  PyObject *__pyx_t_7 = NULL;
+  int32_t __pyx_t_8;
+  PyObject *__pyx_t_9;
+  int __pyx_t_10;
+  long __pyx_t_11;
+  __Pyx_RefNannySetupContext("_textarray_decode", 0);
+
+  /* "asyncpg/protocol/codecs/array.pyx":351
+ *         list new_stride
+ *         Py_UCS4 *ptr
+ *         int32_t ndims = 0             # <<<<<<<<<<<<<<
+ *         int32_t ubound = 0
+ *         int32_t lbound = 0
+ */
+  __pyx_v_ndims = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":352
+ *         Py_UCS4 *ptr
+ *         int32_t ndims = 0
+ *         int32_t ubound = 0             # <<<<<<<<<<<<<<
+ *         int32_t lbound = 0
+ *         int32_t dims[ARRAY_MAXDIM]
+ */
+  __pyx_v_ubound = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":353
+ *         int32_t ndims = 0
+ *         int32_t ubound = 0
+ *         int32_t lbound = 0             # <<<<<<<<<<<<<<
+ *         int32_t dims[ARRAY_MAXDIM]
+ *         int32_t inferred_dims[ARRAY_MAXDIM]
+ */
+  __pyx_v_lbound = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":356
+ *         int32_t dims[ARRAY_MAXDIM]
+ *         int32_t inferred_dims[ARRAY_MAXDIM]
+ *         int32_t inferred_ndims = 0             # <<<<<<<<<<<<<<
+ *         void *strides[ARRAY_MAXDIM]
+ *         int32_t indexes[ARRAY_MAXDIM]
+ */
+  __pyx_v_inferred_ndims = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":359
+ *         void *strides[ARRAY_MAXDIM]
+ *         int32_t indexes[ARRAY_MAXDIM]
+ *         int32_t nest_level = 0             # <<<<<<<<<<<<<<
+ *         int32_t item_level = 0
+ *         bint end_of_array = False
+ */
+  __pyx_v_nest_level = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":360
+ *         int32_t indexes[ARRAY_MAXDIM]
+ *         int32_t nest_level = 0
+ *         int32_t item_level = 0             # <<<<<<<<<<<<<<
+ *         bint end_of_array = False
+ * 
+ */
+  __pyx_v_item_level = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":361
+ *         int32_t nest_level = 0
+ *         int32_t item_level = 0
+ *         bint end_of_array = False             # <<<<<<<<<<<<<<
+ * 
+ *         bint end_of_item = False
+ */
+  __pyx_v_end_of_array = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":363
+ *         bint end_of_array = False
+ * 
+ *         bint end_of_item = False             # <<<<<<<<<<<<<<
+ *         bint has_quoting = False
+ *         bint strip_spaces = False
+ */
+  __pyx_v_end_of_item = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":364
+ * 
+ *         bint end_of_item = False
+ *         bint has_quoting = False             # <<<<<<<<<<<<<<
+ *         bint strip_spaces = False
+ *         bint in_quotes = False
+ */
+  __pyx_v_has_quoting = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":365
+ *         bint end_of_item = False
+ *         bint has_quoting = False
+ *         bint strip_spaces = False             # <<<<<<<<<<<<<<
+ *         bint in_quotes = False
+ *         Py_UCS4 *item_start
+ */
+  __pyx_v_strip_spaces = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":366
+ *         bint has_quoting = False
+ *         bint strip_spaces = False
+ *         bint in_quotes = False             # <<<<<<<<<<<<<<
+ *         Py_UCS4 *item_start
+ *         Py_UCS4 *item_ptr
+ */
+  __pyx_v_in_quotes = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":374
+ *         object item
+ *         str item_text
+ *         FastReadBuffer item_buf = FastReadBuffer.new()             # <<<<<<<<<<<<<<
+ *         char *pg_item_str
+ *         ssize_t pg_item_len
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_new()); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 374, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_item_buf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":378
+ *         ssize_t pg_item_len
+ * 
+ *     ptr = array_text             # <<<<<<<<<<<<<<
+ * 
+ *     while True:
+ */
+  __pyx_v_ptr = __pyx_v_array_text;
+
+  /* "asyncpg/protocol/codecs/array.pyx":380
+ *     ptr = array_text
+ * 
+ *     while True:             # <<<<<<<<<<<<<<
+ *         while apg_ascii_isspace(ptr[0]):
+ *             ptr += 1
+ */
+  while (1) {
+
+    /* "asyncpg/protocol/codecs/array.pyx":381
+ * 
+ *     while True:
+ *         while apg_ascii_isspace(ptr[0]):             # <<<<<<<<<<<<<<
+ *             ptr += 1
+ * 
+ */
+    while (1) {
+      __pyx_t_2 = (__pyx_f_7asyncpg_8protocol_8protocol_apg_ascii_isspace((__pyx_v_ptr[0])) != 0);
+      if (!__pyx_t_2) break;
+
+      /* "asyncpg/protocol/codecs/array.pyx":382
+ *     while True:
+ *         while apg_ascii_isspace(ptr[0]):
+ *             ptr += 1             # <<<<<<<<<<<<<<
+ * 
+ *         if ptr[0] != '[':
+ */
+      __pyx_v_ptr = (__pyx_v_ptr + 1);
+    }
+
+    /* "asyncpg/protocol/codecs/array.pyx":384
+ *             ptr += 1
+ * 
+ *         if ptr[0] != '[':             # <<<<<<<<<<<<<<
+ *             # Finished parsing dimensions spec.
+ *             break
+ */
+    __pyx_t_2 = (((__pyx_v_ptr[0]) != 91) != 0);
+    if (__pyx_t_2) {
+
+      /* "asyncpg/protocol/codecs/array.pyx":386
+ *         if ptr[0] != '[':
+ *             # Finished parsing dimensions spec.
+ *             break             # <<<<<<<<<<<<<<
+ * 
+ *         ptr += 1  # '['
+ */
+      goto __pyx_L4_break;
+
+      /* "asyncpg/protocol/codecs/array.pyx":384
+ *             ptr += 1
+ * 
+ *         if ptr[0] != '[':             # <<<<<<<<<<<<<<
+ *             # Finished parsing dimensions spec.
+ *             break
+ */
+    }
+
+    /* "asyncpg/protocol/codecs/array.pyx":388
+ *             break
+ * 
+ *         ptr += 1  # '['             # <<<<<<<<<<<<<<
+ * 
+ *         if ndims > ARRAY_MAXDIM:
+ */
+    __pyx_v_ptr = (__pyx_v_ptr + 1);
+
+    /* "asyncpg/protocol/codecs/array.pyx":390
+ *         ptr += 1  # '['
+ * 
+ *         if ndims > ARRAY_MAXDIM:             # <<<<<<<<<<<<<<
+ *             raise ValueError(
+ *                 'number of array dimensions ({}) exceed the '
+ */
+    __pyx_t_2 = ((__pyx_v_ndims > 6) != 0);
+    if (__pyx_t_2) {
+
+      /* "asyncpg/protocol/codecs/array.pyx":393
+ *             raise ValueError(
+ *                 'number of array dimensions ({}) exceed the '
+ *                 'maximum expected ({})'.format(ndims, ARRAY_MAXDIM))             # <<<<<<<<<<<<<<
+ * 
+ *         ptr = apg_parse_int32(ptr, &ubound)
+ */
+      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_number_of_array_dimensions_excee, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 393, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_4 = __Pyx_PyInt_From_int32_t(__pyx_v_ndims); if (unlikely(!__pyx_t_4)) __PYX_ERR(20, 393, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_5 = NULL;
+      __pyx_t_6 = 0;
+      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
+        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
+        if (likely(__pyx_t_5)) {
+          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+          __Pyx_INCREF(__pyx_t_5);
+          __Pyx_INCREF(function);
+          __Pyx_DECREF_SET(__pyx_t_3, function);
+          __pyx_t_6 = 1;
+        }
+      }
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_3)) {
+        PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_4, __pyx_int_6};
+        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 393, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
+        PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_4, __pyx_int_6};
+        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 393, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(20, 393, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_7);
+        if (__pyx_t_5) {
+          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
+        }
+        __Pyx_GIVEREF(__pyx_t_4);
+        PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_4);
+        __Pyx_INCREF(__pyx_int_6);
+        __Pyx_GIVEREF(__pyx_int_6);
+        PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_int_6);
+        __pyx_t_4 = 0;
+        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 393, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      }
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+      /* "asyncpg/protocol/codecs/array.pyx":391
+ * 
+ *         if ndims > ARRAY_MAXDIM:
+ *             raise ValueError(             # <<<<<<<<<<<<<<
+ *                 'number of array dimensions ({}) exceed the '
+ *                 'maximum expected ({})'.format(ndims, ARRAY_MAXDIM))
+ */
+      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 391, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_GIVEREF(__pyx_t_1);
+      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
+      __pyx_t_1 = 0;
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 391, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __PYX_ERR(20, 391, __pyx_L1_error)
+
+      /* "asyncpg/protocol/codecs/array.pyx":390
+ *         ptr += 1  # '['
+ * 
+ *         if ndims > ARRAY_MAXDIM:             # <<<<<<<<<<<<<<
+ *             raise ValueError(
+ *                 'number of array dimensions ({}) exceed the '
+ */
+    }
+
+    /* "asyncpg/protocol/codecs/array.pyx":395
+ *                 'maximum expected ({})'.format(ndims, ARRAY_MAXDIM))
+ * 
+ *         ptr = apg_parse_int32(ptr, &ubound)             # <<<<<<<<<<<<<<
+ *         if ptr == NULL:
+ *             raise ValueError('missing array dimension value')
+ */
+    __pyx_v_ptr = __pyx_f_7asyncpg_8protocol_8protocol_apg_parse_int32(__pyx_v_ptr, (&__pyx_v_ubound));
+
+    /* "asyncpg/protocol/codecs/array.pyx":396
+ * 
+ *         ptr = apg_parse_int32(ptr, &ubound)
+ *         if ptr == NULL:             # <<<<<<<<<<<<<<
+ *             raise ValueError('missing array dimension value')
+ * 
+ */
+    __pyx_t_2 = ((__pyx_v_ptr == NULL) != 0);
+    if (__pyx_t_2) {
+
+      /* "asyncpg/protocol/codecs/array.pyx":397
+ *         ptr = apg_parse_int32(ptr, &ubound)
+ *         if ptr == NULL:
+ *             raise ValueError('missing array dimension value')             # <<<<<<<<<<<<<<
+ * 
+ *         if ptr[0] == ':':
+ */
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 397, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __PYX_ERR(20, 397, __pyx_L1_error)
+
+      /* "asyncpg/protocol/codecs/array.pyx":396
+ * 
+ *         ptr = apg_parse_int32(ptr, &ubound)
+ *         if ptr == NULL:             # <<<<<<<<<<<<<<
+ *             raise ValueError('missing array dimension value')
+ * 
+ */
+    }
+
+    /* "asyncpg/protocol/codecs/array.pyx":399
+ *             raise ValueError('missing array dimension value')
+ * 
+ *         if ptr[0] == ':':             # <<<<<<<<<<<<<<
+ *             ptr += 1
+ *             lbound = ubound
+ */
+    __pyx_t_2 = (((__pyx_v_ptr[0]) == 58) != 0);
+    if (__pyx_t_2) {
+
+      /* "asyncpg/protocol/codecs/array.pyx":400
+ * 
+ *         if ptr[0] == ':':
+ *             ptr += 1             # <<<<<<<<<<<<<<
+ *             lbound = ubound
+ * 
+ */
+      __pyx_v_ptr = (__pyx_v_ptr + 1);
+
+      /* "asyncpg/protocol/codecs/array.pyx":401
+ *         if ptr[0] == ':':
+ *             ptr += 1
+ *             lbound = ubound             # <<<<<<<<<<<<<<
+ * 
+ *             # [lower:upper] spec.  We disregard the lbound for decoding.
+ */
+      __pyx_v_lbound = __pyx_v_ubound;
+
+      /* "asyncpg/protocol/codecs/array.pyx":404
+ * 
+ *             # [lower:upper] spec.  We disregard the lbound for decoding.
+ *             ptr = apg_parse_int32(ptr, &ubound)             # <<<<<<<<<<<<<<
+ *             if ptr == NULL:
+ *                 raise ValueError('missing array dimension value')
+ */
+      __pyx_v_ptr = __pyx_f_7asyncpg_8protocol_8protocol_apg_parse_int32(__pyx_v_ptr, (&__pyx_v_ubound));
+
+      /* "asyncpg/protocol/codecs/array.pyx":405
+ *             # [lower:upper] spec.  We disregard the lbound for decoding.
+ *             ptr = apg_parse_int32(ptr, &ubound)
+ *             if ptr == NULL:             # <<<<<<<<<<<<<<
+ *                 raise ValueError('missing array dimension value')
+ *         else:
+ */
+      __pyx_t_2 = ((__pyx_v_ptr == NULL) != 0);
+      if (__pyx_t_2) {
+
+        /* "asyncpg/protocol/codecs/array.pyx":406
+ *             ptr = apg_parse_int32(ptr, &ubound)
+ *             if ptr == NULL:
+ *                 raise ValueError('missing array dimension value')             # <<<<<<<<<<<<<<
+ *         else:
+ *             lbound = 1
+ */
+        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__44, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 406, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __PYX_ERR(20, 406, __pyx_L1_error)
+
+        /* "asyncpg/protocol/codecs/array.pyx":405
+ *             # [lower:upper] spec.  We disregard the lbound for decoding.
+ *             ptr = apg_parse_int32(ptr, &ubound)
+ *             if ptr == NULL:             # <<<<<<<<<<<<<<
+ *                 raise ValueError('missing array dimension value')
+ *         else:
+ */
+      }
+
+      /* "asyncpg/protocol/codecs/array.pyx":399
+ *             raise ValueError('missing array dimension value')
+ * 
+ *         if ptr[0] == ':':             # <<<<<<<<<<<<<<
+ *             ptr += 1
+ *             lbound = ubound
+ */
+      goto __pyx_L10;
+    }
+
+    /* "asyncpg/protocol/codecs/array.pyx":408
+ *                 raise ValueError('missing array dimension value')
+ *         else:
+ *             lbound = 1             # <<<<<<<<<<<<<<
+ * 
+ *         if ptr[0] != ']':
+ */
+    /*else*/ {
+      __pyx_v_lbound = 1;
+    }
+    __pyx_L10:;
+
+    /* "asyncpg/protocol/codecs/array.pyx":410
+ *             lbound = 1
+ * 
+ *         if ptr[0] != ']':             # <<<<<<<<<<<<<<
+ *             raise ValueError('missing \']\' after array dimensions')
+ * 
+ */
+    __pyx_t_2 = (((__pyx_v_ptr[0]) != 93) != 0);
+    if (__pyx_t_2) {
+
+      /* "asyncpg/protocol/codecs/array.pyx":411
+ * 
+ *         if ptr[0] != ']':
+ *             raise ValueError('missing \']\' after array dimensions')             # <<<<<<<<<<<<<<
+ * 
+ *         ptr += 1  # ']'
+ */
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__45, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 411, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __PYX_ERR(20, 411, __pyx_L1_error)
+
+      /* "asyncpg/protocol/codecs/array.pyx":410
+ *             lbound = 1
+ * 
+ *         if ptr[0] != ']':             # <<<<<<<<<<<<<<
+ *             raise ValueError('missing \']\' after array dimensions')
+ * 
+ */
+    }
+
+    /* "asyncpg/protocol/codecs/array.pyx":413
+ *             raise ValueError('missing \']\' after array dimensions')
+ * 
+ *         ptr += 1  # ']'             # <<<<<<<<<<<<<<
+ * 
+ *         dims[ndims] = ubound - lbound + 1
+ */
+    __pyx_v_ptr = (__pyx_v_ptr + 1);
+
+    /* "asyncpg/protocol/codecs/array.pyx":415
+ *         ptr += 1  # ']'
+ * 
+ *         dims[ndims] = ubound - lbound + 1             # <<<<<<<<<<<<<<
+ *         ndims += 1
+ * 
+ */
+    (__pyx_v_dims[__pyx_v_ndims]) = ((__pyx_v_ubound - __pyx_v_lbound) + 1);
+
+    /* "asyncpg/protocol/codecs/array.pyx":416
+ * 
+ *         dims[ndims] = ubound - lbound + 1
+ *         ndims += 1             # <<<<<<<<<<<<<<
+ * 
+ *     if ndims != 0:
+ */
+    __pyx_v_ndims = (__pyx_v_ndims + 1);
+  }
+  __pyx_L4_break:;
+
+  /* "asyncpg/protocol/codecs/array.pyx":418
+ *         ndims += 1
+ * 
+ *     if ndims != 0:             # <<<<<<<<<<<<<<
+ *         # If dimensions were given, the '=' token is expected.
+ *         if ptr[0] != '=':
+ */
+  __pyx_t_2 = ((__pyx_v_ndims != 0) != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/codecs/array.pyx":420
+ *     if ndims != 0:
+ *         # If dimensions were given, the '=' token is expected.
+ *         if ptr[0] != '=':             # <<<<<<<<<<<<<<
+ *             raise ValueError('missing \'=\' after array dimensions')
+ * 
+ */
+    __pyx_t_2 = (((__pyx_v_ptr[0]) != 61) != 0);
+    if (__pyx_t_2) {
+
+      /* "asyncpg/protocol/codecs/array.pyx":421
+ *         # If dimensions were given, the '=' token is expected.
+ *         if ptr[0] != '=':
+ *             raise ValueError('missing \'=\' after array dimensions')             # <<<<<<<<<<<<<<
+ * 
+ *         ptr += 1  # '='
+ */
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__46, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 421, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __PYX_ERR(20, 421, __pyx_L1_error)
+
+      /* "asyncpg/protocol/codecs/array.pyx":420
+ *     if ndims != 0:
+ *         # If dimensions were given, the '=' token is expected.
+ *         if ptr[0] != '=':             # <<<<<<<<<<<<<<
+ *             raise ValueError('missing \'=\' after array dimensions')
+ * 
+ */
+    }
+
+    /* "asyncpg/protocol/codecs/array.pyx":423
+ *             raise ValueError('missing \'=\' after array dimensions')
+ * 
+ *         ptr += 1  # '='             # <<<<<<<<<<<<<<
+ * 
+ *         # Skip any whitespace after the '=', whitespace
+ */
+    __pyx_v_ptr = (__pyx_v_ptr + 1);
+
+    /* "asyncpg/protocol/codecs/array.pyx":427
+ *         # Skip any whitespace after the '=', whitespace
+ *         # before was consumed in the above loop.
+ *         while apg_ascii_isspace(ptr[0]):             # <<<<<<<<<<<<<<
+ *             ptr += 1
+ * 
+ */
+    while (1) {
+      __pyx_t_2 = (__pyx_f_7asyncpg_8protocol_8protocol_apg_ascii_isspace((__pyx_v_ptr[0])) != 0);
+      if (!__pyx_t_2) break;
+
+      /* "asyncpg/protocol/codecs/array.pyx":428
+ *         # before was consumed in the above loop.
+ *         while apg_ascii_isspace(ptr[0]):
+ *             ptr += 1             # <<<<<<<<<<<<<<
+ * 
+ *         # Infer the dimensions from the brace structure in the
+ */
+      __pyx_v_ptr = (__pyx_v_ptr + 1);
+    }
+
+    /* "asyncpg/protocol/codecs/array.pyx":433
+ *         # array literal body, and check that it matches the explicit
+ *         # spec.  This also validates that the array literal is sane.
+ *         _infer_array_dims(ptr, typdelim, inferred_dims, &inferred_ndims)             # <<<<<<<<<<<<<<
+ * 
+ *         if inferred_ndims != ndims:
+ */
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol__infer_array_dims(__pyx_v_ptr, __pyx_v_typdelim, __pyx_v_inferred_dims, (&__pyx_v_inferred_ndims)); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 433, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/codecs/array.pyx":435
+ *         _infer_array_dims(ptr, typdelim, inferred_dims, &inferred_ndims)
+ * 
+ *         if inferred_ndims != ndims:             # <<<<<<<<<<<<<<
+ *             raise ValueError(
+ *                 'specified array dimensions do not match array content')
+ */
+    __pyx_t_2 = ((__pyx_v_inferred_ndims != __pyx_v_ndims) != 0);
+    if (__pyx_t_2) {
+
+      /* "asyncpg/protocol/codecs/array.pyx":436
+ * 
+ *         if inferred_ndims != ndims:
+ *             raise ValueError(             # <<<<<<<<<<<<<<
+ *                 'specified array dimensions do not match array content')
+ * 
+ */
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__47, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 436, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __PYX_ERR(20, 436, __pyx_L1_error)
+
+      /* "asyncpg/protocol/codecs/array.pyx":435
+ *         _infer_array_dims(ptr, typdelim, inferred_dims, &inferred_ndims)
+ * 
+ *         if inferred_ndims != ndims:             # <<<<<<<<<<<<<<
+ *             raise ValueError(
+ *                 'specified array dimensions do not match array content')
+ */
+    }
+
+    /* "asyncpg/protocol/codecs/array.pyx":439
+ *                 'specified array dimensions do not match array content')
+ * 
+ *         for i in range(ndims):             # <<<<<<<<<<<<<<
+ *             if inferred_dims[i] != dims[i]:
+ *                 raise ValueError(
+ */
+    __pyx_t_8 = __pyx_v_ndims;
+    for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_8; __pyx_t_6+=1) {
+      __pyx_v_i = __pyx_t_6;
+
+      /* "asyncpg/protocol/codecs/array.pyx":440
+ * 
+ *         for i in range(ndims):
+ *             if inferred_dims[i] != dims[i]:             # <<<<<<<<<<<<<<
+ *                 raise ValueError(
+ *                     'specified array dimensions do not match array content')
+ */
+      __pyx_t_2 = (((__pyx_v_inferred_dims[__pyx_v_i]) != (__pyx_v_dims[__pyx_v_i])) != 0);
+      if (__pyx_t_2) {
+
+        /* "asyncpg/protocol/codecs/array.pyx":441
+ *         for i in range(ndims):
+ *             if inferred_dims[i] != dims[i]:
+ *                 raise ValueError(             # <<<<<<<<<<<<<<
+ *                     'specified array dimensions do not match array content')
+ *     else:
+ */
+        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__48, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 441, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __PYX_ERR(20, 441, __pyx_L1_error)
+
+        /* "asyncpg/protocol/codecs/array.pyx":440
+ * 
+ *         for i in range(ndims):
+ *             if inferred_dims[i] != dims[i]:             # <<<<<<<<<<<<<<
+ *                 raise ValueError(
+ *                     'specified array dimensions do not match array content')
+ */
+      }
+    }
+
+    /* "asyncpg/protocol/codecs/array.pyx":418
+ *         ndims += 1
+ * 
+ *     if ndims != 0:             # <<<<<<<<<<<<<<
+ *         # If dimensions were given, the '=' token is expected.
+ *         if ptr[0] != '=':
+ */
+    goto __pyx_L13;
+  }
+
+  /* "asyncpg/protocol/codecs/array.pyx":446
+ *         # Infer the dimensions from the brace structure in the array literal
+ *         # body.  This also validates that the array literal is sane.
+ *         _infer_array_dims(ptr, typdelim, dims, &ndims)             # <<<<<<<<<<<<<<
+ * 
+ *     while not end_of_array:
+ */
+  /*else*/ {
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol__infer_array_dims(__pyx_v_ptr, __pyx_v_typdelim, __pyx_v_dims, (&__pyx_v_ndims)); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 446, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  }
+  __pyx_L13:;
+
+  /* "asyncpg/protocol/codecs/array.pyx":448
+ *         _infer_array_dims(ptr, typdelim, dims, &ndims)
+ * 
+ *     while not end_of_array:             # <<<<<<<<<<<<<<
+ *         # We iterate over the literal character by character
+ *         # and modify the string in-place removing the array-specific
+ */
+  while (1) {
+    __pyx_t_2 = ((!(__pyx_v_end_of_array != 0)) != 0);
+    if (!__pyx_t_2) break;
+
+    /* "asyncpg/protocol/codecs/array.pyx":452
+ *         # and modify the string in-place removing the array-specific
+ *         # quoting and determining the boundaries of each element.
+ *         end_of_item = has_quoting = in_quotes = False             # <<<<<<<<<<<<<<
+ *         strip_spaces = True
+ * 
+ */
+    __pyx_v_end_of_item = 0;
+    __pyx_v_has_quoting = 0;
+    __pyx_v_in_quotes = 0;
+
+    /* "asyncpg/protocol/codecs/array.pyx":453
+ *         # quoting and determining the boundaries of each element.
+ *         end_of_item = has_quoting = in_quotes = False
+ *         strip_spaces = True             # <<<<<<<<<<<<<<
+ * 
+ *         # Pointers to array element start, end, and the current pointer
+ */
+    __pyx_v_strip_spaces = 1;
+
+    /* "asyncpg/protocol/codecs/array.pyx":458
+ *         # tracking the position where characters are written when
+ *         # escaping is folded.
+ *         item_start = item_end = item_ptr = ptr             # <<<<<<<<<<<<<<
+ *         item_level = 0
+ * 
+ */
+    __pyx_v_item_start = __pyx_v_ptr;
+    __pyx_v_item_end = __pyx_v_ptr;
+    __pyx_v_item_ptr = __pyx_v_ptr;
+
+    /* "asyncpg/protocol/codecs/array.pyx":459
+ *         # escaping is folded.
+ *         item_start = item_end = item_ptr = ptr
+ *         item_level = 0             # <<<<<<<<<<<<<<
+ * 
+ *         while not end_of_item:
+ */
+    __pyx_v_item_level = 0;
+
+    /* "asyncpg/protocol/codecs/array.pyx":461
+ *         item_level = 0
+ * 
+ *         while not end_of_item:             # <<<<<<<<<<<<<<
+ *             if ptr[0] == '"':
+ *                 in_quotes = not in_quotes
+ */
+    while (1) {
+      __pyx_t_2 = ((!(__pyx_v_end_of_item != 0)) != 0);
+      if (!__pyx_t_2) break;
+
+      /* "asyncpg/protocol/codecs/array.pyx":462
+ * 
+ *         while not end_of_item:
+ *             if ptr[0] == '"':             # <<<<<<<<<<<<<<
+ *                 in_quotes = not in_quotes
+ *                 if in_quotes:
+ */
+      __pyx_t_2 = (((__pyx_v_ptr[0]) == 34) != 0);
+      if (__pyx_t_2) {
+
+        /* "asyncpg/protocol/codecs/array.pyx":463
+ *         while not end_of_item:
+ *             if ptr[0] == '"':
+ *                 in_quotes = not in_quotes             # <<<<<<<<<<<<<<
+ *                 if in_quotes:
+ *                     strip_spaces = False
+ */
+        __pyx_v_in_quotes = (!(__pyx_v_in_quotes != 0));
+
+        /* "asyncpg/protocol/codecs/array.pyx":464
+ *             if ptr[0] == '"':
+ *                 in_quotes = not in_quotes
+ *                 if in_quotes:             # <<<<<<<<<<<<<<
+ *                     strip_spaces = False
+ *                 else:
+ */
+        __pyx_t_2 = (__pyx_v_in_quotes != 0);
+        if (__pyx_t_2) {
+
+          /* "asyncpg/protocol/codecs/array.pyx":465
+ *                 in_quotes = not in_quotes
+ *                 if in_quotes:
+ *                     strip_spaces = False             # <<<<<<<<<<<<<<
+ *                 else:
+ *                     item_end = item_ptr
+ */
+          __pyx_v_strip_spaces = 0;
+
+          /* "asyncpg/protocol/codecs/array.pyx":464
+ *             if ptr[0] == '"':
+ *                 in_quotes = not in_quotes
+ *                 if in_quotes:             # <<<<<<<<<<<<<<
+ *                     strip_spaces = False
+ *                 else:
+ */
+          goto __pyx_L26;
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":467
+ *                     strip_spaces = False
+ *                 else:
+ *                     item_end = item_ptr             # <<<<<<<<<<<<<<
+ *                 has_quoting = True
+ * 
+ */
+        /*else*/ {
+          __pyx_v_item_end = __pyx_v_item_ptr;
+        }
+        __pyx_L26:;
+
+        /* "asyncpg/protocol/codecs/array.pyx":468
+ *                 else:
+ *                     item_end = item_ptr
+ *                 has_quoting = True             # <<<<<<<<<<<<<<
+ * 
+ *             elif ptr[0] == '\\':
+ */
+        __pyx_v_has_quoting = 1;
+
+        /* "asyncpg/protocol/codecs/array.pyx":462
+ * 
+ *         while not end_of_item:
+ *             if ptr[0] == '"':             # <<<<<<<<<<<<<<
+ *                 in_quotes = not in_quotes
+ *                 if in_quotes:
+ */
+        goto __pyx_L25;
+      }
+
+      /* "asyncpg/protocol/codecs/array.pyx":470
+ *                 has_quoting = True
+ * 
+ *             elif ptr[0] == '\\':             # <<<<<<<<<<<<<<
+ *                 # Quoted character, collapse the backslash.
+ *                 ptr += 1
+ */
+      __pyx_t_2 = (((__pyx_v_ptr[0]) == 92) != 0);
+      if (__pyx_t_2) {
+
+        /* "asyncpg/protocol/codecs/array.pyx":472
+ *             elif ptr[0] == '\\':
+ *                 # Quoted character, collapse the backslash.
+ *                 ptr += 1             # <<<<<<<<<<<<<<
+ *                 has_quoting = True
+ *                 item_ptr[0] = ptr[0]
+ */
+        __pyx_v_ptr = (__pyx_v_ptr + 1);
+
+        /* "asyncpg/protocol/codecs/array.pyx":473
+ *                 # Quoted character, collapse the backslash.
+ *                 ptr += 1
+ *                 has_quoting = True             # <<<<<<<<<<<<<<
+ *                 item_ptr[0] = ptr[0]
+ *                 item_ptr += 1
+ */
+        __pyx_v_has_quoting = 1;
+
+        /* "asyncpg/protocol/codecs/array.pyx":474
+ *                 ptr += 1
+ *                 has_quoting = True
+ *                 item_ptr[0] = ptr[0]             # <<<<<<<<<<<<<<
+ *                 item_ptr += 1
+ *                 strip_spaces = False
+ */
+        (__pyx_v_item_ptr[0]) = (__pyx_v_ptr[0]);
+
+        /* "asyncpg/protocol/codecs/array.pyx":475
+ *                 has_quoting = True
+ *                 item_ptr[0] = ptr[0]
+ *                 item_ptr += 1             # <<<<<<<<<<<<<<
+ *                 strip_spaces = False
+ *                 item_end = item_ptr
+ */
+        __pyx_v_item_ptr = (__pyx_v_item_ptr + 1);
+
+        /* "asyncpg/protocol/codecs/array.pyx":476
+ *                 item_ptr[0] = ptr[0]
+ *                 item_ptr += 1
+ *                 strip_spaces = False             # <<<<<<<<<<<<<<
+ *                 item_end = item_ptr
+ * 
+ */
+        __pyx_v_strip_spaces = 0;
+
+        /* "asyncpg/protocol/codecs/array.pyx":477
+ *                 item_ptr += 1
+ *                 strip_spaces = False
+ *                 item_end = item_ptr             # <<<<<<<<<<<<<<
+ * 
+ *             elif in_quotes:
+ */
+        __pyx_v_item_end = __pyx_v_item_ptr;
+
+        /* "asyncpg/protocol/codecs/array.pyx":470
+ *                 has_quoting = True
+ * 
+ *             elif ptr[0] == '\\':             # <<<<<<<<<<<<<<
+ *                 # Quoted character, collapse the backslash.
+ *                 ptr += 1
+ */
+        goto __pyx_L25;
+      }
+
+      /* "asyncpg/protocol/codecs/array.pyx":479
+ *                 item_end = item_ptr
+ * 
+ *             elif in_quotes:             # <<<<<<<<<<<<<<
+ *                 # Consume the string until we see the closing quote.
+ *                 item_ptr[0] = ptr[0]
+ */
+      __pyx_t_2 = (__pyx_v_in_quotes != 0);
+      if (__pyx_t_2) {
+
+        /* "asyncpg/protocol/codecs/array.pyx":481
+ *             elif in_quotes:
+ *                 # Consume the string until we see the closing quote.
+ *                 item_ptr[0] = ptr[0]             # <<<<<<<<<<<<<<
+ *                 item_ptr += 1
+ * 
+ */
+        (__pyx_v_item_ptr[0]) = (__pyx_v_ptr[0]);
+
+        /* "asyncpg/protocol/codecs/array.pyx":482
+ *                 # Consume the string until we see the closing quote.
+ *                 item_ptr[0] = ptr[0]
+ *                 item_ptr += 1             # <<<<<<<<<<<<<<
+ * 
+ *             elif ptr[0] == '{':
+ */
+        __pyx_v_item_ptr = (__pyx_v_item_ptr + 1);
+
+        /* "asyncpg/protocol/codecs/array.pyx":479
+ *                 item_end = item_ptr
+ * 
+ *             elif in_quotes:             # <<<<<<<<<<<<<<
+ *                 # Consume the string until we see the closing quote.
+ *                 item_ptr[0] = ptr[0]
+ */
+        goto __pyx_L25;
+      }
+
+      /* "asyncpg/protocol/codecs/array.pyx":484
+ *                 item_ptr += 1
+ * 
+ *             elif ptr[0] == '{':             # <<<<<<<<<<<<<<
+ *                 # Nesting level increase.
+ *                 nest_level += 1
+ */
+      __pyx_t_2 = (((__pyx_v_ptr[0]) == 0x7B) != 0);
+      if (__pyx_t_2) {
+
+        /* "asyncpg/protocol/codecs/array.pyx":486
+ *             elif ptr[0] == '{':
+ *                 # Nesting level increase.
+ *                 nest_level += 1             # <<<<<<<<<<<<<<
+ * 
+ *                 indexes[nest_level - 1] = 0
+ */
+        __pyx_v_nest_level = (__pyx_v_nest_level + 1);
+
+        /* "asyncpg/protocol/codecs/array.pyx":488
+ *                 nest_level += 1
+ * 
+ *                 indexes[nest_level - 1] = 0             # <<<<<<<<<<<<<<
+ *                 new_stride = cpython.PyList_New(dims[nest_level - 1])
+ *                 strides[nest_level - 1] = \
+ */
+        (__pyx_v_indexes[(__pyx_v_nest_level - 1)]) = 0;
+
+        /* "asyncpg/protocol/codecs/array.pyx":489
+ * 
+ *                 indexes[nest_level - 1] = 0
+ *                 new_stride = cpython.PyList_New(dims[nest_level - 1])             # <<<<<<<<<<<<<<
+ *                 strides[nest_level - 1] = \
+ *                     <void*>(<cpython.PyObject>new_stride)
+ */
+        __pyx_t_1 = PyList_New((__pyx_v_dims[(__pyx_v_nest_level - 1)])); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 489, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_XDECREF_SET(__pyx_v_new_stride, ((PyObject*)__pyx_t_1));
+        __pyx_t_1 = 0;
+
+        /* "asyncpg/protocol/codecs/array.pyx":490
+ *                 indexes[nest_level - 1] = 0
+ *                 new_stride = cpython.PyList_New(dims[nest_level - 1])
+ *                 strides[nest_level - 1] = \             # <<<<<<<<<<<<<<
+ *                     <void*>(<cpython.PyObject>new_stride)
+ * 
+ */
+        (__pyx_v_strides[(__pyx_v_nest_level - 1)]) = ((void *)__pyx_v_new_stride);
+
+        /* "asyncpg/protocol/codecs/array.pyx":493
+ *                     <void*>(<cpython.PyObject>new_stride)
+ * 
+ *                 if nest_level > 1:             # <<<<<<<<<<<<<<
+ *                     cpython.Py_INCREF(new_stride)
+ *                     cpython.PyList_SET_ITEM(
+ */
+        __pyx_t_2 = ((__pyx_v_nest_level > 1) != 0);
+        if (__pyx_t_2) {
+
+          /* "asyncpg/protocol/codecs/array.pyx":494
+ * 
+ *                 if nest_level > 1:
+ *                     cpython.Py_INCREF(new_stride)             # <<<<<<<<<<<<<<
+ *                     cpython.PyList_SET_ITEM(
+ *                         <object><cpython.PyObject*>strides[nest_level - 2],
+ */
+          Py_INCREF(__pyx_v_new_stride);
+
+          /* "asyncpg/protocol/codecs/array.pyx":496
+ *                     cpython.Py_INCREF(new_stride)
+ *                     cpython.PyList_SET_ITEM(
+ *                         <object><cpython.PyObject*>strides[nest_level - 2],             # <<<<<<<<<<<<<<
+ *                         indexes[nest_level - 2],
+ *                         new_stride)
+ */
+          __pyx_t_9 = ((PyObject *)(__pyx_v_strides[(__pyx_v_nest_level - 2)]));
+
+          /* "asyncpg/protocol/codecs/array.pyx":495
+ *                 if nest_level > 1:
+ *                     cpython.Py_INCREF(new_stride)
+ *                     cpython.PyList_SET_ITEM(             # <<<<<<<<<<<<<<
+ *                         <object><cpython.PyObject*>strides[nest_level - 2],
+ *                         indexes[nest_level - 2],
+ */
+          PyList_SET_ITEM(((PyObject *)__pyx_t_9), (__pyx_v_indexes[(__pyx_v_nest_level - 2)]), __pyx_v_new_stride);
+
+          /* "asyncpg/protocol/codecs/array.pyx":493
+ *                     <void*>(<cpython.PyObject>new_stride)
+ * 
+ *                 if nest_level > 1:             # <<<<<<<<<<<<<<
+ *                     cpython.Py_INCREF(new_stride)
+ *                     cpython.PyList_SET_ITEM(
+ */
+          goto __pyx_L27;
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":500
+ *                         new_stride)
+ *                 else:
+ *                     result = new_stride             # <<<<<<<<<<<<<<
+ * 
+ *             elif ptr[0] == '}':
+ */
+        /*else*/ {
+          __Pyx_INCREF(__pyx_v_new_stride);
+          __Pyx_XDECREF_SET(__pyx_v_result, __pyx_v_new_stride);
+        }
+        __pyx_L27:;
+
+        /* "asyncpg/protocol/codecs/array.pyx":484
+ *                 item_ptr += 1
+ * 
+ *             elif ptr[0] == '{':             # <<<<<<<<<<<<<<
+ *                 # Nesting level increase.
+ *                 nest_level += 1
+ */
+        goto __pyx_L25;
+      }
+
+      /* "asyncpg/protocol/codecs/array.pyx":502
+ *                     result = new_stride
+ * 
+ *             elif ptr[0] == '}':             # <<<<<<<<<<<<<<
+ *                 if item_level == 0:
+ *                     # Make sure we keep track of which nesting
+ */
+      __pyx_t_2 = (((__pyx_v_ptr[0]) == 0x7D) != 0);
+      if (__pyx_t_2) {
+
+        /* "asyncpg/protocol/codecs/array.pyx":503
+ * 
+ *             elif ptr[0] == '}':
+ *                 if item_level == 0:             # <<<<<<<<<<<<<<
+ *                     # Make sure we keep track of which nesting
+ *                     # level the item belongs to, as the loop
+ */
+        __pyx_t_2 = ((__pyx_v_item_level == 0) != 0);
+        if (__pyx_t_2) {
+
+          /* "asyncpg/protocol/codecs/array.pyx":508
+ *                     # will continue to consume closing braces
+ *                     # until the delimiter or the end of input.
+ *                     item_level = nest_level             # <<<<<<<<<<<<<<
+ * 
+ *                 nest_level -= 1
+ */
+          __pyx_v_item_level = __pyx_v_nest_level;
+
+          /* "asyncpg/protocol/codecs/array.pyx":503
+ * 
+ *             elif ptr[0] == '}':
+ *                 if item_level == 0:             # <<<<<<<<<<<<<<
+ *                     # Make sure we keep track of which nesting
+ *                     # level the item belongs to, as the loop
+ */
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":510
+ *                     item_level = nest_level
+ * 
+ *                 nest_level -= 1             # <<<<<<<<<<<<<<
+ * 
+ *                 if nest_level == 0:
+ */
+        __pyx_v_nest_level = (__pyx_v_nest_level - 1);
+
+        /* "asyncpg/protocol/codecs/array.pyx":512
+ *                 nest_level -= 1
+ * 
+ *                 if nest_level == 0:             # <<<<<<<<<<<<<<
+ *                     end_of_array = end_of_item = True
+ * 
+ */
+        __pyx_t_2 = ((__pyx_v_nest_level == 0) != 0);
+        if (__pyx_t_2) {
+
+          /* "asyncpg/protocol/codecs/array.pyx":513
+ * 
+ *                 if nest_level == 0:
+ *                     end_of_array = end_of_item = True             # <<<<<<<<<<<<<<
+ * 
+ *             elif ptr[0] == typdelim:
+ */
+          __pyx_v_end_of_array = 1;
+          __pyx_v_end_of_item = 1;
+
+          /* "asyncpg/protocol/codecs/array.pyx":512
+ *                 nest_level -= 1
+ * 
+ *                 if nest_level == 0:             # <<<<<<<<<<<<<<
+ *                     end_of_array = end_of_item = True
+ * 
+ */
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":502
+ *                     result = new_stride
+ * 
+ *             elif ptr[0] == '}':             # <<<<<<<<<<<<<<
+ *                 if item_level == 0:
+ *                     # Make sure we keep track of which nesting
+ */
+        goto __pyx_L25;
+      }
+
+      /* "asyncpg/protocol/codecs/array.pyx":515
+ *                     end_of_array = end_of_item = True
+ * 
+ *             elif ptr[0] == typdelim:             # <<<<<<<<<<<<<<
+ *                 # Array element delimiter,
+ *                 end_of_item = True
+ */
+      __pyx_t_2 = (((__pyx_v_ptr[0]) == __pyx_v_typdelim) != 0);
+      if (__pyx_t_2) {
+
+        /* "asyncpg/protocol/codecs/array.pyx":517
+ *             elif ptr[0] == typdelim:
+ *                 # Array element delimiter,
+ *                 end_of_item = True             # <<<<<<<<<<<<<<
+ *                 if item_level == 0:
+ *                     item_level = nest_level
+ */
+        __pyx_v_end_of_item = 1;
+
+        /* "asyncpg/protocol/codecs/array.pyx":518
+ *                 # Array element delimiter,
+ *                 end_of_item = True
+ *                 if item_level == 0:             # <<<<<<<<<<<<<<
+ *                     item_level = nest_level
+ * 
+ */
+        __pyx_t_2 = ((__pyx_v_item_level == 0) != 0);
+        if (__pyx_t_2) {
+
+          /* "asyncpg/protocol/codecs/array.pyx":519
+ *                 end_of_item = True
+ *                 if item_level == 0:
+ *                     item_level = nest_level             # <<<<<<<<<<<<<<
+ * 
+ *             elif apg_ascii_isspace(ptr[0]):
+ */
+          __pyx_v_item_level = __pyx_v_nest_level;
+
+          /* "asyncpg/protocol/codecs/array.pyx":518
+ *                 # Array element delimiter,
+ *                 end_of_item = True
+ *                 if item_level == 0:             # <<<<<<<<<<<<<<
+ *                     item_level = nest_level
+ * 
+ */
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":515
+ *                     end_of_array = end_of_item = True
+ * 
+ *             elif ptr[0] == typdelim:             # <<<<<<<<<<<<<<
+ *                 # Array element delimiter,
+ *                 end_of_item = True
+ */
+        goto __pyx_L25;
+      }
+
+      /* "asyncpg/protocol/codecs/array.pyx":521
+ *                     item_level = nest_level
+ * 
+ *             elif apg_ascii_isspace(ptr[0]):             # <<<<<<<<<<<<<<
+ *                 if not strip_spaces:
+ *                     item_ptr[0] = ptr[0]
+ */
+      __pyx_t_2 = (__pyx_f_7asyncpg_8protocol_8protocol_apg_ascii_isspace((__pyx_v_ptr[0])) != 0);
+      if (__pyx_t_2) {
+
+        /* "asyncpg/protocol/codecs/array.pyx":522
+ * 
+ *             elif apg_ascii_isspace(ptr[0]):
+ *                 if not strip_spaces:             # <<<<<<<<<<<<<<
+ *                     item_ptr[0] = ptr[0]
+ *                     item_ptr += 1
+ */
+        __pyx_t_2 = ((!(__pyx_v_strip_spaces != 0)) != 0);
+        if (__pyx_t_2) {
+
+          /* "asyncpg/protocol/codecs/array.pyx":523
+ *             elif apg_ascii_isspace(ptr[0]):
+ *                 if not strip_spaces:
+ *                     item_ptr[0] = ptr[0]             # <<<<<<<<<<<<<<
+ *                     item_ptr += 1
+ *                 # Ignore the leading literal whitespace.
+ */
+          (__pyx_v_item_ptr[0]) = (__pyx_v_ptr[0]);
+
+          /* "asyncpg/protocol/codecs/array.pyx":524
+ *                 if not strip_spaces:
+ *                     item_ptr[0] = ptr[0]
+ *                     item_ptr += 1             # <<<<<<<<<<<<<<
+ *                 # Ignore the leading literal whitespace.
+ * 
+ */
+          __pyx_v_item_ptr = (__pyx_v_item_ptr + 1);
+
+          /* "asyncpg/protocol/codecs/array.pyx":522
+ * 
+ *             elif apg_ascii_isspace(ptr[0]):
+ *                 if not strip_spaces:             # <<<<<<<<<<<<<<
+ *                     item_ptr[0] = ptr[0]
+ *                     item_ptr += 1
+ */
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":521
+ *                     item_level = nest_level
+ * 
+ *             elif apg_ascii_isspace(ptr[0]):             # <<<<<<<<<<<<<<
+ *                 if not strip_spaces:
+ *                     item_ptr[0] = ptr[0]
+ */
+        goto __pyx_L25;
+      }
+
+      /* "asyncpg/protocol/codecs/array.pyx":528
+ * 
+ *             else:
+ *                 item_ptr[0] = ptr[0]             # <<<<<<<<<<<<<<
+ *                 item_ptr += 1
+ *                 strip_spaces = False
+ */
+      /*else*/ {
+        (__pyx_v_item_ptr[0]) = (__pyx_v_ptr[0]);
+
+        /* "asyncpg/protocol/codecs/array.pyx":529
+ *             else:
+ *                 item_ptr[0] = ptr[0]
+ *                 item_ptr += 1             # <<<<<<<<<<<<<<
+ *                 strip_spaces = False
+ *                 item_end = item_ptr
+ */
+        __pyx_v_item_ptr = (__pyx_v_item_ptr + 1);
+
+        /* "asyncpg/protocol/codecs/array.pyx":530
+ *                 item_ptr[0] = ptr[0]
+ *                 item_ptr += 1
+ *                 strip_spaces = False             # <<<<<<<<<<<<<<
+ *                 item_end = item_ptr
+ * 
+ */
+        __pyx_v_strip_spaces = 0;
+
+        /* "asyncpg/protocol/codecs/array.pyx":531
+ *                 item_ptr += 1
+ *                 strip_spaces = False
+ *                 item_end = item_ptr             # <<<<<<<<<<<<<<
+ * 
+ *             ptr += 1
+ */
+        __pyx_v_item_end = __pyx_v_item_ptr;
+      }
+      __pyx_L25:;
+
+      /* "asyncpg/protocol/codecs/array.pyx":533
+ *                 item_end = item_ptr
+ * 
+ *             ptr += 1             # <<<<<<<<<<<<<<
+ * 
+ *         # end while not end_of_item
+ */
+      __pyx_v_ptr = (__pyx_v_ptr + 1);
+    }
+
+    /* "asyncpg/protocol/codecs/array.pyx":537
+ *         # end while not end_of_item
+ * 
+ *         if item_end == item_start:             # <<<<<<<<<<<<<<
+ *             # Empty array
+ *             continue
+ */
+    __pyx_t_2 = ((__pyx_v_item_end == __pyx_v_item_start) != 0);
+    if (__pyx_t_2) {
+
+      /* "asyncpg/protocol/codecs/array.pyx":539
+ *         if item_end == item_start:
+ *             # Empty array
+ *             continue             # <<<<<<<<<<<<<<
+ * 
+ *         item_end[0] = '\0'
+ */
+      goto __pyx_L21_continue;
+
+      /* "asyncpg/protocol/codecs/array.pyx":537
+ *         # end while not end_of_item
+ * 
+ *         if item_end == item_start:             # <<<<<<<<<<<<<<
+ *             # Empty array
+ *             continue
+ */
+    }
+
+    /* "asyncpg/protocol/codecs/array.pyx":541
+ *             continue
+ * 
+ *         item_end[0] = '\0'             # <<<<<<<<<<<<<<
+ * 
+ *         if not has_quoting and apg_strcasecmp(item_start, APG_NULL) == 0:
+ */
+    (__pyx_v_item_end[0]) = 0;
+
+    /* "asyncpg/protocol/codecs/array.pyx":543
+ *         item_end[0] = '\0'
+ * 
+ *         if not has_quoting and apg_strcasecmp(item_start, APG_NULL) == 0:             # <<<<<<<<<<<<<<
+ *             # NULL element.
+ *             item = None
+ */
+    __pyx_t_10 = ((!(__pyx_v_has_quoting != 0)) != 0);
+    if (__pyx_t_10) {
+    } else {
+      __pyx_t_2 = __pyx_t_10;
+      goto __pyx_L34_bool_binop_done;
+    }
+    __pyx_t_10 = ((__pyx_f_7asyncpg_8protocol_8protocol_apg_strcasecmp(__pyx_v_item_start, __pyx_v_7asyncpg_8protocol_8protocol_APG_NULL) == 0) != 0);
+    __pyx_t_2 = __pyx_t_10;
+    __pyx_L34_bool_binop_done:;
+    if (__pyx_t_2) {
+
+      /* "asyncpg/protocol/codecs/array.pyx":545
+ *         if not has_quoting and apg_strcasecmp(item_start, APG_NULL) == 0:
+ *             # NULL element.
+ *             item = None             # <<<<<<<<<<<<<<
+ *         else:
+ *             # XXX: find a way to avoid the redundant encode/decode
+ */
+      __Pyx_INCREF(Py_None);
+      __Pyx_XDECREF_SET(__pyx_v_item, Py_None);
+
+      /* "asyncpg/protocol/codecs/array.pyx":543
+ *         item_end[0] = '\0'
+ * 
+ *         if not has_quoting and apg_strcasecmp(item_start, APG_NULL) == 0:             # <<<<<<<<<<<<<<
+ *             # NULL element.
+ *             item = None
+ */
+      goto __pyx_L33;
+    }
+
+    /* "asyncpg/protocol/codecs/array.pyx":549
+ *             # XXX: find a way to avoid the redundant encode/decode
+ *             # cycle here.
+ *             item_text = PyUnicode_FromKindAndData(             # <<<<<<<<<<<<<<
+ *                 PyUnicode_4BYTE_KIND,
+ *                 <void *>item_start,
+ */
+    /*else*/ {
+
+      /* "asyncpg/protocol/codecs/array.pyx":552
+ *                 PyUnicode_4BYTE_KIND,
+ *                 <void *>item_start,
+ *                 item_end - item_start)             # <<<<<<<<<<<<<<
+ * 
+ *             # Prepare the element buffer and call the text decoder
+ */
+      __pyx_t_1 = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, ((void *)__pyx_v_item_start), (__pyx_v_item_end - __pyx_v_item_start)); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 549, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+
+      /* "asyncpg/protocol/codecs/array.pyx":549
+ *             # XXX: find a way to avoid the redundant encode/decode
+ *             # cycle here.
+ *             item_text = PyUnicode_FromKindAndData(             # <<<<<<<<<<<<<<
+ *                 PyUnicode_4BYTE_KIND,
+ *                 <void *>item_start,
+ */
+      if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(20, 549, __pyx_L1_error)
+      __Pyx_XDECREF_SET(__pyx_v_item_text, ((PyObject*)__pyx_t_1));
+      __pyx_t_1 = 0;
+
+      /* "asyncpg/protocol/codecs/array.pyx":556
+ *             # Prepare the element buffer and call the text decoder
+ *             # for the element type.
+ *             as_pg_string_and_size(             # <<<<<<<<<<<<<<
+ *                 settings, item_text, &pg_item_str, &pg_item_len)
+ *             item_buf.buf = pg_item_str
+ */
+      __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_as_pg_string_and_size(__pyx_v_settings, __pyx_v_item_text, (&__pyx_v_pg_item_str), (&__pyx_v_pg_item_len)); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 556, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+      /* "asyncpg/protocol/codecs/array.pyx":558
+ *             as_pg_string_and_size(
+ *                 settings, item_text, &pg_item_str, &pg_item_len)
+ *             item_buf.buf = pg_item_str             # <<<<<<<<<<<<<<
+ *             item_buf.len = pg_item_len
+ *             item = decoder(settings, item_buf, decoder_arg)
+ */
+      __pyx_v_item_buf->buf = __pyx_v_pg_item_str;
+
+      /* "asyncpg/protocol/codecs/array.pyx":559
+ *                 settings, item_text, &pg_item_str, &pg_item_len)
+ *             item_buf.buf = pg_item_str
+ *             item_buf.len = pg_item_len             # <<<<<<<<<<<<<<
+ *             item = decoder(settings, item_buf, decoder_arg)
+ * 
+ */
+      __pyx_v_item_buf->len = __pyx_v_pg_item_len;
+
+      /* "asyncpg/protocol/codecs/array.pyx":560
+ *             item_buf.buf = pg_item_str
+ *             item_buf.len = pg_item_len
+ *             item = decoder(settings, item_buf, decoder_arg)             # <<<<<<<<<<<<<<
+ * 
+ *         # Place the decoded element in the array.
+ */
+      __pyx_t_1 = __pyx_v_decoder(__pyx_v_settings, __pyx_v_item_buf, __pyx_v_decoder_arg); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 560, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_1);
+      __pyx_t_1 = 0;
+    }
+    __pyx_L33:;
+
+    /* "asyncpg/protocol/codecs/array.pyx":563
+ * 
+ *         # Place the decoded element in the array.
+ *         cpython.Py_INCREF(item)             # <<<<<<<<<<<<<<
+ *         cpython.PyList_SET_ITEM(
+ *             <object><cpython.PyObject*>strides[item_level - 1],
+ */
+    Py_INCREF(__pyx_v_item);
+
+    /* "asyncpg/protocol/codecs/array.pyx":565
+ *         cpython.Py_INCREF(item)
+ *         cpython.PyList_SET_ITEM(
+ *             <object><cpython.PyObject*>strides[item_level - 1],             # <<<<<<<<<<<<<<
+ *             indexes[item_level - 1],
+ *             item)
+ */
+    __pyx_t_9 = ((PyObject *)(__pyx_v_strides[(__pyx_v_item_level - 1)]));
+
+    /* "asyncpg/protocol/codecs/array.pyx":564
+ *         # Place the decoded element in the array.
+ *         cpython.Py_INCREF(item)
+ *         cpython.PyList_SET_ITEM(             # <<<<<<<<<<<<<<
+ *             <object><cpython.PyObject*>strides[item_level - 1],
+ *             indexes[item_level - 1],
+ */
+    PyList_SET_ITEM(((PyObject *)__pyx_t_9), (__pyx_v_indexes[(__pyx_v_item_level - 1)]), __pyx_v_item);
+
+    /* "asyncpg/protocol/codecs/array.pyx":569
+ *             item)
+ * 
+ *         indexes[nest_level - 1] += 1             # <<<<<<<<<<<<<<
+ * 
+ *     return result
+ */
+    __pyx_t_11 = (__pyx_v_nest_level - 1);
+    (__pyx_v_indexes[__pyx_t_11]) = ((__pyx_v_indexes[__pyx_t_11]) + 1);
+    __pyx_L21_continue:;
+  }
+
+  /* "asyncpg/protocol/codecs/array.pyx":571
+ *         indexes[nest_level - 1] += 1
+ * 
+ *     return result             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  if (unlikely(!__pyx_v_result)) { __Pyx_RaiseUnboundLocalError("result"); __PYX_ERR(20, 571, __pyx_L1_error) }
+  __Pyx_INCREF(__pyx_v_result);
+  __pyx_r = __pyx_v_result;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":340
+ * 
+ * 
+ * cdef _textarray_decode(ConnectionSettings settings,             # <<<<<<<<<<<<<<
+ *                        Py_UCS4 *array_text,
+ *                        decode_func_ex decoder,
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol._textarray_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_result);
+  __Pyx_XDECREF(__pyx_v_new_stride);
+  __Pyx_XDECREF(__pyx_v_item);
+  __Pyx_XDECREF(__pyx_v_item_text);
+  __Pyx_XDECREF((PyObject *)__pyx_v_item_buf);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/array.pyx":583
+ * 
+ * 
+ * cdef _UnexpectedCharacter(const Py_UCS4 *array_text, const Py_UCS4 *ptr):             # <<<<<<<<<<<<<<
+ *     return ValueError('unexpected character {!r} at position {}'.format(
+ *         cpython.PyUnicode_FromOrdinal(<int>ptr[0]), ptr - array_text + 1))
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol__UnexpectedCharacter(Py_UCS4 const *__pyx_v_array_text, Py_UCS4 const *__pyx_v_ptr) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  int __pyx_t_6;
+  PyObject *__pyx_t_7 = NULL;
+  __Pyx_RefNannySetupContext("_UnexpectedCharacter", 0);
+
+  /* "asyncpg/protocol/codecs/array.pyx":584
+ * 
+ * cdef _UnexpectedCharacter(const Py_UCS4 *array_text, const Py_UCS4 *ptr):
+ *     return ValueError('unexpected character {!r} at position {}'.format(             # <<<<<<<<<<<<<<
+ *         cpython.PyUnicode_FromOrdinal(<int>ptr[0]), ptr - array_text + 1))
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_unexpected_character_r_at_positi, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(20, 584, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+
+  /* "asyncpg/protocol/codecs/array.pyx":585
+ * cdef _UnexpectedCharacter(const Py_UCS4 *array_text, const Py_UCS4 *ptr):
+ *     return ValueError('unexpected character {!r} at position {}'.format(
+ *         cpython.PyUnicode_FromOrdinal(<int>ptr[0]), ptr - array_text + 1))             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_3 = PyUnicode_FromOrdinal(((int)(__pyx_v_ptr[0]))); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 585, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = __Pyx_PyInt_From_ptrdiff_t(((__pyx_v_ptr - __pyx_v_array_text) + 1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(20, 585, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_5 = NULL;
+  __pyx_t_6 = 0;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_5)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_5);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+      __pyx_t_6 = 1;
+    }
+  }
+  #if CYTHON_FAST_PYCALL
+  if (PyFunction_Check(__pyx_t_2)) {
+    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_t_4};
+    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 584, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  } else
+  #endif
+  #if CYTHON_FAST_PYCCALL
+  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_t_4};
+    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 584, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  } else
+  #endif
+  {
+    __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(20, 584, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_7);
+    if (__pyx_t_5) {
+      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
+    }
+    __Pyx_GIVEREF(__pyx_t_3);
+    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
+    __Pyx_GIVEREF(__pyx_t_4);
+    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4);
+    __pyx_t_3 = 0;
+    __pyx_t_4 = 0;
+    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 584, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":584
+ * 
+ * cdef _UnexpectedCharacter(const Py_UCS4 *array_text, const Py_UCS4 *ptr):
+ *     return ValueError('unexpected character {!r} at position {}'.format(             # <<<<<<<<<<<<<<
+ *         cpython.PyUnicode_FromOrdinal(<int>ptr[0]), ptr - array_text + 1))
+ * 
+ */
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(20, 584, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
+  __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 584, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":583
+ * 
+ * 
+ * cdef _UnexpectedCharacter(const Py_UCS4 *array_text, const Py_UCS4 *ptr):             # <<<<<<<<<<<<<<
+ *     return ValueError('unexpected character {!r} at position {}'.format(
+ *         cpython.PyUnicode_FromOrdinal(<int>ptr[0]), ptr - array_text + 1))
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol._UnexpectedCharacter", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/array.pyx":588
+ * 
+ * 
+ * cdef _infer_array_dims(const Py_UCS4 *array_text,             # <<<<<<<<<<<<<<
+ *                        Py_UCS4 typdelim,
+ *                        int32_t *dims,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol__infer_array_dims(Py_UCS4 const *__pyx_v_array_text, Py_UCS4 __pyx_v_typdelim, int32_t *__pyx_v_dims, int32_t *__pyx_v_ndims) {
+  Py_UCS4 const *__pyx_v_ptr;
+  int __pyx_v_i;
+  int __pyx_v_nest_level;
+  int __pyx_v_end_of_array;
+  int __pyx_v_end_of_item;
+  int __pyx_v_in_quotes;
+  int __pyx_v_array_is_empty;
+  int __pyx_v_stride_len[6];
+  int __pyx_v_prev_stride_len[6];
+  enum __pyx_t_7asyncpg_8protocol_8protocol__ArrayParseState __pyx_v_parse_state;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  int __pyx_t_5;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  long __pyx_t_10;
+  __Pyx_RefNannySetupContext("_infer_array_dims", 0);
+
+  /* "asyncpg/protocol/codecs/array.pyx":593
+ *                        int32_t *ndims):
+ *     cdef:
+ *         const Py_UCS4 *ptr = array_text             # <<<<<<<<<<<<<<
+ *         int i
+ *         int nest_level = 0
+ */
+  __pyx_v_ptr = __pyx_v_array_text;
+
+  /* "asyncpg/protocol/codecs/array.pyx":595
+ *         const Py_UCS4 *ptr = array_text
+ *         int i
+ *         int nest_level = 0             # <<<<<<<<<<<<<<
+ *         bint end_of_array = False
+ *         bint end_of_item = False
+ */
+  __pyx_v_nest_level = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":596
+ *         int i
+ *         int nest_level = 0
+ *         bint end_of_array = False             # <<<<<<<<<<<<<<
+ *         bint end_of_item = False
+ *         bint in_quotes = False
+ */
+  __pyx_v_end_of_array = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":597
+ *         int nest_level = 0
+ *         bint end_of_array = False
+ *         bint end_of_item = False             # <<<<<<<<<<<<<<
+ *         bint in_quotes = False
+ *         bint array_is_empty = True
+ */
+  __pyx_v_end_of_item = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":598
+ *         bint end_of_array = False
+ *         bint end_of_item = False
+ *         bint in_quotes = False             # <<<<<<<<<<<<<<
+ *         bint array_is_empty = True
+ *         int stride_len[ARRAY_MAXDIM]
+ */
+  __pyx_v_in_quotes = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":599
+ *         bint end_of_item = False
+ *         bint in_quotes = False
+ *         bint array_is_empty = True             # <<<<<<<<<<<<<<
+ *         int stride_len[ARRAY_MAXDIM]
+ *         int prev_stride_len[ARRAY_MAXDIM]
+ */
+  __pyx_v_array_is_empty = 1;
+
+  /* "asyncpg/protocol/codecs/array.pyx":602
+ *         int stride_len[ARRAY_MAXDIM]
+ *         int prev_stride_len[ARRAY_MAXDIM]
+ *         _ArrayParseState parse_state = APS_START             # <<<<<<<<<<<<<<
+ * 
+ *     for i in range(ARRAY_MAXDIM):
+ */
+  __pyx_v_parse_state = __pyx_e_7asyncpg_8protocol_8protocol_APS_START;
+
+  /* "asyncpg/protocol/codecs/array.pyx":604
+ *         _ArrayParseState parse_state = APS_START
+ * 
+ *     for i in range(ARRAY_MAXDIM):             # <<<<<<<<<<<<<<
+ *         dims[i] = prev_stride_len[i] = 0
+ *         stride_len[i] = 1
+ */
+  for (__pyx_t_1 = 0; __pyx_t_1 < 6; __pyx_t_1+=1) {
+    __pyx_v_i = __pyx_t_1;
+
+    /* "asyncpg/protocol/codecs/array.pyx":605
+ * 
+ *     for i in range(ARRAY_MAXDIM):
+ *         dims[i] = prev_stride_len[i] = 0             # <<<<<<<<<<<<<<
+ *         stride_len[i] = 1
+ * 
+ */
+    (__pyx_v_dims[__pyx_v_i]) = 0;
+    (__pyx_v_prev_stride_len[__pyx_v_i]) = 0;
+
+    /* "asyncpg/protocol/codecs/array.pyx":606
+ *     for i in range(ARRAY_MAXDIM):
+ *         dims[i] = prev_stride_len[i] = 0
+ *         stride_len[i] = 1             # <<<<<<<<<<<<<<
+ * 
+ *     while not end_of_array:
+ */
+    (__pyx_v_stride_len[__pyx_v_i]) = 1;
+  }
+
+  /* "asyncpg/protocol/codecs/array.pyx":608
+ *         stride_len[i] = 1
+ * 
+ *     while not end_of_array:             # <<<<<<<<<<<<<<
+ *         end_of_item = False
+ * 
+ */
+  while (1) {
+    __pyx_t_2 = ((!(__pyx_v_end_of_array != 0)) != 0);
+    if (!__pyx_t_2) break;
+
+    /* "asyncpg/protocol/codecs/array.pyx":609
+ * 
+ *     while not end_of_array:
+ *         end_of_item = False             # <<<<<<<<<<<<<<
+ * 
+ *         while not end_of_item:
+ */
+    __pyx_v_end_of_item = 0;
+
+    /* "asyncpg/protocol/codecs/array.pyx":611
+ *         end_of_item = False
+ * 
+ *         while not end_of_item:             # <<<<<<<<<<<<<<
+ *             if ptr[0] == '\0':
+ *                 raise ValueError('unexpected end of string')
+ */
+    while (1) {
+      __pyx_t_2 = ((!(__pyx_v_end_of_item != 0)) != 0);
+      if (!__pyx_t_2) break;
+
+      /* "asyncpg/protocol/codecs/array.pyx":612
+ * 
+ *         while not end_of_item:
+ *             if ptr[0] == '\0':             # <<<<<<<<<<<<<<
+ *                 raise ValueError('unexpected end of string')
+ * 
+ */
+      __pyx_t_2 = (((__pyx_v_ptr[0]) == 0) != 0);
+      if (__pyx_t_2) {
+
+        /* "asyncpg/protocol/codecs/array.pyx":613
+ *         while not end_of_item:
+ *             if ptr[0] == '\0':
+ *                 raise ValueError('unexpected end of string')             # <<<<<<<<<<<<<<
+ * 
+ *             elif ptr[0] == '"':
+ */
+        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__49, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 613, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __PYX_ERR(20, 613, __pyx_L1_error)
+
+        /* "asyncpg/protocol/codecs/array.pyx":612
+ * 
+ *         while not end_of_item:
+ *             if ptr[0] == '\0':             # <<<<<<<<<<<<<<
+ *                 raise ValueError('unexpected end of string')
+ * 
+ */
+      }
+
+      /* "asyncpg/protocol/codecs/array.pyx":615
+ *                 raise ValueError('unexpected end of string')
+ * 
+ *             elif ptr[0] == '"':             # <<<<<<<<<<<<<<
+ *                 if (parse_state not in (APS_STRIDE_STARTED,
+ *                                         APS_ELEM_DELIMITED) and
+ */
+      __pyx_t_2 = (((__pyx_v_ptr[0]) == 34) != 0);
+      if (__pyx_t_2) {
+
+        /* "asyncpg/protocol/codecs/array.pyx":616
+ * 
+ *             elif ptr[0] == '"':
+ *                 if (parse_state not in (APS_STRIDE_STARTED,             # <<<<<<<<<<<<<<
+ *                                         APS_ELEM_DELIMITED) and
+ *                         not (parse_state == APS_ELEM_STARTED and in_quotes)):
+ */
+        switch (__pyx_v_parse_state) {
+          case __pyx_e_7asyncpg_8protocol_8protocol_APS_STRIDE_STARTED:
+
+          /* "asyncpg/protocol/codecs/array.pyx":617
+ *             elif ptr[0] == '"':
+ *                 if (parse_state not in (APS_STRIDE_STARTED,
+ *                                         APS_ELEM_DELIMITED) and             # <<<<<<<<<<<<<<
+ *                         not (parse_state == APS_ELEM_STARTED and in_quotes)):
+ *                     raise _UnexpectedCharacter(array_text, ptr)
+ */
+          case __pyx_e_7asyncpg_8protocol_8protocol_APS_ELEM_DELIMITED:
+
+          /* "asyncpg/protocol/codecs/array.pyx":616
+ * 
+ *             elif ptr[0] == '"':
+ *                 if (parse_state not in (APS_STRIDE_STARTED,             # <<<<<<<<<<<<<<
+ *                                         APS_ELEM_DELIMITED) and
+ *                         not (parse_state == APS_ELEM_STARTED and in_quotes)):
+ */
+          __pyx_t_4 = 0;
+          break;
+          default:
+          __pyx_t_4 = 1;
+          break;
+        }
+        __pyx_t_5 = (__pyx_t_4 != 0);
+        if (__pyx_t_5) {
+        } else {
+          __pyx_t_2 = __pyx_t_5;
+          goto __pyx_L11_bool_binop_done;
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":618
+ *                 if (parse_state not in (APS_STRIDE_STARTED,
+ *                                         APS_ELEM_DELIMITED) and
+ *                         not (parse_state == APS_ELEM_STARTED and in_quotes)):             # <<<<<<<<<<<<<<
+ *                     raise _UnexpectedCharacter(array_text, ptr)
+ * 
+ */
+        __pyx_t_4 = ((__pyx_v_parse_state == __pyx_e_7asyncpg_8protocol_8protocol_APS_ELEM_STARTED) != 0);
+        if (__pyx_t_4) {
+        } else {
+          __pyx_t_5 = __pyx_t_4;
+          goto __pyx_L13_bool_binop_done;
+        }
+        __pyx_t_4 = (__pyx_v_in_quotes != 0);
+        __pyx_t_5 = __pyx_t_4;
+        __pyx_L13_bool_binop_done:;
+        __pyx_t_4 = ((!__pyx_t_5) != 0);
+        __pyx_t_2 = __pyx_t_4;
+        __pyx_L11_bool_binop_done:;
+
+        /* "asyncpg/protocol/codecs/array.pyx":616
+ * 
+ *             elif ptr[0] == '"':
+ *                 if (parse_state not in (APS_STRIDE_STARTED,             # <<<<<<<<<<<<<<
+ *                                         APS_ELEM_DELIMITED) and
+ *                         not (parse_state == APS_ELEM_STARTED and in_quotes)):
+ */
+        if (__pyx_t_2) {
+
+          /* "asyncpg/protocol/codecs/array.pyx":619
+ *                                         APS_ELEM_DELIMITED) and
+ *                         not (parse_state == APS_ELEM_STARTED and in_quotes)):
+ *                     raise _UnexpectedCharacter(array_text, ptr)             # <<<<<<<<<<<<<<
+ * 
+ *                 in_quotes = not in_quotes
+ */
+          __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol__UnexpectedCharacter(__pyx_v_array_text, __pyx_v_ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 619, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_3);
+          __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+          __PYX_ERR(20, 619, __pyx_L1_error)
+
+          /* "asyncpg/protocol/codecs/array.pyx":616
+ * 
+ *             elif ptr[0] == '"':
+ *                 if (parse_state not in (APS_STRIDE_STARTED,             # <<<<<<<<<<<<<<
+ *                                         APS_ELEM_DELIMITED) and
+ *                         not (parse_state == APS_ELEM_STARTED and in_quotes)):
+ */
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":621
+ *                     raise _UnexpectedCharacter(array_text, ptr)
+ * 
+ *                 in_quotes = not in_quotes             # <<<<<<<<<<<<<<
+ *                 if in_quotes:
+ *                     parse_state = APS_ELEM_STARTED
+ */
+        __pyx_v_in_quotes = (!(__pyx_v_in_quotes != 0));
+
+        /* "asyncpg/protocol/codecs/array.pyx":622
+ * 
+ *                 in_quotes = not in_quotes
+ *                 if in_quotes:             # <<<<<<<<<<<<<<
+ *                     parse_state = APS_ELEM_STARTED
+ *                     array_is_empty = False
+ */
+        __pyx_t_2 = (__pyx_v_in_quotes != 0);
+        if (__pyx_t_2) {
+
+          /* "asyncpg/protocol/codecs/array.pyx":623
+ *                 in_quotes = not in_quotes
+ *                 if in_quotes:
+ *                     parse_state = APS_ELEM_STARTED             # <<<<<<<<<<<<<<
+ *                     array_is_empty = False
+ * 
+ */
+          __pyx_v_parse_state = __pyx_e_7asyncpg_8protocol_8protocol_APS_ELEM_STARTED;
+
+          /* "asyncpg/protocol/codecs/array.pyx":624
+ *                 if in_quotes:
+ *                     parse_state = APS_ELEM_STARTED
+ *                     array_is_empty = False             # <<<<<<<<<<<<<<
+ * 
+ *             elif ptr[0] == '\\':
+ */
+          __pyx_v_array_is_empty = 0;
+
+          /* "asyncpg/protocol/codecs/array.pyx":622
+ * 
+ *                 in_quotes = not in_quotes
+ *                 if in_quotes:             # <<<<<<<<<<<<<<
+ *                     parse_state = APS_ELEM_STARTED
+ *                     array_is_empty = False
+ */
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":615
+ *                 raise ValueError('unexpected end of string')
+ * 
+ *             elif ptr[0] == '"':             # <<<<<<<<<<<<<<
+ *                 if (parse_state not in (APS_STRIDE_STARTED,
+ *                                         APS_ELEM_DELIMITED) and
+ */
+        goto __pyx_L9;
+      }
+
+      /* "asyncpg/protocol/codecs/array.pyx":626
+ *                     array_is_empty = False
+ * 
+ *             elif ptr[0] == '\\':             # <<<<<<<<<<<<<<
+ *                 if parse_state not in (APS_STRIDE_STARTED,
+ *                                        APS_ELEM_STARTED,
+ */
+      __pyx_t_2 = (((__pyx_v_ptr[0]) == 92) != 0);
+      if (__pyx_t_2) {
+
+        /* "asyncpg/protocol/codecs/array.pyx":627
+ * 
+ *             elif ptr[0] == '\\':
+ *                 if parse_state not in (APS_STRIDE_STARTED,             # <<<<<<<<<<<<<<
+ *                                        APS_ELEM_STARTED,
+ *                                        APS_ELEM_DELIMITED):
+ */
+        switch (__pyx_v_parse_state) {
+          case __pyx_e_7asyncpg_8protocol_8protocol_APS_STRIDE_STARTED:
+
+          /* "asyncpg/protocol/codecs/array.pyx":628
+ *             elif ptr[0] == '\\':
+ *                 if parse_state not in (APS_STRIDE_STARTED,
+ *                                        APS_ELEM_STARTED,             # <<<<<<<<<<<<<<
+ *                                        APS_ELEM_DELIMITED):
+ *                     raise _UnexpectedCharacter(array_text, ptr)
+ */
+          case __pyx_e_7asyncpg_8protocol_8protocol_APS_ELEM_STARTED:
+
+          /* "asyncpg/protocol/codecs/array.pyx":629
+ *                 if parse_state not in (APS_STRIDE_STARTED,
+ *                                        APS_ELEM_STARTED,
+ *                                        APS_ELEM_DELIMITED):             # <<<<<<<<<<<<<<
+ *                     raise _UnexpectedCharacter(array_text, ptr)
+ * 
+ */
+          case __pyx_e_7asyncpg_8protocol_8protocol_APS_ELEM_DELIMITED:
+
+          /* "asyncpg/protocol/codecs/array.pyx":627
+ * 
+ *             elif ptr[0] == '\\':
+ *                 if parse_state not in (APS_STRIDE_STARTED,             # <<<<<<<<<<<<<<
+ *                                        APS_ELEM_STARTED,
+ *                                        APS_ELEM_DELIMITED):
+ */
+          __pyx_t_2 = 0;
+          break;
+          default:
+          __pyx_t_2 = 1;
+          break;
+        }
+        __pyx_t_4 = (__pyx_t_2 != 0);
+        if (__pyx_t_4) {
+
+          /* "asyncpg/protocol/codecs/array.pyx":630
+ *                                        APS_ELEM_STARTED,
+ *                                        APS_ELEM_DELIMITED):
+ *                     raise _UnexpectedCharacter(array_text, ptr)             # <<<<<<<<<<<<<<
+ * 
+ *                 parse_state = APS_ELEM_STARTED
+ */
+          __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol__UnexpectedCharacter(__pyx_v_array_text, __pyx_v_ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 630, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_3);
+          __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+          __PYX_ERR(20, 630, __pyx_L1_error)
+
+          /* "asyncpg/protocol/codecs/array.pyx":627
+ * 
+ *             elif ptr[0] == '\\':
+ *                 if parse_state not in (APS_STRIDE_STARTED,             # <<<<<<<<<<<<<<
+ *                                        APS_ELEM_STARTED,
+ *                                        APS_ELEM_DELIMITED):
+ */
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":632
+ *                     raise _UnexpectedCharacter(array_text, ptr)
+ * 
+ *                 parse_state = APS_ELEM_STARTED             # <<<<<<<<<<<<<<
+ *                 array_is_empty = False
+ * 
+ */
+        __pyx_v_parse_state = __pyx_e_7asyncpg_8protocol_8protocol_APS_ELEM_STARTED;
+
+        /* "asyncpg/protocol/codecs/array.pyx":633
+ * 
+ *                 parse_state = APS_ELEM_STARTED
+ *                 array_is_empty = False             # <<<<<<<<<<<<<<
+ * 
+ *                 if ptr[1] != '\0':
+ */
+        __pyx_v_array_is_empty = 0;
+
+        /* "asyncpg/protocol/codecs/array.pyx":635
+ *                 array_is_empty = False
+ * 
+ *                 if ptr[1] != '\0':             # <<<<<<<<<<<<<<
+ *                     ptr += 1
+ *                 else:
+ */
+        __pyx_t_4 = (((__pyx_v_ptr[1]) != 0) != 0);
+        if (__pyx_t_4) {
+
+          /* "asyncpg/protocol/codecs/array.pyx":636
+ * 
+ *                 if ptr[1] != '\0':
+ *                     ptr += 1             # <<<<<<<<<<<<<<
+ *                 else:
+ *                     raise ValueError('unexpected end of string')
+ */
+          __pyx_v_ptr = (__pyx_v_ptr + 1);
+
+          /* "asyncpg/protocol/codecs/array.pyx":635
+ *                 array_is_empty = False
+ * 
+ *                 if ptr[1] != '\0':             # <<<<<<<<<<<<<<
+ *                     ptr += 1
+ *                 else:
+ */
+          goto __pyx_L17;
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":638
+ *                     ptr += 1
+ *                 else:
+ *                     raise ValueError('unexpected end of string')             # <<<<<<<<<<<<<<
+ * 
+ *             elif in_quotes:
+ */
+        /*else*/ {
+          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__50, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 638, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_3);
+          __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+          __PYX_ERR(20, 638, __pyx_L1_error)
+        }
+        __pyx_L17:;
+
+        /* "asyncpg/protocol/codecs/array.pyx":626
+ *                     array_is_empty = False
+ * 
+ *             elif ptr[0] == '\\':             # <<<<<<<<<<<<<<
+ *                 if parse_state not in (APS_STRIDE_STARTED,
+ *                                        APS_ELEM_STARTED,
+ */
+        goto __pyx_L9;
+      }
+
+      /* "asyncpg/protocol/codecs/array.pyx":640
+ *                     raise ValueError('unexpected end of string')
+ * 
+ *             elif in_quotes:             # <<<<<<<<<<<<<<
+ *                 # Ignore everything inside the quotes.
+ *                 pass
+ */
+      __pyx_t_4 = (__pyx_v_in_quotes != 0);
+      if (__pyx_t_4) {
+        goto __pyx_L9;
+      }
+
+      /* "asyncpg/protocol/codecs/array.pyx":644
+ *                 pass
+ * 
+ *             elif ptr[0] == '{':             # <<<<<<<<<<<<<<
+ *                 if parse_state not in (APS_START,
+ *                                        APS_STRIDE_STARTED,
+ */
+      __pyx_t_4 = (((__pyx_v_ptr[0]) == 0x7B) != 0);
+      if (__pyx_t_4) {
+
+        /* "asyncpg/protocol/codecs/array.pyx":645
+ * 
+ *             elif ptr[0] == '{':
+ *                 if parse_state not in (APS_START,             # <<<<<<<<<<<<<<
+ *                                        APS_STRIDE_STARTED,
+ *                                        APS_STRIDE_DELIMITED):
+ */
+        switch (__pyx_v_parse_state) {
+          case __pyx_e_7asyncpg_8protocol_8protocol_APS_START:
+
+          /* "asyncpg/protocol/codecs/array.pyx":646
+ *             elif ptr[0] == '{':
+ *                 if parse_state not in (APS_START,
+ *                                        APS_STRIDE_STARTED,             # <<<<<<<<<<<<<<
+ *                                        APS_STRIDE_DELIMITED):
+ *                     raise _UnexpectedCharacter(array_text, ptr)
+ */
+          case __pyx_e_7asyncpg_8protocol_8protocol_APS_STRIDE_STARTED:
+
+          /* "asyncpg/protocol/codecs/array.pyx":647
+ *                 if parse_state not in (APS_START,
+ *                                        APS_STRIDE_STARTED,
+ *                                        APS_STRIDE_DELIMITED):             # <<<<<<<<<<<<<<
+ *                     raise _UnexpectedCharacter(array_text, ptr)
+ * 
+ */
+          case __pyx_e_7asyncpg_8protocol_8protocol_APS_STRIDE_DELIMITED:
+
+          /* "asyncpg/protocol/codecs/array.pyx":645
+ * 
+ *             elif ptr[0] == '{':
+ *                 if parse_state not in (APS_START,             # <<<<<<<<<<<<<<
+ *                                        APS_STRIDE_STARTED,
+ *                                        APS_STRIDE_DELIMITED):
+ */
+          __pyx_t_4 = 0;
+          break;
+          default:
+          __pyx_t_4 = 1;
+          break;
+        }
+        __pyx_t_2 = (__pyx_t_4 != 0);
+        if (__pyx_t_2) {
+
+          /* "asyncpg/protocol/codecs/array.pyx":648
+ *                                        APS_STRIDE_STARTED,
+ *                                        APS_STRIDE_DELIMITED):
+ *                     raise _UnexpectedCharacter(array_text, ptr)             # <<<<<<<<<<<<<<
+ * 
+ *                 parse_state = APS_STRIDE_STARTED
+ */
+          __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol__UnexpectedCharacter(__pyx_v_array_text, __pyx_v_ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 648, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_3);
+          __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+          __PYX_ERR(20, 648, __pyx_L1_error)
+
+          /* "asyncpg/protocol/codecs/array.pyx":645
+ * 
+ *             elif ptr[0] == '{':
+ *                 if parse_state not in (APS_START,             # <<<<<<<<<<<<<<
+ *                                        APS_STRIDE_STARTED,
+ *                                        APS_STRIDE_DELIMITED):
+ */
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":650
+ *                     raise _UnexpectedCharacter(array_text, ptr)
+ * 
+ *                 parse_state = APS_STRIDE_STARTED             # <<<<<<<<<<<<<<
+ *                 if nest_level >= ARRAY_MAXDIM:
+ *                     raise ValueError(
+ */
+        __pyx_v_parse_state = __pyx_e_7asyncpg_8protocol_8protocol_APS_STRIDE_STARTED;
+
+        /* "asyncpg/protocol/codecs/array.pyx":651
+ * 
+ *                 parse_state = APS_STRIDE_STARTED
+ *                 if nest_level >= ARRAY_MAXDIM:             # <<<<<<<<<<<<<<
+ *                     raise ValueError(
+ *                         'number of array dimensions ({}) exceed the '
+ */
+        __pyx_t_2 = ((__pyx_v_nest_level >= 6) != 0);
+        if (__pyx_t_2) {
+
+          /* "asyncpg/protocol/codecs/array.pyx":654
+ *                     raise ValueError(
+ *                         'number of array dimensions ({}) exceed the '
+ *                         'maximum expected ({})'.format(             # <<<<<<<<<<<<<<
+ *                             nest_level, ARRAY_MAXDIM))
+ * 
+ */
+          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_number_of_array_dimensions_excee, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(20, 654, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_6);
+
+          /* "asyncpg/protocol/codecs/array.pyx":655
+ *                         'number of array dimensions ({}) exceed the '
+ *                         'maximum expected ({})'.format(
+ *                             nest_level, ARRAY_MAXDIM))             # <<<<<<<<<<<<<<
+ * 
+ *                 dims[nest_level] = 0
+ */
+          __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_nest_level); if (unlikely(!__pyx_t_7)) __PYX_ERR(20, 655, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_7);
+          __pyx_t_8 = NULL;
+          __pyx_t_1 = 0;
+          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
+            __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
+            if (likely(__pyx_t_8)) {
+              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
+              __Pyx_INCREF(__pyx_t_8);
+              __Pyx_INCREF(function);
+              __Pyx_DECREF_SET(__pyx_t_6, function);
+              __pyx_t_1 = 1;
+            }
+          }
+          #if CYTHON_FAST_PYCALL
+          if (PyFunction_Check(__pyx_t_6)) {
+            PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_7, __pyx_int_6};
+            __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_1, 2+__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 654, __pyx_L1_error)
+            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+            __Pyx_GOTREF(__pyx_t_3);
+            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+          } else
+          #endif
+          #if CYTHON_FAST_PYCCALL
+          if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
+            PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_7, __pyx_int_6};
+            __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_1, 2+__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 654, __pyx_L1_error)
+            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+            __Pyx_GOTREF(__pyx_t_3);
+            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+          } else
+          #endif
+          {
+            __pyx_t_9 = PyTuple_New(2+__pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(20, 654, __pyx_L1_error)
+            __Pyx_GOTREF(__pyx_t_9);
+            if (__pyx_t_8) {
+              __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
+            }
+            __Pyx_GIVEREF(__pyx_t_7);
+            PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_1, __pyx_t_7);
+            __Pyx_INCREF(__pyx_int_6);
+            __Pyx_GIVEREF(__pyx_int_6);
+            PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_1, __pyx_int_6);
+            __pyx_t_7 = 0;
+            __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 654, __pyx_L1_error)
+            __Pyx_GOTREF(__pyx_t_3);
+            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+          }
+          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+          /* "asyncpg/protocol/codecs/array.pyx":652
+ *                 parse_state = APS_STRIDE_STARTED
+ *                 if nest_level >= ARRAY_MAXDIM:
+ *                     raise ValueError(             # <<<<<<<<<<<<<<
+ *                         'number of array dimensions ({}) exceed the '
+ *                         'maximum expected ({})'.format(
+ */
+          __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(20, 652, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_6);
+          __Pyx_GIVEREF(__pyx_t_3);
+          PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
+          __pyx_t_3 = 0;
+          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 652, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_3);
+          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+          __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+          __PYX_ERR(20, 652, __pyx_L1_error)
+
+          /* "asyncpg/protocol/codecs/array.pyx":651
+ * 
+ *                 parse_state = APS_STRIDE_STARTED
+ *                 if nest_level >= ARRAY_MAXDIM:             # <<<<<<<<<<<<<<
+ *                     raise ValueError(
+ *                         'number of array dimensions ({}) exceed the '
+ */
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":657
+ *                             nest_level, ARRAY_MAXDIM))
+ * 
+ *                 dims[nest_level] = 0             # <<<<<<<<<<<<<<
+ *                 nest_level += 1
+ *                 if ndims[0] < nest_level:
+ */
+        (__pyx_v_dims[__pyx_v_nest_level]) = 0;
+
+        /* "asyncpg/protocol/codecs/array.pyx":658
+ * 
+ *                 dims[nest_level] = 0
+ *                 nest_level += 1             # <<<<<<<<<<<<<<
+ *                 if ndims[0] < nest_level:
+ *                     ndims[0] = nest_level
+ */
+        __pyx_v_nest_level = (__pyx_v_nest_level + 1);
+
+        /* "asyncpg/protocol/codecs/array.pyx":659
+ *                 dims[nest_level] = 0
+ *                 nest_level += 1
+ *                 if ndims[0] < nest_level:             # <<<<<<<<<<<<<<
+ *                     ndims[0] = nest_level
+ * 
+ */
+        __pyx_t_2 = (((__pyx_v_ndims[0]) < __pyx_v_nest_level) != 0);
+        if (__pyx_t_2) {
+
+          /* "asyncpg/protocol/codecs/array.pyx":660
+ *                 nest_level += 1
+ *                 if ndims[0] < nest_level:
+ *                     ndims[0] = nest_level             # <<<<<<<<<<<<<<
+ * 
+ *             elif ptr[0] == '}':
+ */
+          (__pyx_v_ndims[0]) = __pyx_v_nest_level;
+
+          /* "asyncpg/protocol/codecs/array.pyx":659
+ *                 dims[nest_level] = 0
+ *                 nest_level += 1
+ *                 if ndims[0] < nest_level:             # <<<<<<<<<<<<<<
+ *                     ndims[0] = nest_level
+ * 
+ */
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":644
+ *                 pass
+ * 
+ *             elif ptr[0] == '{':             # <<<<<<<<<<<<<<
+ *                 if parse_state not in (APS_START,
+ *                                        APS_STRIDE_STARTED,
+ */
+        goto __pyx_L9;
+      }
+
+      /* "asyncpg/protocol/codecs/array.pyx":662
+ *                     ndims[0] = nest_level
+ * 
+ *             elif ptr[0] == '}':             # <<<<<<<<<<<<<<
+ *                 if (parse_state not in (APS_ELEM_STARTED, APS_STRIDE_DONE) and
+ *                         not (nest_level == 1 and
+ */
+      __pyx_t_2 = (((__pyx_v_ptr[0]) == 0x7D) != 0);
+      if (__pyx_t_2) {
+
+        /* "asyncpg/protocol/codecs/array.pyx":663
+ * 
+ *             elif ptr[0] == '}':
+ *                 if (parse_state not in (APS_ELEM_STARTED, APS_STRIDE_DONE) and             # <<<<<<<<<<<<<<
+ *                         not (nest_level == 1 and
+ *                              parse_state == APS_STRIDE_STARTED)):
+ */
+        switch (__pyx_v_parse_state) {
+          case __pyx_e_7asyncpg_8protocol_8protocol_APS_ELEM_STARTED:
+          case __pyx_e_7asyncpg_8protocol_8protocol_APS_STRIDE_DONE:
+          __pyx_t_4 = 0;
+          break;
+          default:
+          __pyx_t_4 = 1;
+          break;
+        }
+        __pyx_t_5 = (__pyx_t_4 != 0);
+        if (__pyx_t_5) {
+        } else {
+          __pyx_t_2 = __pyx_t_5;
+          goto __pyx_L22_bool_binop_done;
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":664
+ *             elif ptr[0] == '}':
+ *                 if (parse_state not in (APS_ELEM_STARTED, APS_STRIDE_DONE) and
+ *                         not (nest_level == 1 and             # <<<<<<<<<<<<<<
+ *                              parse_state == APS_STRIDE_STARTED)):
+ *                     raise _UnexpectedCharacter(array_text, ptr)
+ */
+        __pyx_t_4 = ((__pyx_v_nest_level == 1) != 0);
+        if (__pyx_t_4) {
+        } else {
+          __pyx_t_5 = __pyx_t_4;
+          goto __pyx_L24_bool_binop_done;
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":665
+ *                 if (parse_state not in (APS_ELEM_STARTED, APS_STRIDE_DONE) and
+ *                         not (nest_level == 1 and
+ *                              parse_state == APS_STRIDE_STARTED)):             # <<<<<<<<<<<<<<
+ *                     raise _UnexpectedCharacter(array_text, ptr)
+ * 
+ */
+        __pyx_t_4 = ((__pyx_v_parse_state == __pyx_e_7asyncpg_8protocol_8protocol_APS_STRIDE_STARTED) != 0);
+        __pyx_t_5 = __pyx_t_4;
+        __pyx_L24_bool_binop_done:;
+
+        /* "asyncpg/protocol/codecs/array.pyx":664
+ *             elif ptr[0] == '}':
+ *                 if (parse_state not in (APS_ELEM_STARTED, APS_STRIDE_DONE) and
+ *                         not (nest_level == 1 and             # <<<<<<<<<<<<<<
+ *                              parse_state == APS_STRIDE_STARTED)):
+ *                     raise _UnexpectedCharacter(array_text, ptr)
+ */
+        __pyx_t_4 = ((!__pyx_t_5) != 0);
+        __pyx_t_2 = __pyx_t_4;
+        __pyx_L22_bool_binop_done:;
+
+        /* "asyncpg/protocol/codecs/array.pyx":663
+ * 
+ *             elif ptr[0] == '}':
+ *                 if (parse_state not in (APS_ELEM_STARTED, APS_STRIDE_DONE) and             # <<<<<<<<<<<<<<
+ *                         not (nest_level == 1 and
+ *                              parse_state == APS_STRIDE_STARTED)):
+ */
+        if (__pyx_t_2) {
+
+          /* "asyncpg/protocol/codecs/array.pyx":666
+ *                         not (nest_level == 1 and
+ *                              parse_state == APS_STRIDE_STARTED)):
+ *                     raise _UnexpectedCharacter(array_text, ptr)             # <<<<<<<<<<<<<<
+ * 
+ *                 parse_state = APS_STRIDE_DONE
+ */
+          __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol__UnexpectedCharacter(__pyx_v_array_text, __pyx_v_ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 666, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_3);
+          __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+          __PYX_ERR(20, 666, __pyx_L1_error)
+
+          /* "asyncpg/protocol/codecs/array.pyx":663
+ * 
+ *             elif ptr[0] == '}':
+ *                 if (parse_state not in (APS_ELEM_STARTED, APS_STRIDE_DONE) and             # <<<<<<<<<<<<<<
+ *                         not (nest_level == 1 and
+ *                              parse_state == APS_STRIDE_STARTED)):
+ */
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":668
+ *                     raise _UnexpectedCharacter(array_text, ptr)
+ * 
+ *                 parse_state = APS_STRIDE_DONE             # <<<<<<<<<<<<<<
+ * 
+ *                 if nest_level == 0:
+ */
+        __pyx_v_parse_state = __pyx_e_7asyncpg_8protocol_8protocol_APS_STRIDE_DONE;
+
+        /* "asyncpg/protocol/codecs/array.pyx":670
+ *                 parse_state = APS_STRIDE_DONE
+ * 
+ *                 if nest_level == 0:             # <<<<<<<<<<<<<<
+ *                     raise _UnexpectedCharacter(array_text, ptr)
+ * 
+ */
+        __pyx_t_2 = ((__pyx_v_nest_level == 0) != 0);
+        if (__pyx_t_2) {
+
+          /* "asyncpg/protocol/codecs/array.pyx":671
+ * 
+ *                 if nest_level == 0:
+ *                     raise _UnexpectedCharacter(array_text, ptr)             # <<<<<<<<<<<<<<
+ * 
+ *                 nest_level -= 1
+ */
+          __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol__UnexpectedCharacter(__pyx_v_array_text, __pyx_v_ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 671, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_3);
+          __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+          __PYX_ERR(20, 671, __pyx_L1_error)
+
+          /* "asyncpg/protocol/codecs/array.pyx":670
+ *                 parse_state = APS_STRIDE_DONE
+ * 
+ *                 if nest_level == 0:             # <<<<<<<<<<<<<<
+ *                     raise _UnexpectedCharacter(array_text, ptr)
+ * 
+ */
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":673
+ *                     raise _UnexpectedCharacter(array_text, ptr)
+ * 
+ *                 nest_level -= 1             # <<<<<<<<<<<<<<
+ * 
+ *                 if (prev_stride_len[nest_level] != 0 and
+ */
+        __pyx_v_nest_level = (__pyx_v_nest_level - 1);
+
+        /* "asyncpg/protocol/codecs/array.pyx":675
+ *                 nest_level -= 1
+ * 
+ *                 if (prev_stride_len[nest_level] != 0 and             # <<<<<<<<<<<<<<
+ *                         stride_len[nest_level] != prev_stride_len[nest_level]):
+ *                     raise ValueError(
+ */
+        __pyx_t_4 = (((__pyx_v_prev_stride_len[__pyx_v_nest_level]) != 0) != 0);
+        if (__pyx_t_4) {
+        } else {
+          __pyx_t_2 = __pyx_t_4;
+          goto __pyx_L28_bool_binop_done;
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":676
+ * 
+ *                 if (prev_stride_len[nest_level] != 0 and
+ *                         stride_len[nest_level] != prev_stride_len[nest_level]):             # <<<<<<<<<<<<<<
+ *                     raise ValueError(
+ *                         'inconsistent sub-array dimensions'
+ */
+        __pyx_t_4 = (((__pyx_v_stride_len[__pyx_v_nest_level]) != (__pyx_v_prev_stride_len[__pyx_v_nest_level])) != 0);
+        __pyx_t_2 = __pyx_t_4;
+        __pyx_L28_bool_binop_done:;
+
+        /* "asyncpg/protocol/codecs/array.pyx":675
+ *                 nest_level -= 1
+ * 
+ *                 if (prev_stride_len[nest_level] != 0 and             # <<<<<<<<<<<<<<
+ *                         stride_len[nest_level] != prev_stride_len[nest_level]):
+ *                     raise ValueError(
+ */
+        if (__pyx_t_2) {
+
+          /* "asyncpg/protocol/codecs/array.pyx":679
+ *                     raise ValueError(
+ *                         'inconsistent sub-array dimensions'
+ *                         ' at position {}'.format(             # <<<<<<<<<<<<<<
+ *                             ptr - array_text + 1))
+ * 
+ */
+          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_inconsistent_sub_array_dimension, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(20, 679, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_6);
+
+          /* "asyncpg/protocol/codecs/array.pyx":680
+ *                         'inconsistent sub-array dimensions'
+ *                         ' at position {}'.format(
+ *                             ptr - array_text + 1))             # <<<<<<<<<<<<<<
+ * 
+ *                 prev_stride_len[nest_level] = stride_len[nest_level]
+ */
+          __pyx_t_9 = __Pyx_PyInt_From_ptrdiff_t(((__pyx_v_ptr - __pyx_v_array_text) + 1)); if (unlikely(!__pyx_t_9)) __PYX_ERR(20, 680, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_9);
+          __pyx_t_7 = NULL;
+          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
+            __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
+            if (likely(__pyx_t_7)) {
+              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
+              __Pyx_INCREF(__pyx_t_7);
+              __Pyx_INCREF(function);
+              __Pyx_DECREF_SET(__pyx_t_6, function);
+            }
+          }
+          if (!__pyx_t_7) {
+            __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 679, __pyx_L1_error)
+            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+            __Pyx_GOTREF(__pyx_t_3);
+          } else {
+            #if CYTHON_FAST_PYCALL
+            if (PyFunction_Check(__pyx_t_6)) {
+              PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_9};
+              __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 679, __pyx_L1_error)
+              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+              __Pyx_GOTREF(__pyx_t_3);
+              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+            } else
+            #endif
+            #if CYTHON_FAST_PYCCALL
+            if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
+              PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_9};
+              __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 679, __pyx_L1_error)
+              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+              __Pyx_GOTREF(__pyx_t_3);
+              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+            } else
+            #endif
+            {
+              __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(20, 679, __pyx_L1_error)
+              __Pyx_GOTREF(__pyx_t_8);
+              __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
+              __Pyx_GIVEREF(__pyx_t_9);
+              PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_9);
+              __pyx_t_9 = 0;
+              __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 679, __pyx_L1_error)
+              __Pyx_GOTREF(__pyx_t_3);
+              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+            }
+          }
+          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+          /* "asyncpg/protocol/codecs/array.pyx":677
+ *                 if (prev_stride_len[nest_level] != 0 and
+ *                         stride_len[nest_level] != prev_stride_len[nest_level]):
+ *                     raise ValueError(             # <<<<<<<<<<<<<<
+ *                         'inconsistent sub-array dimensions'
+ *                         ' at position {}'.format(
+ */
+          __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(20, 677, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_6);
+          __Pyx_GIVEREF(__pyx_t_3);
+          PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
+          __pyx_t_3 = 0;
+          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 677, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_3);
+          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+          __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+          __PYX_ERR(20, 677, __pyx_L1_error)
+
+          /* "asyncpg/protocol/codecs/array.pyx":675
+ *                 nest_level -= 1
+ * 
+ *                 if (prev_stride_len[nest_level] != 0 and             # <<<<<<<<<<<<<<
+ *                         stride_len[nest_level] != prev_stride_len[nest_level]):
+ *                     raise ValueError(
+ */
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":682
+ *                             ptr - array_text + 1))
+ * 
+ *                 prev_stride_len[nest_level] = stride_len[nest_level]             # <<<<<<<<<<<<<<
+ *                 stride_len[nest_level] = 1
+ *                 if nest_level == 0:
+ */
+        (__pyx_v_prev_stride_len[__pyx_v_nest_level]) = (__pyx_v_stride_len[__pyx_v_nest_level]);
+
+        /* "asyncpg/protocol/codecs/array.pyx":683
+ * 
+ *                 prev_stride_len[nest_level] = stride_len[nest_level]
+ *                 stride_len[nest_level] = 1             # <<<<<<<<<<<<<<
+ *                 if nest_level == 0:
+ *                     end_of_array = end_of_item = True
+ */
+        (__pyx_v_stride_len[__pyx_v_nest_level]) = 1;
+
+        /* "asyncpg/protocol/codecs/array.pyx":684
+ *                 prev_stride_len[nest_level] = stride_len[nest_level]
+ *                 stride_len[nest_level] = 1
+ *                 if nest_level == 0:             # <<<<<<<<<<<<<<
+ *                     end_of_array = end_of_item = True
+ *                 else:
+ */
+        __pyx_t_2 = ((__pyx_v_nest_level == 0) != 0);
+        if (__pyx_t_2) {
+
+          /* "asyncpg/protocol/codecs/array.pyx":685
+ *                 stride_len[nest_level] = 1
+ *                 if nest_level == 0:
+ *                     end_of_array = end_of_item = True             # <<<<<<<<<<<<<<
+ *                 else:
+ *                     dims[nest_level - 1] += 1
+ */
+          __pyx_v_end_of_array = 1;
+          __pyx_v_end_of_item = 1;
+
+          /* "asyncpg/protocol/codecs/array.pyx":684
+ *                 prev_stride_len[nest_level] = stride_len[nest_level]
+ *                 stride_len[nest_level] = 1
+ *                 if nest_level == 0:             # <<<<<<<<<<<<<<
+ *                     end_of_array = end_of_item = True
+ *                 else:
+ */
+          goto __pyx_L30;
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":687
+ *                     end_of_array = end_of_item = True
+ *                 else:
+ *                     dims[nest_level - 1] += 1             # <<<<<<<<<<<<<<
+ * 
+ *             elif ptr[0] == typdelim:
+ */
+        /*else*/ {
+          __pyx_t_10 = (__pyx_v_nest_level - 1);
+          (__pyx_v_dims[__pyx_t_10]) = ((__pyx_v_dims[__pyx_t_10]) + 1);
+        }
+        __pyx_L30:;
+
+        /* "asyncpg/protocol/codecs/array.pyx":662
+ *                     ndims[0] = nest_level
+ * 
+ *             elif ptr[0] == '}':             # <<<<<<<<<<<<<<
+ *                 if (parse_state not in (APS_ELEM_STARTED, APS_STRIDE_DONE) and
+ *                         not (nest_level == 1 and
+ */
+        goto __pyx_L9;
+      }
+
+      /* "asyncpg/protocol/codecs/array.pyx":689
+ *                     dims[nest_level - 1] += 1
+ * 
+ *             elif ptr[0] == typdelim:             # <<<<<<<<<<<<<<
+ *                 if parse_state not in (APS_ELEM_STARTED, APS_STRIDE_DONE):
+ *                     raise _UnexpectedCharacter(array_text, ptr)
+ */
+      __pyx_t_2 = (((__pyx_v_ptr[0]) == __pyx_v_typdelim) != 0);
+      if (__pyx_t_2) {
+
+        /* "asyncpg/protocol/codecs/array.pyx":690
+ * 
+ *             elif ptr[0] == typdelim:
+ *                 if parse_state not in (APS_ELEM_STARTED, APS_STRIDE_DONE):             # <<<<<<<<<<<<<<
+ *                     raise _UnexpectedCharacter(array_text, ptr)
+ * 
+ */
+        switch (__pyx_v_parse_state) {
+          case __pyx_e_7asyncpg_8protocol_8protocol_APS_ELEM_STARTED:
+          case __pyx_e_7asyncpg_8protocol_8protocol_APS_STRIDE_DONE:
+          __pyx_t_2 = 0;
+          break;
+          default:
+          __pyx_t_2 = 1;
+          break;
+        }
+        __pyx_t_4 = (__pyx_t_2 != 0);
+        if (__pyx_t_4) {
+
+          /* "asyncpg/protocol/codecs/array.pyx":691
+ *             elif ptr[0] == typdelim:
+ *                 if parse_state not in (APS_ELEM_STARTED, APS_STRIDE_DONE):
+ *                     raise _UnexpectedCharacter(array_text, ptr)             # <<<<<<<<<<<<<<
+ * 
+ *                 if parse_state == APS_STRIDE_DONE:
+ */
+          __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol__UnexpectedCharacter(__pyx_v_array_text, __pyx_v_ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 691, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_3);
+          __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+          __PYX_ERR(20, 691, __pyx_L1_error)
+
+          /* "asyncpg/protocol/codecs/array.pyx":690
+ * 
+ *             elif ptr[0] == typdelim:
+ *                 if parse_state not in (APS_ELEM_STARTED, APS_STRIDE_DONE):             # <<<<<<<<<<<<<<
+ *                     raise _UnexpectedCharacter(array_text, ptr)
+ * 
+ */
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":693
+ *                     raise _UnexpectedCharacter(array_text, ptr)
+ * 
+ *                 if parse_state == APS_STRIDE_DONE:             # <<<<<<<<<<<<<<
+ *                     parse_state = APS_STRIDE_DELIMITED
+ *                 else:
+ */
+        __pyx_t_4 = ((__pyx_v_parse_state == __pyx_e_7asyncpg_8protocol_8protocol_APS_STRIDE_DONE) != 0);
+        if (__pyx_t_4) {
+
+          /* "asyncpg/protocol/codecs/array.pyx":694
+ * 
+ *                 if parse_state == APS_STRIDE_DONE:
+ *                     parse_state = APS_STRIDE_DELIMITED             # <<<<<<<<<<<<<<
+ *                 else:
+ *                     parse_state = APS_ELEM_DELIMITED
+ */
+          __pyx_v_parse_state = __pyx_e_7asyncpg_8protocol_8protocol_APS_STRIDE_DELIMITED;
+
+          /* "asyncpg/protocol/codecs/array.pyx":693
+ *                     raise _UnexpectedCharacter(array_text, ptr)
+ * 
+ *                 if parse_state == APS_STRIDE_DONE:             # <<<<<<<<<<<<<<
+ *                     parse_state = APS_STRIDE_DELIMITED
+ *                 else:
+ */
+          goto __pyx_L32;
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":696
+ *                     parse_state = APS_STRIDE_DELIMITED
+ *                 else:
+ *                     parse_state = APS_ELEM_DELIMITED             # <<<<<<<<<<<<<<
+ *                 end_of_item = True
+ *                 stride_len[nest_level - 1] += 1
+ */
+        /*else*/ {
+          __pyx_v_parse_state = __pyx_e_7asyncpg_8protocol_8protocol_APS_ELEM_DELIMITED;
+        }
+        __pyx_L32:;
+
+        /* "asyncpg/protocol/codecs/array.pyx":697
+ *                 else:
+ *                     parse_state = APS_ELEM_DELIMITED
+ *                 end_of_item = True             # <<<<<<<<<<<<<<
+ *                 stride_len[nest_level - 1] += 1
+ * 
+ */
+        __pyx_v_end_of_item = 1;
+
+        /* "asyncpg/protocol/codecs/array.pyx":698
+ *                     parse_state = APS_ELEM_DELIMITED
+ *                 end_of_item = True
+ *                 stride_len[nest_level - 1] += 1             # <<<<<<<<<<<<<<
+ * 
+ *             elif not apg_ascii_isspace(ptr[0]):
+ */
+        __pyx_t_10 = (__pyx_v_nest_level - 1);
+        (__pyx_v_stride_len[__pyx_t_10]) = ((__pyx_v_stride_len[__pyx_t_10]) + 1);
+
+        /* "asyncpg/protocol/codecs/array.pyx":689
+ *                     dims[nest_level - 1] += 1
+ * 
+ *             elif ptr[0] == typdelim:             # <<<<<<<<<<<<<<
+ *                 if parse_state not in (APS_ELEM_STARTED, APS_STRIDE_DONE):
+ *                     raise _UnexpectedCharacter(array_text, ptr)
+ */
+        goto __pyx_L9;
+      }
+
+      /* "asyncpg/protocol/codecs/array.pyx":700
+ *                 stride_len[nest_level - 1] += 1
+ * 
+ *             elif not apg_ascii_isspace(ptr[0]):             # <<<<<<<<<<<<<<
+ *                 if parse_state not in (APS_STRIDE_STARTED,
+ *                                        APS_ELEM_STARTED,
+ */
+      __pyx_t_4 = ((!(__pyx_f_7asyncpg_8protocol_8protocol_apg_ascii_isspace((__pyx_v_ptr[0])) != 0)) != 0);
+      if (__pyx_t_4) {
+
+        /* "asyncpg/protocol/codecs/array.pyx":701
+ * 
+ *             elif not apg_ascii_isspace(ptr[0]):
+ *                 if parse_state not in (APS_STRIDE_STARTED,             # <<<<<<<<<<<<<<
+ *                                        APS_ELEM_STARTED,
+ *                                        APS_ELEM_DELIMITED):
+ */
+        switch (__pyx_v_parse_state) {
+          case __pyx_e_7asyncpg_8protocol_8protocol_APS_STRIDE_STARTED:
+
+          /* "asyncpg/protocol/codecs/array.pyx":702
+ *             elif not apg_ascii_isspace(ptr[0]):
+ *                 if parse_state not in (APS_STRIDE_STARTED,
+ *                                        APS_ELEM_STARTED,             # <<<<<<<<<<<<<<
+ *                                        APS_ELEM_DELIMITED):
+ *                     raise _UnexpectedCharacter(array_text, ptr)
+ */
+          case __pyx_e_7asyncpg_8protocol_8protocol_APS_ELEM_STARTED:
+
+          /* "asyncpg/protocol/codecs/array.pyx":703
+ *                 if parse_state not in (APS_STRIDE_STARTED,
+ *                                        APS_ELEM_STARTED,
+ *                                        APS_ELEM_DELIMITED):             # <<<<<<<<<<<<<<
+ *                     raise _UnexpectedCharacter(array_text, ptr)
+ * 
+ */
+          case __pyx_e_7asyncpg_8protocol_8protocol_APS_ELEM_DELIMITED:
+
+          /* "asyncpg/protocol/codecs/array.pyx":701
+ * 
+ *             elif not apg_ascii_isspace(ptr[0]):
+ *                 if parse_state not in (APS_STRIDE_STARTED,             # <<<<<<<<<<<<<<
+ *                                        APS_ELEM_STARTED,
+ *                                        APS_ELEM_DELIMITED):
+ */
+          __pyx_t_4 = 0;
+          break;
+          default:
+          __pyx_t_4 = 1;
+          break;
+        }
+        __pyx_t_2 = (__pyx_t_4 != 0);
+        if (__pyx_t_2) {
+
+          /* "asyncpg/protocol/codecs/array.pyx":704
+ *                                        APS_ELEM_STARTED,
+ *                                        APS_ELEM_DELIMITED):
+ *                     raise _UnexpectedCharacter(array_text, ptr)             # <<<<<<<<<<<<<<
+ * 
+ *                 parse_state = APS_ELEM_STARTED
+ */
+          __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol__UnexpectedCharacter(__pyx_v_array_text, __pyx_v_ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 704, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_3);
+          __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+          __PYX_ERR(20, 704, __pyx_L1_error)
+
+          /* "asyncpg/protocol/codecs/array.pyx":701
+ * 
+ *             elif not apg_ascii_isspace(ptr[0]):
+ *                 if parse_state not in (APS_STRIDE_STARTED,             # <<<<<<<<<<<<<<
+ *                                        APS_ELEM_STARTED,
+ *                                        APS_ELEM_DELIMITED):
+ */
+        }
+
+        /* "asyncpg/protocol/codecs/array.pyx":706
+ *                     raise _UnexpectedCharacter(array_text, ptr)
+ * 
+ *                 parse_state = APS_ELEM_STARTED             # <<<<<<<<<<<<<<
+ *                 array_is_empty = False
+ * 
+ */
+        __pyx_v_parse_state = __pyx_e_7asyncpg_8protocol_8protocol_APS_ELEM_STARTED;
+
+        /* "asyncpg/protocol/codecs/array.pyx":707
+ * 
+ *                 parse_state = APS_ELEM_STARTED
+ *                 array_is_empty = False             # <<<<<<<<<<<<<<
+ * 
+ *             if not end_of_item:
+ */
+        __pyx_v_array_is_empty = 0;
+
+        /* "asyncpg/protocol/codecs/array.pyx":700
+ *                 stride_len[nest_level - 1] += 1
+ * 
+ *             elif not apg_ascii_isspace(ptr[0]):             # <<<<<<<<<<<<<<
+ *                 if parse_state not in (APS_STRIDE_STARTED,
+ *                                        APS_ELEM_STARTED,
+ */
+      }
+      __pyx_L9:;
+
+      /* "asyncpg/protocol/codecs/array.pyx":709
+ *                 array_is_empty = False
+ * 
+ *             if not end_of_item:             # <<<<<<<<<<<<<<
+ *                 ptr += 1
+ * 
+ */
+      __pyx_t_2 = ((!(__pyx_v_end_of_item != 0)) != 0);
+      if (__pyx_t_2) {
+
+        /* "asyncpg/protocol/codecs/array.pyx":710
+ * 
+ *             if not end_of_item:
+ *                 ptr += 1             # <<<<<<<<<<<<<<
+ * 
+ *         if not array_is_empty:
+ */
+        __pyx_v_ptr = (__pyx_v_ptr + 1);
+
+        /* "asyncpg/protocol/codecs/array.pyx":709
+ *                 array_is_empty = False
+ * 
+ *             if not end_of_item:             # <<<<<<<<<<<<<<
+ *                 ptr += 1
+ * 
+ */
+      }
+    }
+
+    /* "asyncpg/protocol/codecs/array.pyx":712
+ *                 ptr += 1
+ * 
+ *         if not array_is_empty:             # <<<<<<<<<<<<<<
+ *             dims[ndims[0] - 1] += 1
+ * 
+ */
+    __pyx_t_2 = ((!(__pyx_v_array_is_empty != 0)) != 0);
+    if (__pyx_t_2) {
+
+      /* "asyncpg/protocol/codecs/array.pyx":713
+ * 
+ *         if not array_is_empty:
+ *             dims[ndims[0] - 1] += 1             # <<<<<<<<<<<<<<
+ * 
+ *         ptr += 1
+ */
+      __pyx_t_10 = ((__pyx_v_ndims[0]) - 1);
+      (__pyx_v_dims[__pyx_t_10]) = ((__pyx_v_dims[__pyx_t_10]) + 1);
+
+      /* "asyncpg/protocol/codecs/array.pyx":712
+ *                 ptr += 1
+ * 
+ *         if not array_is_empty:             # <<<<<<<<<<<<<<
+ *             dims[ndims[0] - 1] += 1
+ * 
+ */
+    }
+
+    /* "asyncpg/protocol/codecs/array.pyx":715
+ *             dims[ndims[0] - 1] += 1
+ * 
+ *         ptr += 1             # <<<<<<<<<<<<<<
+ * 
+ *     # only whitespace is allowed after the closing brace
+ */
+    __pyx_v_ptr = (__pyx_v_ptr + 1);
+  }
+
+  /* "asyncpg/protocol/codecs/array.pyx":718
+ * 
+ *     # only whitespace is allowed after the closing brace
+ *     while ptr[0] != '\0':             # <<<<<<<<<<<<<<
+ *         if not apg_ascii_isspace(ptr[0]):
+ *             raise _UnexpectedCharacter(array_text, ptr)
+ */
+  while (1) {
+    __pyx_t_2 = (((__pyx_v_ptr[0]) != 0) != 0);
+    if (!__pyx_t_2) break;
+
+    /* "asyncpg/protocol/codecs/array.pyx":719
+ *     # only whitespace is allowed after the closing brace
+ *     while ptr[0] != '\0':
+ *         if not apg_ascii_isspace(ptr[0]):             # <<<<<<<<<<<<<<
+ *             raise _UnexpectedCharacter(array_text, ptr)
+ * 
+ */
+    __pyx_t_2 = ((!(__pyx_f_7asyncpg_8protocol_8protocol_apg_ascii_isspace((__pyx_v_ptr[0])) != 0)) != 0);
+    if (__pyx_t_2) {
+
+      /* "asyncpg/protocol/codecs/array.pyx":720
+ *     while ptr[0] != '\0':
+ *         if not apg_ascii_isspace(ptr[0]):
+ *             raise _UnexpectedCharacter(array_text, ptr)             # <<<<<<<<<<<<<<
+ * 
+ *         ptr += 1
+ */
+      __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol__UnexpectedCharacter(__pyx_v_array_text, __pyx_v_ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 720, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __PYX_ERR(20, 720, __pyx_L1_error)
+
+      /* "asyncpg/protocol/codecs/array.pyx":719
+ *     # only whitespace is allowed after the closing brace
+ *     while ptr[0] != '\0':
+ *         if not apg_ascii_isspace(ptr[0]):             # <<<<<<<<<<<<<<
+ *             raise _UnexpectedCharacter(array_text, ptr)
+ * 
+ */
+    }
+
+    /* "asyncpg/protocol/codecs/array.pyx":722
+ *             raise _UnexpectedCharacter(array_text, ptr)
+ * 
+ *         ptr += 1             # <<<<<<<<<<<<<<
+ * 
+ *     if array_is_empty:
+ */
+    __pyx_v_ptr = (__pyx_v_ptr + 1);
+  }
+
+  /* "asyncpg/protocol/codecs/array.pyx":724
+ *         ptr += 1
+ * 
+ *     if array_is_empty:             # <<<<<<<<<<<<<<
+ *         ndims[0] = 0
+ * 
+ */
+  __pyx_t_2 = (__pyx_v_array_is_empty != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/codecs/array.pyx":725
+ * 
+ *     if array_is_empty:
+ *         ndims[0] = 0             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+    (__pyx_v_ndims[0]) = 0;
+
+    /* "asyncpg/protocol/codecs/array.pyx":724
+ *         ptr += 1
+ * 
+ *     if array_is_empty:             # <<<<<<<<<<<<<<
+ *         ndims[0] = 0
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/array.pyx":588
+ * 
+ * 
+ * cdef _infer_array_dims(const Py_UCS4 *array_text,             # <<<<<<<<<<<<<<
+ *                        Py_UCS4 typdelim,
+ *                        int32_t *dims,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol._infer_array_dims", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/array.pyx":728
+ * 
+ * 
+ * cdef int4_encode_ex(ConnectionSettings settings, WriteBuffer buf, object obj,             # <<<<<<<<<<<<<<
+ *                     const void *arg):
+ *     return int4_encode(settings, buf, obj)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_int4_encode_ex(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj, CYTHON_UNUSED void const *__pyx_v_arg) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("int4_encode_ex", 0);
+
+  /* "asyncpg/protocol/codecs/array.pyx":730
+ * cdef int4_encode_ex(ConnectionSettings settings, WriteBuffer buf, object obj,
+ *                     const void *arg):
+ *     return int4_encode(settings, buf, obj)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_int4_encode(__pyx_v_settings, __pyx_v_buf, __pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 730, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":728
+ * 
+ * 
+ * cdef int4_encode_ex(ConnectionSettings settings, WriteBuffer buf, object obj,             # <<<<<<<<<<<<<<
+ *                     const void *arg):
+ *     return int4_encode(settings, buf, obj)
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.int4_encode_ex", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/array.pyx":733
+ * 
+ * 
+ * cdef int4_decode_ex(ConnectionSettings settings, FastReadBuffer buf,             # <<<<<<<<<<<<<<
+ *                     const void *arg):
+ *     return int4_decode(settings, buf)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_int4_decode_ex(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf, CYTHON_UNUSED void const *__pyx_v_arg) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("int4_decode_ex", 0);
+
+  /* "asyncpg/protocol/codecs/array.pyx":735
+ * cdef int4_decode_ex(ConnectionSettings settings, FastReadBuffer buf,
+ *                     const void *arg):
+ *     return int4_decode(settings, buf)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_int4_decode(__pyx_v_settings, __pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 735, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":733
+ * 
+ * 
+ * cdef int4_decode_ex(ConnectionSettings settings, FastReadBuffer buf,             # <<<<<<<<<<<<<<
+ *                     const void *arg):
+ *     return int4_decode(settings, buf)
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.int4_decode_ex", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/array.pyx":738
+ * 
+ * 
+ * cdef arrayoid_encode(ConnectionSettings settings, WriteBuffer buf, items):             # <<<<<<<<<<<<<<
+ *     array_encode(settings, buf, items, OIDOID,
+ *                  <encode_func_ex>&int4_encode_ex, NULL)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_arrayoid_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_items) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("arrayoid_encode", 0);
+
+  /* "asyncpg/protocol/codecs/array.pyx":739
+ * 
+ * cdef arrayoid_encode(ConnectionSettings settings, WriteBuffer buf, items):
+ *     array_encode(settings, buf, items, OIDOID,             # <<<<<<<<<<<<<<
+ *                  <encode_func_ex>&int4_encode_ex, NULL)
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_array_encode(__pyx_v_settings, __pyx_v_buf, __pyx_v_items, 26, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func_ex)(&__pyx_f_7asyncpg_8protocol_8protocol_int4_encode_ex)), NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 739, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":738
+ * 
+ * 
+ * cdef arrayoid_encode(ConnectionSettings settings, WriteBuffer buf, items):             # <<<<<<<<<<<<<<
+ *     array_encode(settings, buf, items, OIDOID,
+ *                  <encode_func_ex>&int4_encode_ex, NULL)
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.arrayoid_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/array.pyx":743
+ * 
+ * 
+ * cdef arrayoid_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     return array_decode(settings, buf, <decode_func_ex>&int4_decode_ex, NULL)
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_arrayoid_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("arrayoid_decode", 0);
+
+  /* "asyncpg/protocol/codecs/array.pyx":744
+ * 
+ * cdef arrayoid_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     return array_decode(settings, buf, <decode_func_ex>&int4_decode_ex, NULL)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_array_decode(__pyx_v_settings, __pyx_v_buf, ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func_ex)(&__pyx_f_7asyncpg_8protocol_8protocol_int4_decode_ex)), NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 744, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":743
+ * 
+ * 
+ * cdef arrayoid_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     return array_decode(settings, buf, <decode_func_ex>&int4_decode_ex, NULL)
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.arrayoid_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/array.pyx":747
+ * 
+ * 
+ * cdef text_encode_ex(ConnectionSettings settings, WriteBuffer buf, object obj,             # <<<<<<<<<<<<<<
+ *                     const void *arg):
+ *     return text_encode(settings, buf, obj)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_text_encode_ex(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj, CYTHON_UNUSED void const *__pyx_v_arg) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("text_encode_ex", 0);
+
+  /* "asyncpg/protocol/codecs/array.pyx":749
+ * cdef text_encode_ex(ConnectionSettings settings, WriteBuffer buf, object obj,
+ *                     const void *arg):
+ *     return text_encode(settings, buf, obj)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_text_encode(__pyx_v_settings, __pyx_v_buf, __pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 749, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":747
+ * 
+ * 
+ * cdef text_encode_ex(ConnectionSettings settings, WriteBuffer buf, object obj,             # <<<<<<<<<<<<<<
+ *                     const void *arg):
+ *     return text_encode(settings, buf, obj)
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.text_encode_ex", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/array.pyx":752
+ * 
+ * 
+ * cdef text_decode_ex(ConnectionSettings settings, FastReadBuffer buf,             # <<<<<<<<<<<<<<
+ *                     const void *arg):
+ *     return text_decode(settings, buf)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_text_decode_ex(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf, CYTHON_UNUSED void const *__pyx_v_arg) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("text_decode_ex", 0);
+
+  /* "asyncpg/protocol/codecs/array.pyx":754
+ * cdef text_decode_ex(ConnectionSettings settings, FastReadBuffer buf,
+ *                     const void *arg):
+ *     return text_decode(settings, buf)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_text_decode(__pyx_v_settings, __pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 754, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":752
+ * 
+ * 
+ * cdef text_decode_ex(ConnectionSettings settings, FastReadBuffer buf,             # <<<<<<<<<<<<<<
+ *                     const void *arg):
+ *     return text_decode(settings, buf)
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.text_decode_ex", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/array.pyx":757
+ * 
+ * 
+ * cdef arraytext_encode(ConnectionSettings settings, WriteBuffer buf, items):             # <<<<<<<<<<<<<<
+ *     array_encode(settings, buf, items, TEXTOID,
+ *                  <encode_func_ex>&text_encode_ex, NULL)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_arraytext_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_items) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("arraytext_encode", 0);
+
+  /* "asyncpg/protocol/codecs/array.pyx":758
+ * 
+ * cdef arraytext_encode(ConnectionSettings settings, WriteBuffer buf, items):
+ *     array_encode(settings, buf, items, TEXTOID,             # <<<<<<<<<<<<<<
+ *                  <encode_func_ex>&text_encode_ex, NULL)
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_array_encode(__pyx_v_settings, __pyx_v_buf, __pyx_v_items, 25, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func_ex)(&__pyx_f_7asyncpg_8protocol_8protocol_text_encode_ex)), NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 758, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":757
+ * 
+ * 
+ * cdef arraytext_encode(ConnectionSettings settings, WriteBuffer buf, items):             # <<<<<<<<<<<<<<
+ *     array_encode(settings, buf, items, TEXTOID,
+ *                  <encode_func_ex>&text_encode_ex, NULL)
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.arraytext_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/array.pyx":762
+ * 
+ * 
+ * cdef arraytext_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     return array_decode(settings, buf, <decode_func_ex>&text_decode_ex, NULL)
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_arraytext_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("arraytext_decode", 0);
+
+  /* "asyncpg/protocol/codecs/array.pyx":763
+ * 
+ * cdef arraytext_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     return array_decode(settings, buf, <decode_func_ex>&text_decode_ex, NULL)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_array_decode(__pyx_v_settings, __pyx_v_buf, ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func_ex)(&__pyx_f_7asyncpg_8protocol_8protocol_text_decode_ex)), NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 763, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":762
+ * 
+ * 
+ * cdef arraytext_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     return array_decode(settings, buf, <decode_func_ex>&text_decode_ex, NULL)
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.arraytext_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/array.pyx":766
+ * 
+ * 
+ * cdef anyarray_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     return array_decode(settings, buf, NULL, NULL)
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_anyarray_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("anyarray_decode", 0);
+
+  /* "asyncpg/protocol/codecs/array.pyx":767
+ * 
+ * cdef anyarray_decode(ConnectionSettings settings, FastReadBuffer buf):
+ *     return array_decode(settings, buf, NULL, NULL)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_array_decode(__pyx_v_settings, __pyx_v_buf, NULL, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 767, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":766
+ * 
+ * 
+ * cdef anyarray_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     return array_decode(settings, buf, NULL, NULL)
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.anyarray_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/array.pyx":770
+ * 
+ * 
+ * cdef init_array_codecs():             # <<<<<<<<<<<<<<
+ *     register_core_codec(ANYARRAYOID,
+ *                         NULL,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_array_codecs(void) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("init_array_codecs", 0);
+
+  /* "asyncpg/protocol/codecs/array.pyx":771
+ * 
+ * cdef init_array_codecs():
+ *     register_core_codec(ANYARRAYOID,             # <<<<<<<<<<<<<<
+ *                         NULL,
+ *                         <decode_func>&anyarray_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x8E5, NULL, ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_anyarray_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 771, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":779
+ *     # to make type introspection query work
+ *     #
+ *     register_core_codec(_OIDOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&arrayoid_encode,
+ *                         <decode_func>&arrayoid_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x404, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_arrayoid_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_arrayoid_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 779, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":784
+ *                         PG_FORMAT_BINARY)
+ * 
+ *     register_core_codec(_TEXTOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>&arraytext_encode,
+ *                         <decode_func>&arraytext_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x3F1, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_arraytext_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_arraytext_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 784, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":770
+ * 
+ * 
+ * cdef init_array_codecs():             # <<<<<<<<<<<<<<
+ *     register_core_codec(ANYARRAYOID,
+ *                         NULL,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.init_array_codecs", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/range.pyx":24
+ * 
+ * 
+ * cdef inline bint _range_has_lbound(uint8_t flags):             # <<<<<<<<<<<<<<
+ *     return not (flags & (RANGE_EMPTY | RANGE_LB_INF))
+ * 
+ */
+
+static CYTHON_INLINE int __pyx_f_7asyncpg_8protocol_8protocol__range_has_lbound(uint8_t __pyx_v_flags) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("_range_has_lbound", 0);
+
+  /* "asyncpg/protocol/codecs/range.pyx":25
+ * 
+ * cdef inline bint _range_has_lbound(uint8_t flags):
+ *     return not (flags & (RANGE_EMPTY | RANGE_LB_INF))             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_r = (!((__pyx_v_flags & 9) != 0));
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/range.pyx":24
+ * 
+ * 
+ * cdef inline bint _range_has_lbound(uint8_t flags):             # <<<<<<<<<<<<<<
+ *     return not (flags & (RANGE_EMPTY | RANGE_LB_INF))
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/range.pyx":28
+ * 
+ * 
+ * cdef inline bint _range_has_ubound(uint8_t flags):             # <<<<<<<<<<<<<<
+ *     return not (flags & (RANGE_EMPTY | RANGE_UB_INF))
+ * 
+ */
+
+static CYTHON_INLINE int __pyx_f_7asyncpg_8protocol_8protocol__range_has_ubound(uint8_t __pyx_v_flags) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("_range_has_ubound", 0);
+
+  /* "asyncpg/protocol/codecs/range.pyx":29
+ * 
+ * cdef inline bint _range_has_ubound(uint8_t flags):
+ *     return not (flags & (RANGE_EMPTY | RANGE_UB_INF))             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_r = (!((__pyx_v_flags & 17) != 0));
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/range.pyx":28
+ * 
+ * 
+ * cdef inline bint _range_has_ubound(uint8_t flags):             # <<<<<<<<<<<<<<
+ *     return not (flags & (RANGE_EMPTY | RANGE_UB_INF))
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/range.pyx":32
+ * 
+ * 
+ * cdef inline _RangeArgumentType _range_type(object obj):             # <<<<<<<<<<<<<<
+ *     if cpython.PyTuple_Check(obj) or cpython.PyList_Check(obj):
+ *         return _RANGE_ARGUMENT_TUPLE
+ */
+
+static CYTHON_INLINE enum __pyx_t_7asyncpg_8protocol_8protocol__RangeArgumentType __pyx_f_7asyncpg_8protocol_8protocol__range_type(PyObject *__pyx_v_obj) {
+  enum __pyx_t_7asyncpg_8protocol_8protocol__RangeArgumentType __pyx_r;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  __Pyx_RefNannySetupContext("_range_type", 0);
+
+  /* "asyncpg/protocol/codecs/range.pyx":33
+ * 
+ * cdef inline _RangeArgumentType _range_type(object obj):
+ *     if cpython.PyTuple_Check(obj) or cpython.PyList_Check(obj):             # <<<<<<<<<<<<<<
+ *         return _RANGE_ARGUMENT_TUPLE
+ *     elif isinstance(obj, apg_types.Range):
+ */
+  __pyx_t_2 = (PyTuple_Check(__pyx_v_obj) != 0);
+  if (!__pyx_t_2) {
+  } else {
+    __pyx_t_1 = __pyx_t_2;
+    goto __pyx_L4_bool_binop_done;
+  }
+  __pyx_t_2 = (PyList_Check(__pyx_v_obj) != 0);
+  __pyx_t_1 = __pyx_t_2;
+  __pyx_L4_bool_binop_done:;
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/codecs/range.pyx":34
+ * cdef inline _RangeArgumentType _range_type(object obj):
+ *     if cpython.PyTuple_Check(obj) or cpython.PyList_Check(obj):
+ *         return _RANGE_ARGUMENT_TUPLE             # <<<<<<<<<<<<<<
+ *     elif isinstance(obj, apg_types.Range):
+ *         return _RANGE_ARGUMENT_RANGE
+ */
+    __pyx_r = __pyx_e_7asyncpg_8protocol_8protocol__RANGE_ARGUMENT_TUPLE;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/codecs/range.pyx":33
+ * 
+ * cdef inline _RangeArgumentType _range_type(object obj):
+ *     if cpython.PyTuple_Check(obj) or cpython.PyList_Check(obj):             # <<<<<<<<<<<<<<
+ *         return _RANGE_ARGUMENT_TUPLE
+ *     elif isinstance(obj, apg_types.Range):
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/range.pyx":35
+ *     if cpython.PyTuple_Check(obj) or cpython.PyList_Check(obj):
+ *         return _RANGE_ARGUMENT_TUPLE
+ *     elif isinstance(obj, apg_types.Range):             # <<<<<<<<<<<<<<
+ *         return _RANGE_ARGUMENT_RANGE
+ *     else:
+ */
+  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_types); if (unlikely(!__pyx_t_3)) __PYX_ERR(21, 35, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_Range); if (unlikely(!__pyx_t_4)) __PYX_ERR(21, 35, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_1 = PyObject_IsInstance(__pyx_v_obj, __pyx_t_4); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(21, 35, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_2 = (__pyx_t_1 != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/codecs/range.pyx":36
+ *         return _RANGE_ARGUMENT_TUPLE
+ *     elif isinstance(obj, apg_types.Range):
+ *         return _RANGE_ARGUMENT_RANGE             # <<<<<<<<<<<<<<
+ *     else:
+ *         return _RANGE_ARGUMENT_INVALID
+ */
+    __pyx_r = __pyx_e_7asyncpg_8protocol_8protocol__RANGE_ARGUMENT_RANGE;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/codecs/range.pyx":35
+ *     if cpython.PyTuple_Check(obj) or cpython.PyList_Check(obj):
+ *         return _RANGE_ARGUMENT_TUPLE
+ *     elif isinstance(obj, apg_types.Range):             # <<<<<<<<<<<<<<
+ *         return _RANGE_ARGUMENT_RANGE
+ *     else:
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/range.pyx":38
+ *         return _RANGE_ARGUMENT_RANGE
+ *     else:
+ *         return _RANGE_ARGUMENT_INVALID             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  /*else*/ {
+    __pyx_r = __pyx_e_7asyncpg_8protocol_8protocol__RANGE_ARGUMENT_INVALID;
+    goto __pyx_L0;
+  }
+
+  /* "asyncpg/protocol/codecs/range.pyx":32
+ * 
+ * 
+ * cdef inline _RangeArgumentType _range_type(object obj):             # <<<<<<<<<<<<<<
+ *     if cpython.PyTuple_Check(obj) or cpython.PyList_Check(obj):
+ *         return _RANGE_ARGUMENT_TUPLE
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_WriteUnraisable("asyncpg.protocol.protocol._range_type", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
+  __pyx_r = (enum __pyx_t_7asyncpg_8protocol_8protocol__RangeArgumentType) 0;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/range.pyx":41
+ * 
+ * 
+ * cdef range_encode(ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
+ *                   object obj, uint32_t elem_oid,
+ *                   encode_func_ex encoder, const void *encoder_arg):
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_range_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj, CYTHON_UNUSED uint32_t __pyx_v_elem_oid, __pyx_t_7asyncpg_8protocol_8protocol_encode_func_ex __pyx_v_encoder, void const *__pyx_v_encoder_arg) {
+  Py_ssize_t __pyx_v_obj_len;
+  uint8_t __pyx_v_flags;
+  PyObject *__pyx_v_lower = 0;
+  PyObject *__pyx_v_upper = 0;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_bounds_data = 0;
+  enum __pyx_t_7asyncpg_8protocol_8protocol__RangeArgumentType __pyx_v_arg_type;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  Py_ssize_t __pyx_t_5;
+  int __pyx_t_6;
+  int __pyx_t_7;
+  PyObject *__pyx_t_8 = NULL;
+  int32_t __pyx_t_9;
+  __Pyx_RefNannySetupContext("range_encode", 0);
+
+  /* "asyncpg/protocol/codecs/range.pyx":46
+ *     cdef:
+ *         ssize_t obj_len
+ *         uint8_t flags = 0             # <<<<<<<<<<<<<<
+ *         object lower = None
+ *         object upper = None
+ */
+  __pyx_v_flags = 0;
+
+  /* "asyncpg/protocol/codecs/range.pyx":47
+ *         ssize_t obj_len
+ *         uint8_t flags = 0
+ *         object lower = None             # <<<<<<<<<<<<<<
+ *         object upper = None
+ *         WriteBuffer bounds_data = WriteBuffer.new()
+ */
+  __Pyx_INCREF(Py_None);
+  __pyx_v_lower = Py_None;
+
+  /* "asyncpg/protocol/codecs/range.pyx":48
+ *         uint8_t flags = 0
+ *         object lower = None
+ *         object upper = None             # <<<<<<<<<<<<<<
+ *         WriteBuffer bounds_data = WriteBuffer.new()
+ *         _RangeArgumentType arg_type = _range_type(obj)
+ */
+  __Pyx_INCREF(Py_None);
+  __pyx_v_upper = Py_None;
+
+  /* "asyncpg/protocol/codecs/range.pyx":49
+ *         object lower = None
+ *         object upper = None
+ *         WriteBuffer bounds_data = WriteBuffer.new()             # <<<<<<<<<<<<<<
+ *         _RangeArgumentType arg_type = _range_type(obj)
+ * 
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new()); if (unlikely(!__pyx_t_1)) __PYX_ERR(21, 49, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_bounds_data = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/range.pyx":50
+ *         object upper = None
+ *         WriteBuffer bounds_data = WriteBuffer.new()
+ *         _RangeArgumentType arg_type = _range_type(obj)             # <<<<<<<<<<<<<<
+ * 
+ *     if arg_type == _RANGE_ARGUMENT_INVALID:
+ */
+  __pyx_v_arg_type = __pyx_f_7asyncpg_8protocol_8protocol__range_type(__pyx_v_obj);
+
+  /* "asyncpg/protocol/codecs/range.pyx":52
+ *         _RangeArgumentType arg_type = _range_type(obj)
+ * 
+ *     if arg_type == _RANGE_ARGUMENT_INVALID:             # <<<<<<<<<<<<<<
+ *         raise TypeError(
+ *             'list, tuple or Range object expected (got type {})'.format(
+ */
+  switch (__pyx_v_arg_type) {
+    case __pyx_e_7asyncpg_8protocol_8protocol__RANGE_ARGUMENT_INVALID:
+
+    /* "asyncpg/protocol/codecs/range.pyx":54
+ *     if arg_type == _RANGE_ARGUMENT_INVALID:
+ *         raise TypeError(
+ *             'list, tuple or Range object expected (got type {})'.format(             # <<<<<<<<<<<<<<
+ *                 type(obj)))
+ * 
+ */
+    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_list_tuple_or_Range_object_expec, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(21, 54, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+
+    /* "asyncpg/protocol/codecs/range.pyx":55
+ *         raise TypeError(
+ *             'list, tuple or Range object expected (got type {})'.format(
+ *                 type(obj)))             # <<<<<<<<<<<<<<
+ * 
+ *     elif arg_type == _RANGE_ARGUMENT_TUPLE:
+ */
+    __pyx_t_3 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+      if (likely(__pyx_t_3)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+        __Pyx_INCREF(__pyx_t_3);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_2, function);
+      }
+    }
+    if (!__pyx_t_3) {
+      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)Py_TYPE(__pyx_v_obj))); if (unlikely(!__pyx_t_1)) __PYX_ERR(21, 54, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_2)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)Py_TYPE(__pyx_v_obj))};
+        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(21, 54, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __Pyx_GOTREF(__pyx_t_1);
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)Py_TYPE(__pyx_v_obj))};
+        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(21, 54, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __Pyx_GOTREF(__pyx_t_1);
+      } else
+      #endif
+      {
+        __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(21, 54, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
+        __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_obj)));
+        __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_obj)));
+        PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)Py_TYPE(__pyx_v_obj)));
+        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(21, 54, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "asyncpg/protocol/codecs/range.pyx":53
+ * 
+ *     if arg_type == _RANGE_ARGUMENT_INVALID:
+ *         raise TypeError(             # <<<<<<<<<<<<<<
+ *             'list, tuple or Range object expected (got type {})'.format(
+ *                 type(obj)))
+ */
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(21, 53, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_GIVEREF(__pyx_t_1);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
+    __pyx_t_1 = 0;
+    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(21, 53, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __PYX_ERR(21, 53, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/range.pyx":52
+ *         _RangeArgumentType arg_type = _range_type(obj)
+ * 
+ *     if arg_type == _RANGE_ARGUMENT_INVALID:             # <<<<<<<<<<<<<<
+ *         raise TypeError(
+ *             'list, tuple or Range object expected (got type {})'.format(
+ */
+    break;
+
+    /* "asyncpg/protocol/codecs/range.pyx":57
+ *                 type(obj)))
+ * 
+ *     elif arg_type == _RANGE_ARGUMENT_TUPLE:             # <<<<<<<<<<<<<<
+ *         obj_len = len(obj)
+ *         if obj_len == 2:
+ */
+    case __pyx_e_7asyncpg_8protocol_8protocol__RANGE_ARGUMENT_TUPLE:
+
+    /* "asyncpg/protocol/codecs/range.pyx":58
+ * 
+ *     elif arg_type == _RANGE_ARGUMENT_TUPLE:
+ *         obj_len = len(obj)             # <<<<<<<<<<<<<<
+ *         if obj_len == 2:
+ *             lower = obj[0]
+ */
+    __pyx_t_5 = PyObject_Length(__pyx_v_obj); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(21, 58, __pyx_L1_error)
+    __pyx_v_obj_len = __pyx_t_5;
+
+    /* "asyncpg/protocol/codecs/range.pyx":59
+ *     elif arg_type == _RANGE_ARGUMENT_TUPLE:
+ *         obj_len = len(obj)
+ *         if obj_len == 2:             # <<<<<<<<<<<<<<
+ *             lower = obj[0]
+ *             upper = obj[1]
+ */
+    __pyx_t_6 = ((__pyx_v_obj_len == 2) != 0);
+    if (__pyx_t_6) {
+
+      /* "asyncpg/protocol/codecs/range.pyx":60
+ *         obj_len = len(obj)
+ *         if obj_len == 2:
+ *             lower = obj[0]             # <<<<<<<<<<<<<<
+ *             upper = obj[1]
+ * 
+ */
+      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_obj, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(21, 60, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF_SET(__pyx_v_lower, __pyx_t_1);
+      __pyx_t_1 = 0;
+
+      /* "asyncpg/protocol/codecs/range.pyx":61
+ *         if obj_len == 2:
+ *             lower = obj[0]
+ *             upper = obj[1]             # <<<<<<<<<<<<<<
+ * 
+ *             if lower is None:
+ */
+      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_obj, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(21, 61, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF_SET(__pyx_v_upper, __pyx_t_1);
+      __pyx_t_1 = 0;
+
+      /* "asyncpg/protocol/codecs/range.pyx":63
+ *             upper = obj[1]
+ * 
+ *             if lower is None:             # <<<<<<<<<<<<<<
+ *                 flags |= RANGE_LB_INF
+ * 
+ */
+      __pyx_t_6 = (__pyx_v_lower == Py_None);
+      __pyx_t_7 = (__pyx_t_6 != 0);
+      if (__pyx_t_7) {
+
+        /* "asyncpg/protocol/codecs/range.pyx":64
+ * 
+ *             if lower is None:
+ *                 flags |= RANGE_LB_INF             # <<<<<<<<<<<<<<
+ * 
+ *             if upper is None:
+ */
+        __pyx_v_flags = (__pyx_v_flags | 8);
+
+        /* "asyncpg/protocol/codecs/range.pyx":63
+ *             upper = obj[1]
+ * 
+ *             if lower is None:             # <<<<<<<<<<<<<<
+ *                 flags |= RANGE_LB_INF
+ * 
+ */
+      }
+
+      /* "asyncpg/protocol/codecs/range.pyx":66
+ *                 flags |= RANGE_LB_INF
+ * 
+ *             if upper is None:             # <<<<<<<<<<<<<<
+ *                 flags |= RANGE_UB_INF
+ * 
+ */
+      __pyx_t_7 = (__pyx_v_upper == Py_None);
+      __pyx_t_6 = (__pyx_t_7 != 0);
+      if (__pyx_t_6) {
+
+        /* "asyncpg/protocol/codecs/range.pyx":67
+ * 
+ *             if upper is None:
+ *                 flags |= RANGE_UB_INF             # <<<<<<<<<<<<<<
+ * 
+ *             flags |= RANGE_LB_INC | RANGE_UB_INC
+ */
+        __pyx_v_flags = (__pyx_v_flags | 16);
+
+        /* "asyncpg/protocol/codecs/range.pyx":66
+ *                 flags |= RANGE_LB_INF
+ * 
+ *             if upper is None:             # <<<<<<<<<<<<<<
+ *                 flags |= RANGE_UB_INF
+ * 
+ */
+      }
+
+      /* "asyncpg/protocol/codecs/range.pyx":69
+ *                 flags |= RANGE_UB_INF
+ * 
+ *             flags |= RANGE_LB_INC | RANGE_UB_INC             # <<<<<<<<<<<<<<
+ * 
+ *         elif obj_len == 1:
+ */
+      __pyx_v_flags = (__pyx_v_flags | 6);
+
+      /* "asyncpg/protocol/codecs/range.pyx":59
+ *     elif arg_type == _RANGE_ARGUMENT_TUPLE:
+ *         obj_len = len(obj)
+ *         if obj_len == 2:             # <<<<<<<<<<<<<<
+ *             lower = obj[0]
+ *             upper = obj[1]
+ */
+      goto __pyx_L3;
+    }
+
+    /* "asyncpg/protocol/codecs/range.pyx":71
+ *             flags |= RANGE_LB_INC | RANGE_UB_INC
+ * 
+ *         elif obj_len == 1:             # <<<<<<<<<<<<<<
+ *             lower = obj[0]
+ *             flags |= RANGE_LB_INC | RANGE_UB_INF
+ */
+    __pyx_t_6 = ((__pyx_v_obj_len == 1) != 0);
+    if (__pyx_t_6) {
+
+      /* "asyncpg/protocol/codecs/range.pyx":72
+ * 
+ *         elif obj_len == 1:
+ *             lower = obj[0]             # <<<<<<<<<<<<<<
+ *             flags |= RANGE_LB_INC | RANGE_UB_INF
+ * 
+ */
+      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_obj, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(21, 72, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF_SET(__pyx_v_lower, __pyx_t_1);
+      __pyx_t_1 = 0;
+
+      /* "asyncpg/protocol/codecs/range.pyx":73
+ *         elif obj_len == 1:
+ *             lower = obj[0]
+ *             flags |= RANGE_LB_INC | RANGE_UB_INF             # <<<<<<<<<<<<<<
+ * 
+ *         elif obj_len == 0:
+ */
+      __pyx_v_flags = (__pyx_v_flags | 18);
+
+      /* "asyncpg/protocol/codecs/range.pyx":71
+ *             flags |= RANGE_LB_INC | RANGE_UB_INC
+ * 
+ *         elif obj_len == 1:             # <<<<<<<<<<<<<<
+ *             lower = obj[0]
+ *             flags |= RANGE_LB_INC | RANGE_UB_INF
+ */
+      goto __pyx_L3;
+    }
+
+    /* "asyncpg/protocol/codecs/range.pyx":75
+ *             flags |= RANGE_LB_INC | RANGE_UB_INF
+ * 
+ *         elif obj_len == 0:             # <<<<<<<<<<<<<<
+ *             flags |= RANGE_EMPTY
+ * 
+ */
+    __pyx_t_6 = ((__pyx_v_obj_len == 0) != 0);
+    if (__pyx_t_6) {
+
+      /* "asyncpg/protocol/codecs/range.pyx":76
+ * 
+ *         elif obj_len == 0:
+ *             flags |= RANGE_EMPTY             # <<<<<<<<<<<<<<
+ * 
+ *         else:
+ */
+      __pyx_v_flags = (__pyx_v_flags | 1);
+
+      /* "asyncpg/protocol/codecs/range.pyx":75
+ *             flags |= RANGE_LB_INC | RANGE_UB_INF
+ * 
+ *         elif obj_len == 0:             # <<<<<<<<<<<<<<
+ *             flags |= RANGE_EMPTY
+ * 
+ */
+      goto __pyx_L3;
+    }
+
+    /* "asyncpg/protocol/codecs/range.pyx":79
+ * 
+ *         else:
+ *             raise ValueError(             # <<<<<<<<<<<<<<
+ *                 'expected 0, 1 or 2 elements in range (got {})'.format(
+ *                     obj_len))
+ */
+    /*else*/ {
+
+      /* "asyncpg/protocol/codecs/range.pyx":80
+ *         else:
+ *             raise ValueError(
+ *                 'expected 0, 1 or 2 elements in range (got {})'.format(             # <<<<<<<<<<<<<<
+ *                     obj_len))
+ * 
+ */
+      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_expected_0_1_or_2_elements_in_ra, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(21, 80, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+
+      /* "asyncpg/protocol/codecs/range.pyx":81
+ *             raise ValueError(
+ *                 'expected 0, 1 or 2 elements in range (got {})'.format(
+ *                     obj_len))             # <<<<<<<<<<<<<<
+ * 
+ *     else:
+ */
+      __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_obj_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(21, 81, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_3 = NULL;
+      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+        if (likely(__pyx_t_3)) {
+          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+          __Pyx_INCREF(__pyx_t_3);
+          __Pyx_INCREF(function);
+          __Pyx_DECREF_SET(__pyx_t_2, function);
+        }
+      }
+      if (!__pyx_t_3) {
+        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(21, 80, __pyx_L1_error)
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_GOTREF(__pyx_t_1);
+      } else {
+        #if CYTHON_FAST_PYCALL
+        if (PyFunction_Check(__pyx_t_2)) {
+          PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_4};
+          __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(21, 80, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+          __Pyx_GOTREF(__pyx_t_1);
+          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        } else
+        #endif
+        #if CYTHON_FAST_PYCCALL
+        if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+          PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_4};
+          __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(21, 80, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+          __Pyx_GOTREF(__pyx_t_1);
+          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        } else
+        #endif
+        {
+          __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(21, 80, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_8);
+          __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = NULL;
+          __Pyx_GIVEREF(__pyx_t_4);
+          PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_4);
+          __pyx_t_4 = 0;
+          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(21, 80, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_1);
+          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        }
+      }
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+      /* "asyncpg/protocol/codecs/range.pyx":79
+ * 
+ *         else:
+ *             raise ValueError(             # <<<<<<<<<<<<<<
+ *                 'expected 0, 1 or 2 elements in range (got {})'.format(
+ *                     obj_len))
+ */
+      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(21, 79, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_GIVEREF(__pyx_t_1);
+      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
+      __pyx_t_1 = 0;
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(21, 79, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __PYX_ERR(21, 79, __pyx_L1_error)
+    }
+    __pyx_L3:;
+
+    /* "asyncpg/protocol/codecs/range.pyx":57
+ *                 type(obj)))
+ * 
+ *     elif arg_type == _RANGE_ARGUMENT_TUPLE:             # <<<<<<<<<<<<<<
+ *         obj_len = len(obj)
+ *         if obj_len == 2:
+ */
+    break;
+    default:
+
+    /* "asyncpg/protocol/codecs/range.pyx":84
+ * 
+ *     else:
+ *         if obj.isempty:             # <<<<<<<<<<<<<<
+ *             flags |= RANGE_EMPTY
+ *         else:
+ */
+    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_isempty); if (unlikely(!__pyx_t_1)) __PYX_ERR(21, 84, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(21, 84, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    if (__pyx_t_6) {
+
+      /* "asyncpg/protocol/codecs/range.pyx":85
+ *     else:
+ *         if obj.isempty:
+ *             flags |= RANGE_EMPTY             # <<<<<<<<<<<<<<
+ *         else:
+ *             lower = obj.lower
+ */
+      __pyx_v_flags = (__pyx_v_flags | 1);
+
+      /* "asyncpg/protocol/codecs/range.pyx":84
+ * 
+ *     else:
+ *         if obj.isempty:             # <<<<<<<<<<<<<<
+ *             flags |= RANGE_EMPTY
+ *         else:
+ */
+      goto __pyx_L6;
+    }
+
+    /* "asyncpg/protocol/codecs/range.pyx":87
+ *             flags |= RANGE_EMPTY
+ *         else:
+ *             lower = obj.lower             # <<<<<<<<<<<<<<
+ *             upper = obj.upper
+ * 
+ */
+    /*else*/ {
+      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_lower); if (unlikely(!__pyx_t_1)) __PYX_ERR(21, 87, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF_SET(__pyx_v_lower, __pyx_t_1);
+      __pyx_t_1 = 0;
+
+      /* "asyncpg/protocol/codecs/range.pyx":88
+ *         else:
+ *             lower = obj.lower
+ *             upper = obj.upper             # <<<<<<<<<<<<<<
+ * 
+ *             if obj.lower_inc:
+ */
+      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_upper); if (unlikely(!__pyx_t_1)) __PYX_ERR(21, 88, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF_SET(__pyx_v_upper, __pyx_t_1);
+      __pyx_t_1 = 0;
+
+      /* "asyncpg/protocol/codecs/range.pyx":90
+ *             upper = obj.upper
+ * 
+ *             if obj.lower_inc:             # <<<<<<<<<<<<<<
+ *                 flags |= RANGE_LB_INC
+ *             elif lower is None:
+ */
+      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_lower_inc); if (unlikely(!__pyx_t_1)) __PYX_ERR(21, 90, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(21, 90, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      if (__pyx_t_6) {
+
+        /* "asyncpg/protocol/codecs/range.pyx":91
+ * 
+ *             if obj.lower_inc:
+ *                 flags |= RANGE_LB_INC             # <<<<<<<<<<<<<<
+ *             elif lower is None:
+ *                 flags |= RANGE_LB_INF
+ */
+        __pyx_v_flags = (__pyx_v_flags | 2);
+
+        /* "asyncpg/protocol/codecs/range.pyx":90
+ *             upper = obj.upper
+ * 
+ *             if obj.lower_inc:             # <<<<<<<<<<<<<<
+ *                 flags |= RANGE_LB_INC
+ *             elif lower is None:
+ */
+        goto __pyx_L7;
+      }
+
+      /* "asyncpg/protocol/codecs/range.pyx":92
+ *             if obj.lower_inc:
+ *                 flags |= RANGE_LB_INC
+ *             elif lower is None:             # <<<<<<<<<<<<<<
+ *                 flags |= RANGE_LB_INF
+ * 
+ */
+      __pyx_t_6 = (__pyx_v_lower == Py_None);
+      __pyx_t_7 = (__pyx_t_6 != 0);
+      if (__pyx_t_7) {
+
+        /* "asyncpg/protocol/codecs/range.pyx":93
+ *                 flags |= RANGE_LB_INC
+ *             elif lower is None:
+ *                 flags |= RANGE_LB_INF             # <<<<<<<<<<<<<<
+ * 
+ *             if obj.upper_inc:
+ */
+        __pyx_v_flags = (__pyx_v_flags | 8);
+
+        /* "asyncpg/protocol/codecs/range.pyx":92
+ *             if obj.lower_inc:
+ *                 flags |= RANGE_LB_INC
+ *             elif lower is None:             # <<<<<<<<<<<<<<
+ *                 flags |= RANGE_LB_INF
+ * 
+ */
+      }
+      __pyx_L7:;
+
+      /* "asyncpg/protocol/codecs/range.pyx":95
+ *                 flags |= RANGE_LB_INF
+ * 
+ *             if obj.upper_inc:             # <<<<<<<<<<<<<<
+ *                 flags |= RANGE_UB_INC
+ *             elif upper is None:
+ */
+      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_upper_inc); if (unlikely(!__pyx_t_1)) __PYX_ERR(21, 95, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(21, 95, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      if (__pyx_t_7) {
+
+        /* "asyncpg/protocol/codecs/range.pyx":96
+ * 
+ *             if obj.upper_inc:
+ *                 flags |= RANGE_UB_INC             # <<<<<<<<<<<<<<
+ *             elif upper is None:
+ *                 flags |= RANGE_UB_INF
+ */
+        __pyx_v_flags = (__pyx_v_flags | 4);
+
+        /* "asyncpg/protocol/codecs/range.pyx":95
+ *                 flags |= RANGE_LB_INF
+ * 
+ *             if obj.upper_inc:             # <<<<<<<<<<<<<<
+ *                 flags |= RANGE_UB_INC
+ *             elif upper is None:
+ */
+        goto __pyx_L8;
+      }
+
+      /* "asyncpg/protocol/codecs/range.pyx":97
+ *             if obj.upper_inc:
+ *                 flags |= RANGE_UB_INC
+ *             elif upper is None:             # <<<<<<<<<<<<<<
+ *                 flags |= RANGE_UB_INF
+ * 
+ */
+      __pyx_t_7 = (__pyx_v_upper == Py_None);
+      __pyx_t_6 = (__pyx_t_7 != 0);
+      if (__pyx_t_6) {
+
+        /* "asyncpg/protocol/codecs/range.pyx":98
+ *                 flags |= RANGE_UB_INC
+ *             elif upper is None:
+ *                 flags |= RANGE_UB_INF             # <<<<<<<<<<<<<<
+ * 
+ *     if _range_has_lbound(flags):
+ */
+        __pyx_v_flags = (__pyx_v_flags | 16);
+
+        /* "asyncpg/protocol/codecs/range.pyx":97
+ *             if obj.upper_inc:
+ *                 flags |= RANGE_UB_INC
+ *             elif upper is None:             # <<<<<<<<<<<<<<
+ *                 flags |= RANGE_UB_INF
+ * 
+ */
+      }
+      __pyx_L8:;
+    }
+    __pyx_L6:;
+    break;
+  }
+
+  /* "asyncpg/protocol/codecs/range.pyx":100
+ *                 flags |= RANGE_UB_INF
+ * 
+ *     if _range_has_lbound(flags):             # <<<<<<<<<<<<<<
+ *         encoder(settings, bounds_data, lower, encoder_arg)
+ * 
+ */
+  __pyx_t_6 = (__pyx_f_7asyncpg_8protocol_8protocol__range_has_lbound(__pyx_v_flags) != 0);
+  if (__pyx_t_6) {
+
+    /* "asyncpg/protocol/codecs/range.pyx":101
+ * 
+ *     if _range_has_lbound(flags):
+ *         encoder(settings, bounds_data, lower, encoder_arg)             # <<<<<<<<<<<<<<
+ * 
+ *     if _range_has_ubound(flags):
+ */
+    __pyx_t_1 = __pyx_v_encoder(__pyx_v_settings, __pyx_v_bounds_data, __pyx_v_lower, __pyx_v_encoder_arg); if (unlikely(!__pyx_t_1)) __PYX_ERR(21, 101, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/codecs/range.pyx":100
+ *                 flags |= RANGE_UB_INF
+ * 
+ *     if _range_has_lbound(flags):             # <<<<<<<<<<<<<<
+ *         encoder(settings, bounds_data, lower, encoder_arg)
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/range.pyx":103
+ *         encoder(settings, bounds_data, lower, encoder_arg)
+ * 
+ *     if _range_has_ubound(flags):             # <<<<<<<<<<<<<<
+ *         encoder(settings, bounds_data, upper, encoder_arg)
+ * 
+ */
+  __pyx_t_6 = (__pyx_f_7asyncpg_8protocol_8protocol__range_has_ubound(__pyx_v_flags) != 0);
+  if (__pyx_t_6) {
+
+    /* "asyncpg/protocol/codecs/range.pyx":104
+ * 
+ *     if _range_has_ubound(flags):
+ *         encoder(settings, bounds_data, upper, encoder_arg)             # <<<<<<<<<<<<<<
+ * 
+ *     buf.write_int32(1 + bounds_data.len())
+ */
+    __pyx_t_1 = __pyx_v_encoder(__pyx_v_settings, __pyx_v_bounds_data, __pyx_v_upper, __pyx_v_encoder_arg); if (unlikely(!__pyx_t_1)) __PYX_ERR(21, 104, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/codecs/range.pyx":103
+ *         encoder(settings, bounds_data, lower, encoder_arg)
+ * 
+ *     if _range_has_ubound(flags):             # <<<<<<<<<<<<<<
+ *         encoder(settings, bounds_data, upper, encoder_arg)
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/range.pyx":106
+ *         encoder(settings, bounds_data, upper, encoder_arg)
+ * 
+ *     buf.write_int32(1 + bounds_data.len())             # <<<<<<<<<<<<<<
+ *     buf.write_byte(<int8_t>flags)
+ *     buf.write_buffer(bounds_data)
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_len(__pyx_v_bounds_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(21, 106, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyInt_AddCObj(__pyx_int_1, __pyx_t_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(21, 106, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_9 = __Pyx_PyInt_As_int32_t(__pyx_t_2); if (unlikely((__pyx_t_9 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(21, 106, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(21, 106, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/range.pyx":107
+ * 
+ *     buf.write_int32(1 + bounds_data.len())
+ *     buf.write_byte(<int8_t>flags)             # <<<<<<<<<<<<<<
+ *     buf.write_buffer(bounds_data)
+ * 
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(__pyx_v_buf, ((int8_t)__pyx_v_flags)); if (unlikely(!__pyx_t_2)) __PYX_ERR(21, 107, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/range.pyx":108
+ *     buf.write_int32(1 + bounds_data.len())
+ *     buf.write_byte(<int8_t>flags)
+ *     buf.write_buffer(bounds_data)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_buffer(__pyx_v_buf, __pyx_v_bounds_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(21, 108, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/range.pyx":41
+ * 
+ * 
+ * cdef range_encode(ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
+ *                   object obj, uint32_t elem_oid,
+ *                   encode_func_ex encoder, const void *encoder_arg):
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.range_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_lower);
+  __Pyx_XDECREF(__pyx_v_upper);
+  __Pyx_XDECREF((PyObject *)__pyx_v_bounds_data);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/range.pyx":111
+ * 
+ * 
+ * cdef range_decode(ConnectionSettings settings, FastReadBuffer buf,             # <<<<<<<<<<<<<<
+ *                   decode_func_ex decoder, const void *decoder_arg):
+ *     cdef:
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_range_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf, __pyx_t_7asyncpg_8protocol_8protocol_decode_func_ex __pyx_v_decoder, void const *__pyx_v_decoder_arg) {
+  uint8_t __pyx_v_flags;
+  int32_t __pyx_v_bound_len;
+  PyObject *__pyx_v_lower = 0;
+  PyObject *__pyx_v_upper = 0;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_bound_buf = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  char const *__pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  __Pyx_RefNannySetupContext("range_decode", 0);
+
+  /* "asyncpg/protocol/codecs/range.pyx":114
+ *                   decode_func_ex decoder, const void *decoder_arg):
+ *     cdef:
+ *         uint8_t flags = <uint8_t>buf.read(1)[0]             # <<<<<<<<<<<<<<
+ *         int32_t bound_len
+ *         object lower = None
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 1); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(21, 114, __pyx_L1_error)
+  __pyx_v_flags = ((uint8_t)(__pyx_t_1[0]));
+
+  /* "asyncpg/protocol/codecs/range.pyx":116
+ *         uint8_t flags = <uint8_t>buf.read(1)[0]
+ *         int32_t bound_len
+ *         object lower = None             # <<<<<<<<<<<<<<
+ *         object upper = None
+ *         FastReadBuffer bound_buf = FastReadBuffer.new()
+ */
+  __Pyx_INCREF(Py_None);
+  __pyx_v_lower = Py_None;
+
+  /* "asyncpg/protocol/codecs/range.pyx":117
+ *         int32_t bound_len
+ *         object lower = None
+ *         object upper = None             # <<<<<<<<<<<<<<
+ *         FastReadBuffer bound_buf = FastReadBuffer.new()
+ * 
+ */
+  __Pyx_INCREF(Py_None);
+  __pyx_v_upper = Py_None;
+
+  /* "asyncpg/protocol/codecs/range.pyx":118
+ *         object lower = None
+ *         object upper = None
+ *         FastReadBuffer bound_buf = FastReadBuffer.new()             # <<<<<<<<<<<<<<
+ * 
+ *     if _range_has_lbound(flags):
+ */
+  __pyx_t_2 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_new()); if (unlikely(!__pyx_t_2)) __PYX_ERR(21, 118, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_v_bound_buf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *)__pyx_t_2);
+  __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/range.pyx":120
+ *         FastReadBuffer bound_buf = FastReadBuffer.new()
+ * 
+ *     if _range_has_lbound(flags):             # <<<<<<<<<<<<<<
+ *         bound_len = hton.unpack_int32(buf.read(4))
+ *         if bound_len == -1:
+ */
+  __pyx_t_3 = (__pyx_f_7asyncpg_8protocol_8protocol__range_has_lbound(__pyx_v_flags) != 0);
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/codecs/range.pyx":121
+ * 
+ *     if _range_has_lbound(flags):
+ *         bound_len = hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ *         if bound_len == -1:
+ *             lower = None
+ */
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(21, 121, __pyx_L1_error)
+    __pyx_v_bound_len = __pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_1);
+
+    /* "asyncpg/protocol/codecs/range.pyx":122
+ *     if _range_has_lbound(flags):
+ *         bound_len = hton.unpack_int32(buf.read(4))
+ *         if bound_len == -1:             # <<<<<<<<<<<<<<
+ *             lower = None
+ *         else:
+ */
+    __pyx_t_3 = ((__pyx_v_bound_len == -1L) != 0);
+    if (__pyx_t_3) {
+
+      /* "asyncpg/protocol/codecs/range.pyx":123
+ *         bound_len = hton.unpack_int32(buf.read(4))
+ *         if bound_len == -1:
+ *             lower = None             # <<<<<<<<<<<<<<
+ *         else:
+ *             bound_buf.slice_from(buf, bound_len)
+ */
+      __Pyx_INCREF(Py_None);
+      __Pyx_DECREF_SET(__pyx_v_lower, Py_None);
+
+      /* "asyncpg/protocol/codecs/range.pyx":122
+ *     if _range_has_lbound(flags):
+ *         bound_len = hton.unpack_int32(buf.read(4))
+ *         if bound_len == -1:             # <<<<<<<<<<<<<<
+ *             lower = None
+ *         else:
+ */
+      goto __pyx_L4;
+    }
+
+    /* "asyncpg/protocol/codecs/range.pyx":125
+ *             lower = None
+ *         else:
+ *             bound_buf.slice_from(buf, bound_len)             # <<<<<<<<<<<<<<
+ *             lower = decoder(settings, bound_buf, decoder_arg)
+ * 
+ */
+    /*else*/ {
+      __pyx_t_2 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_slice_from(__pyx_v_bound_buf, __pyx_v_buf, __pyx_v_bound_len)); if (unlikely(!__pyx_t_2)) __PYX_ERR(21, 125, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+      /* "asyncpg/protocol/codecs/range.pyx":126
+ *         else:
+ *             bound_buf.slice_from(buf, bound_len)
+ *             lower = decoder(settings, bound_buf, decoder_arg)             # <<<<<<<<<<<<<<
+ * 
+ *     if _range_has_ubound(flags):
+ */
+      __pyx_t_2 = __pyx_v_decoder(__pyx_v_settings, __pyx_v_bound_buf, __pyx_v_decoder_arg); if (unlikely(!__pyx_t_2)) __PYX_ERR(21, 126, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF_SET(__pyx_v_lower, __pyx_t_2);
+      __pyx_t_2 = 0;
+    }
+    __pyx_L4:;
+
+    /* "asyncpg/protocol/codecs/range.pyx":120
+ *         FastReadBuffer bound_buf = FastReadBuffer.new()
+ * 
+ *     if _range_has_lbound(flags):             # <<<<<<<<<<<<<<
+ *         bound_len = hton.unpack_int32(buf.read(4))
+ *         if bound_len == -1:
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/range.pyx":128
+ *             lower = decoder(settings, bound_buf, decoder_arg)
+ * 
+ *     if _range_has_ubound(flags):             # <<<<<<<<<<<<<<
+ *         bound_len = hton.unpack_int32(buf.read(4))
+ *         if bound_len == -1:
+ */
+  __pyx_t_3 = (__pyx_f_7asyncpg_8protocol_8protocol__range_has_ubound(__pyx_v_flags) != 0);
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/codecs/range.pyx":129
+ * 
+ *     if _range_has_ubound(flags):
+ *         bound_len = hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ *         if bound_len == -1:
+ *             upper = None
+ */
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(21, 129, __pyx_L1_error)
+    __pyx_v_bound_len = __pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_1);
+
+    /* "asyncpg/protocol/codecs/range.pyx":130
+ *     if _range_has_ubound(flags):
+ *         bound_len = hton.unpack_int32(buf.read(4))
+ *         if bound_len == -1:             # <<<<<<<<<<<<<<
+ *             upper = None
+ *         else:
+ */
+    __pyx_t_3 = ((__pyx_v_bound_len == -1L) != 0);
+    if (__pyx_t_3) {
+
+      /* "asyncpg/protocol/codecs/range.pyx":131
+ *         bound_len = hton.unpack_int32(buf.read(4))
+ *         if bound_len == -1:
+ *             upper = None             # <<<<<<<<<<<<<<
+ *         else:
+ *             bound_buf.slice_from(buf, bound_len)
+ */
+      __Pyx_INCREF(Py_None);
+      __Pyx_DECREF_SET(__pyx_v_upper, Py_None);
+
+      /* "asyncpg/protocol/codecs/range.pyx":130
+ *     if _range_has_ubound(flags):
+ *         bound_len = hton.unpack_int32(buf.read(4))
+ *         if bound_len == -1:             # <<<<<<<<<<<<<<
+ *             upper = None
+ *         else:
+ */
+      goto __pyx_L6;
+    }
+
+    /* "asyncpg/protocol/codecs/range.pyx":133
+ *             upper = None
+ *         else:
+ *             bound_buf.slice_from(buf, bound_len)             # <<<<<<<<<<<<<<
+ *             upper = decoder(settings, bound_buf, decoder_arg)
+ * 
+ */
+    /*else*/ {
+      __pyx_t_2 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_slice_from(__pyx_v_bound_buf, __pyx_v_buf, __pyx_v_bound_len)); if (unlikely(!__pyx_t_2)) __PYX_ERR(21, 133, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+      /* "asyncpg/protocol/codecs/range.pyx":134
+ *         else:
+ *             bound_buf.slice_from(buf, bound_len)
+ *             upper = decoder(settings, bound_buf, decoder_arg)             # <<<<<<<<<<<<<<
+ * 
+ *     return apg_types.Range(lower=lower, upper=upper,
+ */
+      __pyx_t_2 = __pyx_v_decoder(__pyx_v_settings, __pyx_v_bound_buf, __pyx_v_decoder_arg); if (unlikely(!__pyx_t_2)) __PYX_ERR(21, 134, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF_SET(__pyx_v_upper, __pyx_t_2);
+      __pyx_t_2 = 0;
+    }
+    __pyx_L6:;
+
+    /* "asyncpg/protocol/codecs/range.pyx":128
+ *             lower = decoder(settings, bound_buf, decoder_arg)
+ * 
+ *     if _range_has_ubound(flags):             # <<<<<<<<<<<<<<
+ *         bound_len = hton.unpack_int32(buf.read(4))
+ *         if bound_len == -1:
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/range.pyx":136
+ *             upper = decoder(settings, bound_buf, decoder_arg)
+ * 
+ *     return apg_types.Range(lower=lower, upper=upper,             # <<<<<<<<<<<<<<
+ *                            lower_inc=(flags & RANGE_LB_INC) != 0,
+ *                            upper_inc=(flags & RANGE_UB_INC) != 0,
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(21, 136, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Range); if (unlikely(!__pyx_t_4)) __PYX_ERR(21, 136, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(21, 136, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_lower, __pyx_v_lower) < 0) __PYX_ERR(21, 136, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_upper, __pyx_v_upper) < 0) __PYX_ERR(21, 136, __pyx_L1_error)
+
+  /* "asyncpg/protocol/codecs/range.pyx":137
+ * 
+ *     return apg_types.Range(lower=lower, upper=upper,
+ *                            lower_inc=(flags & RANGE_LB_INC) != 0,             # <<<<<<<<<<<<<<
+ *                            upper_inc=(flags & RANGE_UB_INC) != 0,
+ *                            empty=(flags & RANGE_EMPTY) != 0)
+ */
+  __pyx_t_5 = __Pyx_PyBool_FromLong(((__pyx_v_flags & 2) != 0)); if (unlikely(!__pyx_t_5)) __PYX_ERR(21, 137, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_lower_inc, __pyx_t_5) < 0) __PYX_ERR(21, 136, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+  /* "asyncpg/protocol/codecs/range.pyx":138
+ *     return apg_types.Range(lower=lower, upper=upper,
+ *                            lower_inc=(flags & RANGE_LB_INC) != 0,
+ *                            upper_inc=(flags & RANGE_UB_INC) != 0,             # <<<<<<<<<<<<<<
+ *                            empty=(flags & RANGE_EMPTY) != 0)
+ * 
+ */
+  __pyx_t_5 = __Pyx_PyBool_FromLong(((__pyx_v_flags & 4) != 0)); if (unlikely(!__pyx_t_5)) __PYX_ERR(21, 138, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_upper_inc, __pyx_t_5) < 0) __PYX_ERR(21, 136, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+  /* "asyncpg/protocol/codecs/range.pyx":139
+ *                            lower_inc=(flags & RANGE_LB_INC) != 0,
+ *                            upper_inc=(flags & RANGE_UB_INC) != 0,
+ *                            empty=(flags & RANGE_EMPTY) != 0)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_5 = __Pyx_PyBool_FromLong(((__pyx_v_flags & 1) != 0)); if (unlikely(!__pyx_t_5)) __PYX_ERR(21, 139, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_empty, __pyx_t_5) < 0) __PYX_ERR(21, 136, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+  /* "asyncpg/protocol/codecs/range.pyx":136
+ *             upper = decoder(settings, bound_buf, decoder_arg)
+ * 
+ *     return apg_types.Range(lower=lower, upper=upper,             # <<<<<<<<<<<<<<
+ *                            lower_inc=(flags & RANGE_LB_INC) != 0,
+ *                            upper_inc=(flags & RANGE_UB_INC) != 0,
+ */
+  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(21, 136, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_r = __pyx_t_5;
+  __pyx_t_5 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/range.pyx":111
+ * 
+ * 
+ * cdef range_decode(ConnectionSettings settings, FastReadBuffer buf,             # <<<<<<<<<<<<<<
+ *                   decode_func_ex decoder, const void *decoder_arg):
+ *     cdef:
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.range_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_lower);
+  __Pyx_XDECREF(__pyx_v_upper);
+  __Pyx_XDECREF((PyObject *)__pyx_v_bound_buf);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/range.pyx":142
+ * 
+ * 
+ * cdef init_range_codecs():             # <<<<<<<<<<<<<<
+ *     register_core_codec(ANYRANGEOID,
+ *                         NULL,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_range_codecs(void) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("init_range_codecs", 0);
+
+  /* "asyncpg/protocol/codecs/range.pyx":143
+ * 
+ * cdef init_range_codecs():
+ *     register_core_codec(ANYRANGEOID,             # <<<<<<<<<<<<<<
+ *                         NULL,
+ *                         <decode_func>&text_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0xEF7, NULL, ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_text_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT); if (unlikely(!__pyx_t_1)) __PYX_ERR(21, 143, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/range.pyx":142
+ * 
+ * 
+ * cdef init_range_codecs():             # <<<<<<<<<<<<<<
+ *     register_core_codec(ANYRANGEOID,
+ *                         NULL,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.init_range_codecs", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/record.pyx":8
+ * 
+ * 
+ * cdef inline record_encode_frame(ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
+ *                                 WriteBuffer elem_data, int32_t elem_count):
+ *     buf.write_int32(4 + elem_data.len())
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_record_encode_frame(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_elem_data, int32_t __pyx_v_elem_count) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  int32_t __pyx_t_3;
+  __Pyx_RefNannySetupContext("record_encode_frame", 0);
+
+  /* "asyncpg/protocol/codecs/record.pyx":10
+ * cdef inline record_encode_frame(ConnectionSettings settings, WriteBuffer buf,
+ *                                 WriteBuffer elem_data, int32_t elem_count):
+ *     buf.write_int32(4 + elem_data.len())             # <<<<<<<<<<<<<<
+ *     # attribute count
+ *     buf.write_int32(elem_count)
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_len(__pyx_v_elem_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(22, 10, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyInt_AddCObj(__pyx_int_4, __pyx_t_1, 4, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 10, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_3 = __Pyx_PyInt_As_int32_t(__pyx_t_2); if (unlikely((__pyx_t_3 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(22, 10, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 10, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/record.pyx":12
+ *     buf.write_int32(4 + elem_data.len())
+ *     # attribute count
+ *     buf.write_int32(elem_count)             # <<<<<<<<<<<<<<
+ *     # encoded attribute data
+ *     buf.write_buffer(elem_data)
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, __pyx_v_elem_count); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 12, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/record.pyx":14
+ *     buf.write_int32(elem_count)
+ *     # encoded attribute data
+ *     buf.write_buffer(elem_data)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_buffer(__pyx_v_buf, __pyx_v_elem_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 14, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/record.pyx":8
+ * 
+ * 
+ * cdef inline record_encode_frame(ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
+ *                                 WriteBuffer elem_data, int32_t elem_count):
+ *     buf.write_int32(4 + elem_data.len())
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.record_encode_frame", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/record.pyx":17
+ * 
+ * 
+ * cdef anonymous_record_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         tuple result
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_anonymous_record_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  PyObject *__pyx_v_result = 0;
+  uint32_t __pyx_v_elem_count;
+  int32_t __pyx_v_elem_len;
+  uint32_t __pyx_v_elem_typ;
+  uint32_t __pyx_v_i;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_elem_codec = 0;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_elem_buf = 0;
+  PyObject *__pyx_v_elem = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  char const *__pyx_t_2;
+  uint32_t __pyx_t_3;
+  uint32_t __pyx_t_4;
+  int __pyx_t_5;
+  int __pyx_t_6;
+  int __pyx_t_7;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  PyObject *__pyx_t_10 = NULL;
+  PyObject *__pyx_t_11 = NULL;
+  int __pyx_t_12;
+  PyObject *__pyx_t_13 = NULL;
+  __Pyx_RefNannySetupContext("anonymous_record_decode", 0);
+
+  /* "asyncpg/protocol/codecs/record.pyx":25
+ *         uint32_t i
+ *         Codec elem_codec
+ *         FastReadBuffer elem_buf = FastReadBuffer.new()             # <<<<<<<<<<<<<<
+ * 
+ *     elem_count = <uint32_t>hton.unpack_int32(buf.read(4))
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_new()); if (unlikely(!__pyx_t_1)) __PYX_ERR(22, 25, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_elem_buf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/record.pyx":27
+ *         FastReadBuffer elem_buf = FastReadBuffer.new()
+ * 
+ *     elem_count = <uint32_t>hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ *     result = cpython.PyTuple_New(elem_count)
+ * 
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_2 == NULL)) __PYX_ERR(22, 27, __pyx_L1_error)
+  __pyx_v_elem_count = ((uint32_t)__pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_2));
+
+  /* "asyncpg/protocol/codecs/record.pyx":28
+ * 
+ *     elem_count = <uint32_t>hton.unpack_int32(buf.read(4))
+ *     result = cpython.PyTuple_New(elem_count)             # <<<<<<<<<<<<<<
+ * 
+ *     for i in range(elem_count):
+ */
+  __pyx_t_1 = PyTuple_New(__pyx_v_elem_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(22, 28, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_result = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/record.pyx":30
+ *     result = cpython.PyTuple_New(elem_count)
+ * 
+ *     for i in range(elem_count):             # <<<<<<<<<<<<<<
+ *         elem_typ = <uint32_t>hton.unpack_int32(buf.read(4))
+ *         elem_len = hton.unpack_int32(buf.read(4))
+ */
+  __pyx_t_3 = __pyx_v_elem_count;
+  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
+    __pyx_v_i = __pyx_t_4;
+
+    /* "asyncpg/protocol/codecs/record.pyx":31
+ * 
+ *     for i in range(elem_count):
+ *         elem_typ = <uint32_t>hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ *         elem_len = hton.unpack_int32(buf.read(4))
+ * 
+ */
+    __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_2 == NULL)) __PYX_ERR(22, 31, __pyx_L1_error)
+    __pyx_v_elem_typ = ((uint32_t)__pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_2));
+
+    /* "asyncpg/protocol/codecs/record.pyx":32
+ *     for i in range(elem_count):
+ *         elem_typ = <uint32_t>hton.unpack_int32(buf.read(4))
+ *         elem_len = hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ * 
+ *         if elem_len == -1:
+ */
+    __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_2 == NULL)) __PYX_ERR(22, 32, __pyx_L1_error)
+    __pyx_v_elem_len = __pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_2);
+
+    /* "asyncpg/protocol/codecs/record.pyx":34
+ *         elem_len = hton.unpack_int32(buf.read(4))
+ * 
+ *         if elem_len == -1:             # <<<<<<<<<<<<<<
+ *             elem = None
+ *         else:
+ */
+    __pyx_t_5 = ((__pyx_v_elem_len == -1L) != 0);
+    if (__pyx_t_5) {
+
+      /* "asyncpg/protocol/codecs/record.pyx":35
+ * 
+ *         if elem_len == -1:
+ *             elem = None             # <<<<<<<<<<<<<<
+ *         else:
+ *             elem_codec = settings.get_data_codec(elem_typ)
+ */
+      __Pyx_INCREF(Py_None);
+      __Pyx_XDECREF_SET(__pyx_v_elem, Py_None);
+
+      /* "asyncpg/protocol/codecs/record.pyx":34
+ *         elem_len = hton.unpack_int32(buf.read(4))
+ * 
+ *         if elem_len == -1:             # <<<<<<<<<<<<<<
+ *             elem = None
+ *         else:
+ */
+      goto __pyx_L5;
+    }
+
+    /* "asyncpg/protocol/codecs/record.pyx":37
+ *             elem = None
+ *         else:
+ *             elem_codec = settings.get_data_codec(elem_typ)             # <<<<<<<<<<<<<<
+ *             if elem_codec is None or not elem_codec.has_decoder():
+ *                 raise RuntimeError(
+ */
+    /*else*/ {
+      __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_data_codec(__pyx_v_settings, __pyx_v_elem_typ, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(22, 37, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_XDECREF_SET(__pyx_v_elem_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_1));
+      __pyx_t_1 = 0;
+
+      /* "asyncpg/protocol/codecs/record.pyx":38
+ *         else:
+ *             elem_codec = settings.get_data_codec(elem_typ)
+ *             if elem_codec is None or not elem_codec.has_decoder():             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError(
+ *                     'no decoder for composite type element in '
+ */
+      __pyx_t_6 = (((PyObject *)__pyx_v_elem_codec) == Py_None);
+      __pyx_t_7 = (__pyx_t_6 != 0);
+      if (!__pyx_t_7) {
+      } else {
+        __pyx_t_5 = __pyx_t_7;
+        goto __pyx_L7_bool_binop_done;
+      }
+      __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_has_decoder(__pyx_v_elem_codec); if (unlikely(!__pyx_t_1)) __PYX_ERR(22, 38, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(22, 38, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __pyx_t_6 = ((!__pyx_t_7) != 0);
+      __pyx_t_5 = __pyx_t_6;
+      __pyx_L7_bool_binop_done:;
+      if (__pyx_t_5) {
+
+        /* "asyncpg/protocol/codecs/record.pyx":41
+ *                 raise RuntimeError(
+ *                     'no decoder for composite type element in '
+ *                     'position {} of type OID {}'.format(i, elem_typ))             # <<<<<<<<<<<<<<
+ *             elem = elem_codec.decode(settings,
+ *                                      elem_buf.slice_from(buf, elem_len))
+ */
+        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_no_decoder_for_composite_type_el, __pyx_n_s_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(22, 41, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_8);
+        __pyx_t_9 = __Pyx_PyInt_From_uint32_t(__pyx_v_i); if (unlikely(!__pyx_t_9)) __PYX_ERR(22, 41, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_9);
+        __pyx_t_10 = __Pyx_PyInt_From_uint32_t(__pyx_v_elem_typ); if (unlikely(!__pyx_t_10)) __PYX_ERR(22, 41, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_10);
+        __pyx_t_11 = NULL;
+        __pyx_t_12 = 0;
+        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
+          __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_8);
+          if (likely(__pyx_t_11)) {
+            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
+            __Pyx_INCREF(__pyx_t_11);
+            __Pyx_INCREF(function);
+            __Pyx_DECREF_SET(__pyx_t_8, function);
+            __pyx_t_12 = 1;
+          }
+        }
+        #if CYTHON_FAST_PYCALL
+        if (PyFunction_Check(__pyx_t_8)) {
+          PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_9, __pyx_t_10};
+          __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(22, 41, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
+          __Pyx_GOTREF(__pyx_t_1);
+          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        } else
+        #endif
+        #if CYTHON_FAST_PYCCALL
+        if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
+          PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_9, __pyx_t_10};
+          __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(22, 41, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
+          __Pyx_GOTREF(__pyx_t_1);
+          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        } else
+        #endif
+        {
+          __pyx_t_13 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(22, 41, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_13);
+          if (__pyx_t_11) {
+            __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_11); __pyx_t_11 = NULL;
+          }
+          __Pyx_GIVEREF(__pyx_t_9);
+          PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_t_9);
+          __Pyx_GIVEREF(__pyx_t_10);
+          PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, __pyx_t_10);
+          __pyx_t_9 = 0;
+          __pyx_t_10 = 0;
+          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_13, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(22, 41, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_1);
+          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+        }
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+
+        /* "asyncpg/protocol/codecs/record.pyx":39
+ *             elem_codec = settings.get_data_codec(elem_typ)
+ *             if elem_codec is None or not elem_codec.has_decoder():
+ *                 raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                     'no decoder for composite type element in '
+ *                     'position {} of type OID {}'.format(i, elem_typ))
+ */
+        __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(22, 39, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_8);
+        __Pyx_GIVEREF(__pyx_t_1);
+        PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
+        __pyx_t_1 = 0;
+        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(22, 39, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __PYX_ERR(22, 39, __pyx_L1_error)
+
+        /* "asyncpg/protocol/codecs/record.pyx":38
+ *         else:
+ *             elem_codec = settings.get_data_codec(elem_typ)
+ *             if elem_codec is None or not elem_codec.has_decoder():             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError(
+ *                     'no decoder for composite type element in '
+ */
+      }
+
+      /* "asyncpg/protocol/codecs/record.pyx":43
+ *                     'position {} of type OID {}'.format(i, elem_typ))
+ *             elem = elem_codec.decode(settings,
+ *                                      elem_buf.slice_from(buf, elem_len))             # <<<<<<<<<<<<<<
+ * 
+ *         cpython.Py_INCREF(elem)
+ */
+      __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_slice_from(__pyx_v_elem_buf, __pyx_v_buf, __pyx_v_elem_len)); if (unlikely(!__pyx_t_1)) __PYX_ERR(22, 43, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+
+      /* "asyncpg/protocol/codecs/record.pyx":42
+ *                     'no decoder for composite type element in '
+ *                     'position {} of type OID {}'.format(i, elem_typ))
+ *             elem = elem_codec.decode(settings,             # <<<<<<<<<<<<<<
+ *                                      elem_buf.slice_from(buf, elem_len))
+ * 
+ */
+      __pyx_t_8 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode(__pyx_v_elem_codec, __pyx_v_settings, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *)__pyx_t_1)); if (unlikely(!__pyx_t_8)) __PYX_ERR(22, 42, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_8);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_XDECREF_SET(__pyx_v_elem, __pyx_t_8);
+      __pyx_t_8 = 0;
+    }
+    __pyx_L5:;
+
+    /* "asyncpg/protocol/codecs/record.pyx":45
+ *                                      elem_buf.slice_from(buf, elem_len))
+ * 
+ *         cpython.Py_INCREF(elem)             # <<<<<<<<<<<<<<
+ *         cpython.PyTuple_SET_ITEM(result, i, elem)
+ * 
+ */
+    Py_INCREF(__pyx_v_elem);
+
+    /* "asyncpg/protocol/codecs/record.pyx":46
+ * 
+ *         cpython.Py_INCREF(elem)
+ *         cpython.PyTuple_SET_ITEM(result, i, elem)             # <<<<<<<<<<<<<<
+ * 
+ *     return result
+ */
+    PyTuple_SET_ITEM(__pyx_v_result, __pyx_v_i, __pyx_v_elem);
+  }
+
+  /* "asyncpg/protocol/codecs/record.pyx":48
+ *         cpython.PyTuple_SET_ITEM(result, i, elem)
+ * 
+ *     return result             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_result);
+  __pyx_r = __pyx_v_result;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/record.pyx":17
+ * 
+ * 
+ * cdef anonymous_record_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         tuple result
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_XDECREF(__pyx_t_11);
+  __Pyx_XDECREF(__pyx_t_13);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.anonymous_record_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_result);
+  __Pyx_XDECREF((PyObject *)__pyx_v_elem_codec);
+  __Pyx_XDECREF((PyObject *)__pyx_v_elem_buf);
+  __Pyx_XDECREF(__pyx_v_elem);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/record.pyx":51
+ * 
+ * 
+ * cdef init_record_codecs():             # <<<<<<<<<<<<<<
+ *     register_core_codec(RECORDOID,
+ *                         <encode_func>NULL,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_record_codecs(void) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("init_record_codecs", 0);
+
+  /* "asyncpg/protocol/codecs/record.pyx":52
+ * 
+ * cdef init_record_codecs():
+ *     register_core_codec(RECORDOID,             # <<<<<<<<<<<<<<
+ *                         <encode_func>NULL,
+ *                         <decode_func>&anonymous_record_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x8C9, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)NULL), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_anonymous_record_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(22, 52, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/record.pyx":51
+ * 
+ * 
+ * cdef init_record_codecs():             # <<<<<<<<<<<<<<
+ *     register_core_codec(RECORDOID,
+ *                         <encode_func>NULL,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.init_record_codecs", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/hstore.pyx":8
+ * 
+ * 
+ * cdef hstore_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         char *str
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_hstore_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
+  char *__pyx_v_str;
+  Py_ssize_t __pyx_v_size;
+  Py_ssize_t __pyx_v_count;
+  PyObject *__pyx_v_items = 0;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_item_buf = 0;
+  PyObject *__pyx_v_k = NULL;
+  PyObject *__pyx_v_v = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  Py_ssize_t __pyx_t_2;
+  int __pyx_t_3;
+  int __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *(*__pyx_t_7)(PyObject *);
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  PyObject *(*__pyx_t_10)(PyObject *);
+  int32_t __pyx_t_11;
+  __Pyx_RefNannySetupContext("hstore_encode", 0);
+
+  /* "asyncpg/protocol/codecs/hstore.pyx":14
+ *         ssize_t count
+ *         object items
+ *         WriteBuffer item_buf = WriteBuffer.new()             # <<<<<<<<<<<<<<
+ * 
+ *     count = len(obj)
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new()); if (unlikely(!__pyx_t_1)) __PYX_ERR(23, 14, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_item_buf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/hstore.pyx":16
+ *         WriteBuffer item_buf = WriteBuffer.new()
+ * 
+ *     count = len(obj)             # <<<<<<<<<<<<<<
+ *     if count > _MAXINT32:
+ *         raise ValueError('hstore value is too large')
+ */
+  __pyx_t_2 = PyObject_Length(__pyx_v_obj); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(23, 16, __pyx_L1_error)
+  __pyx_v_count = __pyx_t_2;
+
+  /* "asyncpg/protocol/codecs/hstore.pyx":17
+ * 
+ *     count = len(obj)
+ *     if count > _MAXINT32:             # <<<<<<<<<<<<<<
+ *         raise ValueError('hstore value is too large')
+ *     item_buf.write_int32(<int32_t>count)
+ */
+  __pyx_t_3 = ((__pyx_v_count > 0x7FFFFFFF) != 0);
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/codecs/hstore.pyx":18
+ *     count = len(obj)
+ *     if count > _MAXINT32:
+ *         raise ValueError('hstore value is too large')             # <<<<<<<<<<<<<<
+ *     item_buf.write_int32(<int32_t>count)
+ * 
+ */
+    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__51, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(23, 18, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __PYX_ERR(23, 18, __pyx_L1_error)
+
+    /* "asyncpg/protocol/codecs/hstore.pyx":17
+ * 
+ *     count = len(obj)
+ *     if count > _MAXINT32:             # <<<<<<<<<<<<<<
+ *         raise ValueError('hstore value is too large')
+ *     item_buf.write_int32(<int32_t>count)
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/hstore.pyx":19
+ *     if count > _MAXINT32:
+ *         raise ValueError('hstore value is too large')
+ *     item_buf.write_int32(<int32_t>count)             # <<<<<<<<<<<<<<
+ * 
+ *     if hasattr(obj, 'items'):
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_item_buf, ((int32_t)__pyx_v_count)); if (unlikely(!__pyx_t_1)) __PYX_ERR(23, 19, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/hstore.pyx":21
+ *     item_buf.write_int32(<int32_t>count)
+ * 
+ *     if hasattr(obj, 'items'):             # <<<<<<<<<<<<<<
+ *         items = obj.items()
+ *     else:
+ */
+  __pyx_t_3 = PyObject_HasAttr(__pyx_v_obj, __pyx_n_u_items); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(23, 21, __pyx_L1_error)
+  __pyx_t_4 = (__pyx_t_3 != 0);
+  if (__pyx_t_4) {
+
+    /* "asyncpg/protocol/codecs/hstore.pyx":22
+ * 
+ *     if hasattr(obj, 'items'):
+ *         items = obj.items()             # <<<<<<<<<<<<<<
+ *     else:
+ *         items = obj
+ */
+    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_items); if (unlikely(!__pyx_t_5)) __PYX_ERR(23, 22, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
+      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
+      if (likely(__pyx_t_6)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+        __Pyx_INCREF(__pyx_t_6);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_5, function);
+      }
+    }
+    if (__pyx_t_6) {
+      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(23, 22, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    } else {
+      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(23, 22, __pyx_L1_error)
+    }
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_v_items = __pyx_t_1;
+    __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/codecs/hstore.pyx":21
+ *     item_buf.write_int32(<int32_t>count)
+ * 
+ *     if hasattr(obj, 'items'):             # <<<<<<<<<<<<<<
+ *         items = obj.items()
+ *     else:
+ */
+    goto __pyx_L4;
+  }
+
+  /* "asyncpg/protocol/codecs/hstore.pyx":24
+ *         items = obj.items()
+ *     else:
+ *         items = obj             # <<<<<<<<<<<<<<
+ * 
+ *     for k, v in items:
+ */
+  /*else*/ {
+    __Pyx_INCREF(__pyx_v_obj);
+    __pyx_v_items = __pyx_v_obj;
+  }
+  __pyx_L4:;
+
+  /* "asyncpg/protocol/codecs/hstore.pyx":26
+ *         items = obj
+ * 
+ *     for k, v in items:             # <<<<<<<<<<<<<<
+ *         if k is None:
+ *             raise ValueError('null value not allowed in hstore key')
+ */
+  if (likely(PyList_CheckExact(__pyx_v_items)) || PyTuple_CheckExact(__pyx_v_items)) {
+    __pyx_t_1 = __pyx_v_items; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
+    __pyx_t_7 = NULL;
+  } else {
+    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_items); if (unlikely(!__pyx_t_1)) __PYX_ERR(23, 26, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(23, 26, __pyx_L1_error)
+  }
+  for (;;) {
+    if (likely(!__pyx_t_7)) {
+      if (likely(PyList_CheckExact(__pyx_t_1))) {
+        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
+        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(23, 26, __pyx_L1_error)
+        #else
+        __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) __PYX_ERR(23, 26, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_5);
+        #endif
+      } else {
+        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(23, 26, __pyx_L1_error)
+        #else
+        __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) __PYX_ERR(23, 26, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_5);
+        #endif
+      }
+    } else {
+      __pyx_t_5 = __pyx_t_7(__pyx_t_1);
+      if (unlikely(!__pyx_t_5)) {
+        PyObject* exc_type = PyErr_Occurred();
+        if (exc_type) {
+          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+          else __PYX_ERR(23, 26, __pyx_L1_error)
+        }
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_5);
+    }
+    if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
+      PyObject* sequence = __pyx_t_5;
+      #if !CYTHON_COMPILING_IN_PYPY
+      Py_ssize_t size = Py_SIZE(sequence);
+      #else
+      Py_ssize_t size = PySequence_Size(sequence);
+      #endif
+      if (unlikely(size != 2)) {
+        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
+        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
+        __PYX_ERR(23, 26, __pyx_L1_error)
+      }
+      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+      if (likely(PyTuple_CheckExact(sequence))) {
+        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
+        __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
+      } else {
+        __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
+        __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
+      }
+      __Pyx_INCREF(__pyx_t_6);
+      __Pyx_INCREF(__pyx_t_8);
+      #else
+      __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(23, 26, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_6);
+      __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(23, 26, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_8);
+      #endif
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    } else {
+      Py_ssize_t index = -1;
+      __pyx_t_9 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(23, 26, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
+      index = 0; __pyx_t_6 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_6)) goto __pyx_L7_unpacking_failed;
+      __Pyx_GOTREF(__pyx_t_6);
+      index = 1; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L7_unpacking_failed;
+      __Pyx_GOTREF(__pyx_t_8);
+      if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) __PYX_ERR(23, 26, __pyx_L1_error)
+      __pyx_t_10 = NULL;
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      goto __pyx_L8_unpacking_done;
+      __pyx_L7_unpacking_failed:;
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __pyx_t_10 = NULL;
+      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
+      __PYX_ERR(23, 26, __pyx_L1_error)
+      __pyx_L8_unpacking_done:;
+    }
+    __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_6);
+    __pyx_t_6 = 0;
+    __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_8);
+    __pyx_t_8 = 0;
+
+    /* "asyncpg/protocol/codecs/hstore.pyx":27
+ * 
+ *     for k, v in items:
+ *         if k is None:             # <<<<<<<<<<<<<<
+ *             raise ValueError('null value not allowed in hstore key')
+ *         as_pg_string_and_size(settings, k, &str, &size)
+ */
+    __pyx_t_4 = (__pyx_v_k == Py_None);
+    __pyx_t_3 = (__pyx_t_4 != 0);
+    if (__pyx_t_3) {
+
+      /* "asyncpg/protocol/codecs/hstore.pyx":28
+ *     for k, v in items:
+ *         if k is None:
+ *             raise ValueError('null value not allowed in hstore key')             # <<<<<<<<<<<<<<
+ *         as_pg_string_and_size(settings, k, &str, &size)
+ *         item_buf.write_int32(<int32_t>size)
+ */
+      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__52, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(23, 28, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __PYX_ERR(23, 28, __pyx_L1_error)
+
+      /* "asyncpg/protocol/codecs/hstore.pyx":27
+ * 
+ *     for k, v in items:
+ *         if k is None:             # <<<<<<<<<<<<<<
+ *             raise ValueError('null value not allowed in hstore key')
+ *         as_pg_string_and_size(settings, k, &str, &size)
+ */
+    }
+
+    /* "asyncpg/protocol/codecs/hstore.pyx":29
+ *         if k is None:
+ *             raise ValueError('null value not allowed in hstore key')
+ *         as_pg_string_and_size(settings, k, &str, &size)             # <<<<<<<<<<<<<<
+ *         item_buf.write_int32(<int32_t>size)
+ *         item_buf.write_cstr(str, size)
+ */
+    __pyx_t_5 = __pyx_f_7asyncpg_8protocol_8protocol_as_pg_string_and_size(__pyx_v_settings, __pyx_v_k, (&__pyx_v_str), (&__pyx_v_size)); if (unlikely(!__pyx_t_5)) __PYX_ERR(23, 29, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+    /* "asyncpg/protocol/codecs/hstore.pyx":30
+ *             raise ValueError('null value not allowed in hstore key')
+ *         as_pg_string_and_size(settings, k, &str, &size)
+ *         item_buf.write_int32(<int32_t>size)             # <<<<<<<<<<<<<<
+ *         item_buf.write_cstr(str, size)
+ *         if v is None:
+ */
+    __pyx_t_5 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_item_buf, ((int32_t)__pyx_v_size)); if (unlikely(!__pyx_t_5)) __PYX_ERR(23, 30, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+    /* "asyncpg/protocol/codecs/hstore.pyx":31
+ *         as_pg_string_and_size(settings, k, &str, &size)
+ *         item_buf.write_int32(<int32_t>size)
+ *         item_buf.write_cstr(str, size)             # <<<<<<<<<<<<<<
+ *         if v is None:
+ *             item_buf.write_int32(<int32_t>-1)
+ */
+    __pyx_t_5 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_cstr(__pyx_v_item_buf, __pyx_v_str, __pyx_v_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(23, 31, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+    /* "asyncpg/protocol/codecs/hstore.pyx":32
+ *         item_buf.write_int32(<int32_t>size)
+ *         item_buf.write_cstr(str, size)
+ *         if v is None:             # <<<<<<<<<<<<<<
+ *             item_buf.write_int32(<int32_t>-1)
+ *         else:
+ */
+    __pyx_t_3 = (__pyx_v_v == Py_None);
+    __pyx_t_4 = (__pyx_t_3 != 0);
+    if (__pyx_t_4) {
+
+      /* "asyncpg/protocol/codecs/hstore.pyx":33
+ *         item_buf.write_cstr(str, size)
+ *         if v is None:
+ *             item_buf.write_int32(<int32_t>-1)             # <<<<<<<<<<<<<<
+ *         else:
+ *             as_pg_string_and_size(settings, v, &str, &size)
+ */
+      __pyx_t_5 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_item_buf, ((int32_t)-1L)); if (unlikely(!__pyx_t_5)) __PYX_ERR(23, 33, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+      /* "asyncpg/protocol/codecs/hstore.pyx":32
+ *         item_buf.write_int32(<int32_t>size)
+ *         item_buf.write_cstr(str, size)
+ *         if v is None:             # <<<<<<<<<<<<<<
+ *             item_buf.write_int32(<int32_t>-1)
+ *         else:
+ */
+      goto __pyx_L10;
+    }
+
+    /* "asyncpg/protocol/codecs/hstore.pyx":35
+ *             item_buf.write_int32(<int32_t>-1)
+ *         else:
+ *             as_pg_string_and_size(settings, v, &str, &size)             # <<<<<<<<<<<<<<
+ *             item_buf.write_int32(<int32_t>size)
+ *             item_buf.write_cstr(str, size)
+ */
+    /*else*/ {
+      __pyx_t_5 = __pyx_f_7asyncpg_8protocol_8protocol_as_pg_string_and_size(__pyx_v_settings, __pyx_v_v, (&__pyx_v_str), (&__pyx_v_size)); if (unlikely(!__pyx_t_5)) __PYX_ERR(23, 35, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+      /* "asyncpg/protocol/codecs/hstore.pyx":36
+ *         else:
+ *             as_pg_string_and_size(settings, v, &str, &size)
+ *             item_buf.write_int32(<int32_t>size)             # <<<<<<<<<<<<<<
+ *             item_buf.write_cstr(str, size)
+ * 
+ */
+      __pyx_t_5 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_item_buf, ((int32_t)__pyx_v_size)); if (unlikely(!__pyx_t_5)) __PYX_ERR(23, 36, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+      /* "asyncpg/protocol/codecs/hstore.pyx":37
+ *             as_pg_string_and_size(settings, v, &str, &size)
+ *             item_buf.write_int32(<int32_t>size)
+ *             item_buf.write_cstr(str, size)             # <<<<<<<<<<<<<<
+ * 
+ *     buf.write_int32(item_buf.len())
+ */
+      __pyx_t_5 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_cstr(__pyx_v_item_buf, __pyx_v_str, __pyx_v_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(23, 37, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    }
+    __pyx_L10:;
+
+    /* "asyncpg/protocol/codecs/hstore.pyx":26
+ *         items = obj
+ * 
+ *     for k, v in items:             # <<<<<<<<<<<<<<
+ *         if k is None:
+ *             raise ValueError('null value not allowed in hstore key')
+ */
+  }
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/hstore.pyx":39
+ *             item_buf.write_cstr(str, size)
+ * 
+ *     buf.write_int32(item_buf.len())             # <<<<<<<<<<<<<<
+ *     buf.write_buffer(item_buf)
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_len(__pyx_v_item_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(23, 39, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_11 = __Pyx_PyInt_As_int32_t(__pyx_t_1); if (unlikely((__pyx_t_11 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(23, 39, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(23, 39, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/hstore.pyx":40
+ * 
+ *     buf.write_int32(item_buf.len())
+ *     buf.write_buffer(item_buf)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_buffer(__pyx_v_buf, __pyx_v_item_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(23, 40, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/hstore.pyx":8
+ * 
+ * 
+ * cdef hstore_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         char *str
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.hstore_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_items);
+  __Pyx_XDECREF((PyObject *)__pyx_v_item_buf);
+  __Pyx_XDECREF(__pyx_v_k);
+  __Pyx_XDECREF(__pyx_v_v);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/hstore.pyx":43
+ * 
+ * 
+ * cdef hstore_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         dict result
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_hstore_decode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
+  PyObject *__pyx_v_result = 0;
+  uint32_t __pyx_v_elem_count;
+  int32_t __pyx_v_elem_len;
+  CYTHON_UNUSED uint32_t __pyx_v_i;
+  PyObject *__pyx_v_k = 0;
+  PyObject *__pyx_v_v = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  char const *__pyx_t_2;
+  int __pyx_t_3;
+  uint32_t __pyx_t_4;
+  uint32_t __pyx_t_5;
+  __Pyx_RefNannySetupContext("hstore_decode", 0);
+
+  /* "asyncpg/protocol/codecs/hstore.pyx":52
+ *         str v
+ * 
+ *     result = {}             # <<<<<<<<<<<<<<
+ * 
+ *     elem_count = <uint32_t>hton.unpack_int32(buf.read(4))
+ */
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(23, 52, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_result = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/hstore.pyx":54
+ *     result = {}
+ * 
+ *     elem_count = <uint32_t>hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ *     if elem_count == 0:
+ *         return result
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_2 == NULL)) __PYX_ERR(23, 54, __pyx_L1_error)
+  __pyx_v_elem_count = ((uint32_t)__pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_2));
+
+  /* "asyncpg/protocol/codecs/hstore.pyx":55
+ * 
+ *     elem_count = <uint32_t>hton.unpack_int32(buf.read(4))
+ *     if elem_count == 0:             # <<<<<<<<<<<<<<
+ *         return result
+ * 
+ */
+  __pyx_t_3 = ((__pyx_v_elem_count == 0) != 0);
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/codecs/hstore.pyx":56
+ *     elem_count = <uint32_t>hton.unpack_int32(buf.read(4))
+ *     if elem_count == 0:
+ *         return result             # <<<<<<<<<<<<<<
+ * 
+ *     for i in range(elem_count):
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(__pyx_v_result);
+    __pyx_r = __pyx_v_result;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/codecs/hstore.pyx":55
+ * 
+ *     elem_count = <uint32_t>hton.unpack_int32(buf.read(4))
+ *     if elem_count == 0:             # <<<<<<<<<<<<<<
+ *         return result
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/codecs/hstore.pyx":58
+ *         return result
+ * 
+ *     for i in range(elem_count):             # <<<<<<<<<<<<<<
+ *         elem_len = hton.unpack_int32(buf.read(4))
+ *         if elem_len < 0:
+ */
+  __pyx_t_4 = __pyx_v_elem_count;
+  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
+    __pyx_v_i = __pyx_t_5;
+
+    /* "asyncpg/protocol/codecs/hstore.pyx":59
+ * 
+ *     for i in range(elem_count):
+ *         elem_len = hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ *         if elem_len < 0:
+ *             raise ValueError('null value not allowed in hstore key')
+ */
+    __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_2 == NULL)) __PYX_ERR(23, 59, __pyx_L1_error)
+    __pyx_v_elem_len = __pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_2);
+
+    /* "asyncpg/protocol/codecs/hstore.pyx":60
+ *     for i in range(elem_count):
+ *         elem_len = hton.unpack_int32(buf.read(4))
+ *         if elem_len < 0:             # <<<<<<<<<<<<<<
+ *             raise ValueError('null value not allowed in hstore key')
+ * 
+ */
+    __pyx_t_3 = ((__pyx_v_elem_len < 0) != 0);
+    if (__pyx_t_3) {
+
+      /* "asyncpg/protocol/codecs/hstore.pyx":61
+ *         elem_len = hton.unpack_int32(buf.read(4))
+ *         if elem_len < 0:
+ *             raise ValueError('null value not allowed in hstore key')             # <<<<<<<<<<<<<<
+ * 
+ *         k = decode_pg_string(settings, buf.read(elem_len), elem_len)
+ */
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__53, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(23, 61, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __PYX_ERR(23, 61, __pyx_L1_error)
+
+      /* "asyncpg/protocol/codecs/hstore.pyx":60
+ *     for i in range(elem_count):
+ *         elem_len = hton.unpack_int32(buf.read(4))
+ *         if elem_len < 0:             # <<<<<<<<<<<<<<
+ *             raise ValueError('null value not allowed in hstore key')
+ * 
+ */
+    }
+
+    /* "asyncpg/protocol/codecs/hstore.pyx":63
+ *             raise ValueError('null value not allowed in hstore key')
+ * 
+ *         k = decode_pg_string(settings, buf.read(elem_len), elem_len)             # <<<<<<<<<<<<<<
+ * 
+ *         elem_len = hton.unpack_int32(buf.read(4))
+ */
+    __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, __pyx_v_elem_len); if (unlikely(__pyx_t_2 == NULL)) __PYX_ERR(23, 63, __pyx_L1_error)
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_decode_pg_string(__pyx_v_settings, __pyx_t_2, __pyx_v_elem_len); if (unlikely(!__pyx_t_1)) __PYX_ERR(23, 63, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(23, 63, __pyx_L1_error)
+    __Pyx_XDECREF_SET(__pyx_v_k, ((PyObject*)__pyx_t_1));
+    __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/codecs/hstore.pyx":65
+ *         k = decode_pg_string(settings, buf.read(elem_len), elem_len)
+ * 
+ *         elem_len = hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
+ *         if elem_len < 0:
+ *             v = None
+ */
+    __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_2 == NULL)) __PYX_ERR(23, 65, __pyx_L1_error)
+    __pyx_v_elem_len = __pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_2);
+
+    /* "asyncpg/protocol/codecs/hstore.pyx":66
+ * 
+ *         elem_len = hton.unpack_int32(buf.read(4))
+ *         if elem_len < 0:             # <<<<<<<<<<<<<<
+ *             v = None
+ *         else:
+ */
+    __pyx_t_3 = ((__pyx_v_elem_len < 0) != 0);
+    if (__pyx_t_3) {
+
+      /* "asyncpg/protocol/codecs/hstore.pyx":67
+ *         elem_len = hton.unpack_int32(buf.read(4))
+ *         if elem_len < 0:
+ *             v = None             # <<<<<<<<<<<<<<
+ *         else:
+ *             v = decode_pg_string(settings, buf.read(elem_len), elem_len)
+ */
+      __Pyx_INCREF(Py_None);
+      __Pyx_XDECREF_SET(__pyx_v_v, ((PyObject*)Py_None));
+
+      /* "asyncpg/protocol/codecs/hstore.pyx":66
+ * 
+ *         elem_len = hton.unpack_int32(buf.read(4))
+ *         if elem_len < 0:             # <<<<<<<<<<<<<<
+ *             v = None
+ *         else:
+ */
+      goto __pyx_L7;
+    }
+
+    /* "asyncpg/protocol/codecs/hstore.pyx":69
+ *             v = None
+ *         else:
+ *             v = decode_pg_string(settings, buf.read(elem_len), elem_len)             # <<<<<<<<<<<<<<
+ * 
+ *         result[k] = v
+ */
+    /*else*/ {
+      __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, __pyx_v_elem_len); if (unlikely(__pyx_t_2 == NULL)) __PYX_ERR(23, 69, __pyx_L1_error)
+      __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_decode_pg_string(__pyx_v_settings, __pyx_t_2, __pyx_v_elem_len); if (unlikely(!__pyx_t_1)) __PYX_ERR(23, 69, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(23, 69, __pyx_L1_error)
+      __Pyx_XDECREF_SET(__pyx_v_v, ((PyObject*)__pyx_t_1));
+      __pyx_t_1 = 0;
+    }
+    __pyx_L7:;
+
+    /* "asyncpg/protocol/codecs/hstore.pyx":71
+ *             v = decode_pg_string(settings, buf.read(elem_len), elem_len)
+ * 
+ *         result[k] = v             # <<<<<<<<<<<<<<
+ * 
+ *     return result
+ */
+    if (unlikely(PyDict_SetItem(__pyx_v_result, __pyx_v_k, __pyx_v_v) < 0)) __PYX_ERR(23, 71, __pyx_L1_error)
+  }
+
+  /* "asyncpg/protocol/codecs/hstore.pyx":73
+ *         result[k] = v
+ * 
+ *     return result             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_result);
+  __pyx_r = __pyx_v_result;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/codecs/hstore.pyx":43
+ * 
+ * 
+ * cdef hstore_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         dict result
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.hstore_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_result);
+  __Pyx_XDECREF(__pyx_v_k);
+  __Pyx_XDECREF(__pyx_v_v);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/codecs/hstore.pyx":76
+ * 
+ * 
+ * cdef init_hstore_codecs():             # <<<<<<<<<<<<<<
+ *     register_extra_codec('pg_contrib.hstore',
+ *                          <encode_func>&hstore_encode,
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_init_hstore_codecs(void) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("init_hstore_codecs", 0);
+
+  /* "asyncpg/protocol/codecs/hstore.pyx":77
+ * 
+ * cdef init_hstore_codecs():
+ *     register_extra_codec('pg_contrib.hstore',             # <<<<<<<<<<<<<<
+ *                          <encode_func>&hstore_encode,
+ *                          <decode_func>&hstore_decode,
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_extra_codec(__pyx_kp_u_pg_contrib_hstore, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_hstore_encode)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_hstore_decode)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_1)) __PYX_ERR(23, 77, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/hstore.pyx":76
+ * 
+ * 
+ * cdef init_hstore_codecs():             # <<<<<<<<<<<<<<
+ *     register_extra_codec('pg_contrib.hstore',
+ *                          <encode_func>&hstore_encode,
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.init_hstore_codecs", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":13
+ * cdef class CoreProtocol:
+ * 
+ *     def __init__(self, con_args):             # <<<<<<<<<<<<<<
+ *         self.buffer = ReadBuffer()
+ *         self.user = con_args.get('user')
+ */
+
+/* Python wrapper */
+static int __pyx_pw_7asyncpg_8protocol_8protocol_12CoreProtocol_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pw_7asyncpg_8protocol_8protocol_12CoreProtocol_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_con_args = 0;
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_con_args,0};
+    PyObject* values[1] = {0};
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_con_args)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+      }
+      if (unlikely(kw_args > 0)) {
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(4, 13, __pyx_L3_error)
+      }
+    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
+      goto __pyx_L5_argtuple_error;
+    } else {
+      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+    }
+    __pyx_v_con_args = values[0];
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(4, 13, __pyx_L3_error)
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return -1;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12CoreProtocol___init__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self), __pyx_v_con_args);
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static int __pyx_pf_7asyncpg_8protocol_8protocol_12CoreProtocol___init__(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_con_args) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("__init__", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":14
+ * 
+ *     def __init__(self, con_args):
+ *         self.buffer = ReadBuffer()             # <<<<<<<<<<<<<<
+ *         self.user = con_args.get('user')
+ *         self.password = con_args.get('password')
+ */
+  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_ReadBuffer), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 14, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  __Pyx_GOTREF(__pyx_v_self->buffer);
+  __Pyx_DECREF(((PyObject *)__pyx_v_self->buffer));
+  __pyx_v_self->buffer = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":15
+ *     def __init__(self, con_args):
+ *         self.buffer = ReadBuffer()
+ *         self.user = con_args.get('user')             # <<<<<<<<<<<<<<
+ *         self.password = con_args.get('password')
+ *         self.auth_msg = None
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_con_args, __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 15, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__54, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 15, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_user, __pyx_t_2) < 0) __PYX_ERR(4, 15, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":16
+ *         self.buffer = ReadBuffer()
+ *         self.user = con_args.get('user')
+ *         self.password = con_args.get('password')             # <<<<<<<<<<<<<<
+ *         self.auth_msg = None
+ *         self.con_args = con_args
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_con_args, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 16, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__55, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 16, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_password, __pyx_t_1) < 0) __PYX_ERR(4, 16, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":17
+ *         self.user = con_args.get('user')
+ *         self.password = con_args.get('password')
+ *         self.auth_msg = None             # <<<<<<<<<<<<<<
+ *         self.con_args = con_args
+ *         self.transport = None
+ */
+  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_auth_msg, Py_None) < 0) __PYX_ERR(4, 17, __pyx_L1_error)
+
+  /* "asyncpg/protocol/coreproto.pyx":18
+ *         self.password = con_args.get('password')
+ *         self.auth_msg = None
+ *         self.con_args = con_args             # <<<<<<<<<<<<<<
+ *         self.transport = None
+ *         self.con_status = CONNECTION_BAD
+ */
+  if (!(likely(PyDict_CheckExact(__pyx_v_con_args))||((__pyx_v_con_args) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_v_con_args)->tp_name), 0))) __PYX_ERR(4, 18, __pyx_L1_error)
+  __pyx_t_1 = __pyx_v_con_args;
+  __Pyx_INCREF(__pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  __Pyx_GOTREF(__pyx_v_self->con_args);
+  __Pyx_DECREF(__pyx_v_self->con_args);
+  __pyx_v_self->con_args = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":19
+ *         self.auth_msg = None
+ *         self.con_args = con_args
+ *         self.transport = None             # <<<<<<<<<<<<<<
+ *         self.con_status = CONNECTION_BAD
+ *         self.state = PROTOCOL_IDLE
+ */
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->transport);
+  __Pyx_DECREF(__pyx_v_self->transport);
+  __pyx_v_self->transport = Py_None;
+
+  /* "asyncpg/protocol/coreproto.pyx":20
+ *         self.con_args = con_args
+ *         self.transport = None
+ *         self.con_status = CONNECTION_BAD             # <<<<<<<<<<<<<<
+ *         self.state = PROTOCOL_IDLE
+ *         self.xact_status = PQTRANS_IDLE
+ */
+  __pyx_v_self->con_status = __pyx_e_7asyncpg_8protocol_8protocol_CONNECTION_BAD;
+
+  /* "asyncpg/protocol/coreproto.pyx":21
+ *         self.transport = None
+ *         self.con_status = CONNECTION_BAD
+ *         self.state = PROTOCOL_IDLE             # <<<<<<<<<<<<<<
+ *         self.xact_status = PQTRANS_IDLE
+ *         self.encoding = 'utf-8'
+ */
+  __pyx_v_self->state = __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_IDLE;
+
+  /* "asyncpg/protocol/coreproto.pyx":22
+ *         self.con_status = CONNECTION_BAD
+ *         self.state = PROTOCOL_IDLE
+ *         self.xact_status = PQTRANS_IDLE             # <<<<<<<<<<<<<<
+ *         self.encoding = 'utf-8'
+ * 
+ */
+  __pyx_v_self->xact_status = __pyx_e_7asyncpg_8protocol_8protocol_PQTRANS_IDLE;
+
+  /* "asyncpg/protocol/coreproto.pyx":23
+ *         self.state = PROTOCOL_IDLE
+ *         self.xact_status = PQTRANS_IDLE
+ *         self.encoding = 'utf-8'             # <<<<<<<<<<<<<<
+ * 
+ *         self._skip_discard = False
+ */
+  __Pyx_INCREF(__pyx_kp_u_utf_8);
+  __Pyx_GIVEREF(__pyx_kp_u_utf_8);
+  __Pyx_GOTREF(__pyx_v_self->encoding);
+  __Pyx_DECREF(__pyx_v_self->encoding);
+  __pyx_v_self->encoding = __pyx_kp_u_utf_8;
+
+  /* "asyncpg/protocol/coreproto.pyx":25
+ *         self.encoding = 'utf-8'
+ * 
+ *         self._skip_discard = False             # <<<<<<<<<<<<<<
+ * 
+ *         # executemany support data
+ */
+  __pyx_v_self->_skip_discard = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":28
+ * 
+ *         # executemany support data
+ *         self._execute_iter = None             # <<<<<<<<<<<<<<
+ *         self._execute_portal_name = None
+ *         self._execute_stmt_name = None
+ */
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->_execute_iter);
+  __Pyx_DECREF(__pyx_v_self->_execute_iter);
+  __pyx_v_self->_execute_iter = Py_None;
+
+  /* "asyncpg/protocol/coreproto.pyx":29
+ *         # executemany support data
+ *         self._execute_iter = None
+ *         self._execute_portal_name = None             # <<<<<<<<<<<<<<
+ *         self._execute_stmt_name = None
+ * 
+ */
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->_execute_portal_name);
+  __Pyx_DECREF(__pyx_v_self->_execute_portal_name);
+  __pyx_v_self->_execute_portal_name = ((PyObject*)Py_None);
+
+  /* "asyncpg/protocol/coreproto.pyx":30
+ *         self._execute_iter = None
+ *         self._execute_portal_name = None
+ *         self._execute_stmt_name = None             # <<<<<<<<<<<<<<
+ * 
+ *         self._reset_result()
+ */
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->_execute_stmt_name);
+  __Pyx_DECREF(__pyx_v_self->_execute_stmt_name);
+  __pyx_v_self->_execute_stmt_name = ((PyObject*)Py_None);
+
+  /* "asyncpg/protocol/coreproto.pyx":32
+ *         self._execute_stmt_name = None
+ * 
+ *         self._reset_result()             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _write(self, buf):
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_reset_result(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 32, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":13
+ * cdef class CoreProtocol:
+ * 
+ *     def __init__(self, con_args):             # <<<<<<<<<<<<<<
+ *         self.buffer = ReadBuffer()
+ *         self.user = con_args.get('user')
+ */
+
+  /* function exit code */
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":34
+ *         self._reset_result()
+ * 
+ *     cdef _write(self, buf):             # <<<<<<<<<<<<<<
+ *         self.transport.write(memoryview(buf))
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__write(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_buf) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  __Pyx_RefNannySetupContext("_write", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":35
+ * 
+ *     cdef _write(self, buf):
+ *         self.transport.write(memoryview(buf))             # <<<<<<<<<<<<<<
+ * 
+ *     cdef inline _write_sync_message(self):
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->transport, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 35, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 35, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_INCREF(__pyx_v_buf);
+  __Pyx_GIVEREF(__pyx_v_buf);
+  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_buf);
+  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_memoryview, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 35, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (!__pyx_t_3) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 35, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_4};
+      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 35, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_4};
+      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 35, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    } else
+    #endif
+    {
+      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 35, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
+      __Pyx_GIVEREF(__pyx_t_4);
+      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
+      __pyx_t_4 = 0;
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 35, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":34
+ *         self._reset_result()
+ * 
+ *     cdef _write(self, buf):             # <<<<<<<<<<<<<<
+ *         self.transport.write(memoryview(buf))
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._write", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":37
+ *         self.transport.write(memoryview(buf))
+ * 
+ *     cdef inline _write_sync_message(self):             # <<<<<<<<<<<<<<
+ *         self.transport.write(SYNC_MESSAGE)
+ * 
+ */
+
+static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__write_sync_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  __Pyx_RefNannySetupContext("_write_sync_message", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":38
+ * 
+ *     cdef inline _write_sync_message(self):
+ *         self.transport.write(SYNC_MESSAGE)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _read_server_messages(self):
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->transport, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 38, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (!__pyx_t_3) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_7asyncpg_8protocol_8protocol_SYNC_MESSAGE); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 38, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_7asyncpg_8protocol_8protocol_SYNC_MESSAGE};
+      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 38, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_7asyncpg_8protocol_8protocol_SYNC_MESSAGE};
+      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 38, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else
+    #endif
+    {
+      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 38, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
+      __Pyx_INCREF(__pyx_v_7asyncpg_8protocol_8protocol_SYNC_MESSAGE);
+      __Pyx_GIVEREF(__pyx_v_7asyncpg_8protocol_8protocol_SYNC_MESSAGE);
+      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_7asyncpg_8protocol_8protocol_SYNC_MESSAGE);
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 38, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":37
+ *         self.transport.write(memoryview(buf))
+ * 
+ *     cdef inline _write_sync_message(self):             # <<<<<<<<<<<<<<
+ *         self.transport.write(SYNC_MESSAGE)
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._write_sync_message", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":40
+ *         self.transport.write(SYNC_MESSAGE)
+ * 
+ *     cdef _read_server_messages(self):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             char mtype
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__read_server_messages(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self) {
+  char __pyx_v_mtype;
+  enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState __pyx_v_state;
+  PyObject *__pyx_v_ex = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int32_t __pyx_t_1;
+  int __pyx_t_2;
+  enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  PyObject *__pyx_t_10 = NULL;
+  PyObject *__pyx_t_11 = NULL;
+  int __pyx_t_12;
+  int __pyx_t_13;
+  char const *__pyx_t_14;
+  PyObject *__pyx_t_15 = NULL;
+  PyObject *__pyx_t_16 = NULL;
+  PyObject *__pyx_t_17 = NULL;
+  PyObject *__pyx_t_18 = NULL;
+  PyObject *__pyx_t_19 = NULL;
+  PyObject *__pyx_t_20 = NULL;
+  char const *__pyx_t_21;
+  __Pyx_RefNannySetupContext("_read_server_messages", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":45
+ *             ProtocolState state
+ * 
+ *         while self.buffer.has_message() == 1:             # <<<<<<<<<<<<<<
+ *             mtype = self.buffer.get_message_type()
+ *             state = self.state
+ */
+  while (1) {
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_has_message(__pyx_v_self->buffer); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(4, 45, __pyx_L1_error)
+    __pyx_t_2 = ((__pyx_t_1 == 1) != 0);
+    if (!__pyx_t_2) break;
+
+    /* "asyncpg/protocol/coreproto.pyx":46
+ * 
+ *         while self.buffer.has_message() == 1:
+ *             mtype = self.buffer.get_message_type()             # <<<<<<<<<<<<<<
+ *             state = self.state
+ * 
+ */
+    __pyx_v_mtype = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_get_message_type(__pyx_v_self->buffer);
+
+    /* "asyncpg/protocol/coreproto.pyx":47
+ *         while self.buffer.has_message() == 1:
+ *             mtype = self.buffer.get_message_type()
+ *             state = self.state             # <<<<<<<<<<<<<<
+ * 
+ *             try:
+ */
+    __pyx_t_3 = __pyx_v_self->state;
+    __pyx_v_state = __pyx_t_3;
+
+    /* "asyncpg/protocol/coreproto.pyx":49
+ *             state = self.state
+ * 
+ *             try:             # <<<<<<<<<<<<<<
+ *                 if mtype == b'S':
+ *                     # ParameterStatus
+ */
+    /*try:*/ {
+      {
+        __Pyx_PyThreadState_declare
+        __Pyx_PyThreadState_assign
+        __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
+        __Pyx_XGOTREF(__pyx_t_4);
+        __Pyx_XGOTREF(__pyx_t_5);
+        __Pyx_XGOTREF(__pyx_t_6);
+        /*try:*/ {
+
+          /* "asyncpg/protocol/coreproto.pyx":50
+ * 
+ *             try:
+ *                 if mtype == b'S':             # <<<<<<<<<<<<<<
+ *                     # ParameterStatus
+ *                     self._parse_msg_parameter_status()
+ */
+          switch (__pyx_v_mtype) {
+            case 'S':
+
+            /* "asyncpg/protocol/coreproto.pyx":52
+ *                 if mtype == b'S':
+ *                     # ParameterStatus
+ *                     self._parse_msg_parameter_status()             # <<<<<<<<<<<<<<
+ *                     continue
+ *                 elif mtype == b'A':
+ */
+            __pyx_t_7 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_parse_msg_parameter_status(__pyx_v_self); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 52, __pyx_L10_error)
+            __Pyx_GOTREF(__pyx_t_7);
+            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+            /* "asyncpg/protocol/coreproto.pyx":53
+ *                     # ParameterStatus
+ *                     self._parse_msg_parameter_status()
+ *                     continue             # <<<<<<<<<<<<<<
+ *                 elif mtype == b'A':
+ *                     # NotificationResponse
+ */
+            goto __pyx_L16_try_continue;
+
+            /* "asyncpg/protocol/coreproto.pyx":50
+ * 
+ *             try:
+ *                 if mtype == b'S':             # <<<<<<<<<<<<<<
+ *                     # ParameterStatus
+ *                     self._parse_msg_parameter_status()
+ */
+            break;
+
+            /* "asyncpg/protocol/coreproto.pyx":54
+ *                     self._parse_msg_parameter_status()
+ *                     continue
+ *                 elif mtype == b'A':             # <<<<<<<<<<<<<<
+ *                     # NotificationResponse
+ *                     self._parse_msg_notification()
+ */
+            case 'A':
+
+            /* "asyncpg/protocol/coreproto.pyx":56
+ *                 elif mtype == b'A':
+ *                     # NotificationResponse
+ *                     self._parse_msg_notification()             # <<<<<<<<<<<<<<
+ *                     continue
+ * 
+ */
+            __pyx_t_7 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_parse_msg_notification(__pyx_v_self); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 56, __pyx_L10_error)
+            __Pyx_GOTREF(__pyx_t_7);
+            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+            /* "asyncpg/protocol/coreproto.pyx":57
+ *                     # NotificationResponse
+ *                     self._parse_msg_notification()
+ *                     continue             # <<<<<<<<<<<<<<
+ * 
+ *                 if state == PROTOCOL_AUTH:
+ */
+            goto __pyx_L16_try_continue;
+
+            /* "asyncpg/protocol/coreproto.pyx":54
+ *                     self._parse_msg_parameter_status()
+ *                     continue
+ *                 elif mtype == b'A':             # <<<<<<<<<<<<<<
+ *                     # NotificationResponse
+ *                     self._parse_msg_notification()
+ */
+            break;
+            default: break;
+          }
+
+          /* "asyncpg/protocol/coreproto.pyx":59
+ *                     continue
+ * 
+ *                 if state == PROTOCOL_AUTH:             # <<<<<<<<<<<<<<
+ *                     self._process__auth(mtype)
+ * 
+ */
+          switch (__pyx_v_state) {
+            case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_AUTH:
+
+            /* "asyncpg/protocol/coreproto.pyx":60
+ * 
+ *                 if state == PROTOCOL_AUTH:
+ *                     self._process__auth(mtype)             # <<<<<<<<<<<<<<
+ * 
+ *                 elif state == PROTOCOL_PREPARE:
+ */
+            __pyx_t_7 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_process__auth(__pyx_v_self, __pyx_v_mtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 60, __pyx_L10_error)
+            __Pyx_GOTREF(__pyx_t_7);
+            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+            /* "asyncpg/protocol/coreproto.pyx":59
+ *                     continue
+ * 
+ *                 if state == PROTOCOL_AUTH:             # <<<<<<<<<<<<<<
+ *                     self._process__auth(mtype)
+ * 
+ */
+            break;
+
+            /* "asyncpg/protocol/coreproto.pyx":62
+ *                     self._process__auth(mtype)
+ * 
+ *                 elif state == PROTOCOL_PREPARE:             # <<<<<<<<<<<<<<
+ *                     self._process__prepare(mtype)
+ * 
+ */
+            case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_PREPARE:
+
+            /* "asyncpg/protocol/coreproto.pyx":63
+ * 
+ *                 elif state == PROTOCOL_PREPARE:
+ *                     self._process__prepare(mtype)             # <<<<<<<<<<<<<<
+ * 
+ *                 elif state == PROTOCOL_BIND_EXECUTE:
+ */
+            __pyx_t_7 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_process__prepare(__pyx_v_self, __pyx_v_mtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 63, __pyx_L10_error)
+            __Pyx_GOTREF(__pyx_t_7);
+            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+            /* "asyncpg/protocol/coreproto.pyx":62
+ *                     self._process__auth(mtype)
+ * 
+ *                 elif state == PROTOCOL_PREPARE:             # <<<<<<<<<<<<<<
+ *                     self._process__prepare(mtype)
+ * 
+ */
+            break;
+
+            /* "asyncpg/protocol/coreproto.pyx":65
+ *                     self._process__prepare(mtype)
+ * 
+ *                 elif state == PROTOCOL_BIND_EXECUTE:             # <<<<<<<<<<<<<<
+ *                     self._process__bind_execute(mtype)
+ * 
+ */
+            case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_BIND_EXECUTE:
+
+            /* "asyncpg/protocol/coreproto.pyx":66
+ * 
+ *                 elif state == PROTOCOL_BIND_EXECUTE:
+ *                     self._process__bind_execute(mtype)             # <<<<<<<<<<<<<<
+ * 
+ *                 elif state == PROTOCOL_BIND_EXECUTE_MANY:
+ */
+            __pyx_t_7 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_process__bind_execute(__pyx_v_self, __pyx_v_mtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 66, __pyx_L10_error)
+            __Pyx_GOTREF(__pyx_t_7);
+            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+            /* "asyncpg/protocol/coreproto.pyx":65
+ *                     self._process__prepare(mtype)
+ * 
+ *                 elif state == PROTOCOL_BIND_EXECUTE:             # <<<<<<<<<<<<<<
+ *                     self._process__bind_execute(mtype)
+ * 
+ */
+            break;
+
+            /* "asyncpg/protocol/coreproto.pyx":68
+ *                     self._process__bind_execute(mtype)
+ * 
+ *                 elif state == PROTOCOL_BIND_EXECUTE_MANY:             # <<<<<<<<<<<<<<
+ *                     self._process__bind_execute_many(mtype)
+ * 
+ */
+            case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_BIND_EXECUTE_MANY:
+
+            /* "asyncpg/protocol/coreproto.pyx":69
+ * 
+ *                 elif state == PROTOCOL_BIND_EXECUTE_MANY:
+ *                     self._process__bind_execute_many(mtype)             # <<<<<<<<<<<<<<
+ * 
+ *                 elif state == PROTOCOL_EXECUTE:
+ */
+            __pyx_t_7 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_process__bind_execute_many(__pyx_v_self, __pyx_v_mtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 69, __pyx_L10_error)
+            __Pyx_GOTREF(__pyx_t_7);
+            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+            /* "asyncpg/protocol/coreproto.pyx":68
+ *                     self._process__bind_execute(mtype)
+ * 
+ *                 elif state == PROTOCOL_BIND_EXECUTE_MANY:             # <<<<<<<<<<<<<<
+ *                     self._process__bind_execute_many(mtype)
+ * 
+ */
+            break;
+
+            /* "asyncpg/protocol/coreproto.pyx":71
+ *                     self._process__bind_execute_many(mtype)
+ * 
+ *                 elif state == PROTOCOL_EXECUTE:             # <<<<<<<<<<<<<<
+ *                     self._process__bind_execute(mtype)
+ * 
+ */
+            case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_EXECUTE:
+
+            /* "asyncpg/protocol/coreproto.pyx":72
+ * 
+ *                 elif state == PROTOCOL_EXECUTE:
+ *                     self._process__bind_execute(mtype)             # <<<<<<<<<<<<<<
+ * 
+ *                 elif state == PROTOCOL_BIND:
+ */
+            __pyx_t_7 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_process__bind_execute(__pyx_v_self, __pyx_v_mtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 72, __pyx_L10_error)
+            __Pyx_GOTREF(__pyx_t_7);
+            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+            /* "asyncpg/protocol/coreproto.pyx":71
+ *                     self._process__bind_execute_many(mtype)
+ * 
+ *                 elif state == PROTOCOL_EXECUTE:             # <<<<<<<<<<<<<<
+ *                     self._process__bind_execute(mtype)
+ * 
+ */
+            break;
+
+            /* "asyncpg/protocol/coreproto.pyx":74
+ *                     self._process__bind_execute(mtype)
+ * 
+ *                 elif state == PROTOCOL_BIND:             # <<<<<<<<<<<<<<
+ *                     self._process__bind(mtype)
+ * 
+ */
+            case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_BIND:
+
+            /* "asyncpg/protocol/coreproto.pyx":75
+ * 
+ *                 elif state == PROTOCOL_BIND:
+ *                     self._process__bind(mtype)             # <<<<<<<<<<<<<<
+ * 
+ *                 elif state == PROTOCOL_CLOSE_STMT_PORTAL:
+ */
+            __pyx_t_7 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_process__bind(__pyx_v_self, __pyx_v_mtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 75, __pyx_L10_error)
+            __Pyx_GOTREF(__pyx_t_7);
+            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+            /* "asyncpg/protocol/coreproto.pyx":74
+ *                     self._process__bind_execute(mtype)
+ * 
+ *                 elif state == PROTOCOL_BIND:             # <<<<<<<<<<<<<<
+ *                     self._process__bind(mtype)
+ * 
+ */
+            break;
+
+            /* "asyncpg/protocol/coreproto.pyx":77
+ *                     self._process__bind(mtype)
+ * 
+ *                 elif state == PROTOCOL_CLOSE_STMT_PORTAL:             # <<<<<<<<<<<<<<
+ *                     self._process__close_stmt_portal(mtype)
+ * 
+ */
+            case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_CLOSE_STMT_PORTAL:
+
+            /* "asyncpg/protocol/coreproto.pyx":78
+ * 
+ *                 elif state == PROTOCOL_CLOSE_STMT_PORTAL:
+ *                     self._process__close_stmt_portal(mtype)             # <<<<<<<<<<<<<<
+ * 
+ *                 elif state == PROTOCOL_SIMPLE_QUERY:
+ */
+            __pyx_t_7 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_process__close_stmt_portal(__pyx_v_self, __pyx_v_mtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 78, __pyx_L10_error)
+            __Pyx_GOTREF(__pyx_t_7);
+            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+            /* "asyncpg/protocol/coreproto.pyx":77
+ *                     self._process__bind(mtype)
+ * 
+ *                 elif state == PROTOCOL_CLOSE_STMT_PORTAL:             # <<<<<<<<<<<<<<
+ *                     self._process__close_stmt_portal(mtype)
+ * 
+ */
+            break;
+
+            /* "asyncpg/protocol/coreproto.pyx":80
+ *                     self._process__close_stmt_portal(mtype)
+ * 
+ *                 elif state == PROTOCOL_SIMPLE_QUERY:             # <<<<<<<<<<<<<<
+ *                     self._process__simple_query(mtype)
+ * 
+ */
+            case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_SIMPLE_QUERY:
+
+            /* "asyncpg/protocol/coreproto.pyx":81
+ * 
+ *                 elif state == PROTOCOL_SIMPLE_QUERY:
+ *                     self._process__simple_query(mtype)             # <<<<<<<<<<<<<<
+ * 
+ *                 elif state == PROTOCOL_ERROR_CONSUME:
+ */
+            __pyx_t_7 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_process__simple_query(__pyx_v_self, __pyx_v_mtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 81, __pyx_L10_error)
+            __Pyx_GOTREF(__pyx_t_7);
+            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+            /* "asyncpg/protocol/coreproto.pyx":80
+ *                     self._process__close_stmt_portal(mtype)
+ * 
+ *                 elif state == PROTOCOL_SIMPLE_QUERY:             # <<<<<<<<<<<<<<
+ *                     self._process__simple_query(mtype)
+ * 
+ */
+            break;
+
+            /* "asyncpg/protocol/coreproto.pyx":83
+ *                     self._process__simple_query(mtype)
+ * 
+ *                 elif state == PROTOCOL_ERROR_CONSUME:             # <<<<<<<<<<<<<<
+ *                     # Error in protocol (on asyncpg side);
+ *                     # discard all messages until sync message
+ */
+            case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_ERROR_CONSUME:
+
+            /* "asyncpg/protocol/coreproto.pyx":87
+ *                     # discard all messages until sync message
+ * 
+ *                     if mtype == b'Z':             # <<<<<<<<<<<<<<
+ *                         # Sync point, self to push the result
+ *                         if self.result_type != RESULT_FAILED:
+ */
+            __pyx_t_2 = ((__pyx_v_mtype == 'Z') != 0);
+            if (__pyx_t_2) {
+
+              /* "asyncpg/protocol/coreproto.pyx":89
+ *                     if mtype == b'Z':
+ *                         # Sync point, self to push the result
+ *                         if self.result_type != RESULT_FAILED:             # <<<<<<<<<<<<<<
+ *                             self.result_type = RESULT_FAILED
+ *                             self.result = RuntimeError(
+ */
+              __pyx_t_2 = ((__pyx_v_self->result_type != __pyx_e_7asyncpg_8protocol_8protocol_RESULT_FAILED) != 0);
+              if (__pyx_t_2) {
+
+                /* "asyncpg/protocol/coreproto.pyx":90
+ *                         # Sync point, self to push the result
+ *                         if self.result_type != RESULT_FAILED:
+ *                             self.result_type = RESULT_FAILED             # <<<<<<<<<<<<<<
+ *                             self.result = RuntimeError(
+ *                                 'unknown error in protocol implementation')
+ */
+                __pyx_v_self->result_type = __pyx_e_7asyncpg_8protocol_8protocol_RESULT_FAILED;
+
+                /* "asyncpg/protocol/coreproto.pyx":91
+ *                         if self.result_type != RESULT_FAILED:
+ *                             self.result_type = RESULT_FAILED
+ *                             self.result = RuntimeError(             # <<<<<<<<<<<<<<
+ *                                 'unknown error in protocol implementation')
+ * 
+ */
+                __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__56, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 91, __pyx_L10_error)
+                __Pyx_GOTREF(__pyx_t_7);
+                __Pyx_GIVEREF(__pyx_t_7);
+                __Pyx_GOTREF(__pyx_v_self->result);
+                __Pyx_DECREF(__pyx_v_self->result);
+                __pyx_v_self->result = __pyx_t_7;
+                __pyx_t_7 = 0;
+
+                /* "asyncpg/protocol/coreproto.pyx":89
+ *                     if mtype == b'Z':
+ *                         # Sync point, self to push the result
+ *                         if self.result_type != RESULT_FAILED:             # <<<<<<<<<<<<<<
+ *                             self.result_type = RESULT_FAILED
+ *                             self.result = RuntimeError(
+ */
+              }
+
+              /* "asyncpg/protocol/coreproto.pyx":94
+ *                                 'unknown error in protocol implementation')
+ * 
+ *                         self._push_result()             # <<<<<<<<<<<<<<
+ * 
+ *                     else:
+ */
+              __pyx_t_7 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_push_result(__pyx_v_self); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 94, __pyx_L10_error)
+              __Pyx_GOTREF(__pyx_t_7);
+              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+              /* "asyncpg/protocol/coreproto.pyx":87
+ *                     # discard all messages until sync message
+ * 
+ *                     if mtype == b'Z':             # <<<<<<<<<<<<<<
+ *                         # Sync point, self to push the result
+ *                         if self.result_type != RESULT_FAILED:
+ */
+              goto __pyx_L18;
+            }
+
+            /* "asyncpg/protocol/coreproto.pyx":97
+ * 
+ *                     else:
+ *                         self.buffer.consume_message()             # <<<<<<<<<<<<<<
+ * 
+ *                 else:
+ */
+            /*else*/ {
+              __pyx_t_7 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(__pyx_v_self->buffer)); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 97, __pyx_L10_error)
+              __Pyx_GOTREF(__pyx_t_7);
+              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+            }
+            __pyx_L18:;
+
+            /* "asyncpg/protocol/coreproto.pyx":83
+ *                     self._process__simple_query(mtype)
+ * 
+ *                 elif state == PROTOCOL_ERROR_CONSUME:             # <<<<<<<<<<<<<<
+ *                     # Error in protocol (on asyncpg side);
+ *                     # discard all messages until sync message
+ */
+            break;
+            default:
+
+            /* "asyncpg/protocol/coreproto.pyx":101
+ *                 else:
+ *                     raise RuntimeError(
+ *                         'protocol is in an unknown state {}'.format(state))             # <<<<<<<<<<<<<<
+ * 
+ *             except Exception as ex:
+ */
+            __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_protocol_is_in_an_unknown_state, __pyx_n_s_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 101, __pyx_L10_error)
+            __Pyx_GOTREF(__pyx_t_8);
+            __pyx_t_9 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ProtocolState(__pyx_v_state); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 101, __pyx_L10_error)
+            __Pyx_GOTREF(__pyx_t_9);
+            __pyx_t_10 = NULL;
+            if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
+              __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_8);
+              if (likely(__pyx_t_10)) {
+                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
+                __Pyx_INCREF(__pyx_t_10);
+                __Pyx_INCREF(function);
+                __Pyx_DECREF_SET(__pyx_t_8, function);
+              }
+            }
+            if (!__pyx_t_10) {
+              __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 101, __pyx_L10_error)
+              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+              __Pyx_GOTREF(__pyx_t_7);
+            } else {
+              #if CYTHON_FAST_PYCALL
+              if (PyFunction_Check(__pyx_t_8)) {
+                PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_9};
+                __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 101, __pyx_L10_error)
+                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
+                __Pyx_GOTREF(__pyx_t_7);
+                __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+              } else
+              #endif
+              #if CYTHON_FAST_PYCCALL
+              if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
+                PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_9};
+                __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 101, __pyx_L10_error)
+                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
+                __Pyx_GOTREF(__pyx_t_7);
+                __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+              } else
+              #endif
+              {
+                __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(4, 101, __pyx_L10_error)
+                __Pyx_GOTREF(__pyx_t_11);
+                __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
+                __Pyx_GIVEREF(__pyx_t_9);
+                PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_9);
+                __pyx_t_9 = 0;
+                __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 101, __pyx_L10_error)
+                __Pyx_GOTREF(__pyx_t_7);
+                __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+              }
+            }
+            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+
+            /* "asyncpg/protocol/coreproto.pyx":100
+ * 
+ *                 else:
+ *                     raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                         'protocol is in an unknown state {}'.format(state))
+ * 
+ */
+            __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 100, __pyx_L10_error)
+            __Pyx_GOTREF(__pyx_t_8);
+            __Pyx_GIVEREF(__pyx_t_7);
+            PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7);
+            __pyx_t_7 = 0;
+            __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 100, __pyx_L10_error)
+            __Pyx_GOTREF(__pyx_t_7);
+            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+            __Pyx_Raise(__pyx_t_7, 0, 0, 0);
+            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+            __PYX_ERR(4, 100, __pyx_L10_error)
+            break;
+          }
+
+          /* "asyncpg/protocol/coreproto.pyx":49
+ *             state = self.state
+ * 
+ *             try:             # <<<<<<<<<<<<<<
+ *                 if mtype == b'S':
+ *                     # ParameterStatus
+ */
+        }
+        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+        goto __pyx_L17_try_end;
+        __pyx_L10_error:;
+        __Pyx_PyThreadState_assign
+        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
+        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
+        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+        /* "asyncpg/protocol/coreproto.pyx":103
+ *                         'protocol is in an unknown state {}'.format(state))
+ * 
+ *             except Exception as ex:             # <<<<<<<<<<<<<<
+ *                 self.result_type = RESULT_FAILED
+ *                 self.result = ex
+ */
+        __pyx_t_12 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
+        if (__pyx_t_12) {
+          __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._read_server_messages", __pyx_clineno, __pyx_lineno, __pyx_filename);
+          if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_11) < 0) __PYX_ERR(4, 103, __pyx_L12_except_error)
+          __Pyx_GOTREF(__pyx_t_7);
+          __Pyx_GOTREF(__pyx_t_8);
+          __Pyx_GOTREF(__pyx_t_11);
+          __Pyx_INCREF(__pyx_t_8);
+          __pyx_v_ex = __pyx_t_8;
+          /*try:*/ {
+
+            /* "asyncpg/protocol/coreproto.pyx":104
+ * 
+ *             except Exception as ex:
+ *                 self.result_type = RESULT_FAILED             # <<<<<<<<<<<<<<
+ *                 self.result = ex
+ * 
+ */
+            __pyx_v_self->result_type = __pyx_e_7asyncpg_8protocol_8protocol_RESULT_FAILED;
+
+            /* "asyncpg/protocol/coreproto.pyx":105
+ *             except Exception as ex:
+ *                 self.result_type = RESULT_FAILED
+ *                 self.result = ex             # <<<<<<<<<<<<<<
+ * 
+ *                 if mtype == b'Z':
+ */
+            __Pyx_INCREF(__pyx_v_ex);
+            __Pyx_GIVEREF(__pyx_v_ex);
+            __Pyx_GOTREF(__pyx_v_self->result);
+            __Pyx_DECREF(__pyx_v_self->result);
+            __pyx_v_self->result = __pyx_v_ex;
+
+            /* "asyncpg/protocol/coreproto.pyx":107
+ *                 self.result = ex
+ * 
+ *                 if mtype == b'Z':             # <<<<<<<<<<<<<<
+ *                     self._push_result()
+ *                 else:
+ */
+            __pyx_t_2 = ((__pyx_v_mtype == 'Z') != 0);
+            if (__pyx_t_2) {
+
+              /* "asyncpg/protocol/coreproto.pyx":108
+ * 
+ *                 if mtype == b'Z':
+ *                     self._push_result()             # <<<<<<<<<<<<<<
+ *                 else:
+ *                     self.state = PROTOCOL_ERROR_CONSUME
+ */
+              __pyx_t_9 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_push_result(__pyx_v_self); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 108, __pyx_L25_error)
+              __Pyx_GOTREF(__pyx_t_9);
+              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+
+              /* "asyncpg/protocol/coreproto.pyx":107
+ *                 self.result = ex
+ * 
+ *                 if mtype == b'Z':             # <<<<<<<<<<<<<<
+ *                     self._push_result()
+ *                 else:
+ */
+              goto __pyx_L27;
+            }
+
+            /* "asyncpg/protocol/coreproto.pyx":110
+ *                     self._push_result()
+ *                 else:
+ *                     self.state = PROTOCOL_ERROR_CONSUME             # <<<<<<<<<<<<<<
+ * 
+ *             finally:
+ */
+            /*else*/ {
+              __pyx_v_self->state = __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_ERROR_CONSUME;
+            }
+            __pyx_L27:;
+          }
+
+          /* "asyncpg/protocol/coreproto.pyx":103
+ *                         'protocol is in an unknown state {}'.format(state))
+ * 
+ *             except Exception as ex:             # <<<<<<<<<<<<<<
+ *                 self.result_type = RESULT_FAILED
+ *                 self.result = ex
+ */
+          /*finally:*/ {
+            /*normal exit:*/{
+              __Pyx_DECREF(__pyx_v_ex);
+              __pyx_v_ex = NULL;
+              goto __pyx_L26;
+            }
+            /*exception exit:*/{
+              __Pyx_PyThreadState_declare
+              __pyx_L25_error:;
+              __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
+              __Pyx_PyThreadState_assign
+              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
+              __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
+              if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20);
+              if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
+              __Pyx_XGOTREF(__pyx_t_15);
+              __Pyx_XGOTREF(__pyx_t_16);
+              __Pyx_XGOTREF(__pyx_t_17);
+              __Pyx_XGOTREF(__pyx_t_18);
+              __Pyx_XGOTREF(__pyx_t_19);
+              __Pyx_XGOTREF(__pyx_t_20);
+              __pyx_t_12 = __pyx_lineno; __pyx_t_13 = __pyx_clineno; __pyx_t_14 = __pyx_filename;
+              {
+                __Pyx_DECREF(__pyx_v_ex);
+                __pyx_v_ex = NULL;
+              }
+              __Pyx_PyThreadState_assign
+              if (PY_MAJOR_VERSION >= 3) {
+                __Pyx_XGIVEREF(__pyx_t_18);
+                __Pyx_XGIVEREF(__pyx_t_19);
+                __Pyx_XGIVEREF(__pyx_t_20);
+                __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20);
+              }
+              __Pyx_XGIVEREF(__pyx_t_15);
+              __Pyx_XGIVEREF(__pyx_t_16);
+              __Pyx_XGIVEREF(__pyx_t_17);
+              __Pyx_ErrRestore(__pyx_t_15, __pyx_t_16, __pyx_t_17);
+              __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
+              __pyx_lineno = __pyx_t_12; __pyx_clineno = __pyx_t_13; __pyx_filename = __pyx_t_14;
+              goto __pyx_L12_except_error;
+            }
+            __pyx_L26:;
+          }
+          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+          goto __pyx_L11_exception_handled;
+        }
+        goto __pyx_L12_except_error;
+        __pyx_L12_except_error:;
+
+        /* "asyncpg/protocol/coreproto.pyx":49
+ *             state = self.state
+ * 
+ *             try:             # <<<<<<<<<<<<<<
+ *                 if mtype == b'S':
+ *                     # ParameterStatus
+ */
+        __Pyx_PyThreadState_assign
+        __Pyx_XGIVEREF(__pyx_t_4);
+        __Pyx_XGIVEREF(__pyx_t_5);
+        __Pyx_XGIVEREF(__pyx_t_6);
+        __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
+        goto __pyx_L8_error;
+        __pyx_L16_try_continue:;
+        __Pyx_PyThreadState_assign
+        __Pyx_XGIVEREF(__pyx_t_4);
+        __Pyx_XGIVEREF(__pyx_t_5);
+        __Pyx_XGIVEREF(__pyx_t_6);
+        __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
+        goto __pyx_L5_continue;
+        __pyx_L11_exception_handled:;
+        __Pyx_PyThreadState_assign
+        __Pyx_XGIVEREF(__pyx_t_4);
+        __Pyx_XGIVEREF(__pyx_t_5);
+        __Pyx_XGIVEREF(__pyx_t_6);
+        __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
+        __pyx_L17_try_end:;
+      }
+    }
+
+    /* "asyncpg/protocol/coreproto.pyx":113
+ * 
+ *             finally:
+ *                 if self._skip_discard:             # <<<<<<<<<<<<<<
+ *                     self._skip_discard = False
+ *                 else:
+ */
+    /*finally:*/ {
+      /*normal exit:*/{
+        __pyx_t_2 = (__pyx_v_self->_skip_discard != 0);
+        if (__pyx_t_2) {
+
+          /* "asyncpg/protocol/coreproto.pyx":114
+ *             finally:
+ *                 if self._skip_discard:
+ *                     self._skip_discard = False             # <<<<<<<<<<<<<<
+ *                 else:
+ *                     self.buffer.discard_message()
+ */
+          __pyx_v_self->_skip_discard = 0;
+
+          /* "asyncpg/protocol/coreproto.pyx":113
+ * 
+ *             finally:
+ *                 if self._skip_discard:             # <<<<<<<<<<<<<<
+ *                     self._skip_discard = False
+ *                 else:
+ */
+          goto __pyx_L32;
+        }
+
+        /* "asyncpg/protocol/coreproto.pyx":116
+ *                     self._skip_discard = False
+ *                 else:
+ *                     self.buffer.discard_message()             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _process__auth(self, char mtype):
+ */
+        /*else*/ {
+          __pyx_t_11 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_discard_message(__pyx_v_self->buffer); if (unlikely(!__pyx_t_11)) __PYX_ERR(4, 116, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_11);
+          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+        }
+        __pyx_L32:;
+        goto __pyx_L9;
+      }
+      /*exception exit:*/{
+        __Pyx_PyThreadState_declare
+        __pyx_L8_error:;
+        __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_4 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0;
+        __Pyx_PyThreadState_assign
+        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
+        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
+        if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_19, &__pyx_t_18);
+        if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4) < 0)) __Pyx_ErrFetch(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4);
+        __Pyx_XGOTREF(__pyx_t_6);
+        __Pyx_XGOTREF(__pyx_t_5);
+        __Pyx_XGOTREF(__pyx_t_4);
+        __Pyx_XGOTREF(__pyx_t_20);
+        __Pyx_XGOTREF(__pyx_t_19);
+        __Pyx_XGOTREF(__pyx_t_18);
+        __pyx_t_13 = __pyx_lineno; __pyx_t_12 = __pyx_clineno; __pyx_t_21 = __pyx_filename;
+        {
+
+          /* "asyncpg/protocol/coreproto.pyx":113
+ * 
+ *             finally:
+ *                 if self._skip_discard:             # <<<<<<<<<<<<<<
+ *                     self._skip_discard = False
+ *                 else:
+ */
+          __pyx_t_2 = (__pyx_v_self->_skip_discard != 0);
+          if (__pyx_t_2) {
+
+            /* "asyncpg/protocol/coreproto.pyx":114
+ *             finally:
+ *                 if self._skip_discard:
+ *                     self._skip_discard = False             # <<<<<<<<<<<<<<
+ *                 else:
+ *                     self.buffer.discard_message()
+ */
+            __pyx_v_self->_skip_discard = 0;
+
+            /* "asyncpg/protocol/coreproto.pyx":113
+ * 
+ *             finally:
+ *                 if self._skip_discard:             # <<<<<<<<<<<<<<
+ *                     self._skip_discard = False
+ *                 else:
+ */
+            goto __pyx_L37;
+          }
+
+          /* "asyncpg/protocol/coreproto.pyx":116
+ *                     self._skip_discard = False
+ *                 else:
+ *                     self.buffer.discard_message()             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _process__auth(self, char mtype):
+ */
+          /*else*/ {
+            __pyx_t_11 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_discard_message(__pyx_v_self->buffer); if (unlikely(!__pyx_t_11)) __PYX_ERR(4, 116, __pyx_L36_error)
+            __Pyx_GOTREF(__pyx_t_11);
+            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+          }
+          __pyx_L37:;
+        }
+        __Pyx_PyThreadState_assign
+        if (PY_MAJOR_VERSION >= 3) {
+          __Pyx_XGIVEREF(__pyx_t_20);
+          __Pyx_XGIVEREF(__pyx_t_19);
+          __Pyx_XGIVEREF(__pyx_t_18);
+          __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_19, __pyx_t_18);
+        }
+        __Pyx_XGIVEREF(__pyx_t_6);
+        __Pyx_XGIVEREF(__pyx_t_5);
+        __Pyx_XGIVEREF(__pyx_t_4);
+        __Pyx_ErrRestore(__pyx_t_6, __pyx_t_5, __pyx_t_4);
+        __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_4 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0;
+        __pyx_lineno = __pyx_t_13; __pyx_clineno = __pyx_t_12; __pyx_filename = __pyx_t_21;
+        goto __pyx_L1_error;
+        __pyx_L36_error:;
+        __Pyx_PyThreadState_assign
+        if (PY_MAJOR_VERSION >= 3) {
+          __Pyx_XGIVEREF(__pyx_t_20);
+          __Pyx_XGIVEREF(__pyx_t_19);
+          __Pyx_XGIVEREF(__pyx_t_18);
+          __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_19, __pyx_t_18);
+        }
+        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0;
+        goto __pyx_L1_error;
+      }
+      __pyx_L5_continue: {
+
+        /* "asyncpg/protocol/coreproto.pyx":113
+ * 
+ *             finally:
+ *                 if self._skip_discard:             # <<<<<<<<<<<<<<
+ *                     self._skip_discard = False
+ *                 else:
+ */
+        __pyx_t_2 = (__pyx_v_self->_skip_discard != 0);
+        if (__pyx_t_2) {
+
+          /* "asyncpg/protocol/coreproto.pyx":114
+ *             finally:
+ *                 if self._skip_discard:
+ *                     self._skip_discard = False             # <<<<<<<<<<<<<<
+ *                 else:
+ *                     self.buffer.discard_message()
+ */
+          __pyx_v_self->_skip_discard = 0;
+
+          /* "asyncpg/protocol/coreproto.pyx":113
+ * 
+ *             finally:
+ *                 if self._skip_discard:             # <<<<<<<<<<<<<<
+ *                     self._skip_discard = False
+ *                 else:
+ */
+          goto __pyx_L38;
+        }
+
+        /* "asyncpg/protocol/coreproto.pyx":116
+ *                     self._skip_discard = False
+ *                 else:
+ *                     self.buffer.discard_message()             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _process__auth(self, char mtype):
+ */
+        /*else*/ {
+          __pyx_t_11 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_discard_message(__pyx_v_self->buffer); if (unlikely(!__pyx_t_11)) __PYX_ERR(4, 116, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_11);
+          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+        }
+        __pyx_L38:;
+        goto __pyx_L3_continue;
+      }
+      __pyx_L9:;
+    }
+    __pyx_L3_continue:;
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":40
+ *         self.transport.write(SYNC_MESSAGE)
+ * 
+ *     cdef _read_server_messages(self):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             char mtype
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_XDECREF(__pyx_t_11);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._read_server_messages", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_ex);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":118
+ *                     self.buffer.discard_message()
+ * 
+ *     cdef _process__auth(self, char mtype):             # <<<<<<<<<<<<<<
+ *         if mtype == b'R':
+ *             # Authentication...
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__auth(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, char __pyx_v_mtype) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  int __pyx_t_5;
+  __Pyx_RefNannySetupContext("_process__auth", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":119
+ * 
+ *     cdef _process__auth(self, char mtype):
+ *         if mtype == b'R':             # <<<<<<<<<<<<<<
+ *             # Authentication...
+ *             self._parse_msg_authentication()
+ */
+  switch (__pyx_v_mtype) {
+    case 'R':
+
+    /* "asyncpg/protocol/coreproto.pyx":121
+ *         if mtype == b'R':
+ *             # Authentication...
+ *             self._parse_msg_authentication()             # <<<<<<<<<<<<<<
+ *             if self.result_type != RESULT_OK:
+ *                 self.con_status = CONNECTION_BAD
+ */
+    __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_parse_msg_authentication(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 121, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":122
+ *             # Authentication...
+ *             self._parse_msg_authentication()
+ *             if self.result_type != RESULT_OK:             # <<<<<<<<<<<<<<
+ *                 self.con_status = CONNECTION_BAD
+ *                 self._push_result()
+ */
+    __pyx_t_2 = ((__pyx_v_self->result_type != __pyx_e_7asyncpg_8protocol_8protocol_RESULT_OK) != 0);
+    if (__pyx_t_2) {
+
+      /* "asyncpg/protocol/coreproto.pyx":123
+ *             self._parse_msg_authentication()
+ *             if self.result_type != RESULT_OK:
+ *                 self.con_status = CONNECTION_BAD             # <<<<<<<<<<<<<<
+ *                 self._push_result()
+ *                 self.transport.close()
+ */
+      __pyx_v_self->con_status = __pyx_e_7asyncpg_8protocol_8protocol_CONNECTION_BAD;
+
+      /* "asyncpg/protocol/coreproto.pyx":124
+ *             if self.result_type != RESULT_OK:
+ *                 self.con_status = CONNECTION_BAD
+ *                 self._push_result()             # <<<<<<<<<<<<<<
+ *                 self.transport.close()
+ * 
+ */
+      __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_push_result(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 124, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+      /* "asyncpg/protocol/coreproto.pyx":125
+ *                 self.con_status = CONNECTION_BAD
+ *                 self._push_result()
+ *                 self.transport.close()             # <<<<<<<<<<<<<<
+ * 
+ *             elif self.auth_msg is not None:
+ */
+      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->transport, __pyx_n_s_close); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 125, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_4 = NULL;
+      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
+        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
+        if (likely(__pyx_t_4)) {
+          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+          __Pyx_INCREF(__pyx_t_4);
+          __Pyx_INCREF(function);
+          __Pyx_DECREF_SET(__pyx_t_3, function);
+        }
+      }
+      if (__pyx_t_4) {
+        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 125, __pyx_L1_error)
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      } else {
+        __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 125, __pyx_L1_error)
+      }
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+      /* "asyncpg/protocol/coreproto.pyx":122
+ *             # Authentication...
+ *             self._parse_msg_authentication()
+ *             if self.result_type != RESULT_OK:             # <<<<<<<<<<<<<<
+ *                 self.con_status = CONNECTION_BAD
+ *                 self._push_result()
+ */
+      goto __pyx_L3;
+    }
+
+    /* "asyncpg/protocol/coreproto.pyx":127
+ *                 self.transport.close()
+ * 
+ *             elif self.auth_msg is not None:             # <<<<<<<<<<<<<<
+ *                 # Server wants us to send auth data, so do that.
+ *                 self._write(self.auth_msg)
+ */
+    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_auth_msg); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 127, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_2 = (__pyx_t_1 != Py_None);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_5 = (__pyx_t_2 != 0);
+    if (__pyx_t_5) {
+
+      /* "asyncpg/protocol/coreproto.pyx":129
+ *             elif self.auth_msg is not None:
+ *                 # Server wants us to send auth data, so do that.
+ *                 self._write(self.auth_msg)             # <<<<<<<<<<<<<<
+ *                 self.auth_msg = None
+ * 
+ */
+      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_auth_msg); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 129, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_write(__pyx_v_self, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 129, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+      /* "asyncpg/protocol/coreproto.pyx":130
+ *                 # Server wants us to send auth data, so do that.
+ *                 self._write(self.auth_msg)
+ *                 self.auth_msg = None             # <<<<<<<<<<<<<<
+ * 
+ *         elif mtype == b'K':
+ */
+      if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_auth_msg, Py_None) < 0) __PYX_ERR(4, 130, __pyx_L1_error)
+
+      /* "asyncpg/protocol/coreproto.pyx":127
+ *                 self.transport.close()
+ * 
+ *             elif self.auth_msg is not None:             # <<<<<<<<<<<<<<
+ *                 # Server wants us to send auth data, so do that.
+ *                 self._write(self.auth_msg)
+ */
+    }
+    __pyx_L3:;
+
+    /* "asyncpg/protocol/coreproto.pyx":119
+ * 
+ *     cdef _process__auth(self, char mtype):
+ *         if mtype == b'R':             # <<<<<<<<<<<<<<
+ *             # Authentication...
+ *             self._parse_msg_authentication()
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":132
+ *                 self.auth_msg = None
+ * 
+ *         elif mtype == b'K':             # <<<<<<<<<<<<<<
+ *             # BackendKeyData
+ *             self._parse_msg_backend_key_data()
+ */
+    case 'K':
+
+    /* "asyncpg/protocol/coreproto.pyx":134
+ *         elif mtype == b'K':
+ *             # BackendKeyData
+ *             self._parse_msg_backend_key_data()             # <<<<<<<<<<<<<<
+ * 
+ *         elif mtype == b'E':
+ */
+    __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_parse_msg_backend_key_data(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 134, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":132
+ *                 self.auth_msg = None
+ * 
+ *         elif mtype == b'K':             # <<<<<<<<<<<<<<
+ *             # BackendKeyData
+ *             self._parse_msg_backend_key_data()
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":136
+ *             self._parse_msg_backend_key_data()
+ * 
+ *         elif mtype == b'E':             # <<<<<<<<<<<<<<
+ *             # ErrorResponse
+ *             self.con_status = CONNECTION_BAD
+ */
+    case 'E':
+
+    /* "asyncpg/protocol/coreproto.pyx":138
+ *         elif mtype == b'E':
+ *             # ErrorResponse
+ *             self.con_status = CONNECTION_BAD             # <<<<<<<<<<<<<<
+ *             self._parse_msg_error_response(True)
+ *             self._push_result()
+ */
+    __pyx_v_self->con_status = __pyx_e_7asyncpg_8protocol_8protocol_CONNECTION_BAD;
+
+    /* "asyncpg/protocol/coreproto.pyx":139
+ *             # ErrorResponse
+ *             self.con_status = CONNECTION_BAD
+ *             self._parse_msg_error_response(True)             # <<<<<<<<<<<<<<
+ *             self._push_result()
+ * 
+ */
+    __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_parse_msg_error_response(__pyx_v_self, Py_True); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 139, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":140
+ *             self.con_status = CONNECTION_BAD
+ *             self._parse_msg_error_response(True)
+ *             self._push_result()             # <<<<<<<<<<<<<<
+ * 
+ *         elif mtype == b'Z':
+ */
+    __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_push_result(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 140, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":136
+ *             self._parse_msg_backend_key_data()
+ * 
+ *         elif mtype == b'E':             # <<<<<<<<<<<<<<
+ *             # ErrorResponse
+ *             self.con_status = CONNECTION_BAD
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":142
+ *             self._push_result()
+ * 
+ *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()
+ */
+    case 'Z':
+
+    /* "asyncpg/protocol/coreproto.pyx":144
+ *         elif mtype == b'Z':
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()             # <<<<<<<<<<<<<<
+ *             self.con_status = CONNECTION_OK
+ *             self._push_result()
+ */
+    __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_parse_msg_ready_for_query(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 144, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":145
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()
+ *             self.con_status = CONNECTION_OK             # <<<<<<<<<<<<<<
+ *             self._push_result()
+ * 
+ */
+    __pyx_v_self->con_status = __pyx_e_7asyncpg_8protocol_8protocol_CONNECTION_OK;
+
+    /* "asyncpg/protocol/coreproto.pyx":146
+ *             self._parse_msg_ready_for_query()
+ *             self.con_status = CONNECTION_OK
+ *             self._push_result()             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _process__prepare(self, char mtype):
+ */
+    __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_push_result(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 146, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":142
+ *             self._push_result()
+ * 
+ *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()
+ */
+    break;
+    default: break;
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":118
+ *                     self.buffer.discard_message()
+ * 
+ *     cdef _process__auth(self, char mtype):             # <<<<<<<<<<<<<<
+ *         if mtype == b'R':
+ *             # Authentication...
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._process__auth", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":148
+ *             self._push_result()
+ * 
+ *     cdef _process__prepare(self, char mtype):             # <<<<<<<<<<<<<<
+ *         if mtype == b't':
+ *             # Parameters description
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__prepare(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, char __pyx_v_mtype) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("_process__prepare", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":149
+ * 
+ *     cdef _process__prepare(self, char mtype):
+ *         if mtype == b't':             # <<<<<<<<<<<<<<
+ *             # Parameters description
+ *             self.result_param_desc = self.buffer.consume_message().as_bytes()
+ */
+  switch (__pyx_v_mtype) {
+    case 't':
+
+    /* "asyncpg/protocol/coreproto.pyx":151
+ *         if mtype == b't':
+ *             # Parameters description
+ *             self.result_param_desc = self.buffer.consume_message().as_bytes()             # <<<<<<<<<<<<<<
+ * 
+ *         elif mtype == b'1':
+ */
+    __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(__pyx_v_self->buffer)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 151, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_6Memory_as_bytes(((struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 151, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(4, 151, __pyx_L1_error)
+    __Pyx_GIVEREF(__pyx_t_2);
+    __Pyx_GOTREF(__pyx_v_self->result_param_desc);
+    __Pyx_DECREF(__pyx_v_self->result_param_desc);
+    __pyx_v_self->result_param_desc = ((PyObject*)__pyx_t_2);
+    __pyx_t_2 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":149
+ * 
+ *     cdef _process__prepare(self, char mtype):
+ *         if mtype == b't':             # <<<<<<<<<<<<<<
+ *             # Parameters description
+ *             self.result_param_desc = self.buffer.consume_message().as_bytes()
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":153
+ *             self.result_param_desc = self.buffer.consume_message().as_bytes()
+ * 
+ *         elif mtype == b'1':             # <<<<<<<<<<<<<<
+ *             # ParseComplete
+ *             self.buffer.consume_message()
+ */
+    case '1':
+
+    /* "asyncpg/protocol/coreproto.pyx":155
+ *         elif mtype == b'1':
+ *             # ParseComplete
+ *             self.buffer.consume_message()             # <<<<<<<<<<<<<<
+ * 
+ *         elif mtype == b'T':
+ */
+    __pyx_t_2 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(__pyx_v_self->buffer)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 155, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":153
+ *             self.result_param_desc = self.buffer.consume_message().as_bytes()
+ * 
+ *         elif mtype == b'1':             # <<<<<<<<<<<<<<
+ *             # ParseComplete
+ *             self.buffer.consume_message()
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":157
+ *             self.buffer.consume_message()
+ * 
+ *         elif mtype == b'T':             # <<<<<<<<<<<<<<
+ *             # Row description
+ *             self.result_row_desc = self.buffer.consume_message().as_bytes()
+ */
+    case 'T':
+
+    /* "asyncpg/protocol/coreproto.pyx":159
+ *         elif mtype == b'T':
+ *             # Row description
+ *             self.result_row_desc = self.buffer.consume_message().as_bytes()             # <<<<<<<<<<<<<<
+ * 
+ *         elif mtype == b'E':
+ */
+    __pyx_t_2 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(__pyx_v_self->buffer)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 159, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_6Memory_as_bytes(((struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 159, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(4, 159, __pyx_L1_error)
+    __Pyx_GIVEREF(__pyx_t_1);
+    __Pyx_GOTREF(__pyx_v_self->result_row_desc);
+    __Pyx_DECREF(__pyx_v_self->result_row_desc);
+    __pyx_v_self->result_row_desc = ((PyObject*)__pyx_t_1);
+    __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":157
+ *             self.buffer.consume_message()
+ * 
+ *         elif mtype == b'T':             # <<<<<<<<<<<<<<
+ *             # Row description
+ *             self.result_row_desc = self.buffer.consume_message().as_bytes()
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":161
+ *             self.result_row_desc = self.buffer.consume_message().as_bytes()
+ * 
+ *         elif mtype == b'E':             # <<<<<<<<<<<<<<
+ *             # ErrorResponse
+ *             self._parse_msg_error_response(True)
+ */
+    case 'E':
+
+    /* "asyncpg/protocol/coreproto.pyx":163
+ *         elif mtype == b'E':
+ *             # ErrorResponse
+ *             self._parse_msg_error_response(True)             # <<<<<<<<<<<<<<
+ * 
+ *         elif mtype == b'Z':
+ */
+    __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_parse_msg_error_response(__pyx_v_self, Py_True); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 163, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":161
+ *             self.result_row_desc = self.buffer.consume_message().as_bytes()
+ * 
+ *         elif mtype == b'E':             # <<<<<<<<<<<<<<
+ *             # ErrorResponse
+ *             self._parse_msg_error_response(True)
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":165
+ *             self._parse_msg_error_response(True)
+ * 
+ *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()
+ */
+    case 'Z':
+
+    /* "asyncpg/protocol/coreproto.pyx":167
+ *         elif mtype == b'Z':
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()             # <<<<<<<<<<<<<<
+ *             self._push_result()
+ * 
+ */
+    __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_parse_msg_ready_for_query(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 167, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":168
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()
+ *             self._push_result()             # <<<<<<<<<<<<<<
+ * 
+ *         elif mtype == b'n':
+ */
+    __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_push_result(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 168, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":165
+ *             self._parse_msg_error_response(True)
+ * 
+ *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":170
+ *             self._push_result()
+ * 
+ *         elif mtype == b'n':             # <<<<<<<<<<<<<<
+ *             # NoData
+ *             self.buffer.consume_message()
+ */
+    case 'n':
+
+    /* "asyncpg/protocol/coreproto.pyx":172
+ *         elif mtype == b'n':
+ *             # NoData
+ *             self.buffer.consume_message()             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _process__bind_execute(self, char mtype):
+ */
+    __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(__pyx_v_self->buffer)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 172, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":170
+ *             self._push_result()
+ * 
+ *         elif mtype == b'n':             # <<<<<<<<<<<<<<
+ *             # NoData
+ *             self.buffer.consume_message()
+ */
+    break;
+    default: break;
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":148
+ *             self._push_result()
+ * 
+ *     cdef _process__prepare(self, char mtype):             # <<<<<<<<<<<<<<
+ *         if mtype == b't':
+ *             # Parameters description
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._process__prepare", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":174
+ *             self.buffer.consume_message()
+ * 
+ *     cdef _process__bind_execute(self, char mtype):             # <<<<<<<<<<<<<<
+ *         if mtype == b'D':
+ *             # DataRow
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__bind_execute(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, char __pyx_v_mtype) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("_process__bind_execute", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":175
+ * 
+ *     cdef _process__bind_execute(self, char mtype):
+ *         if mtype == b'D':             # <<<<<<<<<<<<<<
+ *             # DataRow
+ *             self._parse_data_msgs()
+ */
+  switch (__pyx_v_mtype) {
+    case 'D':
+
+    /* "asyncpg/protocol/coreproto.pyx":177
+ *         if mtype == b'D':
+ *             # DataRow
+ *             self._parse_data_msgs()             # <<<<<<<<<<<<<<
+ * 
+ *         elif mtype == b's':
+ */
+    __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_parse_data_msgs(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 177, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":175
+ * 
+ *     cdef _process__bind_execute(self, char mtype):
+ *         if mtype == b'D':             # <<<<<<<<<<<<<<
+ *             # DataRow
+ *             self._parse_data_msgs()
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":179
+ *             self._parse_data_msgs()
+ * 
+ *         elif mtype == b's':             # <<<<<<<<<<<<<<
+ *             # PortalSuspended
+ *             self.buffer.consume_message()
+ */
+    case 's':
+
+    /* "asyncpg/protocol/coreproto.pyx":181
+ *         elif mtype == b's':
+ *             # PortalSuspended
+ *             self.buffer.consume_message()             # <<<<<<<<<<<<<<
+ * 
+ *         elif mtype == b'C':
+ */
+    __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(__pyx_v_self->buffer)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 181, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":179
+ *             self._parse_data_msgs()
+ * 
+ *         elif mtype == b's':             # <<<<<<<<<<<<<<
+ *             # PortalSuspended
+ *             self.buffer.consume_message()
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":183
+ *             self.buffer.consume_message()
+ * 
+ *         elif mtype == b'C':             # <<<<<<<<<<<<<<
+ *             # CommandComplete
+ *             self.result_execute_completed = True
+ */
+    case 'C':
+
+    /* "asyncpg/protocol/coreproto.pyx":185
+ *         elif mtype == b'C':
+ *             # CommandComplete
+ *             self.result_execute_completed = True             # <<<<<<<<<<<<<<
+ *             self._parse_msg_command_complete()
+ * 
+ */
+    __pyx_v_self->result_execute_completed = 1;
+
+    /* "asyncpg/protocol/coreproto.pyx":186
+ *             # CommandComplete
+ *             self.result_execute_completed = True
+ *             self._parse_msg_command_complete()             # <<<<<<<<<<<<<<
+ * 
+ *         elif mtype == b'E':
+ */
+    __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_parse_msg_command_complete(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 186, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":183
+ *             self.buffer.consume_message()
+ * 
+ *         elif mtype == b'C':             # <<<<<<<<<<<<<<
+ *             # CommandComplete
+ *             self.result_execute_completed = True
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":188
+ *             self._parse_msg_command_complete()
+ * 
+ *         elif mtype == b'E':             # <<<<<<<<<<<<<<
+ *             # ErrorResponse
+ *             self._parse_msg_error_response(True)
+ */
+    case 'E':
+
+    /* "asyncpg/protocol/coreproto.pyx":190
+ *         elif mtype == b'E':
+ *             # ErrorResponse
+ *             self._parse_msg_error_response(True)             # <<<<<<<<<<<<<<
+ * 
+ *         elif mtype == b'2':
+ */
+    __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_parse_msg_error_response(__pyx_v_self, Py_True); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 190, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":188
+ *             self._parse_msg_command_complete()
+ * 
+ *         elif mtype == b'E':             # <<<<<<<<<<<<<<
+ *             # ErrorResponse
+ *             self._parse_msg_error_response(True)
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":192
+ *             self._parse_msg_error_response(True)
+ * 
+ *         elif mtype == b'2':             # <<<<<<<<<<<<<<
+ *             # BindComplete
+ *             self.buffer.consume_message()
+ */
+    case '2':
+
+    /* "asyncpg/protocol/coreproto.pyx":194
+ *         elif mtype == b'2':
+ *             # BindComplete
+ *             self.buffer.consume_message()             # <<<<<<<<<<<<<<
+ * 
+ *         elif mtype == b'Z':
+ */
+    __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(__pyx_v_self->buffer)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 194, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":192
+ *             self._parse_msg_error_response(True)
+ * 
+ *         elif mtype == b'2':             # <<<<<<<<<<<<<<
+ *             # BindComplete
+ *             self.buffer.consume_message()
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":196
+ *             self.buffer.consume_message()
+ * 
+ *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()
+ */
+    case 'Z':
+
+    /* "asyncpg/protocol/coreproto.pyx":198
+ *         elif mtype == b'Z':
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()             # <<<<<<<<<<<<<<
+ *             self._push_result()
+ * 
+ */
+    __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_parse_msg_ready_for_query(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 198, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":199
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()
+ *             self._push_result()             # <<<<<<<<<<<<<<
+ * 
+ *         elif mtype == b'I':
+ */
+    __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_push_result(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 199, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":196
+ *             self.buffer.consume_message()
+ * 
+ *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":201
+ *             self._push_result()
+ * 
+ *         elif mtype == b'I':             # <<<<<<<<<<<<<<
+ *             # EmptyQueryResponse
+ *             self.buffer.consume_message()
+ */
+    case 'I':
+
+    /* "asyncpg/protocol/coreproto.pyx":203
+ *         elif mtype == b'I':
+ *             # EmptyQueryResponse
+ *             self.buffer.consume_message()             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _process__bind_execute_many(self, char mtype):
+ */
+    __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(__pyx_v_self->buffer)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 203, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":201
+ *             self._push_result()
+ * 
+ *         elif mtype == b'I':             # <<<<<<<<<<<<<<
+ *             # EmptyQueryResponse
+ *             self.buffer.consume_message()
+ */
+    break;
+    default: break;
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":174
+ *             self.buffer.consume_message()
+ * 
+ *     cdef _process__bind_execute(self, char mtype):             # <<<<<<<<<<<<<<
+ *         if mtype == b'D':
+ *             # DataRow
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._process__bind_execute", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":205
+ *             self.buffer.consume_message()
+ * 
+ *     cdef _process__bind_execute_many(self, char mtype):             # <<<<<<<<<<<<<<
+ *         cdef WriteBuffer buf
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__bind_execute_many(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, char __pyx_v_mtype) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  int __pyx_t_8;
+  PyObject *__pyx_t_9 = NULL;
+  __Pyx_RefNannySetupContext("_process__bind_execute_many", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":208
+ *         cdef WriteBuffer buf
+ * 
+ *         if mtype == b'D':             # <<<<<<<<<<<<<<
+ *             # DataRow
+ *             self._parse_data_msgs()
+ */
+  switch (__pyx_v_mtype) {
+    case 'D':
+
+    /* "asyncpg/protocol/coreproto.pyx":210
+ *         if mtype == b'D':
+ *             # DataRow
+ *             self._parse_data_msgs()             # <<<<<<<<<<<<<<
+ * 
+ *         elif mtype == b's':
+ */
+    __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_parse_data_msgs(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 210, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":208
+ *         cdef WriteBuffer buf
+ * 
+ *         if mtype == b'D':             # <<<<<<<<<<<<<<
+ *             # DataRow
+ *             self._parse_data_msgs()
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":212
+ *             self._parse_data_msgs()
+ * 
+ *         elif mtype == b's':             # <<<<<<<<<<<<<<
+ *             # PortalSuspended
+ *             self.buffer.consume_message()
+ */
+    case 's':
+
+    /* "asyncpg/protocol/coreproto.pyx":214
+ *         elif mtype == b's':
+ *             # PortalSuspended
+ *             self.buffer.consume_message()             # <<<<<<<<<<<<<<
+ * 
+ *         elif mtype == b'C':
+ */
+    __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(__pyx_v_self->buffer)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 214, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":212
+ *             self._parse_data_msgs()
+ * 
+ *         elif mtype == b's':             # <<<<<<<<<<<<<<
+ *             # PortalSuspended
+ *             self.buffer.consume_message()
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":216
+ *             self.buffer.consume_message()
+ * 
+ *         elif mtype == b'C':             # <<<<<<<<<<<<<<
+ *             # CommandComplete
+ *             self._parse_msg_command_complete()
+ */
+    case 'C':
+
+    /* "asyncpg/protocol/coreproto.pyx":218
+ *         elif mtype == b'C':
+ *             # CommandComplete
+ *             self._parse_msg_command_complete()             # <<<<<<<<<<<<<<
+ * 
+ *         elif mtype == b'E':
+ */
+    __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_parse_msg_command_complete(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 218, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":216
+ *             self.buffer.consume_message()
+ * 
+ *         elif mtype == b'C':             # <<<<<<<<<<<<<<
+ *             # CommandComplete
+ *             self._parse_msg_command_complete()
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":220
+ *             self._parse_msg_command_complete()
+ * 
+ *         elif mtype == b'E':             # <<<<<<<<<<<<<<
+ *             # ErrorResponse
+ *             self._parse_msg_error_response(True)
+ */
+    case 'E':
+
+    /* "asyncpg/protocol/coreproto.pyx":222
+ *         elif mtype == b'E':
+ *             # ErrorResponse
+ *             self._parse_msg_error_response(True)             # <<<<<<<<<<<<<<
+ * 
+ *         elif mtype == b'2':
+ */
+    __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_parse_msg_error_response(__pyx_v_self, Py_True); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 222, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":220
+ *             self._parse_msg_command_complete()
+ * 
+ *         elif mtype == b'E':             # <<<<<<<<<<<<<<
+ *             # ErrorResponse
+ *             self._parse_msg_error_response(True)
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":224
+ *             self._parse_msg_error_response(True)
+ * 
+ *         elif mtype == b'2':             # <<<<<<<<<<<<<<
+ *             # BindComplete
+ *             self.buffer.consume_message()
+ */
+    case '2':
+
+    /* "asyncpg/protocol/coreproto.pyx":226
+ *         elif mtype == b'2':
+ *             # BindComplete
+ *             self.buffer.consume_message()             # <<<<<<<<<<<<<<
+ * 
+ *         elif mtype == b'Z':
+ */
+    __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(__pyx_v_self->buffer)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 226, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":224
+ *             self._parse_msg_error_response(True)
+ * 
+ *         elif mtype == b'2':             # <<<<<<<<<<<<<<
+ *             # BindComplete
+ *             self.buffer.consume_message()
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":228
+ *             self.buffer.consume_message()
+ * 
+ *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()
+ */
+    case 'Z':
+
+    /* "asyncpg/protocol/coreproto.pyx":230
+ *         elif mtype == b'Z':
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()             # <<<<<<<<<<<<<<
+ *             if self.result_type == RESULT_FAILED:
+ *                 self._push_result()
+ */
+    __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_parse_msg_ready_for_query(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 230, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":231
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()
+ *             if self.result_type == RESULT_FAILED:             # <<<<<<<<<<<<<<
+ *                 self._push_result()
+ *             else:
+ */
+    __pyx_t_2 = ((__pyx_v_self->result_type == __pyx_e_7asyncpg_8protocol_8protocol_RESULT_FAILED) != 0);
+    if (__pyx_t_2) {
+
+      /* "asyncpg/protocol/coreproto.pyx":232
+ *             self._parse_msg_ready_for_query()
+ *             if self.result_type == RESULT_FAILED:
+ *                 self._push_result()             # <<<<<<<<<<<<<<
+ *             else:
+ *                 try:
+ */
+      __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_push_result(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 232, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+      /* "asyncpg/protocol/coreproto.pyx":231
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()
+ *             if self.result_type == RESULT_FAILED:             # <<<<<<<<<<<<<<
+ *                 self._push_result()
+ *             else:
+ */
+      goto __pyx_L3;
+    }
+
+    /* "asyncpg/protocol/coreproto.pyx":234
+ *                 self._push_result()
+ *             else:
+ *                 try:             # <<<<<<<<<<<<<<
+ *                     buf = <WriteBuffer>next(self._execute_iter)
+ *                 except StopIteration:
+ */
+    /*else*/ {
+      {
+        __Pyx_PyThreadState_declare
+        __Pyx_PyThreadState_assign
+        __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
+        __Pyx_XGOTREF(__pyx_t_3);
+        __Pyx_XGOTREF(__pyx_t_4);
+        __Pyx_XGOTREF(__pyx_t_5);
+        /*try:*/ {
+
+          /* "asyncpg/protocol/coreproto.pyx":235
+ *             else:
+ *                 try:
+ *                     buf = <WriteBuffer>next(self._execute_iter)             # <<<<<<<<<<<<<<
+ *                 except StopIteration:
+ *                     self._push_result()
+ */
+          __pyx_t_1 = __pyx_v_self->_execute_iter;
+          __Pyx_INCREF(__pyx_t_1);
+          __pyx_t_6 = __Pyx_PyIter_Next(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 235, __pyx_L4_error)
+          __Pyx_GOTREF(__pyx_t_6);
+          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+          __pyx_t_1 = __pyx_t_6;
+          __Pyx_INCREF(__pyx_t_1);
+          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+          __pyx_v_buf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_1);
+          __pyx_t_1 = 0;
+
+          /* "asyncpg/protocol/coreproto.pyx":234
+ *                 self._push_result()
+ *             else:
+ *                 try:             # <<<<<<<<<<<<<<
+ *                     buf = <WriteBuffer>next(self._execute_iter)
+ *                 except StopIteration:
+ */
+        }
+
+        /* "asyncpg/protocol/coreproto.pyx":240
+ *                 else:
+ *                     # Next iteration over the executemany() arg sequence
+ *                     self._send_bind_message(             # <<<<<<<<<<<<<<
+ *                         self._execute_portal_name, self._execute_stmt_name,
+ *                         buf, 0)
+ */
+        /*else:*/ {
+
+          /* "asyncpg/protocol/coreproto.pyx":241
+ *                     # Next iteration over the executemany() arg sequence
+ *                     self._send_bind_message(
+ *                         self._execute_portal_name, self._execute_stmt_name,             # <<<<<<<<<<<<<<
+ *                         buf, 0)
+ * 
+ */
+          __pyx_t_1 = __pyx_v_self->_execute_portal_name;
+          __Pyx_INCREF(__pyx_t_1);
+          __pyx_t_6 = __pyx_v_self->_execute_stmt_name;
+          __Pyx_INCREF(__pyx_t_6);
+
+          /* "asyncpg/protocol/coreproto.pyx":240
+ *                 else:
+ *                     # Next iteration over the executemany() arg sequence
+ *                     self._send_bind_message(             # <<<<<<<<<<<<<<
+ *                         self._execute_portal_name, self._execute_stmt_name,
+ *                         buf, 0)
+ */
+          __pyx_t_7 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_send_bind_message(__pyx_v_self, ((PyObject*)__pyx_t_1), ((PyObject*)__pyx_t_6), __pyx_v_buf, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 240, __pyx_L6_except_error)
+          __Pyx_GOTREF(__pyx_t_7);
+          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        }
+        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        goto __pyx_L11_try_end;
+        __pyx_L4_error:;
+        __Pyx_PyThreadState_assign
+        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+        /* "asyncpg/protocol/coreproto.pyx":236
+ *                 try:
+ *                     buf = <WriteBuffer>next(self._execute_iter)
+ *                 except StopIteration:             # <<<<<<<<<<<<<<
+ *                     self._push_result()
+ *                 else:
+ */
+        __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_StopIteration);
+        if (__pyx_t_8) {
+          __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._process__bind_execute_many", __pyx_clineno, __pyx_lineno, __pyx_filename);
+          if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_6, &__pyx_t_1) < 0) __PYX_ERR(4, 236, __pyx_L6_except_error)
+          __Pyx_GOTREF(__pyx_t_7);
+          __Pyx_GOTREF(__pyx_t_6);
+          __Pyx_GOTREF(__pyx_t_1);
+
+          /* "asyncpg/protocol/coreproto.pyx":237
+ *                     buf = <WriteBuffer>next(self._execute_iter)
+ *                 except StopIteration:
+ *                     self._push_result()             # <<<<<<<<<<<<<<
+ *                 else:
+ *                     # Next iteration over the executemany() arg sequence
+ */
+          __pyx_t_9 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_push_result(__pyx_v_self); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 237, __pyx_L6_except_error)
+          __Pyx_GOTREF(__pyx_t_9);
+          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+          goto __pyx_L5_exception_handled;
+        }
+        goto __pyx_L6_except_error;
+        __pyx_L6_except_error:;
+
+        /* "asyncpg/protocol/coreproto.pyx":234
+ *                 self._push_result()
+ *             else:
+ *                 try:             # <<<<<<<<<<<<<<
+ *                     buf = <WriteBuffer>next(self._execute_iter)
+ *                 except StopIteration:
+ */
+        __Pyx_PyThreadState_assign
+        __Pyx_XGIVEREF(__pyx_t_3);
+        __Pyx_XGIVEREF(__pyx_t_4);
+        __Pyx_XGIVEREF(__pyx_t_5);
+        __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
+        goto __pyx_L1_error;
+        __pyx_L5_exception_handled:;
+        __Pyx_PyThreadState_assign
+        __Pyx_XGIVEREF(__pyx_t_3);
+        __Pyx_XGIVEREF(__pyx_t_4);
+        __Pyx_XGIVEREF(__pyx_t_5);
+        __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
+        __pyx_L11_try_end:;
+      }
+    }
+    __pyx_L3:;
+
+    /* "asyncpg/protocol/coreproto.pyx":228
+ *             self.buffer.consume_message()
+ * 
+ *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":244
+ *                         buf, 0)
+ * 
+ *         elif mtype == b'I':             # <<<<<<<<<<<<<<
+ *             # EmptyQueryResponse
+ *             self.buffer.consume_message()
+ */
+    case 'I':
+
+    /* "asyncpg/protocol/coreproto.pyx":246
+ *         elif mtype == b'I':
+ *             # EmptyQueryResponse
+ *             self.buffer.consume_message()             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _process__bind(self, char mtype):
+ */
+    __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(__pyx_v_self->buffer)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 246, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":244
+ *                         buf, 0)
+ * 
+ *         elif mtype == b'I':             # <<<<<<<<<<<<<<
+ *             # EmptyQueryResponse
+ *             self.buffer.consume_message()
+ */
+    break;
+    default: break;
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":205
+ *             self.buffer.consume_message()
+ * 
+ *     cdef _process__bind_execute_many(self, char mtype):             # <<<<<<<<<<<<<<
+ *         cdef WriteBuffer buf
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._process__bind_execute_many", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_buf);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":248
+ *             self.buffer.consume_message()
+ * 
+ *     cdef _process__bind(self, char mtype):             # <<<<<<<<<<<<<<
+ *         if mtype == b'E':
+ *             # ErrorResponse
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__bind(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, char __pyx_v_mtype) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("_process__bind", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":249
+ * 
+ *     cdef _process__bind(self, char mtype):
+ *         if mtype == b'E':             # <<<<<<<<<<<<<<
+ *             # ErrorResponse
+ *             self._parse_msg_error_response(True)
+ */
+  switch (__pyx_v_mtype) {
+    case 'E':
+
+    /* "asyncpg/protocol/coreproto.pyx":251
+ *         if mtype == b'E':
+ *             # ErrorResponse
+ *             self._parse_msg_error_response(True)             # <<<<<<<<<<<<<<
+ * 
+ *         elif mtype == b'2':
+ */
+    __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_parse_msg_error_response(__pyx_v_self, Py_True); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 251, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":249
+ * 
+ *     cdef _process__bind(self, char mtype):
+ *         if mtype == b'E':             # <<<<<<<<<<<<<<
+ *             # ErrorResponse
+ *             self._parse_msg_error_response(True)
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":253
+ *             self._parse_msg_error_response(True)
+ * 
+ *         elif mtype == b'2':             # <<<<<<<<<<<<<<
+ *             # BindComplete
+ *             self.buffer.consume_message()
+ */
+    case '2':
+
+    /* "asyncpg/protocol/coreproto.pyx":255
+ *         elif mtype == b'2':
+ *             # BindComplete
+ *             self.buffer.consume_message()             # <<<<<<<<<<<<<<
+ * 
+ *         elif mtype == b'Z':
+ */
+    __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(__pyx_v_self->buffer)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 255, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":253
+ *             self._parse_msg_error_response(True)
+ * 
+ *         elif mtype == b'2':             # <<<<<<<<<<<<<<
+ *             # BindComplete
+ *             self.buffer.consume_message()
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":257
+ *             self.buffer.consume_message()
+ * 
+ *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()
+ */
+    case 'Z':
+
+    /* "asyncpg/protocol/coreproto.pyx":259
+ *         elif mtype == b'Z':
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()             # <<<<<<<<<<<<<<
+ *             self._push_result()
+ * 
+ */
+    __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_parse_msg_ready_for_query(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 259, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":260
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()
+ *             self._push_result()             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _process__close_stmt_portal(self, char mtype):
+ */
+    __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_push_result(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 260, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":257
+ *             self.buffer.consume_message()
+ * 
+ *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()
+ */
+    break;
+    default: break;
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":248
+ *             self.buffer.consume_message()
+ * 
+ *     cdef _process__bind(self, char mtype):             # <<<<<<<<<<<<<<
+ *         if mtype == b'E':
+ *             # ErrorResponse
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._process__bind", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":262
+ *             self._push_result()
+ * 
+ *     cdef _process__close_stmt_portal(self, char mtype):             # <<<<<<<<<<<<<<
+ *         if mtype == b'E':
+ *             # ErrorResponse
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__close_stmt_portal(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, char __pyx_v_mtype) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("_process__close_stmt_portal", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":263
+ * 
+ *     cdef _process__close_stmt_portal(self, char mtype):
+ *         if mtype == b'E':             # <<<<<<<<<<<<<<
+ *             # ErrorResponse
+ *             self._parse_msg_error_response(True)
+ */
+  switch (__pyx_v_mtype) {
+    case 'E':
+
+    /* "asyncpg/protocol/coreproto.pyx":265
+ *         if mtype == b'E':
+ *             # ErrorResponse
+ *             self._parse_msg_error_response(True)             # <<<<<<<<<<<<<<
+ * 
+ *         elif mtype == b'3':
+ */
+    __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_parse_msg_error_response(__pyx_v_self, Py_True); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 265, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":263
+ * 
+ *     cdef _process__close_stmt_portal(self, char mtype):
+ *         if mtype == b'E':             # <<<<<<<<<<<<<<
+ *             # ErrorResponse
+ *             self._parse_msg_error_response(True)
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":267
+ *             self._parse_msg_error_response(True)
+ * 
+ *         elif mtype == b'3':             # <<<<<<<<<<<<<<
+ *             # CloseComplete
+ *             self.buffer.consume_message()
+ */
+    case '3':
+
+    /* "asyncpg/protocol/coreproto.pyx":269
+ *         elif mtype == b'3':
+ *             # CloseComplete
+ *             self.buffer.consume_message()             # <<<<<<<<<<<<<<
+ * 
+ *         elif mtype == b'Z':
+ */
+    __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(__pyx_v_self->buffer)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 269, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":267
+ *             self._parse_msg_error_response(True)
+ * 
+ *         elif mtype == b'3':             # <<<<<<<<<<<<<<
+ *             # CloseComplete
+ *             self.buffer.consume_message()
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":271
+ *             self.buffer.consume_message()
+ * 
+ *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()
+ */
+    case 'Z':
+
+    /* "asyncpg/protocol/coreproto.pyx":273
+ *         elif mtype == b'Z':
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()             # <<<<<<<<<<<<<<
+ *             self._push_result()
+ * 
+ */
+    __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_parse_msg_ready_for_query(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 273, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":274
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()
+ *             self._push_result()             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _process__simple_query(self, char mtype):
+ */
+    __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_push_result(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 274, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":271
+ *             self.buffer.consume_message()
+ * 
+ *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()
+ */
+    break;
+    default: break;
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":262
+ *             self._push_result()
+ * 
+ *     cdef _process__close_stmt_portal(self, char mtype):             # <<<<<<<<<<<<<<
+ *         if mtype == b'E':
+ *             # ErrorResponse
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._process__close_stmt_portal", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":276
+ *             self._push_result()
+ * 
+ *     cdef _process__simple_query(self, char mtype):             # <<<<<<<<<<<<<<
+ *         if mtype in {b'D', b'I', b'N', b'T'}:
+ *             # 'D' - DataRow
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__simple_query(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, char __pyx_v_mtype) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("_process__simple_query", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":277
+ * 
+ *     cdef _process__simple_query(self, char mtype):
+ *         if mtype in {b'D', b'I', b'N', b'T'}:             # <<<<<<<<<<<<<<
+ *             # 'D' - DataRow
+ *             # 'I' - EmptyQueryResponse
+ */
+  switch (__pyx_v_mtype) {
+    case 'D':
+    case 'I':
+    case 'N':
+    case 'T':
+
+    /* "asyncpg/protocol/coreproto.pyx":282
+ *             # 'N' - NoticeResponse
+ *             # 'T' - RowDescription
+ *             self.buffer.consume_message()             # <<<<<<<<<<<<<<
+ * 
+ *         elif mtype == b'E':
+ */
+    __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(__pyx_v_self->buffer)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 282, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":277
+ * 
+ *     cdef _process__simple_query(self, char mtype):
+ *         if mtype in {b'D', b'I', b'N', b'T'}:             # <<<<<<<<<<<<<<
+ *             # 'D' - DataRow
+ *             # 'I' - EmptyQueryResponse
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":284
+ *             self.buffer.consume_message()
+ * 
+ *         elif mtype == b'E':             # <<<<<<<<<<<<<<
+ *             # ErrorResponse
+ *             self._parse_msg_error_response(True)
+ */
+    case 'E':
+
+    /* "asyncpg/protocol/coreproto.pyx":286
+ *         elif mtype == b'E':
+ *             # ErrorResponse
+ *             self._parse_msg_error_response(True)             # <<<<<<<<<<<<<<
+ * 
+ *         elif mtype == b'Z':
+ */
+    __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_parse_msg_error_response(__pyx_v_self, Py_True); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 286, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":284
+ *             self.buffer.consume_message()
+ * 
+ *         elif mtype == b'E':             # <<<<<<<<<<<<<<
+ *             # ErrorResponse
+ *             self._parse_msg_error_response(True)
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":288
+ *             self._parse_msg_error_response(True)
+ * 
+ *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()
+ */
+    case 'Z':
+
+    /* "asyncpg/protocol/coreproto.pyx":290
+ *         elif mtype == b'Z':
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()             # <<<<<<<<<<<<<<
+ *             self._push_result()
+ * 
+ */
+    __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_parse_msg_ready_for_query(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 290, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":291
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()
+ *             self._push_result()             # <<<<<<<<<<<<<<
+ * 
+ *         elif mtype == b'C':
+ */
+    __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_push_result(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 291, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":288
+ *             self._parse_msg_error_response(True)
+ * 
+ *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
+ *             # ReadyForQuery
+ *             self._parse_msg_ready_for_query()
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":293
+ *             self._push_result()
+ * 
+ *         elif mtype == b'C':             # <<<<<<<<<<<<<<
+ *             # CommandComplete
+ *             self._parse_msg_command_complete()
+ */
+    case 'C':
+
+    /* "asyncpg/protocol/coreproto.pyx":295
+ *         elif mtype == b'C':
+ *             # CommandComplete
+ *             self._parse_msg_command_complete()             # <<<<<<<<<<<<<<
+ * 
+ *         else:
+ */
+    __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_parse_msg_command_complete(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 295, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":293
+ *             self._push_result()
+ * 
+ *         elif mtype == b'C':             # <<<<<<<<<<<<<<
+ *             # CommandComplete
+ *             self._parse_msg_command_complete()
+ */
+    break;
+    default:
+
+    /* "asyncpg/protocol/coreproto.pyx":299
+ *         else:
+ *             # We don't really care about COPY IN etc
+ *             self.buffer.consume_message()             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _parse_msg_command_complete(self):
+ */
+    __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(__pyx_v_self->buffer)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 299, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    break;
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":276
+ *             self._push_result()
+ * 
+ *     cdef _process__simple_query(self, char mtype):             # <<<<<<<<<<<<<<
+ *         if mtype in {b'D', b'I', b'N', b'T'}:
+ *             # 'D' - DataRow
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._process__simple_query", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":301
+ *             self.buffer.consume_message()
+ * 
+ *     cdef _parse_msg_command_complete(self):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             char* cbuf
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__parse_msg_command_complete(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self) {
+  char *__pyx_v_cbuf;
+  Py_ssize_t __pyx_v_cbuf_len;
+  PyObject *__pyx_v_msg = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("_parse_msg_command_complete", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":306
+ *             ssize_t cbuf_len
+ * 
+ *         cbuf = self.buffer.try_consume_message(&cbuf_len)             # <<<<<<<<<<<<<<
+ *         if cbuf != NULL and cbuf_len > 0:
+ *             msg = cpython.PyBytes_FromStringAndSize(cbuf, cbuf_len - 1)
+ */
+  __pyx_v_cbuf = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_try_consume_message(__pyx_v_self->buffer, (&__pyx_v_cbuf_len));
+
+  /* "asyncpg/protocol/coreproto.pyx":307
+ * 
+ *         cbuf = self.buffer.try_consume_message(&cbuf_len)
+ *         if cbuf != NULL and cbuf_len > 0:             # <<<<<<<<<<<<<<
+ *             msg = cpython.PyBytes_FromStringAndSize(cbuf, cbuf_len - 1)
+ *         else:
+ */
+  __pyx_t_2 = ((__pyx_v_cbuf != NULL) != 0);
+  if (__pyx_t_2) {
+  } else {
+    __pyx_t_1 = __pyx_t_2;
+    goto __pyx_L4_bool_binop_done;
+  }
+  __pyx_t_2 = ((__pyx_v_cbuf_len > 0) != 0);
+  __pyx_t_1 = __pyx_t_2;
+  __pyx_L4_bool_binop_done:;
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/coreproto.pyx":308
+ *         cbuf = self.buffer.try_consume_message(&cbuf_len)
+ *         if cbuf != NULL and cbuf_len > 0:
+ *             msg = cpython.PyBytes_FromStringAndSize(cbuf, cbuf_len - 1)             # <<<<<<<<<<<<<<
+ *         else:
+ *             msg = self.buffer.read_cstr()
+ */
+    __pyx_t_3 = PyBytes_FromStringAndSize(__pyx_v_cbuf, (__pyx_v_cbuf_len - 1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 308, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_v_msg = __pyx_t_3;
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":307
+ * 
+ *         cbuf = self.buffer.try_consume_message(&cbuf_len)
+ *         if cbuf != NULL and cbuf_len > 0:             # <<<<<<<<<<<<<<
+ *             msg = cpython.PyBytes_FromStringAndSize(cbuf, cbuf_len - 1)
+ *         else:
+ */
+    goto __pyx_L3;
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":310
+ *             msg = cpython.PyBytes_FromStringAndSize(cbuf, cbuf_len - 1)
+ *         else:
+ *             msg = self.buffer.read_cstr()             # <<<<<<<<<<<<<<
+ *         self.result_status_msg = msg
+ * 
+ */
+  /*else*/ {
+    __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_cstr(__pyx_v_self->buffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 310, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_v_msg = __pyx_t_3;
+    __pyx_t_3 = 0;
+  }
+  __pyx_L3:;
+
+  /* "asyncpg/protocol/coreproto.pyx":311
+ *         else:
+ *             msg = self.buffer.read_cstr()
+ *         self.result_status_msg = msg             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _parse_data_msgs(self):
+ */
+  if (!(likely(PyBytes_CheckExact(__pyx_v_msg))||((__pyx_v_msg) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_msg)->tp_name), 0))) __PYX_ERR(4, 311, __pyx_L1_error)
+  __pyx_t_3 = __pyx_v_msg;
+  __Pyx_INCREF(__pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_3);
+  __Pyx_GOTREF(__pyx_v_self->result_status_msg);
+  __Pyx_DECREF(__pyx_v_self->result_status_msg);
+  __pyx_v_self->result_status_msg = ((PyObject*)__pyx_t_3);
+  __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":301
+ *             self.buffer.consume_message()
+ * 
+ *     cdef _parse_msg_command_complete(self):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             char* cbuf
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._parse_msg_command_complete", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_msg);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":313
+ *         self.result_status_msg = msg
+ * 
+ *     cdef _parse_data_msgs(self):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             ReadBuffer buf = self.buffer
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__parse_data_msgs(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_buf = 0;
+  PyObject *__pyx_v_rows = 0;
+  __pyx_t_7asyncpg_8protocol_8protocol_decode_row_method __pyx_v_decoder;
+  char *__pyx_v_cbuf;
+  Py_ssize_t __pyx_v_cbuf_len;
+  PyObject *__pyx_v_row = 0;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *__pyx_v_mem = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  int32_t __pyx_t_3;
+  int __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  int __pyx_t_8;
+  __Pyx_RefNannySetupContext("_parse_data_msgs", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":315
+ *     cdef _parse_data_msgs(self):
+ *         cdef:
+ *             ReadBuffer buf = self.buffer             # <<<<<<<<<<<<<<
+ *             list rows
+ *             decode_row_method decoder = <decode_row_method>self._decode_row
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_v_self->buffer);
+  __Pyx_INCREF(__pyx_t_1);
+  __pyx_v_buf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":317
+ *             ReadBuffer buf = self.buffer
+ *             list rows
+ *             decode_row_method decoder = <decode_row_method>self._decode_row             # <<<<<<<<<<<<<<
+ * 
+ *             char* cbuf
+ */
+  __pyx_v_decoder = ((__pyx_t_7asyncpg_8protocol_8protocol_decode_row_method)((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_decode_row);
+
+  /* "asyncpg/protocol/coreproto.pyx":324
+ *             Memory mem
+ * 
+ *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
+ *             if buf.get_message_type() != b'D':
+ *                 raise RuntimeError(
+ */
+  __pyx_t_2 = (ASYNCPG_DEBUG != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/coreproto.pyx":325
+ * 
+ *         if ASYNCPG_DEBUG:
+ *             if buf.get_message_type() != b'D':             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError(
+ *                     '_parse_data_msgs: first message is not "D"')
+ */
+    __pyx_t_2 = ((__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_get_message_type(__pyx_v_buf) != 'D') != 0);
+    if (__pyx_t_2) {
+
+      /* "asyncpg/protocol/coreproto.pyx":326
+ *         if ASYNCPG_DEBUG:
+ *             if buf.get_message_type() != b'D':
+ *                 raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                     '_parse_data_msgs: first message is not "D"')
+ * 
+ */
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__57, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 326, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __PYX_ERR(4, 326, __pyx_L1_error)
+
+      /* "asyncpg/protocol/coreproto.pyx":325
+ * 
+ *         if ASYNCPG_DEBUG:
+ *             if buf.get_message_type() != b'D':             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError(
+ *                     '_parse_data_msgs: first message is not "D"')
+ */
+    }
+
+    /* "asyncpg/protocol/coreproto.pyx":324
+ *             Memory mem
+ * 
+ *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
+ *             if buf.get_message_type() != b'D':
+ *                 raise RuntimeError(
+ */
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":329
+ *                     '_parse_data_msgs: first message is not "D"')
+ * 
+ *         if self._discard_data:             # <<<<<<<<<<<<<<
+ *             while True:
+ *                 buf.consume_message()
+ */
+  __pyx_t_2 = (__pyx_v_self->_discard_data != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/coreproto.pyx":330
+ * 
+ *         if self._discard_data:
+ *             while True:             # <<<<<<<<<<<<<<
+ *                 buf.consume_message()
+ *                 if not buf.has_message() or buf.get_message_type() != b'D':
+ */
+    while (1) {
+
+      /* "asyncpg/protocol/coreproto.pyx":331
+ *         if self._discard_data:
+ *             while True:
+ *                 buf.consume_message()             # <<<<<<<<<<<<<<
+ *                 if not buf.has_message() or buf.get_message_type() != b'D':
+ *                     self._skip_discard = True
+ */
+      __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(__pyx_v_buf)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 331, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+      /* "asyncpg/protocol/coreproto.pyx":332
+ *             while True:
+ *                 buf.consume_message()
+ *                 if not buf.has_message() or buf.get_message_type() != b'D':             # <<<<<<<<<<<<<<
+ *                     self._skip_discard = True
+ *                     return
+ */
+      __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_has_message(__pyx_v_buf); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(4, 332, __pyx_L1_error)
+      __pyx_t_4 = ((!(__pyx_t_3 != 0)) != 0);
+      if (!__pyx_t_4) {
+      } else {
+        __pyx_t_2 = __pyx_t_4;
+        goto __pyx_L9_bool_binop_done;
+      }
+      __pyx_t_4 = ((__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_get_message_type(__pyx_v_buf) != 'D') != 0);
+      __pyx_t_2 = __pyx_t_4;
+      __pyx_L9_bool_binop_done:;
+      if (__pyx_t_2) {
+
+        /* "asyncpg/protocol/coreproto.pyx":333
+ *                 buf.consume_message()
+ *                 if not buf.has_message() or buf.get_message_type() != b'D':
+ *                     self._skip_discard = True             # <<<<<<<<<<<<<<
+ *                     return
+ * 
+ */
+        __pyx_v_self->_skip_discard = 1;
+
+        /* "asyncpg/protocol/coreproto.pyx":334
+ *                 if not buf.has_message() or buf.get_message_type() != b'D':
+ *                     self._skip_discard = True
+ *                     return             # <<<<<<<<<<<<<<
+ * 
+ *         if ASYNCPG_DEBUG:
+ */
+        __Pyx_XDECREF(__pyx_r);
+        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+        goto __pyx_L0;
+
+        /* "asyncpg/protocol/coreproto.pyx":332
+ *             while True:
+ *                 buf.consume_message()
+ *                 if not buf.has_message() or buf.get_message_type() != b'D':             # <<<<<<<<<<<<<<
+ *                     self._skip_discard = True
+ *                     return
+ */
+      }
+    }
+
+    /* "asyncpg/protocol/coreproto.pyx":329
+ *                     '_parse_data_msgs: first message is not "D"')
+ * 
+ *         if self._discard_data:             # <<<<<<<<<<<<<<
+ *             while True:
+ *                 buf.consume_message()
+ */
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":336
+ *                     return
+ * 
+ *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
+ *             if type(self.result) is not list:
+ *                 raise RuntimeError(
+ */
+  __pyx_t_2 = (ASYNCPG_DEBUG != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/coreproto.pyx":337
+ * 
+ *         if ASYNCPG_DEBUG:
+ *             if type(self.result) is not list:             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError(
+ *                     '_parse_data_msgs: result is not a list, but {!r}'.
+ */
+    __pyx_t_2 = (((PyObject *)Py_TYPE(__pyx_v_self->result)) != ((PyObject *)(&PyList_Type)));
+    __pyx_t_4 = (__pyx_t_2 != 0);
+    if (__pyx_t_4) {
+
+      /* "asyncpg/protocol/coreproto.pyx":339
+ *             if type(self.result) is not list:
+ *                 raise RuntimeError(
+ *                     '_parse_data_msgs: result is not a list, but {!r}'.             # <<<<<<<<<<<<<<
+ *                     format(self.result))
+ * 
+ */
+      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_parse_data_msgs_result_is_not_a, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 339, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_5);
+
+      /* "asyncpg/protocol/coreproto.pyx":340
+ *                 raise RuntimeError(
+ *                     '_parse_data_msgs: result is not a list, but {!r}'.
+ *                     format(self.result))             # <<<<<<<<<<<<<<
+ * 
+ *         rows = self.result
+ */
+      __pyx_t_6 = NULL;
+      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
+        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
+        if (likely(__pyx_t_6)) {
+          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+          __Pyx_INCREF(__pyx_t_6);
+          __Pyx_INCREF(function);
+          __Pyx_DECREF_SET(__pyx_t_5, function);
+        }
+      }
+      if (!__pyx_t_6) {
+        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_self->result); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 340, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_1);
+      } else {
+        #if CYTHON_FAST_PYCALL
+        if (PyFunction_Check(__pyx_t_5)) {
+          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_self->result};
+          __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 340, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+          __Pyx_GOTREF(__pyx_t_1);
+        } else
+        #endif
+        #if CYTHON_FAST_PYCCALL
+        if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
+          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_self->result};
+          __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 340, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+          __Pyx_GOTREF(__pyx_t_1);
+        } else
+        #endif
+        {
+          __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 340, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_7);
+          __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
+          __Pyx_INCREF(__pyx_v_self->result);
+          __Pyx_GIVEREF(__pyx_v_self->result);
+          PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_self->result);
+          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 340, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_1);
+          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        }
+      }
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+      /* "asyncpg/protocol/coreproto.pyx":338
+ *         if ASYNCPG_DEBUG:
+ *             if type(self.result) is not list:
+ *                 raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                     '_parse_data_msgs: result is not a list, but {!r}'.
+ *                     format(self.result))
+ */
+      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 338, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_GIVEREF(__pyx_t_1);
+      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
+      __pyx_t_1 = 0;
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 338, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __PYX_ERR(4, 338, __pyx_L1_error)
+
+      /* "asyncpg/protocol/coreproto.pyx":337
+ * 
+ *         if ASYNCPG_DEBUG:
+ *             if type(self.result) is not list:             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError(
+ *                     '_parse_data_msgs: result is not a list, but {!r}'.
+ */
+    }
+
+    /* "asyncpg/protocol/coreproto.pyx":336
+ *                     return
+ * 
+ *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
+ *             if type(self.result) is not list:
+ *                 raise RuntimeError(
+ */
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":342
+ *                     format(self.result))
+ * 
+ *         rows = self.result             # <<<<<<<<<<<<<<
+ *         while True:
+ *             cbuf = buf.try_consume_message(&cbuf_len)
+ */
+  if (!(likely(PyList_CheckExact(__pyx_v_self->result))||((__pyx_v_self->result) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_self->result)->tp_name), 0))) __PYX_ERR(4, 342, __pyx_L1_error)
+  __pyx_t_1 = __pyx_v_self->result;
+  __Pyx_INCREF(__pyx_t_1);
+  __pyx_v_rows = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":343
+ * 
+ *         rows = self.result
+ *         while True:             # <<<<<<<<<<<<<<
+ *             cbuf = buf.try_consume_message(&cbuf_len)
+ *             if cbuf != NULL:
+ */
+  while (1) {
+
+    /* "asyncpg/protocol/coreproto.pyx":344
+ *         rows = self.result
+ *         while True:
+ *             cbuf = buf.try_consume_message(&cbuf_len)             # <<<<<<<<<<<<<<
+ *             if cbuf != NULL:
+ *                 row = decoder(self, cbuf, cbuf_len)
+ */
+    __pyx_v_cbuf = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_try_consume_message(__pyx_v_buf, (&__pyx_v_cbuf_len));
+
+    /* "asyncpg/protocol/coreproto.pyx":345
+ *         while True:
+ *             cbuf = buf.try_consume_message(&cbuf_len)
+ *             if cbuf != NULL:             # <<<<<<<<<<<<<<
+ *                 row = decoder(self, cbuf, cbuf_len)
+ *             else:
+ */
+    __pyx_t_4 = ((__pyx_v_cbuf != NULL) != 0);
+    if (__pyx_t_4) {
+
+      /* "asyncpg/protocol/coreproto.pyx":346
+ *             cbuf = buf.try_consume_message(&cbuf_len)
+ *             if cbuf != NULL:
+ *                 row = decoder(self, cbuf, cbuf_len)             # <<<<<<<<<<<<<<
+ *             else:
+ *                 mem = buf.consume_message()
+ */
+      __pyx_t_1 = __pyx_v_decoder(((PyObject *)__pyx_v_self), __pyx_v_cbuf, __pyx_v_cbuf_len); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 346, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_XDECREF_SET(__pyx_v_row, __pyx_t_1);
+      __pyx_t_1 = 0;
+
+      /* "asyncpg/protocol/coreproto.pyx":345
+ *         while True:
+ *             cbuf = buf.try_consume_message(&cbuf_len)
+ *             if cbuf != NULL:             # <<<<<<<<<<<<<<
+ *                 row = decoder(self, cbuf, cbuf_len)
+ *             else:
+ */
+      goto __pyx_L15;
+    }
+
+    /* "asyncpg/protocol/coreproto.pyx":348
+ *                 row = decoder(self, cbuf, cbuf_len)
+ *             else:
+ *                 mem = buf.consume_message()             # <<<<<<<<<<<<<<
+ *                 row = decoder(self, mem.buf, mem.length)
+ * 
+ */
+    /*else*/ {
+      __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(__pyx_v_buf)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 348, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_XDECREF_SET(__pyx_v_mem, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *)__pyx_t_1));
+      __pyx_t_1 = 0;
+
+      /* "asyncpg/protocol/coreproto.pyx":349
+ *             else:
+ *                 mem = buf.consume_message()
+ *                 row = decoder(self, mem.buf, mem.length)             # <<<<<<<<<<<<<<
+ * 
+ *             cpython.PyList_Append(rows, row)
+ */
+      __pyx_t_1 = __pyx_v_decoder(((PyObject *)__pyx_v_self), __pyx_v_mem->buf, __pyx_v_mem->length); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 349, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_XDECREF_SET(__pyx_v_row, __pyx_t_1);
+      __pyx_t_1 = 0;
+    }
+    __pyx_L15:;
+
+    /* "asyncpg/protocol/coreproto.pyx":351
+ *                 row = decoder(self, mem.buf, mem.length)
+ * 
+ *             cpython.PyList_Append(rows, row)             # <<<<<<<<<<<<<<
+ * 
+ *             if not buf.has_message() or buf.get_message_type() != b'D':
+ */
+    __pyx_t_8 = PyList_Append(__pyx_v_rows, __pyx_v_row); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(4, 351, __pyx_L1_error)
+
+    /* "asyncpg/protocol/coreproto.pyx":353
+ *             cpython.PyList_Append(rows, row)
+ * 
+ *             if not buf.has_message() or buf.get_message_type() != b'D':             # <<<<<<<<<<<<<<
+ *                 self._skip_discard = True
+ *                 return
+ */
+    __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_has_message(__pyx_v_buf); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(4, 353, __pyx_L1_error)
+    __pyx_t_2 = ((!(__pyx_t_3 != 0)) != 0);
+    if (!__pyx_t_2) {
+    } else {
+      __pyx_t_4 = __pyx_t_2;
+      goto __pyx_L17_bool_binop_done;
+    }
+    __pyx_t_2 = ((__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_get_message_type(__pyx_v_buf) != 'D') != 0);
+    __pyx_t_4 = __pyx_t_2;
+    __pyx_L17_bool_binop_done:;
+    if (__pyx_t_4) {
+
+      /* "asyncpg/protocol/coreproto.pyx":354
+ * 
+ *             if not buf.has_message() or buf.get_message_type() != b'D':
+ *                 self._skip_discard = True             # <<<<<<<<<<<<<<
+ *                 return
+ * 
+ */
+      __pyx_v_self->_skip_discard = 1;
+
+      /* "asyncpg/protocol/coreproto.pyx":355
+ *             if not buf.has_message() or buf.get_message_type() != b'D':
+ *                 self._skip_discard = True
+ *                 return             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _parse_msg_backend_key_data(self):
+ */
+      __Pyx_XDECREF(__pyx_r);
+      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+      goto __pyx_L0;
+
+      /* "asyncpg/protocol/coreproto.pyx":353
+ *             cpython.PyList_Append(rows, row)
+ * 
+ *             if not buf.has_message() or buf.get_message_type() != b'D':             # <<<<<<<<<<<<<<
+ *                 self._skip_discard = True
+ *                 return
+ */
+    }
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":313
+ *         self.result_status_msg = msg
+ * 
+ *     cdef _parse_data_msgs(self):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             ReadBuffer buf = self.buffer
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._parse_data_msgs", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_buf);
+  __Pyx_XDECREF(__pyx_v_rows);
+  __Pyx_XDECREF(__pyx_v_row);
+  __Pyx_XDECREF((PyObject *)__pyx_v_mem);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":357
+ *                 return
+ * 
+ *     cdef _parse_msg_backend_key_data(self):             # <<<<<<<<<<<<<<
+ *         self.backend_pid = self.buffer.read_int32()
+ *         self.backend_secret = self.buffer.read_int32()
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__parse_msg_backend_key_data(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int32_t __pyx_t_2;
+  __Pyx_RefNannySetupContext("_parse_msg_backend_key_data", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":358
+ * 
+ *     cdef _parse_msg_backend_key_data(self):
+ *         self.backend_pid = self.buffer.read_int32()             # <<<<<<<<<<<<<<
+ *         self.backend_secret = self.buffer.read_int32()
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_int32(__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 358, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyInt_As_int32_t(__pyx_t_1); if (unlikely((__pyx_t_2 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(4, 358, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_self->backend_pid = __pyx_t_2;
+
+  /* "asyncpg/protocol/coreproto.pyx":359
+ *     cdef _parse_msg_backend_key_data(self):
+ *         self.backend_pid = self.buffer.read_int32()
+ *         self.backend_secret = self.buffer.read_int32()             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _parse_msg_parameter_status(self):
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_int32(__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 359, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyInt_As_int32_t(__pyx_t_1); if (unlikely((__pyx_t_2 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(4, 359, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_self->backend_secret = __pyx_t_2;
+
+  /* "asyncpg/protocol/coreproto.pyx":357
+ *                 return
+ * 
+ *     cdef _parse_msg_backend_key_data(self):             # <<<<<<<<<<<<<<
+ *         self.backend_pid = self.buffer.read_int32()
+ *         self.backend_secret = self.buffer.read_int32()
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._parse_msg_backend_key_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":361
+ *         self.backend_secret = self.buffer.read_int32()
+ * 
+ *     cdef _parse_msg_parameter_status(self):             # <<<<<<<<<<<<<<
+ *         name = self.buffer.read_cstr()
+ *         name = name.decode(self.encoding)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__parse_msg_parameter_status(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self) {
+  PyObject *__pyx_v_name = NULL;
+  PyObject *__pyx_v_val = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  __Pyx_RefNannySetupContext("_parse_msg_parameter_status", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":362
+ * 
+ *     cdef _parse_msg_parameter_status(self):
+ *         name = self.buffer.read_cstr()             # <<<<<<<<<<<<<<
+ *         name = name.decode(self.encoding)
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_cstr(__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 362, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_name = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":363
+ *     cdef _parse_msg_parameter_status(self):
+ *         name = self.buffer.read_cstr()
+ *         name = name.decode(self.encoding)             # <<<<<<<<<<<<<<
+ * 
+ *         val = self.buffer.read_cstr()
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_name, __pyx_n_s_decode); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 363, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (!__pyx_t_3) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_self->encoding); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 363, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_self->encoding};
+      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 363, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_self->encoding};
+      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 363, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else
+    #endif
+    {
+      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 363, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
+      __Pyx_INCREF(__pyx_v_self->encoding);
+      __Pyx_GIVEREF(__pyx_v_self->encoding);
+      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self->encoding);
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 363, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF_SET(__pyx_v_name, __pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":365
+ *         name = name.decode(self.encoding)
+ * 
+ *         val = self.buffer.read_cstr()             # <<<<<<<<<<<<<<
+ *         val = val.decode(self.encoding)
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_cstr(__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 365, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_val = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":366
+ * 
+ *         val = self.buffer.read_cstr()
+ *         val = val.decode(self.encoding)             # <<<<<<<<<<<<<<
+ * 
+ *         self._set_server_parameter(name, val)
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_val, __pyx_n_s_decode); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 366, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_4)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_4);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (!__pyx_t_4) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_self->encoding); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 366, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_self->encoding};
+      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 366, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_self->encoding};
+      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 366, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else
+    #endif
+    {
+      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 366, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
+      __Pyx_INCREF(__pyx_v_self->encoding);
+      __Pyx_GIVEREF(__pyx_v_self->encoding);
+      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_self->encoding);
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 366, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF_SET(__pyx_v_val, __pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":368
+ *         val = val.decode(self.encoding)
+ * 
+ *         self._set_server_parameter(name, val)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _parse_msg_notification(self):
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_set_server_parameter(__pyx_v_self, __pyx_v_name, __pyx_v_val); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 368, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":361
+ *         self.backend_secret = self.buffer.read_int32()
+ * 
+ *     cdef _parse_msg_parameter_status(self):             # <<<<<<<<<<<<<<
+ *         name = self.buffer.read_cstr()
+ *         name = name.decode(self.encoding)
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._parse_msg_parameter_status", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_name);
+  __Pyx_XDECREF(__pyx_v_val);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":370
+ *         self._set_server_parameter(name, val)
+ * 
+ *     cdef _parse_msg_notification(self):             # <<<<<<<<<<<<<<
+ *         pid = self.buffer.read_int32()
+ *         channel = self.buffer.read_cstr().decode(self.encoding)
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__parse_msg_notification(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self) {
+  PyObject *__pyx_v_pid = NULL;
+  PyObject *__pyx_v_channel = NULL;
+  PyObject *__pyx_v_payload = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  __Pyx_RefNannySetupContext("_parse_msg_notification", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":371
+ * 
+ *     cdef _parse_msg_notification(self):
+ *         pid = self.buffer.read_int32()             # <<<<<<<<<<<<<<
+ *         channel = self.buffer.read_cstr().decode(self.encoding)
+ *         payload = self.buffer.read_cstr().decode(self.encoding)
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_int32(__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 371, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_pid = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":372
+ *     cdef _parse_msg_notification(self):
+ *         pid = self.buffer.read_int32()
+ *         channel = self.buffer.read_cstr().decode(self.encoding)             # <<<<<<<<<<<<<<
+ *         payload = self.buffer.read_cstr().decode(self.encoding)
+ *         self._on_notification(pid, channel, payload)
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_cstr(__pyx_v_self->buffer); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 372, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_decode); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 372, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
+    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
+    if (likely(__pyx_t_2)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+      __Pyx_INCREF(__pyx_t_2);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_3, function);
+    }
+  }
+  if (!__pyx_t_2) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->encoding); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 372, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_3)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_self->encoding};
+      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 372, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_self->encoding};
+      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 372, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else
+    #endif
+    {
+      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 372, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
+      __Pyx_INCREF(__pyx_v_self->encoding);
+      __Pyx_GIVEREF(__pyx_v_self->encoding);
+      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self->encoding);
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 372, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_v_channel = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":373
+ *         pid = self.buffer.read_int32()
+ *         channel = self.buffer.read_cstr().decode(self.encoding)
+ *         payload = self.buffer.read_cstr().decode(self.encoding)             # <<<<<<<<<<<<<<
+ *         self._on_notification(pid, channel, payload)
+ * 
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_cstr(__pyx_v_self->buffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 373, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_decode); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 373, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_4, function);
+    }
+  }
+  if (!__pyx_t_3) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_self->encoding); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 373, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_4)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_self->encoding};
+      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 373, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_self->encoding};
+      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 373, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else
+    #endif
+    {
+      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 373, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = NULL;
+      __Pyx_INCREF(__pyx_v_self->encoding);
+      __Pyx_GIVEREF(__pyx_v_self->encoding);
+      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_self->encoding);
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 373, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_v_payload = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":374
+ *         channel = self.buffer.read_cstr().decode(self.encoding)
+ *         payload = self.buffer.read_cstr().decode(self.encoding)
+ *         self._on_notification(pid, channel, payload)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _parse_msg_authentication(self):
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_on_notification(__pyx_v_self, __pyx_v_pid, __pyx_v_channel, __pyx_v_payload); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 374, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":370
+ *         self._set_server_parameter(name, val)
+ * 
+ *     cdef _parse_msg_notification(self):             # <<<<<<<<<<<<<<
+ *         pid = self.buffer.read_int32()
+ *         channel = self.buffer.read_cstr().decode(self.encoding)
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._parse_msg_notification", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_pid);
+  __Pyx_XDECREF(__pyx_v_channel);
+  __Pyx_XDECREF(__pyx_v_payload);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":376
+ *         self._on_notification(pid, channel, payload)
+ * 
+ *     cdef _parse_msg_authentication(self):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             int32_t status
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__parse_msg_authentication(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self) {
+  int32_t __pyx_v_status;
+  PyObject *__pyx_v_md5_salt = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int32_t __pyx_t_2;
+  char *__pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  __Pyx_RefNannySetupContext("_parse_msg_authentication", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":381
+ *             bytes md5_salt
+ * 
+ *         status = self.buffer.read_int32()             # <<<<<<<<<<<<<<
+ * 
+ *         if status == AUTH_SUCCESSFUL:
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_int32(__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 381, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyInt_As_int32_t(__pyx_t_1); if (unlikely((__pyx_t_2 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(4, 381, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_status = __pyx_t_2;
+
+  /* "asyncpg/protocol/coreproto.pyx":383
+ *         status = self.buffer.read_int32()
+ * 
+ *         if status == AUTH_SUCCESSFUL:             # <<<<<<<<<<<<<<
+ *             # AuthenticationOk
+ *             self.result_type = RESULT_OK
+ */
+  switch (__pyx_v_status) {
+    case __pyx_e_7asyncpg_8protocol_8protocol_AUTH_SUCCESSFUL:
+
+    /* "asyncpg/protocol/coreproto.pyx":385
+ *         if status == AUTH_SUCCESSFUL:
+ *             # AuthenticationOk
+ *             self.result_type = RESULT_OK             # <<<<<<<<<<<<<<
+ * 
+ *         elif status == AUTH_REQUIRED_PASSWORD:
+ */
+    __pyx_v_self->result_type = __pyx_e_7asyncpg_8protocol_8protocol_RESULT_OK;
+
+    /* "asyncpg/protocol/coreproto.pyx":383
+ *         status = self.buffer.read_int32()
+ * 
+ *         if status == AUTH_SUCCESSFUL:             # <<<<<<<<<<<<<<
+ *             # AuthenticationOk
+ *             self.result_type = RESULT_OK
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":387
+ *             self.result_type = RESULT_OK
+ * 
+ *         elif status == AUTH_REQUIRED_PASSWORD:             # <<<<<<<<<<<<<<
+ *             # AuthenticationCleartextPassword
+ *             self.result_type = RESULT_OK
+ */
+    case __pyx_e_7asyncpg_8protocol_8protocol_AUTH_REQUIRED_PASSWORD:
+
+    /* "asyncpg/protocol/coreproto.pyx":389
+ *         elif status == AUTH_REQUIRED_PASSWORD:
+ *             # AuthenticationCleartextPassword
+ *             self.result_type = RESULT_OK             # <<<<<<<<<<<<<<
+ *             self.auth_msg = self._auth_password_message_cleartext()
+ * 
+ */
+    __pyx_v_self->result_type = __pyx_e_7asyncpg_8protocol_8protocol_RESULT_OK;
+
+    /* "asyncpg/protocol/coreproto.pyx":390
+ *             # AuthenticationCleartextPassword
+ *             self.result_type = RESULT_OK
+ *             self.auth_msg = self._auth_password_message_cleartext()             # <<<<<<<<<<<<<<
+ * 
+ *         elif status == AUTH_REQUIRED_PASSWORDMD5:
+ */
+    __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_auth_password_message_cleartext(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 390, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_auth_msg, __pyx_t_1) < 0) __PYX_ERR(4, 390, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":387
+ *             self.result_type = RESULT_OK
+ * 
+ *         elif status == AUTH_REQUIRED_PASSWORD:             # <<<<<<<<<<<<<<
+ *             # AuthenticationCleartextPassword
+ *             self.result_type = RESULT_OK
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":392
+ *             self.auth_msg = self._auth_password_message_cleartext()
+ * 
+ *         elif status == AUTH_REQUIRED_PASSWORDMD5:             # <<<<<<<<<<<<<<
+ *             # AuthenticationMD5Password
+ *             # Note: MD5 salt is passed as a four-byte sequence
+ */
+    case __pyx_e_7asyncpg_8protocol_8protocol_AUTH_REQUIRED_PASSWORDMD5:
+
+    /* "asyncpg/protocol/coreproto.pyx":396
+ *             # Note: MD5 salt is passed as a four-byte sequence
+ *             md5_salt = cpython.PyBytes_FromStringAndSize(
+ *                 self.buffer.read_bytes(4), 4)             # <<<<<<<<<<<<<<
+ *             self.auth_msg = self._auth_password_message_md5(md5_salt)
+ * 
+ */
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_bytes(__pyx_v_self->buffer, 4); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 396, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_3 = __Pyx_PyObject_AsString(__pyx_t_1); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(4, 396, __pyx_L1_error)
+
+    /* "asyncpg/protocol/coreproto.pyx":395
+ *             # AuthenticationMD5Password
+ *             # Note: MD5 salt is passed as a four-byte sequence
+ *             md5_salt = cpython.PyBytes_FromStringAndSize(             # <<<<<<<<<<<<<<
+ *                 self.buffer.read_bytes(4), 4)
+ *             self.auth_msg = self._auth_password_message_md5(md5_salt)
+ */
+    __pyx_t_4 = PyBytes_FromStringAndSize(__pyx_t_3, 4); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 395, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_v_md5_salt = ((PyObject*)__pyx_t_4);
+    __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":397
+ *             md5_salt = cpython.PyBytes_FromStringAndSize(
+ *                 self.buffer.read_bytes(4), 4)
+ *             self.auth_msg = self._auth_password_message_md5(md5_salt)             # <<<<<<<<<<<<<<
+ * 
+ *         elif status in (AUTH_REQUIRED_KERBEROS, AUTH_REQUIRED_SCMCRED,
+ */
+    __pyx_t_4 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_auth_password_message_md5(__pyx_v_self, __pyx_v_md5_salt); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 397, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_auth_msg, __pyx_t_4) < 0) __PYX_ERR(4, 397, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":392
+ *             self.auth_msg = self._auth_password_message_cleartext()
+ * 
+ *         elif status == AUTH_REQUIRED_PASSWORDMD5:             # <<<<<<<<<<<<<<
+ *             # AuthenticationMD5Password
+ *             # Note: MD5 salt is passed as a four-byte sequence
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":399
+ *             self.auth_msg = self._auth_password_message_md5(md5_salt)
+ * 
+ *         elif status in (AUTH_REQUIRED_KERBEROS, AUTH_REQUIRED_SCMCRED,             # <<<<<<<<<<<<<<
+ *                         AUTH_REQUIRED_GSS, AUTH_REQUIRED_GSS_CONTINUE,
+ *                         AUTH_REQUIRED_SSPI):
+ */
+    case __pyx_e_7asyncpg_8protocol_8protocol_AUTH_REQUIRED_KERBEROS:
+    case __pyx_e_7asyncpg_8protocol_8protocol_AUTH_REQUIRED_SCMCRED:
+
+    /* "asyncpg/protocol/coreproto.pyx":400
+ * 
+ *         elif status in (AUTH_REQUIRED_KERBEROS, AUTH_REQUIRED_SCMCRED,
+ *                         AUTH_REQUIRED_GSS, AUTH_REQUIRED_GSS_CONTINUE,             # <<<<<<<<<<<<<<
+ *                         AUTH_REQUIRED_SSPI):
+ *             self.result_type = RESULT_FAILED
+ */
+    case __pyx_e_7asyncpg_8protocol_8protocol_AUTH_REQUIRED_GSS:
+    case __pyx_e_7asyncpg_8protocol_8protocol_AUTH_REQUIRED_GSS_CONTINUE:
+
+    /* "asyncpg/protocol/coreproto.pyx":401
+ *         elif status in (AUTH_REQUIRED_KERBEROS, AUTH_REQUIRED_SCMCRED,
+ *                         AUTH_REQUIRED_GSS, AUTH_REQUIRED_GSS_CONTINUE,
+ *                         AUTH_REQUIRED_SSPI):             # <<<<<<<<<<<<<<
+ *             self.result_type = RESULT_FAILED
+ *             self.result = apg_exc.InterfaceError(
+ */
+    case __pyx_e_7asyncpg_8protocol_8protocol_AUTH_REQUIRED_SSPI:
+
+    /* "asyncpg/protocol/coreproto.pyx":402
+ *                         AUTH_REQUIRED_GSS, AUTH_REQUIRED_GSS_CONTINUE,
+ *                         AUTH_REQUIRED_SSPI):
+ *             self.result_type = RESULT_FAILED             # <<<<<<<<<<<<<<
+ *             self.result = apg_exc.InterfaceError(
+ *                 'unsupported authentication method requested by the '
+ */
+    __pyx_v_self->result_type = __pyx_e_7asyncpg_8protocol_8protocol_RESULT_FAILED;
+
+    /* "asyncpg/protocol/coreproto.pyx":403
+ *                         AUTH_REQUIRED_SSPI):
+ *             self.result_type = RESULT_FAILED
+ *             self.result = apg_exc.InterfaceError(             # <<<<<<<<<<<<<<
+ *                 'unsupported authentication method requested by the '
+ *                 'server: {!r}'.format(AUTH_METHOD_NAME[status]))
+ */
+    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 403, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_InterfaceError); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 403, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":405
+ *             self.result = apg_exc.InterfaceError(
+ *                 'unsupported authentication method requested by the '
+ *                 'server: {!r}'.format(AUTH_METHOD_NAME[status]))             # <<<<<<<<<<<<<<
+ * 
+ *         else:
+ */
+    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_unsupported_authentication_metho, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 405, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_AUTH_METHOD_NAME); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 405, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_7);
+    __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_7, __pyx_v_status, int32_t, 1, __Pyx_PyInt_From_int32_t, 0, 1, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 405, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_8);
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __pyx_t_7 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
+      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
+      if (likely(__pyx_t_7)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
+        __Pyx_INCREF(__pyx_t_7);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_6, function);
+      }
+    }
+    if (!__pyx_t_7) {
+      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 405, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_6)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_8};
+        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 405, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_8};
+        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 405, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 405, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_9);
+        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
+        __Pyx_GIVEREF(__pyx_t_8);
+        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_8);
+        __pyx_t_8 = 0;
+        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 405, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __pyx_t_6 = NULL;
+    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
+      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
+      if (likely(__pyx_t_6)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+        __Pyx_INCREF(__pyx_t_6);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_5, function);
+      }
+    }
+    if (!__pyx_t_6) {
+      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 403, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_GOTREF(__pyx_t_4);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_5)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_1};
+        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 403, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_1};
+        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 403, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 403, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_9);
+        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __pyx_t_6 = NULL;
+        __Pyx_GIVEREF(__pyx_t_1);
+        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_1);
+        __pyx_t_1 = 0;
+        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 403, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":403
+ *                         AUTH_REQUIRED_SSPI):
+ *             self.result_type = RESULT_FAILED
+ *             self.result = apg_exc.InterfaceError(             # <<<<<<<<<<<<<<
+ *                 'unsupported authentication method requested by the '
+ *                 'server: {!r}'.format(AUTH_METHOD_NAME[status]))
+ */
+    __Pyx_GIVEREF(__pyx_t_4);
+    __Pyx_GOTREF(__pyx_v_self->result);
+    __Pyx_DECREF(__pyx_v_self->result);
+    __pyx_v_self->result = __pyx_t_4;
+    __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":399
+ *             self.auth_msg = self._auth_password_message_md5(md5_salt)
+ * 
+ *         elif status in (AUTH_REQUIRED_KERBEROS, AUTH_REQUIRED_SCMCRED,             # <<<<<<<<<<<<<<
+ *                         AUTH_REQUIRED_GSS, AUTH_REQUIRED_GSS_CONTINUE,
+ *                         AUTH_REQUIRED_SSPI):
+ */
+    break;
+    default:
+
+    /* "asyncpg/protocol/coreproto.pyx":408
+ * 
+ *         else:
+ *             self.result_type = RESULT_FAILED             # <<<<<<<<<<<<<<
+ *             self.result = apg_exc.InterfaceError(
+ *                 'unsupported authentication method requested by the '
+ */
+    __pyx_v_self->result_type = __pyx_e_7asyncpg_8protocol_8protocol_RESULT_FAILED;
+
+    /* "asyncpg/protocol/coreproto.pyx":409
+ *         else:
+ *             self.result_type = RESULT_FAILED
+ *             self.result = apg_exc.InterfaceError(             # <<<<<<<<<<<<<<
+ *                 'unsupported authentication method requested by the '
+ *                 'server: {}'.format(status))
+ */
+    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 409, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_InterfaceError); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 409, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_9);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":411
+ *             self.result = apg_exc.InterfaceError(
+ *                 'unsupported authentication method requested by the '
+ *                 'server: {}'.format(status))             # <<<<<<<<<<<<<<
+ * 
+ *         self.buffer.consume_message()
+ */
+    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_unsupported_authentication_metho_2, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 411, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_6 = __Pyx_PyInt_From_int32_t(__pyx_v_status); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 411, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_8 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
+      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
+      if (likely(__pyx_t_8)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
+        __Pyx_INCREF(__pyx_t_8);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_1, function);
+      }
+    }
+    if (!__pyx_t_8) {
+      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 411, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_GOTREF(__pyx_t_5);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_1)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
+        __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 411, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
+        __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 411, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 411, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = NULL;
+        __Pyx_GIVEREF(__pyx_t_6);
+        PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_6);
+        __pyx_t_6 = 0;
+        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 411, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_1 = NULL;
+    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
+      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_9);
+      if (likely(__pyx_t_1)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
+        __Pyx_INCREF(__pyx_t_1);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_9, function);
+      }
+    }
+    if (!__pyx_t_1) {
+      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 409, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_GOTREF(__pyx_t_4);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_9)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_5};
+        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 409, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_5};
+        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 409, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 409, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); __pyx_t_1 = NULL;
+        __Pyx_GIVEREF(__pyx_t_5);
+        PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5);
+        __pyx_t_5 = 0;
+        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 409, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":409
+ *         else:
+ *             self.result_type = RESULT_FAILED
+ *             self.result = apg_exc.InterfaceError(             # <<<<<<<<<<<<<<
+ *                 'unsupported authentication method requested by the '
+ *                 'server: {}'.format(status))
+ */
+    __Pyx_GIVEREF(__pyx_t_4);
+    __Pyx_GOTREF(__pyx_v_self->result);
+    __Pyx_DECREF(__pyx_v_self->result);
+    __pyx_v_self->result = __pyx_t_4;
+    __pyx_t_4 = 0;
+    break;
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":413
+ *                 'server: {}'.format(status))
+ * 
+ *         self.buffer.consume_message()             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _auth_password_message_cleartext(self):
+ */
+  __pyx_t_4 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(__pyx_v_self->buffer)); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 413, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":376
+ *         self._on_notification(pid, channel, payload)
+ * 
+ *     cdef _parse_msg_authentication(self):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             int32_t status
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._parse_msg_authentication", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_md5_salt);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":415
+ *         self.buffer.consume_message()
+ * 
+ *     cdef _auth_password_message_cleartext(self):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             WriteBuffer msg
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__auth_password_message_cleartext(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_msg = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("_auth_password_message_cleartext", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":419
+ *             WriteBuffer msg
+ * 
+ *         msg = WriteBuffer.new_message(b'p')             # <<<<<<<<<<<<<<
+ *         msg.write_bytestring(self.password.encode('ascii'))
+ *         msg.end_message()
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new_message('p')); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 419, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_msg = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":420
+ * 
+ *         msg = WriteBuffer.new_message(b'p')
+ *         msg.write_bytestring(self.password.encode('ascii'))             # <<<<<<<<<<<<<<
+ *         msg.end_message()
+ * 
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_password); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 420, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 420, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__58, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 420, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(4, 420, __pyx_L1_error)
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_bytestring(__pyx_v_msg, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 420, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":421
+ *         msg = WriteBuffer.new_message(b'p')
+ *         msg.write_bytestring(self.password.encode('ascii'))
+ *         msg.end_message()             # <<<<<<<<<<<<<<
+ * 
+ *         return msg
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_end_message(__pyx_v_msg); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 421, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":423
+ *         msg.end_message()
+ * 
+ *         return msg             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _auth_password_message_md5(self, bytes salt):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(((PyObject *)__pyx_v_msg));
+  __pyx_r = ((PyObject *)__pyx_v_msg);
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/coreproto.pyx":415
+ *         self.buffer.consume_message()
+ * 
+ *     cdef _auth_password_message_cleartext(self):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             WriteBuffer msg
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._auth_password_message_cleartext", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_msg);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":425
+ *         return msg
+ * 
+ *     cdef _auth_password_message_md5(self, bytes salt):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             WriteBuffer msg
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__auth_password_message_md5(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_salt) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_msg = 0;
+  PyObject *__pyx_v_userpass = NULL;
+  PyObject *__pyx_v_hash = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  __Pyx_RefNannySetupContext("_auth_password_message_md5", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":429
+ *             WriteBuffer msg
+ * 
+ *         msg = WriteBuffer.new_message(b'p')             # <<<<<<<<<<<<<<
+ * 
+ *         # 'md5' + md5(md5(password + username) + salt))
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new_message('p')); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 429, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_msg = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":432
+ * 
+ *         # 'md5' + md5(md5(password + username) + salt))
+ *         userpass = ((self.password or '') + (self.user or '')).encode('ascii')             # <<<<<<<<<<<<<<
+ *         hash = hashlib_md5(hashlib_md5(userpass).hexdigest().\
+ *                 encode('ascii') + salt).hexdigest().encode('ascii')
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_password); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 432, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(4, 432, __pyx_L1_error)
+  if (!__pyx_t_3) {
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  } else {
+    __Pyx_INCREF(__pyx_t_2);
+    __pyx_t_1 = __pyx_t_2;
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    goto __pyx_L3_bool_binop_done;
+  }
+  __Pyx_INCREF(__pyx_kp_u__18);
+  __pyx_t_1 = __pyx_kp_u__18;
+  __pyx_L3_bool_binop_done:;
+  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_user); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 432, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(4, 432, __pyx_L1_error)
+  if (!__pyx_t_3) {
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  } else {
+    __Pyx_INCREF(__pyx_t_4);
+    __pyx_t_2 = __pyx_t_4;
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    goto __pyx_L5_bool_binop_done;
+  }
+  __Pyx_INCREF(__pyx_kp_u__18);
+  __pyx_t_2 = __pyx_kp_u__18;
+  __pyx_L5_bool_binop_done:;
+  __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 432, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 432, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__59, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 432, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_v_userpass = __pyx_t_4;
+  __pyx_t_4 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":433
+ *         # 'md5' + md5(md5(password + username) + salt))
+ *         userpass = ((self.password or '') + (self.user or '')).encode('ascii')
+ *         hash = hashlib_md5(hashlib_md5(userpass).hexdigest().\             # <<<<<<<<<<<<<<
+ *                 encode('ascii') + salt).hexdigest().encode('ascii')
+ * 
+ */
+  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_hashlib_md5); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 433, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_hashlib_md5); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 433, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_7);
+  __pyx_t_8 = NULL;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
+    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
+    if (likely(__pyx_t_8)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
+      __Pyx_INCREF(__pyx_t_8);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_7, function);
+    }
+  }
+  if (!__pyx_t_8) {
+    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_userpass); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 433, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_6);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_7)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_userpass};
+      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 433, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __Pyx_GOTREF(__pyx_t_6);
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_userpass};
+      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 433, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __Pyx_GOTREF(__pyx_t_6);
+    } else
+    #endif
+    {
+      __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 433, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
+      __Pyx_INCREF(__pyx_v_userpass);
+      __Pyx_GIVEREF(__pyx_v_userpass);
+      PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_userpass);
+      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 433, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_hexdigest); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 433, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_7);
+  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  __pyx_t_6 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
+    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
+    if (likely(__pyx_t_6)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
+      __Pyx_INCREF(__pyx_t_6);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_7, function);
+    }
+  }
+  if (__pyx_t_6) {
+    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 433, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  } else {
+    __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 433, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_encode); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 433, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_7);
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":434
+ *         userpass = ((self.password or '') + (self.user or '')).encode('ascii')
+ *         hash = hashlib_md5(hashlib_md5(userpass).hexdigest().\
+ *                 encode('ascii') + salt).hexdigest().encode('ascii')             # <<<<<<<<<<<<<<
+ * 
+ *         msg.write_bytestring(b'md5' + hash)
+ */
+  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__60, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 434, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+  __pyx_t_7 = PyNumber_Add(__pyx_t_5, __pyx_v_salt); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 434, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_7);
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __pyx_t_5 = NULL;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
+    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
+    if (likely(__pyx_t_5)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
+      __Pyx_INCREF(__pyx_t_5);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_1, function);
+    }
+  }
+  if (!__pyx_t_5) {
+    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 433, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_GOTREF(__pyx_t_2);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_1)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_7};
+      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 433, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_7};
+      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 433, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    } else
+    #endif
+    {
+      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 433, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
+      __Pyx_GIVEREF(__pyx_t_7);
+      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_7);
+      __pyx_t_7 = 0;
+      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 433, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_hexdigest); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 434, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
+    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
+    if (likely(__pyx_t_2)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
+      __Pyx_INCREF(__pyx_t_2);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_1, function);
+    }
+  }
+  if (__pyx_t_2) {
+    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 434, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  } else {
+    __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 434, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_encode); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 434, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__61, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 434, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_hash = __pyx_t_4;
+  __pyx_t_4 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":436
+ *                 encode('ascii') + salt).hexdigest().encode('ascii')
+ * 
+ *         msg.write_bytestring(b'md5' + hash)             # <<<<<<<<<<<<<<
+ *         msg.end_message()
+ * 
+ */
+  __pyx_t_4 = PyNumber_Add(__pyx_n_b_md5, __pyx_v_hash); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 436, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(4, 436, __pyx_L1_error)
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_bytestring(__pyx_v_msg, ((PyObject*)__pyx_t_4)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 436, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":437
+ * 
+ *         msg.write_bytestring(b'md5' + hash)
+ *         msg.end_message()             # <<<<<<<<<<<<<<
+ * 
+ *         return msg
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_end_message(__pyx_v_msg); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 437, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":439
+ *         msg.end_message()
+ * 
+ *         return msg             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _parse_msg_ready_for_query(self):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(((PyObject *)__pyx_v_msg));
+  __pyx_r = ((PyObject *)__pyx_v_msg);
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/coreproto.pyx":425
+ *         return msg
+ * 
+ *     cdef _auth_password_message_md5(self, bytes salt):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             WriteBuffer msg
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._auth_password_message_md5", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_msg);
+  __Pyx_XDECREF(__pyx_v_userpass);
+  __Pyx_XDECREF(__pyx_v_hash);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":441
+ *         return msg
+ * 
+ *     cdef _parse_msg_ready_for_query(self):             # <<<<<<<<<<<<<<
+ *         cdef char status = self.buffer.read_byte()
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__parse_msg_ready_for_query(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self) {
+  char __pyx_v_status;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  char __pyx_t_2;
+  __Pyx_RefNannySetupContext("_parse_msg_ready_for_query", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":442
+ * 
+ *     cdef _parse_msg_ready_for_query(self):
+ *         cdef char status = self.buffer.read_byte()             # <<<<<<<<<<<<<<
+ * 
+ *         if status == b'I':
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_byte(__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 442, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_2 == (char)-1) && PyErr_Occurred())) __PYX_ERR(4, 442, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_status = __pyx_t_2;
+
+  /* "asyncpg/protocol/coreproto.pyx":444
+ *         cdef char status = self.buffer.read_byte()
+ * 
+ *         if status == b'I':             # <<<<<<<<<<<<<<
+ *             self.xact_status = PQTRANS_IDLE
+ *         elif status == b'T':
+ */
+  switch (__pyx_v_status) {
+    case 'I':
+
+    /* "asyncpg/protocol/coreproto.pyx":445
+ * 
+ *         if status == b'I':
+ *             self.xact_status = PQTRANS_IDLE             # <<<<<<<<<<<<<<
+ *         elif status == b'T':
+ *             self.xact_status = PQTRANS_INTRANS
+ */
+    __pyx_v_self->xact_status = __pyx_e_7asyncpg_8protocol_8protocol_PQTRANS_IDLE;
+
+    /* "asyncpg/protocol/coreproto.pyx":444
+ *         cdef char status = self.buffer.read_byte()
+ * 
+ *         if status == b'I':             # <<<<<<<<<<<<<<
+ *             self.xact_status = PQTRANS_IDLE
+ *         elif status == b'T':
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":446
+ *         if status == b'I':
+ *             self.xact_status = PQTRANS_IDLE
+ *         elif status == b'T':             # <<<<<<<<<<<<<<
+ *             self.xact_status = PQTRANS_INTRANS
+ *         elif status == b'E':
+ */
+    case 'T':
+
+    /* "asyncpg/protocol/coreproto.pyx":447
+ *             self.xact_status = PQTRANS_IDLE
+ *         elif status == b'T':
+ *             self.xact_status = PQTRANS_INTRANS             # <<<<<<<<<<<<<<
+ *         elif status == b'E':
+ *             self.xact_status = PQTRANS_INERROR
+ */
+    __pyx_v_self->xact_status = __pyx_e_7asyncpg_8protocol_8protocol_PQTRANS_INTRANS;
+
+    /* "asyncpg/protocol/coreproto.pyx":446
+ *         if status == b'I':
+ *             self.xact_status = PQTRANS_IDLE
+ *         elif status == b'T':             # <<<<<<<<<<<<<<
+ *             self.xact_status = PQTRANS_INTRANS
+ *         elif status == b'E':
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":448
+ *         elif status == b'T':
+ *             self.xact_status = PQTRANS_INTRANS
+ *         elif status == b'E':             # <<<<<<<<<<<<<<
+ *             self.xact_status = PQTRANS_INERROR
+ *         else:
+ */
+    case 'E':
+
+    /* "asyncpg/protocol/coreproto.pyx":449
+ *             self.xact_status = PQTRANS_INTRANS
+ *         elif status == b'E':
+ *             self.xact_status = PQTRANS_INERROR             # <<<<<<<<<<<<<<
+ *         else:
+ *             self.xact_status = PQTRANS_UNKNOWN
+ */
+    __pyx_v_self->xact_status = __pyx_e_7asyncpg_8protocol_8protocol_PQTRANS_INERROR;
+
+    /* "asyncpg/protocol/coreproto.pyx":448
+ *         elif status == b'T':
+ *             self.xact_status = PQTRANS_INTRANS
+ *         elif status == b'E':             # <<<<<<<<<<<<<<
+ *             self.xact_status = PQTRANS_INERROR
+ *         else:
+ */
+    break;
+    default:
+
+    /* "asyncpg/protocol/coreproto.pyx":451
+ *             self.xact_status = PQTRANS_INERROR
+ *         else:
+ *             self.xact_status = PQTRANS_UNKNOWN             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _parse_msg_error_response(self, is_error):
+ */
+    __pyx_v_self->xact_status = __pyx_e_7asyncpg_8protocol_8protocol_PQTRANS_UNKNOWN;
+    break;
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":441
+ *         return msg
+ * 
+ *     cdef _parse_msg_ready_for_query(self):             # <<<<<<<<<<<<<<
+ *         cdef char status = self.buffer.read_byte()
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._parse_msg_ready_for_query", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":453
+ *             self.xact_status = PQTRANS_UNKNOWN
+ * 
+ *     cdef _parse_msg_error_response(self, is_error):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             char code
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__parse_msg_error_response(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_is_error) {
+  char __pyx_v_code;
+  PyObject *__pyx_v_message = 0;
+  PyObject *__pyx_v_parsed = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  char __pyx_t_2;
+  int __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  __Pyx_RefNannySetupContext("_parse_msg_error_response", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":457
+ *             char code
+ *             bytes message
+ *             dict parsed = {}             # <<<<<<<<<<<<<<
+ * 
+ *         while True:
+ */
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 457, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_parsed = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":459
+ *             dict parsed = {}
+ * 
+ *         while True:             # <<<<<<<<<<<<<<
+ *             code = self.buffer.read_byte()
+ *             if code == 0:
+ */
+  while (1) {
+
+    /* "asyncpg/protocol/coreproto.pyx":460
+ * 
+ *         while True:
+ *             code = self.buffer.read_byte()             # <<<<<<<<<<<<<<
+ *             if code == 0:
+ *                 break
+ */
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_byte(__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 460, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_2 = __Pyx_PyInt_As_char(__pyx_t_1); if (unlikely((__pyx_t_2 == (char)-1) && PyErr_Occurred())) __PYX_ERR(4, 460, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_v_code = __pyx_t_2;
+
+    /* "asyncpg/protocol/coreproto.pyx":461
+ *         while True:
+ *             code = self.buffer.read_byte()
+ *             if code == 0:             # <<<<<<<<<<<<<<
+ *                 break
+ * 
+ */
+    __pyx_t_3 = ((__pyx_v_code == 0) != 0);
+    if (__pyx_t_3) {
+
+      /* "asyncpg/protocol/coreproto.pyx":462
+ *             code = self.buffer.read_byte()
+ *             if code == 0:
+ *                 break             # <<<<<<<<<<<<<<
+ * 
+ *             message = self.buffer.read_cstr()
+ */
+      goto __pyx_L4_break;
+
+      /* "asyncpg/protocol/coreproto.pyx":461
+ *         while True:
+ *             code = self.buffer.read_byte()
+ *             if code == 0:             # <<<<<<<<<<<<<<
+ *                 break
+ * 
+ */
+    }
+
+    /* "asyncpg/protocol/coreproto.pyx":464
+ *                 break
+ * 
+ *             message = self.buffer.read_cstr()             # <<<<<<<<<<<<<<
+ * 
+ *             parsed[chr(code)] = message.decode()
+ */
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_cstr(__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 464, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(4, 464, __pyx_L1_error)
+    __Pyx_XDECREF_SET(__pyx_v_message, ((PyObject*)__pyx_t_1));
+    __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":466
+ *             message = self.buffer.read_cstr()
+ * 
+ *             parsed[chr(code)] = message.decode()             # <<<<<<<<<<<<<<
+ * 
+ *         if is_error:
+ */
+    if (unlikely(__pyx_v_message == Py_None)) {
+      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "decode");
+      __PYX_ERR(4, 466, __pyx_L1_error)
+    }
+    __pyx_t_1 = __Pyx_decode_bytes(__pyx_v_message, 0, PY_SSIZE_T_MAX, NULL, NULL, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 466, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_4 = __Pyx_PyInt_From_char(__pyx_v_code); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 466, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 466, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_GIVEREF(__pyx_t_4);
+    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
+    __pyx_t_4 = 0;
+    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_chr, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 466, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    if (unlikely(PyDict_SetItem(__pyx_v_parsed, __pyx_t_4, __pyx_t_1) < 0)) __PYX_ERR(4, 466, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  }
+  __pyx_L4_break:;
+
+  /* "asyncpg/protocol/coreproto.pyx":468
+ *             parsed[chr(code)] = message.decode()
+ * 
+ *         if is_error:             # <<<<<<<<<<<<<<
+ *             self.result_type = RESULT_FAILED
+ *             self.result = parsed
+ */
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_is_error); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(4, 468, __pyx_L1_error)
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/coreproto.pyx":469
+ * 
+ *         if is_error:
+ *             self.result_type = RESULT_FAILED             # <<<<<<<<<<<<<<
+ *             self.result = parsed
+ * 
+ */
+    __pyx_v_self->result_type = __pyx_e_7asyncpg_8protocol_8protocol_RESULT_FAILED;
+
+    /* "asyncpg/protocol/coreproto.pyx":470
+ *         if is_error:
+ *             self.result_type = RESULT_FAILED
+ *             self.result = parsed             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _push_result(self):
+ */
+    __Pyx_INCREF(__pyx_v_parsed);
+    __Pyx_GIVEREF(__pyx_v_parsed);
+    __Pyx_GOTREF(__pyx_v_self->result);
+    __Pyx_DECREF(__pyx_v_self->result);
+    __pyx_v_self->result = __pyx_v_parsed;
+
+    /* "asyncpg/protocol/coreproto.pyx":468
+ *             parsed[chr(code)] = message.decode()
+ * 
+ *         if is_error:             # <<<<<<<<<<<<<<
+ *             self.result_type = RESULT_FAILED
+ *             self.result = parsed
+ */
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":453
+ *             self.xact_status = PQTRANS_UNKNOWN
+ * 
+ *     cdef _parse_msg_error_response(self, is_error):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             char code
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._parse_msg_error_response", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_message);
+  __Pyx_XDECREF(__pyx_v_parsed);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":472
+ *             self.result = parsed
+ * 
+ *     cdef _push_result(self):             # <<<<<<<<<<<<<<
+ *         try:
+ *             self._on_result()
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__push_result(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  int __pyx_t_3;
+  char const *__pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  PyObject *__pyx_t_10 = NULL;
+  __Pyx_RefNannySetupContext("_push_result", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":473
+ * 
+ *     cdef _push_result(self):
+ *         try:             # <<<<<<<<<<<<<<
+ *             self._on_result()
+ *         finally:
+ */
+  /*try:*/ {
+
+    /* "asyncpg/protocol/coreproto.pyx":474
+ *     cdef _push_result(self):
+ *         try:
+ *             self._on_result()             # <<<<<<<<<<<<<<
+ *         finally:
+ *             self._set_state(PROTOCOL_IDLE)
+ */
+    __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_on_result(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 474, __pyx_L4_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":476
+ *             self._on_result()
+ *         finally:
+ *             self._set_state(PROTOCOL_IDLE)             # <<<<<<<<<<<<<<
+ *             self._reset_result()
+ * 
+ */
+  /*finally:*/ {
+    /*normal exit:*/{
+      __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_set_state(__pyx_v_self, __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_IDLE); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 476, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+      /* "asyncpg/protocol/coreproto.pyx":477
+ *         finally:
+ *             self._set_state(PROTOCOL_IDLE)
+ *             self._reset_result()             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _reset_result(self):
+ */
+      __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_reset_result(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 477, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      goto __pyx_L5;
+    }
+    /*exception exit:*/{
+      __Pyx_PyThreadState_declare
+      __pyx_L4_error:;
+      __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0;
+      __Pyx_PyThreadState_assign
+      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
+      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0)) __Pyx_ErrFetch(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
+      __Pyx_XGOTREF(__pyx_t_5);
+      __Pyx_XGOTREF(__pyx_t_6);
+      __Pyx_XGOTREF(__pyx_t_7);
+      __Pyx_XGOTREF(__pyx_t_8);
+      __Pyx_XGOTREF(__pyx_t_9);
+      __Pyx_XGOTREF(__pyx_t_10);
+      __pyx_t_2 = __pyx_lineno; __pyx_t_3 = __pyx_clineno; __pyx_t_4 = __pyx_filename;
+      {
+
+        /* "asyncpg/protocol/coreproto.pyx":476
+ *             self._on_result()
+ *         finally:
+ *             self._set_state(PROTOCOL_IDLE)             # <<<<<<<<<<<<<<
+ *             self._reset_result()
+ * 
+ */
+        __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_set_state(__pyx_v_self, __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_IDLE); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 476, __pyx_L7_error)
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+        /* "asyncpg/protocol/coreproto.pyx":477
+ *         finally:
+ *             self._set_state(PROTOCOL_IDLE)
+ *             self._reset_result()             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _reset_result(self):
+ */
+        __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_reset_result(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 477, __pyx_L7_error)
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      }
+      __Pyx_PyThreadState_assign
+      if (PY_MAJOR_VERSION >= 3) {
+        __Pyx_XGIVEREF(__pyx_t_8);
+        __Pyx_XGIVEREF(__pyx_t_9);
+        __Pyx_XGIVEREF(__pyx_t_10);
+        __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
+      }
+      __Pyx_XGIVEREF(__pyx_t_5);
+      __Pyx_XGIVEREF(__pyx_t_6);
+      __Pyx_XGIVEREF(__pyx_t_7);
+      __Pyx_ErrRestore(__pyx_t_5, __pyx_t_6, __pyx_t_7);
+      __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0;
+      __pyx_lineno = __pyx_t_2; __pyx_clineno = __pyx_t_3; __pyx_filename = __pyx_t_4;
+      goto __pyx_L1_error;
+      __pyx_L7_error:;
+      __Pyx_PyThreadState_assign
+      if (PY_MAJOR_VERSION >= 3) {
+        __Pyx_XGIVEREF(__pyx_t_8);
+        __Pyx_XGIVEREF(__pyx_t_9);
+        __Pyx_XGIVEREF(__pyx_t_10);
+        __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
+      }
+      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0;
+      goto __pyx_L1_error;
+    }
+    __pyx_L5:;
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":472
+ *             self.result = parsed
+ * 
+ *     cdef _push_result(self):             # <<<<<<<<<<<<<<
+ *         try:
+ *             self._on_result()
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._push_result", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":479
+ *             self._reset_result()
+ * 
+ *     cdef _reset_result(self):             # <<<<<<<<<<<<<<
+ *         self.result_type = RESULT_OK
+ *         self.result = None
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__reset_result(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("_reset_result", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":480
+ * 
+ *     cdef _reset_result(self):
+ *         self.result_type = RESULT_OK             # <<<<<<<<<<<<<<
+ *         self.result = None
+ *         self.result_param_desc = None
+ */
+  __pyx_v_self->result_type = __pyx_e_7asyncpg_8protocol_8protocol_RESULT_OK;
+
+  /* "asyncpg/protocol/coreproto.pyx":481
+ *     cdef _reset_result(self):
+ *         self.result_type = RESULT_OK
+ *         self.result = None             # <<<<<<<<<<<<<<
+ *         self.result_param_desc = None
+ *         self.result_row_desc = None
+ */
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->result);
+  __Pyx_DECREF(__pyx_v_self->result);
+  __pyx_v_self->result = Py_None;
+
+  /* "asyncpg/protocol/coreproto.pyx":482
+ *         self.result_type = RESULT_OK
+ *         self.result = None
+ *         self.result_param_desc = None             # <<<<<<<<<<<<<<
+ *         self.result_row_desc = None
+ *         self.result_status_msg = None
+ */
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->result_param_desc);
+  __Pyx_DECREF(__pyx_v_self->result_param_desc);
+  __pyx_v_self->result_param_desc = ((PyObject*)Py_None);
+
+  /* "asyncpg/protocol/coreproto.pyx":483
+ *         self.result = None
+ *         self.result_param_desc = None
+ *         self.result_row_desc = None             # <<<<<<<<<<<<<<
+ *         self.result_status_msg = None
+ *         self.result_execute_completed = False
+ */
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->result_row_desc);
+  __Pyx_DECREF(__pyx_v_self->result_row_desc);
+  __pyx_v_self->result_row_desc = ((PyObject*)Py_None);
+
+  /* "asyncpg/protocol/coreproto.pyx":484
+ *         self.result_param_desc = None
+ *         self.result_row_desc = None
+ *         self.result_status_msg = None             # <<<<<<<<<<<<<<
+ *         self.result_execute_completed = False
+ *         self._discard_data = False
+ */
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->result_status_msg);
+  __Pyx_DECREF(__pyx_v_self->result_status_msg);
+  __pyx_v_self->result_status_msg = ((PyObject*)Py_None);
+
+  /* "asyncpg/protocol/coreproto.pyx":485
+ *         self.result_row_desc = None
+ *         self.result_status_msg = None
+ *         self.result_execute_completed = False             # <<<<<<<<<<<<<<
+ *         self._discard_data = False
+ * 
+ */
+  __pyx_v_self->result_execute_completed = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":486
+ *         self.result_status_msg = None
+ *         self.result_execute_completed = False
+ *         self._discard_data = False             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _set_state(self, ProtocolState new_state):
+ */
+  __pyx_v_self->_discard_data = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":479
+ *             self._reset_result()
+ * 
+ *     cdef _reset_result(self):             # <<<<<<<<<<<<<<
+ *         self.result_type = RESULT_OK
+ *         self.result = None
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":488
+ *         self._discard_data = False
+ * 
+ *     cdef _set_state(self, ProtocolState new_state):             # <<<<<<<<<<<<<<
+ *         if new_state == PROTOCOL_IDLE:
+ *             if self.state == PROTOCOL_FAILED:
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__set_state(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState __pyx_v_new_state) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  int __pyx_t_7;
+  PyObject *__pyx_t_8 = NULL;
+  __Pyx_RefNannySetupContext("_set_state", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":489
+ * 
+ *     cdef _set_state(self, ProtocolState new_state):
+ *         if new_state == PROTOCOL_IDLE:             # <<<<<<<<<<<<<<
+ *             if self.state == PROTOCOL_FAILED:
+ *                 raise RuntimeError(
+ */
+  switch (__pyx_v_new_state) {
+    case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_IDLE:
+
+    /* "asyncpg/protocol/coreproto.pyx":490
+ *     cdef _set_state(self, ProtocolState new_state):
+ *         if new_state == PROTOCOL_IDLE:
+ *             if self.state == PROTOCOL_FAILED:             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError(
+ *                     'cannot switch to "idle" state; '
+ */
+    __pyx_t_1 = ((__pyx_v_self->state == __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_FAILED) != 0);
+    if (__pyx_t_1) {
+
+      /* "asyncpg/protocol/coreproto.pyx":491
+ *         if new_state == PROTOCOL_IDLE:
+ *             if self.state == PROTOCOL_FAILED:
+ *                 raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                     'cannot switch to "idle" state; '
+ *                     'protocol is in the "failed" state')
+ */
+      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__62, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 491, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __PYX_ERR(4, 491, __pyx_L1_error)
+
+      /* "asyncpg/protocol/coreproto.pyx":490
+ *     cdef _set_state(self, ProtocolState new_state):
+ *         if new_state == PROTOCOL_IDLE:
+ *             if self.state == PROTOCOL_FAILED:             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError(
+ *                     'cannot switch to "idle" state; '
+ */
+    }
+
+    /* "asyncpg/protocol/coreproto.pyx":494
+ *                     'cannot switch to "idle" state; '
+ *                     'protocol is in the "failed" state')
+ *             elif self.state == PROTOCOL_IDLE:             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError(
+ *                     'protocol is already in the "idle" state')
+ */
+    __pyx_t_1 = ((__pyx_v_self->state == __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_IDLE) != 0);
+    if (__pyx_t_1) {
+
+      /* "asyncpg/protocol/coreproto.pyx":495
+ *                     'protocol is in the "failed" state')
+ *             elif self.state == PROTOCOL_IDLE:
+ *                 raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                     'protocol is already in the "idle" state')
+ *             else:
+ */
+      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__63, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 495, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __PYX_ERR(4, 495, __pyx_L1_error)
+
+      /* "asyncpg/protocol/coreproto.pyx":494
+ *                     'cannot switch to "idle" state; '
+ *                     'protocol is in the "failed" state')
+ *             elif self.state == PROTOCOL_IDLE:             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError(
+ *                     'protocol is already in the "idle" state')
+ */
+    }
+
+    /* "asyncpg/protocol/coreproto.pyx":498
+ *                     'protocol is already in the "idle" state')
+ *             else:
+ *                 self.state = new_state             # <<<<<<<<<<<<<<
+ * 
+ *         elif new_state == PROTOCOL_FAILED:
+ */
+    /*else*/ {
+      __pyx_v_self->state = __pyx_v_new_state;
+    }
+
+    /* "asyncpg/protocol/coreproto.pyx":489
+ * 
+ *     cdef _set_state(self, ProtocolState new_state):
+ *         if new_state == PROTOCOL_IDLE:             # <<<<<<<<<<<<<<
+ *             if self.state == PROTOCOL_FAILED:
+ *                 raise RuntimeError(
+ */
+    break;
+
+    /* "asyncpg/protocol/coreproto.pyx":500
+ *                 self.state = new_state
+ * 
+ *         elif new_state == PROTOCOL_FAILED:             # <<<<<<<<<<<<<<
+ *             self.state = PROTOCOL_FAILED
+ * 
+ */
+    case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_FAILED:
+
+    /* "asyncpg/protocol/coreproto.pyx":501
+ * 
+ *         elif new_state == PROTOCOL_FAILED:
+ *             self.state = PROTOCOL_FAILED             # <<<<<<<<<<<<<<
+ * 
+ *         else:
+ */
+    __pyx_v_self->state = __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_FAILED;
+
+    /* "asyncpg/protocol/coreproto.pyx":500
+ *                 self.state = new_state
+ * 
+ *         elif new_state == PROTOCOL_FAILED:             # <<<<<<<<<<<<<<
+ *             self.state = PROTOCOL_FAILED
+ * 
+ */
+    break;
+    default:
+
+    /* "asyncpg/protocol/coreproto.pyx":504
+ * 
+ *         else:
+ *             if self.state == PROTOCOL_IDLE:             # <<<<<<<<<<<<<<
+ *                 self.state = new_state
+ * 
+ */
+    __pyx_t_1 = ((__pyx_v_self->state == __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_IDLE) != 0);
+    if (__pyx_t_1) {
+
+      /* "asyncpg/protocol/coreproto.pyx":505
+ *         else:
+ *             if self.state == PROTOCOL_IDLE:
+ *                 self.state = new_state             # <<<<<<<<<<<<<<
+ * 
+ *             elif self.state == PROTOCOL_FAILED:
+ */
+      __pyx_v_self->state = __pyx_v_new_state;
+
+      /* "asyncpg/protocol/coreproto.pyx":504
+ * 
+ *         else:
+ *             if self.state == PROTOCOL_IDLE:             # <<<<<<<<<<<<<<
+ *                 self.state = new_state
+ * 
+ */
+      goto __pyx_L4;
+    }
+
+    /* "asyncpg/protocol/coreproto.pyx":507
+ *                 self.state = new_state
+ * 
+ *             elif self.state == PROTOCOL_FAILED:             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError(
+ *                     'cannot switch to state {}; '
+ */
+    __pyx_t_1 = ((__pyx_v_self->state == __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_FAILED) != 0);
+    if (__pyx_t_1) {
+
+      /* "asyncpg/protocol/coreproto.pyx":510
+ *                 raise RuntimeError(
+ *                     'cannot switch to state {}; '
+ *                     'protocol is in the "failed" state'.format(new_state))             # <<<<<<<<<<<<<<
+ *             else:
+ *                 raise RuntimeError(
+ */
+      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_cannot_switch_to_state_protocol, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 510, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_4 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ProtocolState(__pyx_v_new_state); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 510, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_5 = NULL;
+      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
+        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
+        if (likely(__pyx_t_5)) {
+          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+          __Pyx_INCREF(__pyx_t_5);
+          __Pyx_INCREF(function);
+          __Pyx_DECREF_SET(__pyx_t_3, function);
+        }
+      }
+      if (!__pyx_t_5) {
+        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 510, __pyx_L1_error)
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_GOTREF(__pyx_t_2);
+      } else {
+        #if CYTHON_FAST_PYCALL
+        if (PyFunction_Check(__pyx_t_3)) {
+          PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
+          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 510, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+          __Pyx_GOTREF(__pyx_t_2);
+          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        } else
+        #endif
+        #if CYTHON_FAST_PYCCALL
+        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
+          PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
+          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 510, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+          __Pyx_GOTREF(__pyx_t_2);
+          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        } else
+        #endif
+        {
+          __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 510, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_6);
+          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
+          __Pyx_GIVEREF(__pyx_t_4);
+          PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
+          __pyx_t_4 = 0;
+          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 510, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_2);
+          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+        }
+      }
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+      /* "asyncpg/protocol/coreproto.pyx":508
+ * 
+ *             elif self.state == PROTOCOL_FAILED:
+ *                 raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                     'cannot switch to state {}; '
+ *                     'protocol is in the "failed" state'.format(new_state))
+ */
+      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 508, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_GIVEREF(__pyx_t_2);
+      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
+      __pyx_t_2 = 0;
+      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 508, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __PYX_ERR(4, 508, __pyx_L1_error)
+
+      /* "asyncpg/protocol/coreproto.pyx":507
+ *                 self.state = new_state
+ * 
+ *             elif self.state == PROTOCOL_FAILED:             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError(
+ *                     'cannot switch to state {}; '
+ */
+    }
+
+    /* "asyncpg/protocol/coreproto.pyx":512
+ *                     'protocol is in the "failed" state'.format(new_state))
+ *             else:
+ *                 raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                     'cannot switch to state {}; '
+ *                     'another operation ({}) is in progress'.format(
+ */
+    /*else*/ {
+
+      /* "asyncpg/protocol/coreproto.pyx":514
+ *                 raise RuntimeError(
+ *                     'cannot switch to state {}; '
+ *                     'another operation ({}) is in progress'.format(             # <<<<<<<<<<<<<<
+ *                         new_state, self.state))
+ * 
+ */
+      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_cannot_switch_to_state_another_o, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 514, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+
+      /* "asyncpg/protocol/coreproto.pyx":515
+ *                     'cannot switch to state {}; '
+ *                     'another operation ({}) is in progress'.format(
+ *                         new_state, self.state))             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _ensure_connected(self):
+ */
+      __pyx_t_6 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ProtocolState(__pyx_v_new_state); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 515, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_6);
+      __pyx_t_4 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ProtocolState(__pyx_v_self->state); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 515, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_5 = NULL;
+      __pyx_t_7 = 0;
+      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
+        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
+        if (likely(__pyx_t_5)) {
+          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+          __Pyx_INCREF(__pyx_t_5);
+          __Pyx_INCREF(function);
+          __Pyx_DECREF_SET(__pyx_t_3, function);
+          __pyx_t_7 = 1;
+        }
+      }
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_3)) {
+        PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_6, __pyx_t_4};
+        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 514, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
+        PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_6, __pyx_t_4};
+        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 514, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 514, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_8);
+        if (__pyx_t_5) {
+          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
+        }
+        __Pyx_GIVEREF(__pyx_t_6);
+        PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_6);
+        __Pyx_GIVEREF(__pyx_t_4);
+        PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4);
+        __pyx_t_6 = 0;
+        __pyx_t_4 = 0;
+        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 514, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+      }
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+      /* "asyncpg/protocol/coreproto.pyx":512
+ *                     'protocol is in the "failed" state'.format(new_state))
+ *             else:
+ *                 raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                     'cannot switch to state {}; '
+ *                     'another operation ({}) is in progress'.format(
+ */
+      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 512, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_GIVEREF(__pyx_t_2);
+      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
+      __pyx_t_2 = 0;
+      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 512, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __PYX_ERR(4, 512, __pyx_L1_error)
+    }
+    __pyx_L4:;
+    break;
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":488
+ *         self._discard_data = False
+ * 
+ *     cdef _set_state(self, ProtocolState new_state):             # <<<<<<<<<<<<<<
+ *         if new_state == PROTOCOL_IDLE:
+ *             if self.state == PROTOCOL_FAILED:
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":517
+ *                         new_state, self.state))
+ * 
+ *     cdef _ensure_connected(self):             # <<<<<<<<<<<<<<
+ *         if self.con_status != CONNECTION_OK:
+ *             raise RuntimeError('not connected')
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__ensure_connected(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("_ensure_connected", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":518
+ * 
+ *     cdef _ensure_connected(self):
+ *         if self.con_status != CONNECTION_OK:             # <<<<<<<<<<<<<<
+ *             raise RuntimeError('not connected')
+ * 
+ */
+  __pyx_t_1 = ((__pyx_v_self->con_status != __pyx_e_7asyncpg_8protocol_8protocol_CONNECTION_OK) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/coreproto.pyx":519
+ *     cdef _ensure_connected(self):
+ *         if self.con_status != CONNECTION_OK:
+ *             raise RuntimeError('not connected')             # <<<<<<<<<<<<<<
+ * 
+ *     cdef WriteBuffer _build_bind_message(self, str portal_name,
+ */
+    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__64, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 519, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __PYX_ERR(4, 519, __pyx_L1_error)
+
+    /* "asyncpg/protocol/coreproto.pyx":518
+ * 
+ *     cdef _ensure_connected(self):
+ *         if self.con_status != CONNECTION_OK:             # <<<<<<<<<<<<<<
+ *             raise RuntimeError('not connected')
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":517
+ *                         new_state, self.state))
+ * 
+ *     cdef _ensure_connected(self):             # <<<<<<<<<<<<<<
+ *         if self.con_status != CONNECTION_OK:
+ *             raise RuntimeError('not connected')
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._ensure_connected", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":521
+ *             raise RuntimeError('not connected')
+ * 
+ *     cdef WriteBuffer _build_bind_message(self, str portal_name,             # <<<<<<<<<<<<<<
+ *                                          str stmt_name,
+ *                                          WriteBuffer bind_data):
+ */
+
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__build_bind_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_portal_name, PyObject *__pyx_v_stmt_name, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_bind_data) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf = 0;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("_build_bind_message", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":526
+ *         cdef WriteBuffer buf
+ * 
+ *         buf = WriteBuffer.new_message(b'B')             # <<<<<<<<<<<<<<
+ *         buf.write_str(portal_name, self.encoding)
+ *         buf.write_str(stmt_name, self.encoding)
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new_message('B')); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 526, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_buf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":527
+ * 
+ *         buf = WriteBuffer.new_message(b'B')
+ *         buf.write_str(portal_name, self.encoding)             # <<<<<<<<<<<<<<
+ *         buf.write_str(stmt_name, self.encoding)
+ * 
+ */
+  __pyx_t_1 = __pyx_v_self->encoding;
+  __Pyx_INCREF(__pyx_t_1);
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_str(__pyx_v_buf, __pyx_v_portal_name, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 527, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":528
+ *         buf = WriteBuffer.new_message(b'B')
+ *         buf.write_str(portal_name, self.encoding)
+ *         buf.write_str(stmt_name, self.encoding)             # <<<<<<<<<<<<<<
+ * 
+ *         # Arguments
+ */
+  __pyx_t_2 = __pyx_v_self->encoding;
+  __Pyx_INCREF(__pyx_t_2);
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_str(__pyx_v_buf, __pyx_v_stmt_name, ((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 528, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":531
+ * 
+ *         # Arguments
+ *         buf.write_buffer(bind_data)             # <<<<<<<<<<<<<<
+ * 
+ *         buf.end_message()
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_buffer(__pyx_v_buf, __pyx_v_bind_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 531, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":533
+ *         buf.write_buffer(bind_data)
+ * 
+ *         buf.end_message()             # <<<<<<<<<<<<<<
+ *         return buf
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_end_message(__pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 533, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":534
+ * 
+ *         buf.end_message()
+ *         return buf             # <<<<<<<<<<<<<<
+ * 
+ *     # API for subclasses
+ */
+  __Pyx_XDECREF(((PyObject *)__pyx_r));
+  __Pyx_INCREF(((PyObject *)__pyx_v_buf));
+  __pyx_r = __pyx_v_buf;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/coreproto.pyx":521
+ *             raise RuntimeError('not connected')
+ * 
+ *     cdef WriteBuffer _build_bind_message(self, str portal_name,             # <<<<<<<<<<<<<<
+ *                                          str stmt_name,
+ *                                          WriteBuffer bind_data):
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._build_bind_message", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_buf);
+  __Pyx_XGIVEREF((PyObject *)__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":538
+ *     # API for subclasses
+ * 
+ *     cdef _connect(self):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             WriteBuffer buf
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__connect(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf = 0;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_outbuf = 0;
+  PyObject *__pyx_v_param = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  Py_ssize_t __pyx_t_6;
+  Py_ssize_t __pyx_t_7;
+  int __pyx_t_8;
+  int __pyx_t_9;
+  int32_t __pyx_t_10;
+  __Pyx_RefNannySetupContext("_connect", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":543
+ *             WriteBuffer outbuf
+ * 
+ *         if self.con_status != CONNECTION_BAD:             # <<<<<<<<<<<<<<
+ *             raise RuntimeError('already connected')
+ * 
+ */
+  __pyx_t_1 = ((__pyx_v_self->con_status != __pyx_e_7asyncpg_8protocol_8protocol_CONNECTION_BAD) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/coreproto.pyx":544
+ * 
+ *         if self.con_status != CONNECTION_BAD:
+ *             raise RuntimeError('already connected')             # <<<<<<<<<<<<<<
+ * 
+ *         self._set_state(PROTOCOL_AUTH)
+ */
+    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__65, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 544, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __PYX_ERR(4, 544, __pyx_L1_error)
+
+    /* "asyncpg/protocol/coreproto.pyx":543
+ *             WriteBuffer outbuf
+ * 
+ *         if self.con_status != CONNECTION_BAD:             # <<<<<<<<<<<<<<
+ *             raise RuntimeError('already connected')
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":546
+ *             raise RuntimeError('already connected')
+ * 
+ *         self._set_state(PROTOCOL_AUTH)             # <<<<<<<<<<<<<<
+ *         self.con_status = CONNECTION_STARTED
+ * 
+ */
+  __pyx_t_2 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_set_state(__pyx_v_self, __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_AUTH); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 546, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":547
+ * 
+ *         self._set_state(PROTOCOL_AUTH)
+ *         self.con_status = CONNECTION_STARTED             # <<<<<<<<<<<<<<
+ * 
+ *         # Assemble a startup message
+ */
+  __pyx_v_self->con_status = __pyx_e_7asyncpg_8protocol_8protocol_CONNECTION_STARTED;
+
+  /* "asyncpg/protocol/coreproto.pyx":550
+ * 
+ *         # Assemble a startup message
+ *         buf = WriteBuffer()             # <<<<<<<<<<<<<<
+ * 
+ *         # protocol version
+ */
+  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_WriteBuffer), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 550, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_v_buf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_2);
+  __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":553
+ * 
+ *         # protocol version
+ *         buf.write_int16(3)             # <<<<<<<<<<<<<<
+ *         buf.write_int16(0)
+ * 
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int16(__pyx_v_buf, 3); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 553, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":554
+ *         # protocol version
+ *         buf.write_int16(3)
+ *         buf.write_int16(0)             # <<<<<<<<<<<<<<
+ * 
+ *         buf.write_bytestring(b'client_encoding')
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int16(__pyx_v_buf, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 554, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":556
+ *         buf.write_int16(0)
+ * 
+ *         buf.write_bytestring(b'client_encoding')             # <<<<<<<<<<<<<<
+ *         buf.write_bytestring("'{}'".format(self.encoding).encode('ascii'))
+ * 
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_bytestring(__pyx_v_buf, __pyx_n_b_client_encoding); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 556, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":557
+ * 
+ *         buf.write_bytestring(b'client_encoding')
+ *         buf.write_bytestring("'{}'".format(self.encoding).encode('ascii'))             # <<<<<<<<<<<<<<
+ * 
+ *         for param in self.con_args:
+ */
+  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u__66, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 557, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
+    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
+    if (likely(__pyx_t_4)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+      __Pyx_INCREF(__pyx_t_4);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_3, function);
+    }
+  }
+  if (!__pyx_t_4) {
+    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->encoding); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 557, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_3)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_self->encoding};
+      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 557, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_GOTREF(__pyx_t_2);
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_self->encoding};
+      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 557, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_GOTREF(__pyx_t_2);
+    } else
+    #endif
+    {
+      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 557, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
+      __Pyx_INCREF(__pyx_v_self->encoding);
+      __Pyx_GIVEREF(__pyx_v_self->encoding);
+      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_self->encoding);
+      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 557, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_encode); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 557, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__67, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 557, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(4, 557, __pyx_L1_error)
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_bytestring(__pyx_v_buf, ((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 557, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":559
+ *         buf.write_bytestring("'{}'".format(self.encoding).encode('ascii'))
+ * 
+ *         for param in self.con_args:             # <<<<<<<<<<<<<<
+ *             if param == 'password':
+ *                 continue
+ */
+  __pyx_t_6 = 0;
+  if (unlikely(__pyx_v_self->con_args == Py_None)) {
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
+    __PYX_ERR(4, 559, __pyx_L1_error)
+  }
+  __pyx_t_2 = __Pyx_dict_iterator(__pyx_v_self->con_args, 1, ((PyObject *)NULL), (&__pyx_t_7), (&__pyx_t_8)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 559, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __pyx_t_3 = __pyx_t_2;
+  __pyx_t_2 = 0;
+  while (1) {
+    __pyx_t_9 = __Pyx_dict_iter_next(__pyx_t_3, __pyx_t_7, &__pyx_t_6, &__pyx_t_2, NULL, NULL, __pyx_t_8);
+    if (unlikely(__pyx_t_9 == 0)) break;
+    if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(4, 559, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_XDECREF_SET(__pyx_v_param, __pyx_t_2);
+    __pyx_t_2 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":560
+ * 
+ *         for param in self.con_args:
+ *             if param == 'password':             # <<<<<<<<<<<<<<
+ *                 continue
+ *             buf.write_str(param, self.encoding)
+ */
+    __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_param, __pyx_n_u_password, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(4, 560, __pyx_L1_error)
+    if (__pyx_t_1) {
+
+      /* "asyncpg/protocol/coreproto.pyx":561
+ *         for param in self.con_args:
+ *             if param == 'password':
+ *                 continue             # <<<<<<<<<<<<<<
+ *             buf.write_str(param, self.encoding)
+ *             buf.write_str(self.con_args[param], self.encoding)
+ */
+      goto __pyx_L4_continue;
+
+      /* "asyncpg/protocol/coreproto.pyx":560
+ * 
+ *         for param in self.con_args:
+ *             if param == 'password':             # <<<<<<<<<<<<<<
+ *                 continue
+ *             buf.write_str(param, self.encoding)
+ */
+    }
+
+    /* "asyncpg/protocol/coreproto.pyx":562
+ *             if param == 'password':
+ *                 continue
+ *             buf.write_str(param, self.encoding)             # <<<<<<<<<<<<<<
+ *             buf.write_str(self.con_args[param], self.encoding)
+ * 
+ */
+    if (!(likely(PyUnicode_CheckExact(__pyx_v_param))||((__pyx_v_param) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_v_param)->tp_name), 0))) __PYX_ERR(4, 562, __pyx_L1_error)
+    __pyx_t_2 = __pyx_v_self->encoding;
+    __Pyx_INCREF(__pyx_t_2);
+    __pyx_t_5 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_str(__pyx_v_buf, ((PyObject*)__pyx_v_param), ((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 562, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":563
+ *                 continue
+ *             buf.write_str(param, self.encoding)
+ *             buf.write_str(self.con_args[param], self.encoding)             # <<<<<<<<<<<<<<
+ * 
+ *         buf.write_bytestring(b'')
+ */
+    if (unlikely(__pyx_v_self->con_args == Py_None)) {
+      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+      __PYX_ERR(4, 563, __pyx_L1_error)
+    }
+    __pyx_t_5 = __Pyx_PyDict_GetItem(__pyx_v_self->con_args, __pyx_v_param); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 563, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    if (!(likely(PyUnicode_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_5)->tp_name), 0))) __PYX_ERR(4, 563, __pyx_L1_error)
+    __pyx_t_2 = __pyx_v_self->encoding;
+    __Pyx_INCREF(__pyx_t_2);
+    __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_str(__pyx_v_buf, ((PyObject*)__pyx_t_5), ((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 563, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_L4_continue:;
+  }
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":565
+ *             buf.write_str(self.con_args[param], self.encoding)
+ * 
+ *         buf.write_bytestring(b'')             # <<<<<<<<<<<<<<
+ * 
+ *         # Send the buffer
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_bytestring(__pyx_v_buf, __pyx_kp_b__18); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 565, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":568
+ * 
+ *         # Send the buffer
+ *         outbuf = WriteBuffer()             # <<<<<<<<<<<<<<
+ *         outbuf.write_int32(buf.len() + 4)
+ *         outbuf.write_buffer(buf)
+ */
+  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_WriteBuffer), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 568, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_v_outbuf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_3);
+  __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":569
+ *         # Send the buffer
+ *         outbuf = WriteBuffer()
+ *         outbuf.write_int32(buf.len() + 4)             # <<<<<<<<<<<<<<
+ *         outbuf.write_buffer(buf)
+ *         self._write(outbuf)
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_len(__pyx_v_buf); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 569, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_4, 4, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 569, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_10 = __Pyx_PyInt_As_int32_t(__pyx_t_4); if (unlikely((__pyx_t_10 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(4, 569, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_outbuf, __pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 569, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":570
+ *         outbuf = WriteBuffer()
+ *         outbuf.write_int32(buf.len() + 4)
+ *         outbuf.write_buffer(buf)             # <<<<<<<<<<<<<<
+ *         self._write(outbuf)
+ * 
+ */
+  __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_buffer(__pyx_v_outbuf, __pyx_v_buf); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 570, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":571
+ *         outbuf.write_int32(buf.len() + 4)
+ *         outbuf.write_buffer(buf)
+ *         self._write(outbuf)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _prepare(self, str stmt_name, str query):
+ */
+  __pyx_t_4 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_write(__pyx_v_self, ((PyObject *)__pyx_v_outbuf)); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 571, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":538
+ *     # API for subclasses
+ * 
+ *     cdef _connect(self):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             WriteBuffer buf
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._connect", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_buf);
+  __Pyx_XDECREF((PyObject *)__pyx_v_outbuf);
+  __Pyx_XDECREF(__pyx_v_param);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":573
+ *         self._write(outbuf)
+ * 
+ *     cdef _prepare(self, str stmt_name, str query):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             WriteBuffer packet
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__prepare(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_stmt_name, PyObject *__pyx_v_query) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_packet = 0;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  __Pyx_RefNannySetupContext("_prepare", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":578
+ *             WriteBuffer buf
+ * 
+ *         self._ensure_connected()             # <<<<<<<<<<<<<<
+ *         self._set_state(PROTOCOL_PREPARE)
+ * 
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_ensure_connected(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 578, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":579
+ * 
+ *         self._ensure_connected()
+ *         self._set_state(PROTOCOL_PREPARE)             # <<<<<<<<<<<<<<
+ * 
+ *         packet = WriteBuffer.new()
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_set_state(__pyx_v_self, __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_PREPARE); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 579, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":581
+ *         self._set_state(PROTOCOL_PREPARE)
+ * 
+ *         packet = WriteBuffer.new()             # <<<<<<<<<<<<<<
+ * 
+ *         buf = WriteBuffer.new_message(b'P')
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new()); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 581, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_packet = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":583
+ *         packet = WriteBuffer.new()
+ * 
+ *         buf = WriteBuffer.new_message(b'P')             # <<<<<<<<<<<<<<
+ *         buf.write_str(stmt_name, self.encoding)
+ *         buf.write_str(query, self.encoding)
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new_message('P')); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 583, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_buf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":584
+ * 
+ *         buf = WriteBuffer.new_message(b'P')
+ *         buf.write_str(stmt_name, self.encoding)             # <<<<<<<<<<<<<<
+ *         buf.write_str(query, self.encoding)
+ *         buf.write_int16(0)
+ */
+  __pyx_t_1 = __pyx_v_self->encoding;
+  __Pyx_INCREF(__pyx_t_1);
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_str(__pyx_v_buf, __pyx_v_stmt_name, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 584, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":585
+ *         buf = WriteBuffer.new_message(b'P')
+ *         buf.write_str(stmt_name, self.encoding)
+ *         buf.write_str(query, self.encoding)             # <<<<<<<<<<<<<<
+ *         buf.write_int16(0)
+ *         buf.end_message()
+ */
+  __pyx_t_2 = __pyx_v_self->encoding;
+  __Pyx_INCREF(__pyx_t_2);
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_str(__pyx_v_buf, __pyx_v_query, ((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 585, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":586
+ *         buf.write_str(stmt_name, self.encoding)
+ *         buf.write_str(query, self.encoding)
+ *         buf.write_int16(0)             # <<<<<<<<<<<<<<
+ *         buf.end_message()
+ *         packet.write_buffer(buf)
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int16(__pyx_v_buf, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 586, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":587
+ *         buf.write_str(query, self.encoding)
+ *         buf.write_int16(0)
+ *         buf.end_message()             # <<<<<<<<<<<<<<
+ *         packet.write_buffer(buf)
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_end_message(__pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 587, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":588
+ *         buf.write_int16(0)
+ *         buf.end_message()
+ *         packet.write_buffer(buf)             # <<<<<<<<<<<<<<
+ * 
+ *         buf = WriteBuffer.new_message(b'D')
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_buffer(__pyx_v_packet, __pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 588, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":590
+ *         packet.write_buffer(buf)
+ * 
+ *         buf = WriteBuffer.new_message(b'D')             # <<<<<<<<<<<<<<
+ *         buf.write_byte(b'S')
+ *         buf.write_str(stmt_name, self.encoding)
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new_message('D')); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 590, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF_SET(__pyx_v_buf, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_1));
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":591
+ * 
+ *         buf = WriteBuffer.new_message(b'D')
+ *         buf.write_byte(b'S')             # <<<<<<<<<<<<<<
+ *         buf.write_str(stmt_name, self.encoding)
+ *         buf.end_message()
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(__pyx_v_buf, 'S'); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 591, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":592
+ *         buf = WriteBuffer.new_message(b'D')
+ *         buf.write_byte(b'S')
+ *         buf.write_str(stmt_name, self.encoding)             # <<<<<<<<<<<<<<
+ *         buf.end_message()
+ *         packet.write_buffer(buf)
+ */
+  __pyx_t_1 = __pyx_v_self->encoding;
+  __Pyx_INCREF(__pyx_t_1);
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_str(__pyx_v_buf, __pyx_v_stmt_name, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 592, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":593
+ *         buf.write_byte(b'S')
+ *         buf.write_str(stmt_name, self.encoding)
+ *         buf.end_message()             # <<<<<<<<<<<<<<
+ *         packet.write_buffer(buf)
+ * 
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_end_message(__pyx_v_buf); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 593, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":594
+ *         buf.write_str(stmt_name, self.encoding)
+ *         buf.end_message()
+ *         packet.write_buffer(buf)             # <<<<<<<<<<<<<<
+ * 
+ *         packet.write_bytes(SYNC_MESSAGE)
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_buffer(__pyx_v_packet, __pyx_v_buf); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 594, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":596
+ *         packet.write_buffer(buf)
+ * 
+ *         packet.write_bytes(SYNC_MESSAGE)             # <<<<<<<<<<<<<<
+ * 
+ *         self.transport.write(memoryview(packet))
+ */
+  __pyx_t_2 = __pyx_v_7asyncpg_8protocol_8protocol_SYNC_MESSAGE;
+  __Pyx_INCREF(__pyx_t_2);
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_bytes(__pyx_v_packet, ((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 596, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":598
+ *         packet.write_bytes(SYNC_MESSAGE)
+ * 
+ *         self.transport.write(memoryview(packet))             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _send_bind_message(self, str portal_name, str stmt_name,
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->transport, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 598, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 598, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_INCREF(((PyObject *)__pyx_v_packet));
+  __Pyx_GIVEREF(((PyObject *)__pyx_v_packet));
+  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_packet));
+  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_memoryview, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 598, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (!__pyx_t_3) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 598, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_4};
+      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 598, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_4};
+      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 598, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    } else
+    #endif
+    {
+      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 598, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
+      __Pyx_GIVEREF(__pyx_t_4);
+      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
+      __pyx_t_4 = 0;
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 598, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":573
+ *         self._write(outbuf)
+ * 
+ *     cdef _prepare(self, str stmt_name, str query):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             WriteBuffer packet
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._prepare", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_packet);
+  __Pyx_XDECREF((PyObject *)__pyx_v_buf);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":600
+ *         self.transport.write(memoryview(packet))
+ * 
+ *     cdef _send_bind_message(self, str portal_name, str stmt_name,             # <<<<<<<<<<<<<<
+ *                             WriteBuffer bind_data, int32_t limit):
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__send_bind_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_portal_name, PyObject *__pyx_v_stmt_name, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_bind_data, int32_t __pyx_v_limit) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("_send_bind_message", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":605
+ *         cdef WriteBuffer buf
+ * 
+ *         buf = self._build_bind_message(portal_name, stmt_name, bind_data)             # <<<<<<<<<<<<<<
+ *         self._write(buf)
+ * 
+ */
+  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_build_bind_message(__pyx_v_self, __pyx_v_portal_name, __pyx_v_stmt_name, __pyx_v_bind_data)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 605, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_buf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":606
+ * 
+ *         buf = self._build_bind_message(portal_name, stmt_name, bind_data)
+ *         self._write(buf)             # <<<<<<<<<<<<<<
+ * 
+ *         buf = WriteBuffer.new_message(b'E')
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_write(__pyx_v_self, ((PyObject *)__pyx_v_buf)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 606, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":608
+ *         self._write(buf)
+ * 
+ *         buf = WriteBuffer.new_message(b'E')             # <<<<<<<<<<<<<<
+ *         buf.write_str(portal_name, self.encoding)  # name of the portal
+ *         buf.write_int32(limit)  # number of rows to return; 0 - all
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new_message('E')); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 608, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF_SET(__pyx_v_buf, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_1));
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":609
+ * 
+ *         buf = WriteBuffer.new_message(b'E')
+ *         buf.write_str(portal_name, self.encoding)  # name of the portal             # <<<<<<<<<<<<<<
+ *         buf.write_int32(limit)  # number of rows to return; 0 - all
+ *         buf.end_message()
+ */
+  __pyx_t_1 = __pyx_v_self->encoding;
+  __Pyx_INCREF(__pyx_t_1);
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_str(__pyx_v_buf, __pyx_v_portal_name, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 609, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":610
+ *         buf = WriteBuffer.new_message(b'E')
+ *         buf.write_str(portal_name, self.encoding)  # name of the portal
+ *         buf.write_int32(limit)  # number of rows to return; 0 - all             # <<<<<<<<<<<<<<
+ *         buf.end_message()
+ *         self._write(buf)
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, __pyx_v_limit); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 610, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":611
+ *         buf.write_str(portal_name, self.encoding)  # name of the portal
+ *         buf.write_int32(limit)  # number of rows to return; 0 - all
+ *         buf.end_message()             # <<<<<<<<<<<<<<
+ *         self._write(buf)
+ * 
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_end_message(__pyx_v_buf); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 611, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":612
+ *         buf.write_int32(limit)  # number of rows to return; 0 - all
+ *         buf.end_message()
+ *         self._write(buf)             # <<<<<<<<<<<<<<
+ * 
+ *         self._write_sync_message()
+ */
+  __pyx_t_2 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_write(__pyx_v_self, ((PyObject *)__pyx_v_buf)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 612, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":614
+ *         self._write(buf)
+ * 
+ *         self._write_sync_message()             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _bind_execute(self, str portal_name, str stmt_name,
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__write_sync_message(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 614, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":600
+ *         self.transport.write(memoryview(packet))
+ * 
+ *     cdef _send_bind_message(self, str portal_name, str stmt_name,             # <<<<<<<<<<<<<<
+ *                             WriteBuffer bind_data, int32_t limit):
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._send_bind_message", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_buf);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":616
+ *         self._write_sync_message()
+ * 
+ *     cdef _bind_execute(self, str portal_name, str stmt_name,             # <<<<<<<<<<<<<<
+ *                        WriteBuffer bind_data, int32_t limit):
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__bind_execute(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_portal_name, PyObject *__pyx_v_stmt_name, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_bind_data, int32_t __pyx_v_limit) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("_bind_execute", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":621
+ *         cdef WriteBuffer buf
+ * 
+ *         self._ensure_connected()             # <<<<<<<<<<<<<<
+ *         self._set_state(PROTOCOL_BIND_EXECUTE)
+ * 
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_ensure_connected(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 621, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":622
+ * 
+ *         self._ensure_connected()
+ *         self._set_state(PROTOCOL_BIND_EXECUTE)             # <<<<<<<<<<<<<<
+ * 
+ *         self.result = []
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_set_state(__pyx_v_self, __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_BIND_EXECUTE); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 622, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":624
+ *         self._set_state(PROTOCOL_BIND_EXECUTE)
+ * 
+ *         self.result = []             # <<<<<<<<<<<<<<
+ * 
+ *         self._send_bind_message(portal_name, stmt_name, bind_data, limit)
+ */
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 624, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  __Pyx_GOTREF(__pyx_v_self->result);
+  __Pyx_DECREF(__pyx_v_self->result);
+  __pyx_v_self->result = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":626
+ *         self.result = []
+ * 
+ *         self._send_bind_message(portal_name, stmt_name, bind_data, limit)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _bind_execute_many(self, str portal_name, str stmt_name,
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_send_bind_message(__pyx_v_self, __pyx_v_portal_name, __pyx_v_stmt_name, __pyx_v_bind_data, __pyx_v_limit); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 626, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":616
+ *         self._write_sync_message()
+ * 
+ *     cdef _bind_execute(self, str portal_name, str stmt_name,             # <<<<<<<<<<<<<<
+ *                        WriteBuffer bind_data, int32_t limit):
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._bind_execute", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":628
+ *         self._send_bind_message(portal_name, stmt_name, bind_data, limit)
+ * 
+ *     cdef _bind_execute_many(self, str portal_name, str stmt_name,             # <<<<<<<<<<<<<<
+ *                             object bind_data):
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__bind_execute_many(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_portal_name, PyObject *__pyx_v_stmt_name, PyObject *__pyx_v_bind_data) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  int __pyx_t_6;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  __Pyx_RefNannySetupContext("_bind_execute_many", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":633
+ *         cdef WriteBuffer buf
+ * 
+ *         self._ensure_connected()             # <<<<<<<<<<<<<<
+ *         self._set_state(PROTOCOL_BIND_EXECUTE_MANY)
+ * 
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_ensure_connected(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 633, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":634
+ * 
+ *         self._ensure_connected()
+ *         self._set_state(PROTOCOL_BIND_EXECUTE_MANY)             # <<<<<<<<<<<<<<
+ * 
+ *         self.result = None
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_set_state(__pyx_v_self, __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_BIND_EXECUTE_MANY); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 634, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":636
+ *         self._set_state(PROTOCOL_BIND_EXECUTE_MANY)
+ * 
+ *         self.result = None             # <<<<<<<<<<<<<<
+ *         self._discard_data = True
+ *         self._execute_iter = bind_data
+ */
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->result);
+  __Pyx_DECREF(__pyx_v_self->result);
+  __pyx_v_self->result = Py_None;
+
+  /* "asyncpg/protocol/coreproto.pyx":637
+ * 
+ *         self.result = None
+ *         self._discard_data = True             # <<<<<<<<<<<<<<
+ *         self._execute_iter = bind_data
+ *         self._execute_portal_name = portal_name
+ */
+  __pyx_v_self->_discard_data = 1;
+
+  /* "asyncpg/protocol/coreproto.pyx":638
+ *         self.result = None
+ *         self._discard_data = True
+ *         self._execute_iter = bind_data             # <<<<<<<<<<<<<<
+ *         self._execute_portal_name = portal_name
+ *         self._execute_stmt_name = stmt_name
+ */
+  __Pyx_INCREF(__pyx_v_bind_data);
+  __Pyx_GIVEREF(__pyx_v_bind_data);
+  __Pyx_GOTREF(__pyx_v_self->_execute_iter);
+  __Pyx_DECREF(__pyx_v_self->_execute_iter);
+  __pyx_v_self->_execute_iter = __pyx_v_bind_data;
+
+  /* "asyncpg/protocol/coreproto.pyx":639
+ *         self._discard_data = True
+ *         self._execute_iter = bind_data
+ *         self._execute_portal_name = portal_name             # <<<<<<<<<<<<<<
+ *         self._execute_stmt_name = stmt_name
+ * 
+ */
+  __Pyx_INCREF(__pyx_v_portal_name);
+  __Pyx_GIVEREF(__pyx_v_portal_name);
+  __Pyx_GOTREF(__pyx_v_self->_execute_portal_name);
+  __Pyx_DECREF(__pyx_v_self->_execute_portal_name);
+  __pyx_v_self->_execute_portal_name = __pyx_v_portal_name;
+
+  /* "asyncpg/protocol/coreproto.pyx":640
+ *         self._execute_iter = bind_data
+ *         self._execute_portal_name = portal_name
+ *         self._execute_stmt_name = stmt_name             # <<<<<<<<<<<<<<
+ * 
+ *         try:
+ */
+  __Pyx_INCREF(__pyx_v_stmt_name);
+  __Pyx_GIVEREF(__pyx_v_stmt_name);
+  __Pyx_GOTREF(__pyx_v_self->_execute_stmt_name);
+  __Pyx_DECREF(__pyx_v_self->_execute_stmt_name);
+  __pyx_v_self->_execute_stmt_name = __pyx_v_stmt_name;
+
+  /* "asyncpg/protocol/coreproto.pyx":642
+ *         self._execute_stmt_name = stmt_name
+ * 
+ *         try:             # <<<<<<<<<<<<<<
+ *             buf = <WriteBuffer>next(bind_data)
+ *         except StopIteration:
+ */
+  {
+    __Pyx_PyThreadState_declare
+    __Pyx_PyThreadState_assign
+    __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
+    __Pyx_XGOTREF(__pyx_t_2);
+    __Pyx_XGOTREF(__pyx_t_3);
+    __Pyx_XGOTREF(__pyx_t_4);
+    /*try:*/ {
+
+      /* "asyncpg/protocol/coreproto.pyx":643
+ * 
+ *         try:
+ *             buf = <WriteBuffer>next(bind_data)             # <<<<<<<<<<<<<<
+ *         except StopIteration:
+ *             self._push_result()
+ */
+      __pyx_t_1 = __Pyx_PyIter_Next(__pyx_v_bind_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 643, __pyx_L3_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_5 = __pyx_t_1;
+      __Pyx_INCREF(__pyx_t_5);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __pyx_v_buf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_5);
+      __pyx_t_5 = 0;
+
+      /* "asyncpg/protocol/coreproto.pyx":642
+ *         self._execute_stmt_name = stmt_name
+ * 
+ *         try:             # <<<<<<<<<<<<<<
+ *             buf = <WriteBuffer>next(bind_data)
+ *         except StopIteration:
+ */
+    }
+
+    /* "asyncpg/protocol/coreproto.pyx":647
+ *             self._push_result()
+ *         else:
+ *             self._send_bind_message(portal_name, stmt_name, buf, 0)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _execute(self, str portal_name, int32_t limit):
+ */
+    /*else:*/ {
+      __pyx_t_5 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_send_bind_message(__pyx_v_self, __pyx_v_portal_name, __pyx_v_stmt_name, __pyx_v_buf, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 647, __pyx_L5_except_error)
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    }
+    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+    goto __pyx_L10_try_end;
+    __pyx_L3_error:;
+    __Pyx_PyThreadState_assign
+    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":644
+ *         try:
+ *             buf = <WriteBuffer>next(bind_data)
+ *         except StopIteration:             # <<<<<<<<<<<<<<
+ *             self._push_result()
+ *         else:
+ */
+    __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_StopIteration);
+    if (__pyx_t_6) {
+      __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._bind_execute_many", __pyx_clineno, __pyx_lineno, __pyx_filename);
+      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_1, &__pyx_t_7) < 0) __PYX_ERR(4, 644, __pyx_L5_except_error)
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_GOTREF(__pyx_t_7);
+
+      /* "asyncpg/protocol/coreproto.pyx":645
+ *             buf = <WriteBuffer>next(bind_data)
+ *         except StopIteration:
+ *             self._push_result()             # <<<<<<<<<<<<<<
+ *         else:
+ *             self._send_bind_message(portal_name, stmt_name, buf, 0)
+ */
+      __pyx_t_8 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_push_result(__pyx_v_self); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 645, __pyx_L5_except_error)
+      __Pyx_GOTREF(__pyx_t_8);
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      goto __pyx_L4_exception_handled;
+    }
+    goto __pyx_L5_except_error;
+    __pyx_L5_except_error:;
+
+    /* "asyncpg/protocol/coreproto.pyx":642
+ *         self._execute_stmt_name = stmt_name
+ * 
+ *         try:             # <<<<<<<<<<<<<<
+ *             buf = <WriteBuffer>next(bind_data)
+ *         except StopIteration:
+ */
+    __Pyx_PyThreadState_assign
+    __Pyx_XGIVEREF(__pyx_t_2);
+    __Pyx_XGIVEREF(__pyx_t_3);
+    __Pyx_XGIVEREF(__pyx_t_4);
+    __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
+    goto __pyx_L1_error;
+    __pyx_L4_exception_handled:;
+    __Pyx_PyThreadState_assign
+    __Pyx_XGIVEREF(__pyx_t_2);
+    __Pyx_XGIVEREF(__pyx_t_3);
+    __Pyx_XGIVEREF(__pyx_t_4);
+    __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
+    __pyx_L10_try_end:;
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":628
+ *         self._send_bind_message(portal_name, stmt_name, bind_data, limit)
+ * 
+ *     cdef _bind_execute_many(self, str portal_name, str stmt_name,             # <<<<<<<<<<<<<<
+ *                             object bind_data):
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._bind_execute_many", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_buf);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":649
+ *             self._send_bind_message(portal_name, stmt_name, buf, 0)
+ * 
+ *     cdef _execute(self, str portal_name, int32_t limit):             # <<<<<<<<<<<<<<
+ *         cdef WriteBuffer buf
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__execute(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_portal_name, int32_t __pyx_v_limit) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("_execute", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":652
+ *         cdef WriteBuffer buf
+ * 
+ *         self._ensure_connected()             # <<<<<<<<<<<<<<
+ *         self._set_state(PROTOCOL_EXECUTE)
+ * 
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_ensure_connected(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 652, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":653
+ * 
+ *         self._ensure_connected()
+ *         self._set_state(PROTOCOL_EXECUTE)             # <<<<<<<<<<<<<<
+ * 
+ *         self.result = []
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_set_state(__pyx_v_self, __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_EXECUTE); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 653, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":655
+ *         self._set_state(PROTOCOL_EXECUTE)
+ * 
+ *         self.result = []             # <<<<<<<<<<<<<<
+ * 
+ *         buf = WriteBuffer.new_message(b'E')
+ */
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 655, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  __Pyx_GOTREF(__pyx_v_self->result);
+  __Pyx_DECREF(__pyx_v_self->result);
+  __pyx_v_self->result = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":657
+ *         self.result = []
+ * 
+ *         buf = WriteBuffer.new_message(b'E')             # <<<<<<<<<<<<<<
+ *         buf.write_str(portal_name, self.encoding)  # name of the portal
+ *         buf.write_int32(limit)  # number of rows to return; 0 - all
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new_message('E')); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 657, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_buf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":658
+ * 
+ *         buf = WriteBuffer.new_message(b'E')
+ *         buf.write_str(portal_name, self.encoding)  # name of the portal             # <<<<<<<<<<<<<<
+ *         buf.write_int32(limit)  # number of rows to return; 0 - all
+ *         buf.end_message()
+ */
+  __pyx_t_1 = __pyx_v_self->encoding;
+  __Pyx_INCREF(__pyx_t_1);
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_str(__pyx_v_buf, __pyx_v_portal_name, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 658, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":659
+ *         buf = WriteBuffer.new_message(b'E')
+ *         buf.write_str(portal_name, self.encoding)  # name of the portal
+ *         buf.write_int32(limit)  # number of rows to return; 0 - all             # <<<<<<<<<<<<<<
+ *         buf.end_message()
+ *         self._write(buf)
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, __pyx_v_limit); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 659, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":660
+ *         buf.write_str(portal_name, self.encoding)  # name of the portal
+ *         buf.write_int32(limit)  # number of rows to return; 0 - all
+ *         buf.end_message()             # <<<<<<<<<<<<<<
+ *         self._write(buf)
+ *         self._write_sync_message()
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_end_message(__pyx_v_buf); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 660, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":661
+ *         buf.write_int32(limit)  # number of rows to return; 0 - all
+ *         buf.end_message()
+ *         self._write(buf)             # <<<<<<<<<<<<<<
+ *         self._write_sync_message()
+ * 
+ */
+  __pyx_t_2 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_write(__pyx_v_self, ((PyObject *)__pyx_v_buf)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 661, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":662
+ *         buf.end_message()
+ *         self._write(buf)
+ *         self._write_sync_message()             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _bind(self, str portal_name, str stmt_name,
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__write_sync_message(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 662, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":649
+ *             self._send_bind_message(portal_name, stmt_name, buf, 0)
+ * 
+ *     cdef _execute(self, str portal_name, int32_t limit):             # <<<<<<<<<<<<<<
+ *         cdef WriteBuffer buf
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._execute", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_buf);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":664
+ *         self._write_sync_message()
+ * 
+ *     cdef _bind(self, str portal_name, str stmt_name,             # <<<<<<<<<<<<<<
+ *                WriteBuffer bind_data):
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__bind(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_portal_name, PyObject *__pyx_v_stmt_name, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_bind_data) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("_bind", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":669
+ *         cdef WriteBuffer buf
+ * 
+ *         self._ensure_connected()             # <<<<<<<<<<<<<<
+ *         self._set_state(PROTOCOL_BIND)
+ * 
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_ensure_connected(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 669, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":670
+ * 
+ *         self._ensure_connected()
+ *         self._set_state(PROTOCOL_BIND)             # <<<<<<<<<<<<<<
+ * 
+ *         buf = self._build_bind_message(portal_name, stmt_name, bind_data)
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_set_state(__pyx_v_self, __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_BIND); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 670, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":672
+ *         self._set_state(PROTOCOL_BIND)
+ * 
+ *         buf = self._build_bind_message(portal_name, stmt_name, bind_data)             # <<<<<<<<<<<<<<
+ *         self._write(buf)
+ *         self._write_sync_message()
+ */
+  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_build_bind_message(__pyx_v_self, __pyx_v_portal_name, __pyx_v_stmt_name, __pyx_v_bind_data)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 672, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_buf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":673
+ * 
+ *         buf = self._build_bind_message(portal_name, stmt_name, bind_data)
+ *         self._write(buf)             # <<<<<<<<<<<<<<
+ *         self._write_sync_message()
+ * 
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_write(__pyx_v_self, ((PyObject *)__pyx_v_buf)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 673, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":674
+ *         buf = self._build_bind_message(portal_name, stmt_name, bind_data)
+ *         self._write(buf)
+ *         self._write_sync_message()             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _close(self, str name, bint is_portal):
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__write_sync_message(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 674, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":664
+ *         self._write_sync_message()
+ * 
+ *     cdef _bind(self, str portal_name, str stmt_name,             # <<<<<<<<<<<<<<
+ *                WriteBuffer bind_data):
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._bind", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_buf);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":676
+ *         self._write_sync_message()
+ * 
+ *     cdef _close(self, str name, bint is_portal):             # <<<<<<<<<<<<<<
+ *         cdef WriteBuffer buf
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__close(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_name, int __pyx_v_is_portal) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("_close", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":679
+ *         cdef WriteBuffer buf
+ * 
+ *         self._ensure_connected()             # <<<<<<<<<<<<<<
+ *         self._set_state(PROTOCOL_CLOSE_STMT_PORTAL)
+ * 
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_ensure_connected(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 679, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":680
+ * 
+ *         self._ensure_connected()
+ *         self._set_state(PROTOCOL_CLOSE_STMT_PORTAL)             # <<<<<<<<<<<<<<
+ * 
+ *         buf = WriteBuffer.new_message(b'C')
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_set_state(__pyx_v_self, __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_CLOSE_STMT_PORTAL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 680, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":682
+ *         self._set_state(PROTOCOL_CLOSE_STMT_PORTAL)
+ * 
+ *         buf = WriteBuffer.new_message(b'C')             # <<<<<<<<<<<<<<
+ * 
+ *         if is_portal:
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new_message('C')); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 682, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_buf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":684
+ *         buf = WriteBuffer.new_message(b'C')
+ * 
+ *         if is_portal:             # <<<<<<<<<<<<<<
+ *             buf.write_byte(b'P')
+ *         else:
+ */
+  __pyx_t_2 = (__pyx_v_is_portal != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/coreproto.pyx":685
+ * 
+ *         if is_portal:
+ *             buf.write_byte(b'P')             # <<<<<<<<<<<<<<
+ *         else:
+ *             buf.write_byte(b'S')
+ */
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(__pyx_v_buf, 'P'); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 685, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":684
+ *         buf = WriteBuffer.new_message(b'C')
+ * 
+ *         if is_portal:             # <<<<<<<<<<<<<<
+ *             buf.write_byte(b'P')
+ *         else:
+ */
+    goto __pyx_L3;
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":687
+ *             buf.write_byte(b'P')
+ *         else:
+ *             buf.write_byte(b'S')             # <<<<<<<<<<<<<<
+ * 
+ *         buf.write_str(name, self.encoding)
+ */
+  /*else*/ {
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(__pyx_v_buf, 'S'); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 687, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  }
+  __pyx_L3:;
+
+  /* "asyncpg/protocol/coreproto.pyx":689
+ *             buf.write_byte(b'S')
+ * 
+ *         buf.write_str(name, self.encoding)             # <<<<<<<<<<<<<<
+ *         buf.end_message()
+ *         self._write(buf)
+ */
+  __pyx_t_1 = __pyx_v_self->encoding;
+  __Pyx_INCREF(__pyx_t_1);
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_str(__pyx_v_buf, __pyx_v_name, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 689, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":690
+ * 
+ *         buf.write_str(name, self.encoding)
+ *         buf.end_message()             # <<<<<<<<<<<<<<
+ *         self._write(buf)
+ * 
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_end_message(__pyx_v_buf); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 690, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":691
+ *         buf.write_str(name, self.encoding)
+ *         buf.end_message()
+ *         self._write(buf)             # <<<<<<<<<<<<<<
+ * 
+ *         self._write_sync_message()
+ */
+  __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_write(__pyx_v_self, ((PyObject *)__pyx_v_buf)); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 691, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":693
+ *         self._write(buf)
+ * 
+ *         self._write_sync_message()             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _simple_query(self, str query):
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__write_sync_message(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 693, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":676
+ *         self._write_sync_message()
+ * 
+ *     cdef _close(self, str name, bint is_portal):             # <<<<<<<<<<<<<<
+ *         cdef WriteBuffer buf
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._close", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_buf);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":695
+ *         self._write_sync_message()
+ * 
+ *     cdef _simple_query(self, str query):             # <<<<<<<<<<<<<<
+ *         cdef WriteBuffer buf
+ *         self._ensure_connected()
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__simple_query(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_query) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("_simple_query", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":697
+ *     cdef _simple_query(self, str query):
+ *         cdef WriteBuffer buf
+ *         self._ensure_connected()             # <<<<<<<<<<<<<<
+ *         self._set_state(PROTOCOL_SIMPLE_QUERY)
+ *         buf = WriteBuffer.new_message(b'Q')
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_ensure_connected(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 697, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":698
+ *         cdef WriteBuffer buf
+ *         self._ensure_connected()
+ *         self._set_state(PROTOCOL_SIMPLE_QUERY)             # <<<<<<<<<<<<<<
+ *         buf = WriteBuffer.new_message(b'Q')
+ *         buf.write_str(query, self.encoding)
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_set_state(__pyx_v_self, __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_SIMPLE_QUERY); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 698, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":699
+ *         self._ensure_connected()
+ *         self._set_state(PROTOCOL_SIMPLE_QUERY)
+ *         buf = WriteBuffer.new_message(b'Q')             # <<<<<<<<<<<<<<
+ *         buf.write_str(query, self.encoding)
+ *         buf.end_message()
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new_message('Q')); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 699, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_buf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":700
+ *         self._set_state(PROTOCOL_SIMPLE_QUERY)
+ *         buf = WriteBuffer.new_message(b'Q')
+ *         buf.write_str(query, self.encoding)             # <<<<<<<<<<<<<<
+ *         buf.end_message()
+ *         self._write(buf)
+ */
+  __pyx_t_1 = __pyx_v_self->encoding;
+  __Pyx_INCREF(__pyx_t_1);
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_str(__pyx_v_buf, __pyx_v_query, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 700, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":701
+ *         buf = WriteBuffer.new_message(b'Q')
+ *         buf.write_str(query, self.encoding)
+ *         buf.end_message()             # <<<<<<<<<<<<<<
+ *         self._write(buf)
+ * 
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_end_message(__pyx_v_buf); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 701, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":702
+ *         buf.write_str(query, self.encoding)
+ *         buf.end_message()
+ *         self._write(buf)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _terminate(self):
+ */
+  __pyx_t_2 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_write(__pyx_v_self, ((PyObject *)__pyx_v_buf)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 702, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":695
+ *         self._write_sync_message()
+ * 
+ *     cdef _simple_query(self, str query):             # <<<<<<<<<<<<<<
+ *         cdef WriteBuffer buf
+ *         self._ensure_connected()
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._simple_query", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_buf);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":704
+ *         self._write(buf)
+ * 
+ *     cdef _terminate(self):             # <<<<<<<<<<<<<<
+ *         cdef WriteBuffer buf
+ *         self._ensure_connected()
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__terminate(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("_terminate", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":706
+ *     cdef _terminate(self):
+ *         cdef WriteBuffer buf
+ *         self._ensure_connected()             # <<<<<<<<<<<<<<
+ *         buf = WriteBuffer.new_message(b'X')
+ *         buf.end_message()
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_ensure_connected(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 706, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":707
+ *         cdef WriteBuffer buf
+ *         self._ensure_connected()
+ *         buf = WriteBuffer.new_message(b'X')             # <<<<<<<<<<<<<<
+ *         buf.end_message()
+ *         self._write(buf)
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new_message('X')); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 707, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_buf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":708
+ *         self._ensure_connected()
+ *         buf = WriteBuffer.new_message(b'X')
+ *         buf.end_message()             # <<<<<<<<<<<<<<
+ *         self._write(buf)
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_end_message(__pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 708, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":709
+ *         buf = WriteBuffer.new_message(b'X')
+ *         buf.end_message()
+ *         self._write(buf)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _decode_row(self, const char* buf, ssize_t buf_len):
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_write(__pyx_v_self, ((PyObject *)__pyx_v_buf)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 709, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":704
+ *         self._write(buf)
+ * 
+ *     cdef _terminate(self):             # <<<<<<<<<<<<<<
+ *         cdef WriteBuffer buf
+ *         self._ensure_connected()
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._terminate", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_buf);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":711
+ *         self._write(buf)
+ * 
+ *     cdef _decode_row(self, const char* buf, ssize_t buf_len):             # <<<<<<<<<<<<<<
+ *         pass
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__decode_row(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, CYTHON_UNUSED char const *__pyx_v_buf, CYTHON_UNUSED Py_ssize_t __pyx_v_buf_len) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("_decode_row", 0);
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":714
+ *         pass
+ * 
+ *     cdef _set_server_parameter(self, name, val):             # <<<<<<<<<<<<<<
+ *         pass
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__set_server_parameter(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_name, CYTHON_UNUSED PyObject *__pyx_v_val) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("_set_server_parameter", 0);
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":717
+ *         pass
+ * 
+ *     cdef _on_result(self):             # <<<<<<<<<<<<<<
+ *         pass
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__on_result(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("_on_result", 0);
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":720
+ *         pass
+ * 
+ *     cdef _on_notification(self, pid, channel, payload):             # <<<<<<<<<<<<<<
+ *         pass
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__on_notification(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_pid, CYTHON_UNUSED PyObject *__pyx_v_channel, CYTHON_UNUSED PyObject *__pyx_v_payload) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("_on_notification", 0);
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":723
+ *         pass
+ * 
+ *     cdef _on_connection_lost(self, exc):             # <<<<<<<<<<<<<<
+ *         pass
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__on_connection_lost(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_exc) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("_on_connection_lost", 0);
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":728
+ *     # asyncio callbacks:
+ * 
+ *     def data_received(self, data):             # <<<<<<<<<<<<<<
+ *         self.buffer.feed_data(data)
+ *         self._read_server_messages()
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12CoreProtocol_3data_received(PyObject *__pyx_v_self, PyObject *__pyx_v_data); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12CoreProtocol_3data_received(PyObject *__pyx_v_self, PyObject *__pyx_v_data) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("data_received (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12CoreProtocol_2data_received(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self), ((PyObject *)__pyx_v_data));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12CoreProtocol_2data_received(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_data) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("data_received", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":729
+ * 
+ *     def data_received(self, data):
+ *         self.buffer.feed_data(data)             # <<<<<<<<<<<<<<
+ *         self._read_server_messages()
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_feed_data(__pyx_v_self->buffer, __pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 729, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":730
+ *     def data_received(self, data):
+ *         self.buffer.feed_data(data)
+ *         self._read_server_messages()             # <<<<<<<<<<<<<<
+ * 
+ *     def connection_made(self, transport):
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_read_server_messages(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 730, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":728
+ *     # asyncio callbacks:
+ * 
+ *     def data_received(self, data):             # <<<<<<<<<<<<<<
+ *         self.buffer.feed_data(data)
+ *         self._read_server_messages()
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol.data_received", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":732
+ *         self._read_server_messages()
+ * 
+ *     def connection_made(self, transport):             # <<<<<<<<<<<<<<
+ *         self.transport = transport
+ * 
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12CoreProtocol_5connection_made(PyObject *__pyx_v_self, PyObject *__pyx_v_transport); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12CoreProtocol_5connection_made(PyObject *__pyx_v_self, PyObject *__pyx_v_transport) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("connection_made (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12CoreProtocol_4connection_made(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self), ((PyObject *)__pyx_v_transport));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12CoreProtocol_4connection_made(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_transport) {
+  PyObject *__pyx_v_sock = NULL;
+  PyObject *__pyx_v_ex = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_3;
+  int __pyx_t_4;
+  int __pyx_t_5;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  int __pyx_t_9;
+  PyObject *__pyx_t_10 = NULL;
+  PyObject *__pyx_t_11 = NULL;
+  PyObject *__pyx_t_12 = NULL;
+  PyObject *__pyx_t_13 = NULL;
+  PyObject *__pyx_t_14 = NULL;
+  int __pyx_t_15;
+  char const *__pyx_t_16;
+  PyObject *__pyx_t_17 = NULL;
+  PyObject *__pyx_t_18 = NULL;
+  PyObject *__pyx_t_19 = NULL;
+  PyObject *__pyx_t_20 = NULL;
+  PyObject *__pyx_t_21 = NULL;
+  PyObject *__pyx_t_22 = NULL;
+  __Pyx_RefNannySetupContext("connection_made", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":733
+ * 
+ *     def connection_made(self, transport):
+ *         self.transport = transport             # <<<<<<<<<<<<<<
+ * 
+ *         sock = transport.get_extra_info('socket')
+ */
+  __Pyx_INCREF(__pyx_v_transport);
+  __Pyx_GIVEREF(__pyx_v_transport);
+  __Pyx_GOTREF(__pyx_v_self->transport);
+  __Pyx_DECREF(__pyx_v_self->transport);
+  __pyx_v_self->transport = __pyx_v_transport;
+
+  /* "asyncpg/protocol/coreproto.pyx":735
+ *         self.transport = transport
+ * 
+ *         sock = transport.get_extra_info('socket')             # <<<<<<<<<<<<<<
+ *         if (sock is not None and
+ *               (not hasattr(socket, 'AF_UNIX')
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_transport, __pyx_n_s_get_extra_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 735, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__68, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 735, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_sock = __pyx_t_2;
+  __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":736
+ * 
+ *         sock = transport.get_extra_info('socket')
+ *         if (sock is not None and             # <<<<<<<<<<<<<<
+ *               (not hasattr(socket, 'AF_UNIX')
+ *                or sock.family != socket.AF_UNIX)):
+ */
+  __pyx_t_4 = (__pyx_v_sock != Py_None);
+  __pyx_t_5 = (__pyx_t_4 != 0);
+  if (__pyx_t_5) {
+  } else {
+    __pyx_t_3 = __pyx_t_5;
+    goto __pyx_L4_bool_binop_done;
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":737
+ *         sock = transport.get_extra_info('socket')
+ *         if (sock is not None and
+ *               (not hasattr(socket, 'AF_UNIX')             # <<<<<<<<<<<<<<
+ *                or sock.family != socket.AF_UNIX)):
+ *             sock.setsockopt(socket.IPPROTO_TCP,
+ */
+  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_socket); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 737, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_5 = PyObject_HasAttr(__pyx_t_2, __pyx_n_u_AF_UNIX); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(4, 737, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_4 = ((!(__pyx_t_5 != 0)) != 0);
+  if (!__pyx_t_4) {
+  } else {
+    __pyx_t_3 = __pyx_t_4;
+    goto __pyx_L4_bool_binop_done;
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":738
+ *         if (sock is not None and
+ *               (not hasattr(socket, 'AF_UNIX')
+ *                or sock.family != socket.AF_UNIX)):             # <<<<<<<<<<<<<<
+ *             sock.setsockopt(socket.IPPROTO_TCP,
+ *                             socket.TCP_NODELAY, 1)
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_sock, __pyx_n_s_family); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 738, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_socket); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 738, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_AF_UNIX); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 738, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_6);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_6, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 738, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(4, 738, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_3 = __pyx_t_4;
+  __pyx_L4_bool_binop_done:;
+
+  /* "asyncpg/protocol/coreproto.pyx":736
+ * 
+ *         sock = transport.get_extra_info('socket')
+ *         if (sock is not None and             # <<<<<<<<<<<<<<
+ *               (not hasattr(socket, 'AF_UNIX')
+ *                or sock.family != socket.AF_UNIX)):
+ */
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/coreproto.pyx":739
+ *               (not hasattr(socket, 'AF_UNIX')
+ *                or sock.family != socket.AF_UNIX)):
+ *             sock.setsockopt(socket.IPPROTO_TCP,             # <<<<<<<<<<<<<<
+ *                             socket.TCP_NODELAY, 1)
+ * 
+ */
+    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_sock, __pyx_n_s_setsockopt); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 739, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_socket); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 739, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_IPPROTO_TCP); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 739, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_7);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":740
+ *                or sock.family != socket.AF_UNIX)):
+ *             sock.setsockopt(socket.IPPROTO_TCP,
+ *                             socket.TCP_NODELAY, 1)             # <<<<<<<<<<<<<<
+ * 
+ *         try:
+ */
+    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_socket); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 740, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_TCP_NODELAY); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 740, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_8);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_2 = NULL;
+    __pyx_t_9 = 0;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
+      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6);
+      if (likely(__pyx_t_2)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
+        __Pyx_INCREF(__pyx_t_2);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_6, function);
+        __pyx_t_9 = 1;
+      }
+    }
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_6)) {
+      PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_t_7, __pyx_t_8, __pyx_int_1};
+      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 739, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
+      PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_t_7, __pyx_t_8, __pyx_int_1};
+      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 739, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+    } else
+    #endif
+    {
+      __pyx_t_10 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(4, 739, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_10);
+      if (__pyx_t_2) {
+        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2); __pyx_t_2 = NULL;
+      }
+      __Pyx_GIVEREF(__pyx_t_7);
+      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_7);
+      __Pyx_GIVEREF(__pyx_t_8);
+      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_8);
+      __Pyx_INCREF(__pyx_int_1);
+      __Pyx_GIVEREF(__pyx_int_1);
+      PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_int_1);
+      __pyx_t_7 = 0;
+      __pyx_t_8 = 0;
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 739, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":736
+ * 
+ *         sock = transport.get_extra_info('socket')
+ *         if (sock is not None and             # <<<<<<<<<<<<<<
+ *               (not hasattr(socket, 'AF_UNIX')
+ *                or sock.family != socket.AF_UNIX)):
+ */
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":742
+ *                             socket.TCP_NODELAY, 1)
+ * 
+ *         try:             # <<<<<<<<<<<<<<
+ *             self._connect()
+ *         except Exception as ex:
+ */
+  {
+    __Pyx_PyThreadState_declare
+    __Pyx_PyThreadState_assign
+    __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
+    __Pyx_XGOTREF(__pyx_t_11);
+    __Pyx_XGOTREF(__pyx_t_12);
+    __Pyx_XGOTREF(__pyx_t_13);
+    /*try:*/ {
+
+      /* "asyncpg/protocol/coreproto.pyx":743
+ * 
+ *         try:
+ *             self._connect()             # <<<<<<<<<<<<<<
+ *         except Exception as ex:
+ *             transport.abort()
+ */
+      __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_connect(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 743, __pyx_L7_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+      /* "asyncpg/protocol/coreproto.pyx":742
+ *                             socket.TCP_NODELAY, 1)
+ * 
+ *         try:             # <<<<<<<<<<<<<<
+ *             self._connect()
+ *         except Exception as ex:
+ */
+    }
+    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
+    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
+    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
+    goto __pyx_L14_try_end;
+    __pyx_L7_error:;
+    __Pyx_PyThreadState_assign
+    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
+    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/coreproto.pyx":744
+ *         try:
+ *             self._connect()
+ *         except Exception as ex:             # <<<<<<<<<<<<<<
+ *             transport.abort()
+ *             self.con_status = CONNECTION_BAD
+ */
+    __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
+    if (__pyx_t_9) {
+      __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol.connection_made", __pyx_clineno, __pyx_lineno, __pyx_filename);
+      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_6, &__pyx_t_10) < 0) __PYX_ERR(4, 744, __pyx_L9_except_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_GOTREF(__pyx_t_10);
+      __Pyx_INCREF(__pyx_t_6);
+      __pyx_v_ex = __pyx_t_6;
+      /*try:*/ {
+
+        /* "asyncpg/protocol/coreproto.pyx":745
+ *             self._connect()
+ *         except Exception as ex:
+ *             transport.abort()             # <<<<<<<<<<<<<<
+ *             self.con_status = CONNECTION_BAD
+ *             self._set_state(PROTOCOL_FAILED)
+ */
+        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_transport, __pyx_n_s_abort); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 745, __pyx_L20_error)
+        __Pyx_GOTREF(__pyx_t_7);
+        __pyx_t_2 = NULL;
+        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
+          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7);
+          if (likely(__pyx_t_2)) {
+            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
+            __Pyx_INCREF(__pyx_t_2);
+            __Pyx_INCREF(function);
+            __Pyx_DECREF_SET(__pyx_t_7, function);
+          }
+        }
+        if (__pyx_t_2) {
+          __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 745, __pyx_L20_error)
+          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        } else {
+          __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 745, __pyx_L20_error)
+        }
+        __Pyx_GOTREF(__pyx_t_8);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+
+        /* "asyncpg/protocol/coreproto.pyx":746
+ *         except Exception as ex:
+ *             transport.abort()
+ *             self.con_status = CONNECTION_BAD             # <<<<<<<<<<<<<<
+ *             self._set_state(PROTOCOL_FAILED)
+ *             self._on_error(ex)
+ */
+        __pyx_v_self->con_status = __pyx_e_7asyncpg_8protocol_8protocol_CONNECTION_BAD;
+
+        /* "asyncpg/protocol/coreproto.pyx":747
+ *             transport.abort()
+ *             self.con_status = CONNECTION_BAD
+ *             self._set_state(PROTOCOL_FAILED)             # <<<<<<<<<<<<<<
+ *             self._on_error(ex)
+ * 
+ */
+        __pyx_t_8 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_set_state(__pyx_v_self, __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_FAILED); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 747, __pyx_L20_error)
+        __Pyx_GOTREF(__pyx_t_8);
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+
+        /* "asyncpg/protocol/coreproto.pyx":748
+ *             self.con_status = CONNECTION_BAD
+ *             self._set_state(PROTOCOL_FAILED)
+ *             self._on_error(ex)             # <<<<<<<<<<<<<<
+ * 
+ *     def connection_lost(self, exc):
+ */
+        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_error); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 748, __pyx_L20_error)
+        __Pyx_GOTREF(__pyx_t_7);
+        __pyx_t_2 = NULL;
+        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
+          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7);
+          if (likely(__pyx_t_2)) {
+            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
+            __Pyx_INCREF(__pyx_t_2);
+            __Pyx_INCREF(function);
+            __Pyx_DECREF_SET(__pyx_t_7, function);
+          }
+        }
+        if (!__pyx_t_2) {
+          __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_ex); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 748, __pyx_L20_error)
+          __Pyx_GOTREF(__pyx_t_8);
+        } else {
+          #if CYTHON_FAST_PYCALL
+          if (PyFunction_Check(__pyx_t_7)) {
+            PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_ex};
+            __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 748, __pyx_L20_error)
+            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+            __Pyx_GOTREF(__pyx_t_8);
+          } else
+          #endif
+          #if CYTHON_FAST_PYCCALL
+          if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
+            PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_ex};
+            __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 748, __pyx_L20_error)
+            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+            __Pyx_GOTREF(__pyx_t_8);
+          } else
+          #endif
+          {
+            __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(4, 748, __pyx_L20_error)
+            __Pyx_GOTREF(__pyx_t_14);
+            __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_2); __pyx_t_2 = NULL;
+            __Pyx_INCREF(__pyx_v_ex);
+            __Pyx_GIVEREF(__pyx_v_ex);
+            PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_v_ex);
+            __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_14, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 748, __pyx_L20_error)
+            __Pyx_GOTREF(__pyx_t_8);
+            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+          }
+        }
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+      }
+
+      /* "asyncpg/protocol/coreproto.pyx":744
+ *         try:
+ *             self._connect()
+ *         except Exception as ex:             # <<<<<<<<<<<<<<
+ *             transport.abort()
+ *             self.con_status = CONNECTION_BAD
+ */
+      /*finally:*/ {
+        /*normal exit:*/{
+          __Pyx_DECREF(__pyx_v_ex);
+          __pyx_v_ex = NULL;
+          goto __pyx_L21;
+        }
+        /*exception exit:*/{
+          __Pyx_PyThreadState_declare
+          __pyx_L20_error:;
+          __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0;
+          __Pyx_PyThreadState_assign
+          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
+          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+          if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
+          if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
+          __Pyx_XGOTREF(__pyx_t_17);
+          __Pyx_XGOTREF(__pyx_t_18);
+          __Pyx_XGOTREF(__pyx_t_19);
+          __Pyx_XGOTREF(__pyx_t_20);
+          __Pyx_XGOTREF(__pyx_t_21);
+          __Pyx_XGOTREF(__pyx_t_22);
+          __pyx_t_9 = __pyx_lineno; __pyx_t_15 = __pyx_clineno; __pyx_t_16 = __pyx_filename;
+          {
+            __Pyx_DECREF(__pyx_v_ex);
+            __pyx_v_ex = NULL;
+          }
+          __Pyx_PyThreadState_assign
+          if (PY_MAJOR_VERSION >= 3) {
+            __Pyx_XGIVEREF(__pyx_t_20);
+            __Pyx_XGIVEREF(__pyx_t_21);
+            __Pyx_XGIVEREF(__pyx_t_22);
+            __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22);
+          }
+          __Pyx_XGIVEREF(__pyx_t_17);
+          __Pyx_XGIVEREF(__pyx_t_18);
+          __Pyx_XGIVEREF(__pyx_t_19);
+          __Pyx_ErrRestore(__pyx_t_17, __pyx_t_18, __pyx_t_19);
+          __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0;
+          __pyx_lineno = __pyx_t_9; __pyx_clineno = __pyx_t_15; __pyx_filename = __pyx_t_16;
+          goto __pyx_L9_except_error;
+        }
+        __pyx_L21:;
+      }
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      goto __pyx_L8_exception_handled;
+    }
+    goto __pyx_L9_except_error;
+    __pyx_L9_except_error:;
+
+    /* "asyncpg/protocol/coreproto.pyx":742
+ *                             socket.TCP_NODELAY, 1)
+ * 
+ *         try:             # <<<<<<<<<<<<<<
+ *             self._connect()
+ *         except Exception as ex:
+ */
+    __Pyx_PyThreadState_assign
+    __Pyx_XGIVEREF(__pyx_t_11);
+    __Pyx_XGIVEREF(__pyx_t_12);
+    __Pyx_XGIVEREF(__pyx_t_13);
+    __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
+    goto __pyx_L1_error;
+    __pyx_L8_exception_handled:;
+    __Pyx_PyThreadState_assign
+    __Pyx_XGIVEREF(__pyx_t_11);
+    __Pyx_XGIVEREF(__pyx_t_12);
+    __Pyx_XGIVEREF(__pyx_t_13);
+    __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
+    __pyx_L14_try_end:;
+  }
+
+  /* "asyncpg/protocol/coreproto.pyx":732
+ *         self._read_server_messages()
+ * 
+ *     def connection_made(self, transport):             # <<<<<<<<<<<<<<
+ *         self.transport = transport
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_XDECREF(__pyx_t_14);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol.connection_made", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_sock);
+  __Pyx_XDECREF(__pyx_v_ex);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pyx":750
+ *             self._on_error(ex)
+ * 
+ *     def connection_lost(self, exc):             # <<<<<<<<<<<<<<
+ *         self.con_status = CONNECTION_BAD
+ *         self._set_state(PROTOCOL_FAILED)
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12CoreProtocol_7connection_lost(PyObject *__pyx_v_self, PyObject *__pyx_v_exc); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12CoreProtocol_7connection_lost(PyObject *__pyx_v_self, PyObject *__pyx_v_exc) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("connection_lost (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12CoreProtocol_6connection_lost(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self), ((PyObject *)__pyx_v_exc));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12CoreProtocol_6connection_lost(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_exc) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("connection_lost", 0);
+
+  /* "asyncpg/protocol/coreproto.pyx":751
+ * 
+ *     def connection_lost(self, exc):
+ *         self.con_status = CONNECTION_BAD             # <<<<<<<<<<<<<<
+ *         self._set_state(PROTOCOL_FAILED)
+ *         self._on_connection_lost(exc)
+ */
+  __pyx_v_self->con_status = __pyx_e_7asyncpg_8protocol_8protocol_CONNECTION_BAD;
+
+  /* "asyncpg/protocol/coreproto.pyx":752
+ *     def connection_lost(self, exc):
+ *         self.con_status = CONNECTION_BAD
+ *         self._set_state(PROTOCOL_FAILED)             # <<<<<<<<<<<<<<
+ *         self._on_connection_lost(exc)
+ * 
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_set_state(__pyx_v_self, __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_FAILED); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 752, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":753
+ *         self.con_status = CONNECTION_BAD
+ *         self._set_state(PROTOCOL_FAILED)
+ *         self._on_connection_lost(exc)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_on_connection_lost(__pyx_v_self, __pyx_v_exc); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 753, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":750
+ *             self._on_error(ex)
+ * 
+ *     def connection_lost(self, exc):             # <<<<<<<<<<<<<<
+ *         self.con_status = CONNECTION_BAD
+ *         self._set_state(PROTOCOL_FAILED)
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol.connection_lost", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pxd":89
+ *         dict con_args
+ * 
+ *         readonly int32_t backend_pid             # <<<<<<<<<<<<<<
+ *         readonly int32_t backend_secret
+ * 
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12CoreProtocol_11backend_pid_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12CoreProtocol_11backend_pid_1__get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12CoreProtocol_11backend_pid___get__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12CoreProtocol_11backend_pid___get__(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("__get__", 0);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __Pyx_PyInt_From_int32_t(__pyx_v_self->backend_pid); if (unlikely(!__pyx_t_1)) __PYX_ERR(24, 89, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol.backend_pid.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/coreproto.pxd":90
+ * 
+ *         readonly int32_t backend_pid
+ *         readonly int32_t backend_secret             # <<<<<<<<<<<<<<
+ * 
+ *         ## Result
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12CoreProtocol_14backend_secret_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12CoreProtocol_14backend_secret_1__get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12CoreProtocol_14backend_secret___get__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12CoreProtocol_14backend_secret___get__(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("__get__", 0);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __Pyx_PyInt_From_int32_t(__pyx_v_self->backend_secret); if (unlikely(!__pyx_t_1)) __PYX_ERR(24, 90, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol.backend_secret.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/prepared_stmt.pyx":11
+ * cdef class PreparedStatementState:
+ * 
+ *     def __cinit__(self, str name, str query, BaseProtocol protocol):             # <<<<<<<<<<<<<<
+ *         self.name = name
+ *         self.query = query
+ */
+
+/* Python wrapper */
+static int __pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_name = 0;
+  PyObject *__pyx_v_query = 0;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_protocol = 0;
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,&__pyx_n_s_query,&__pyx_n_s_protocol,0};
+    PyObject* values[3] = {0,0,0};
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+        case  1:
+        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_query)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 3, 3, 1); __PYX_ERR(25, 11, __pyx_L3_error)
+        }
+        case  2:
+        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_protocol)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 3, 3, 2); __PYX_ERR(25, 11, __pyx_L3_error)
+        }
+      }
+      if (unlikely(kw_args > 0)) {
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(25, 11, __pyx_L3_error)
+      }
+    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
+      goto __pyx_L5_argtuple_error;
+    } else {
+      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+    }
+    __pyx_v_name = ((PyObject*)values[0]);
+    __pyx_v_query = ((PyObject*)values[1]);
+    __pyx_v_protocol = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)values[2]);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(25, 11, __pyx_L3_error)
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.PreparedStatementState.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return -1;
+  __pyx_L4_argument_unpacking_done:;
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_name), (&PyUnicode_Type), 1, "name", 1))) __PYX_ERR(25, 11, __pyx_L1_error)
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_query), (&PyUnicode_Type), 1, "query", 1))) __PYX_ERR(25, 11, __pyx_L1_error)
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_protocol), __pyx_ptype_7asyncpg_8protocol_8protocol_BaseProtocol, 1, "protocol", 0))) __PYX_ERR(25, 11, __pyx_L1_error)
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState___cinit__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)__pyx_v_self), __pyx_v_name, __pyx_v_query, __pyx_v_protocol);
+
+  /* function exit code */
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static int __pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState___cinit__(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_query, struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_protocol) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("__cinit__", 0);
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":12
+ * 
+ *     def __cinit__(self, str name, str query, BaseProtocol protocol):
+ *         self.name = name             # <<<<<<<<<<<<<<
+ *         self.query = query
+ *         self.protocol = protocol
+ */
+  __Pyx_INCREF(__pyx_v_name);
+  __Pyx_GIVEREF(__pyx_v_name);
+  __Pyx_GOTREF(__pyx_v_self->name);
+  __Pyx_DECREF(__pyx_v_self->name);
+  __pyx_v_self->name = __pyx_v_name;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":13
+ *     def __cinit__(self, str name, str query, BaseProtocol protocol):
+ *         self.name = name
+ *         self.query = query             # <<<<<<<<<<<<<<
+ *         self.protocol = protocol
+ *         self.settings = protocol.settings
+ */
+  __Pyx_INCREF(__pyx_v_query);
+  __Pyx_GIVEREF(__pyx_v_query);
+  __Pyx_GOTREF(__pyx_v_self->query);
+  __Pyx_DECREF(__pyx_v_self->query);
+  __pyx_v_self->query = __pyx_v_query;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":14
+ *         self.name = name
+ *         self.query = query
+ *         self.protocol = protocol             # <<<<<<<<<<<<<<
+ *         self.settings = protocol.settings
+ *         self.row_desc = self.parameters_desc = None
+ */
+  __Pyx_INCREF(((PyObject *)__pyx_v_protocol));
+  __Pyx_GIVEREF(((PyObject *)__pyx_v_protocol));
+  __Pyx_GOTREF(__pyx_v_self->protocol);
+  __Pyx_DECREF(((PyObject *)__pyx_v_self->protocol));
+  __pyx_v_self->protocol = __pyx_v_protocol;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":15
+ *         self.query = query
+ *         self.protocol = protocol
+ *         self.settings = protocol.settings             # <<<<<<<<<<<<<<
+ *         self.row_desc = self.parameters_desc = None
+ *         self.args_codecs = self.rows_codecs = None
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_v_protocol->settings);
+  __Pyx_INCREF(__pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  __Pyx_GOTREF(__pyx_v_self->settings);
+  __Pyx_DECREF(((PyObject *)__pyx_v_self->settings));
+  __pyx_v_self->settings = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":16
+ *         self.protocol = protocol
+ *         self.settings = protocol.settings
+ *         self.row_desc = self.parameters_desc = None             # <<<<<<<<<<<<<<
+ *         self.args_codecs = self.rows_codecs = None
+ *         self.args_num = self.cols_num = 0
+ */
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->row_desc);
+  __Pyx_DECREF(__pyx_v_self->row_desc);
+  __pyx_v_self->row_desc = ((PyObject*)Py_None);
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->parameters_desc);
+  __Pyx_DECREF(__pyx_v_self->parameters_desc);
+  __pyx_v_self->parameters_desc = ((PyObject*)Py_None);
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":17
+ *         self.settings = protocol.settings
+ *         self.row_desc = self.parameters_desc = None
+ *         self.args_codecs = self.rows_codecs = None             # <<<<<<<<<<<<<<
+ *         self.args_num = self.cols_num = 0
+ *         self.cols_desc = None
+ */
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->args_codecs);
+  __Pyx_DECREF(__pyx_v_self->args_codecs);
+  __pyx_v_self->args_codecs = ((PyObject*)Py_None);
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->rows_codecs);
+  __Pyx_DECREF(__pyx_v_self->rows_codecs);
+  __pyx_v_self->rows_codecs = ((PyObject*)Py_None);
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":18
+ *         self.row_desc = self.parameters_desc = None
+ *         self.args_codecs = self.rows_codecs = None
+ *         self.args_num = self.cols_num = 0             # <<<<<<<<<<<<<<
+ *         self.cols_desc = None
+ *         self.closed = False
+ */
+  __pyx_v_self->args_num = 0;
+  __pyx_v_self->cols_num = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":19
+ *         self.args_codecs = self.rows_codecs = None
+ *         self.args_num = self.cols_num = 0
+ *         self.cols_desc = None             # <<<<<<<<<<<<<<
+ *         self.closed = False
+ *         self.refs = 0
+ */
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->cols_desc);
+  __Pyx_DECREF(__pyx_v_self->cols_desc);
+  __pyx_v_self->cols_desc = Py_None;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":20
+ *         self.args_num = self.cols_num = 0
+ *         self.cols_desc = None
+ *         self.closed = False             # <<<<<<<<<<<<<<
+ *         self.refs = 0
+ *         self.buffer = FastReadBuffer.new()
+ */
+  __pyx_v_self->closed = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":21
+ *         self.cols_desc = None
+ *         self.closed = False
+ *         self.refs = 0             # <<<<<<<<<<<<<<
+ *         self.buffer = FastReadBuffer.new()
+ * 
+ */
+  __pyx_v_self->refs = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":22
+ *         self.closed = False
+ *         self.refs = 0
+ *         self.buffer = FastReadBuffer.new()             # <<<<<<<<<<<<<<
+ * 
+ *     def _get_parameters(self):
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_new()); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 22, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  __Pyx_GOTREF(__pyx_v_self->buffer);
+  __Pyx_DECREF(((PyObject *)__pyx_v_self->buffer));
+  __pyx_v_self->buffer = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":11
+ * cdef class PreparedStatementState:
+ * 
+ *     def __cinit__(self, str name, str query, BaseProtocol protocol):             # <<<<<<<<<<<<<<
+ *         self.name = name
+ *         self.query = query
+ */
+
+  /* function exit code */
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.PreparedStatementState.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/prepared_stmt.pyx":24
+ *         self.buffer = FastReadBuffer.new()
+ * 
+ *     def _get_parameters(self):             # <<<<<<<<<<<<<<
+ *         cdef Codec codec
+ * 
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_3_get_parameters(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_3_get_parameters(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("_get_parameters (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_2_get_parameters(((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_2_get_parameters(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_codec = 0;
+  PyObject *__pyx_v_result = NULL;
+  PyObject *__pyx_v_oid = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  Py_ssize_t __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  uint32_t __pyx_t_4;
+  int __pyx_t_5;
+  int __pyx_t_6;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  int __pyx_t_9;
+  PyObject *__pyx_t_10 = NULL;
+  int __pyx_t_11;
+  __Pyx_RefNannySetupContext("_get_parameters", 0);
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":27
+ *         cdef Codec codec
+ * 
+ *         result = []             # <<<<<<<<<<<<<<
+ *         for oid in self.parameters_desc:
+ *             codec = self.settings.get_data_codec(oid)
+ */
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 27, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_result = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":28
+ * 
+ *         result = []
+ *         for oid in self.parameters_desc:             # <<<<<<<<<<<<<<
+ *             codec = self.settings.get_data_codec(oid)
+ *             if codec is None:
+ */
+  if (unlikely(__pyx_v_self->parameters_desc == Py_None)) {
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
+    __PYX_ERR(25, 28, __pyx_L1_error)
+  }
+  __pyx_t_1 = __pyx_v_self->parameters_desc; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
+  for (;;) {
+    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
+    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(25, 28, __pyx_L1_error)
+    #else
+    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(25, 28, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    #endif
+    __Pyx_XDECREF_SET(__pyx_v_oid, __pyx_t_3);
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":29
+ *         result = []
+ *         for oid in self.parameters_desc:
+ *             codec = self.settings.get_data_codec(oid)             # <<<<<<<<<<<<<<
+ *             if codec is None:
+ *                 raise RuntimeError
+ */
+    __pyx_t_4 = __Pyx_PyInt_As_uint32_t(__pyx_v_oid); if (unlikely((__pyx_t_4 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(25, 29, __pyx_L1_error)
+    __pyx_t_3 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_data_codec(__pyx_v_self->settings, __pyx_t_4, 0, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(25, 29, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_XDECREF_SET(__pyx_v_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_3));
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":30
+ *         for oid in self.parameters_desc:
+ *             codec = self.settings.get_data_codec(oid)
+ *             if codec is None:             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError
+ *             result.append(apg_types.Type(
+ */
+    __pyx_t_5 = (((PyObject *)__pyx_v_codec) == Py_None);
+    __pyx_t_6 = (__pyx_t_5 != 0);
+    if (__pyx_t_6) {
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":31
+ *             codec = self.settings.get_data_codec(oid)
+ *             if codec is None:
+ *                 raise RuntimeError             # <<<<<<<<<<<<<<
+ *             result.append(apg_types.Type(
+ *                 oid, codec.name, codec.kind, codec.schema))
+ */
+      __Pyx_Raise(__pyx_builtin_RuntimeError, 0, 0, 0);
+      __PYX_ERR(25, 31, __pyx_L1_error)
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":30
+ *         for oid in self.parameters_desc:
+ *             codec = self.settings.get_data_codec(oid)
+ *             if codec is None:             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError
+ *             result.append(apg_types.Type(
+ */
+    }
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":32
+ *             if codec is None:
+ *                 raise RuntimeError
+ *             result.append(apg_types.Type(             # <<<<<<<<<<<<<<
+ *                 oid, codec.name, codec.kind, codec.schema))
+ * 
+ */
+    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_types); if (unlikely(!__pyx_t_7)) __PYX_ERR(25, 32, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_7);
+    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_Type); if (unlikely(!__pyx_t_8)) __PYX_ERR(25, 32, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_8);
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":33
+ *                 raise RuntimeError
+ *             result.append(apg_types.Type(
+ *                 oid, codec.name, codec.kind, codec.schema))             # <<<<<<<<<<<<<<
+ * 
+ *         return tuple(result)
+ */
+    __pyx_t_7 = NULL;
+    __pyx_t_9 = 0;
+    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
+      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
+      if (likely(__pyx_t_7)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
+        __Pyx_INCREF(__pyx_t_7);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_8, function);
+        __pyx_t_9 = 1;
+      }
+    }
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_8)) {
+      PyObject *__pyx_temp[5] = {__pyx_t_7, __pyx_v_oid, __pyx_v_codec->name, __pyx_v_codec->kind, __pyx_v_codec->schema};
+      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(25, 32, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
+      PyObject *__pyx_temp[5] = {__pyx_t_7, __pyx_v_oid, __pyx_v_codec->name, __pyx_v_codec->kind, __pyx_v_codec->schema};
+      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(25, 32, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+    } else
+    #endif
+    {
+      __pyx_t_10 = PyTuple_New(4+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(25, 32, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_10);
+      if (__pyx_t_7) {
+        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7); __pyx_t_7 = NULL;
+      }
+      __Pyx_INCREF(__pyx_v_oid);
+      __Pyx_GIVEREF(__pyx_v_oid);
+      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_v_oid);
+      __Pyx_INCREF(__pyx_v_codec->name);
+      __Pyx_GIVEREF(__pyx_v_codec->name);
+      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_v_codec->name);
+      __Pyx_INCREF(__pyx_v_codec->kind);
+      __Pyx_GIVEREF(__pyx_v_codec->kind);
+      PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_v_codec->kind);
+      __Pyx_INCREF(__pyx_v_codec->schema);
+      __Pyx_GIVEREF(__pyx_v_codec->schema);
+      PyTuple_SET_ITEM(__pyx_t_10, 3+__pyx_t_9, __pyx_v_codec->schema);
+      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(25, 32, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":32
+ *             if codec is None:
+ *                 raise RuntimeError
+ *             result.append(apg_types.Type(             # <<<<<<<<<<<<<<
+ *                 oid, codec.name, codec.kind, codec.schema))
+ * 
+ */
+    __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(25, 32, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":28
+ * 
+ *         result = []
+ *         for oid in self.parameters_desc:             # <<<<<<<<<<<<<<
+ *             codec = self.settings.get_data_codec(oid)
+ *             if codec is None:
+ */
+  }
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":35
+ *                 oid, codec.name, codec.kind, codec.schema))
+ * 
+ *         return tuple(result)             # <<<<<<<<<<<<<<
+ * 
+ *     def _get_attributes(self):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyList_AsTuple(__pyx_v_result); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 35, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":24
+ *         self.buffer = FastReadBuffer.new()
+ * 
+ *     def _get_parameters(self):             # <<<<<<<<<<<<<<
+ *         cdef Codec codec
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.PreparedStatementState._get_parameters", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
+  __Pyx_XDECREF(__pyx_v_result);
+  __Pyx_XDECREF(__pyx_v_oid);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/prepared_stmt.pyx":37
+ *         return tuple(result)
+ * 
+ *     def _get_attributes(self):             # <<<<<<<<<<<<<<
+ *         cdef Codec codec
+ * 
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_5_get_attributes(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_5_get_attributes(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("_get_attributes (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_4_get_attributes(((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_4_get_attributes(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_codec = 0;
+  PyObject *__pyx_v_result = NULL;
+  PyObject *__pyx_v_d = NULL;
+  PyObject *__pyx_v_name = NULL;
+  PyObject *__pyx_v_oid = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  Py_ssize_t __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  uint32_t __pyx_t_4;
+  int __pyx_t_5;
+  int __pyx_t_6;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  PyObject *__pyx_t_10 = NULL;
+  int __pyx_t_11;
+  PyObject *__pyx_t_12 = NULL;
+  int __pyx_t_13;
+  __Pyx_RefNannySetupContext("_get_attributes", 0);
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":40
+ *         cdef Codec codec
+ * 
+ *         result = []             # <<<<<<<<<<<<<<
+ *         for d in self.row_desc:
+ *             name = d[0]
+ */
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 40, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_result = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":41
+ * 
+ *         result = []
+ *         for d in self.row_desc:             # <<<<<<<<<<<<<<
+ *             name = d[0]
+ *             oid = d[3]
+ */
+  if (unlikely(__pyx_v_self->row_desc == Py_None)) {
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
+    __PYX_ERR(25, 41, __pyx_L1_error)
+  }
+  __pyx_t_1 = __pyx_v_self->row_desc; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
+  for (;;) {
+    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
+    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(25, 41, __pyx_L1_error)
+    #else
+    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(25, 41, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    #endif
+    __Pyx_XDECREF_SET(__pyx_v_d, __pyx_t_3);
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":42
+ *         result = []
+ *         for d in self.row_desc:
+ *             name = d[0]             # <<<<<<<<<<<<<<
+ *             oid = d[3]
+ * 
+ */
+    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_d, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(25, 42, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_3);
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":43
+ *         for d in self.row_desc:
+ *             name = d[0]
+ *             oid = d[3]             # <<<<<<<<<<<<<<
+ * 
+ *             codec = self.settings.get_data_codec(oid)
+ */
+    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_d, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(25, 43, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_XDECREF_SET(__pyx_v_oid, __pyx_t_3);
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":45
+ *             oid = d[3]
+ * 
+ *             codec = self.settings.get_data_codec(oid)             # <<<<<<<<<<<<<<
+ *             if codec is None:
+ *                 raise RuntimeError
+ */
+    __pyx_t_4 = __Pyx_PyInt_As_uint32_t(__pyx_v_oid); if (unlikely((__pyx_t_4 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(25, 45, __pyx_L1_error)
+    __pyx_t_3 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_data_codec(__pyx_v_self->settings, __pyx_t_4, 0, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(25, 45, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_XDECREF_SET(__pyx_v_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_3));
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":46
+ * 
+ *             codec = self.settings.get_data_codec(oid)
+ *             if codec is None:             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError
+ * 
+ */
+    __pyx_t_5 = (((PyObject *)__pyx_v_codec) == Py_None);
+    __pyx_t_6 = (__pyx_t_5 != 0);
+    if (__pyx_t_6) {
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":47
+ *             codec = self.settings.get_data_codec(oid)
+ *             if codec is None:
+ *                 raise RuntimeError             # <<<<<<<<<<<<<<
+ * 
+ *             name = name.decode(self.settings._encoding)
+ */
+      __Pyx_Raise(__pyx_builtin_RuntimeError, 0, 0, 0);
+      __PYX_ERR(25, 47, __pyx_L1_error)
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":46
+ * 
+ *             codec = self.settings.get_data_codec(oid)
+ *             if codec is None:             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError
+ * 
+ */
+    }
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":49
+ *                 raise RuntimeError
+ * 
+ *             name = name.decode(self.settings._encoding)             # <<<<<<<<<<<<<<
+ * 
+ *             result.append(
+ */
+    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_name, __pyx_n_s_decode); if (unlikely(!__pyx_t_7)) __PYX_ERR(25, 49, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_7);
+    __pyx_t_8 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
+      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
+      if (likely(__pyx_t_8)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
+        __Pyx_INCREF(__pyx_t_8);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_7, function);
+      }
+    }
+    if (!__pyx_t_8) {
+      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_self->settings->_encoding); if (unlikely(!__pyx_t_3)) __PYX_ERR(25, 49, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_7)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_self->settings->_encoding};
+        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(25, 49, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_self->settings->_encoding};
+        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(25, 49, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+      } else
+      #endif
+      {
+        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(25, 49, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_9);
+        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
+        __Pyx_INCREF(__pyx_v_self->settings->_encoding);
+        __Pyx_GIVEREF(__pyx_v_self->settings->_encoding);
+        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_self->settings->_encoding);
+        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(25, 49, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_DECREF_SET(__pyx_v_name, __pyx_t_3);
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":52
+ * 
+ *             result.append(
+ *                 apg_types.Attribute(name,             # <<<<<<<<<<<<<<
+ *                     apg_types.Type(oid, codec.name, codec.kind, codec.schema)))
+ * 
+ */
+    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_types); if (unlikely(!__pyx_t_7)) __PYX_ERR(25, 52, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_7);
+    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_Attribute); if (unlikely(!__pyx_t_9)) __PYX_ERR(25, 52, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_9);
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":53
+ *             result.append(
+ *                 apg_types.Attribute(name,
+ *                     apg_types.Type(oid, codec.name, codec.kind, codec.schema)))             # <<<<<<<<<<<<<<
+ * 
+ *         return tuple(result)
+ */
+    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_types); if (unlikely(!__pyx_t_8)) __PYX_ERR(25, 53, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_8);
+    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_Type); if (unlikely(!__pyx_t_10)) __PYX_ERR(25, 53, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_10);
+    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+    __pyx_t_8 = NULL;
+    __pyx_t_11 = 0;
+    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
+      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_10);
+      if (likely(__pyx_t_8)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
+        __Pyx_INCREF(__pyx_t_8);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_10, function);
+        __pyx_t_11 = 1;
+      }
+    }
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_10)) {
+      PyObject *__pyx_temp[5] = {__pyx_t_8, __pyx_v_oid, __pyx_v_codec->name, __pyx_v_codec->kind, __pyx_v_codec->schema};
+      __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_11, 4+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(25, 53, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __Pyx_GOTREF(__pyx_t_7);
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
+      PyObject *__pyx_temp[5] = {__pyx_t_8, __pyx_v_oid, __pyx_v_codec->name, __pyx_v_codec->kind, __pyx_v_codec->schema};
+      __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_11, 4+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(25, 53, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __Pyx_GOTREF(__pyx_t_7);
+    } else
+    #endif
+    {
+      __pyx_t_12 = PyTuple_New(4+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(25, 53, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_12);
+      if (__pyx_t_8) {
+        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_8); __pyx_t_8 = NULL;
+      }
+      __Pyx_INCREF(__pyx_v_oid);
+      __Pyx_GIVEREF(__pyx_v_oid);
+      PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_v_oid);
+      __Pyx_INCREF(__pyx_v_codec->name);
+      __Pyx_GIVEREF(__pyx_v_codec->name);
+      PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_v_codec->name);
+      __Pyx_INCREF(__pyx_v_codec->kind);
+      __Pyx_GIVEREF(__pyx_v_codec->kind);
+      PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_11, __pyx_v_codec->kind);
+      __Pyx_INCREF(__pyx_v_codec->schema);
+      __Pyx_GIVEREF(__pyx_v_codec->schema);
+      PyTuple_SET_ITEM(__pyx_t_12, 3+__pyx_t_11, __pyx_v_codec->schema);
+      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_12, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(25, 53, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+    __pyx_t_10 = NULL;
+    __pyx_t_11 = 0;
+    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
+      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
+      if (likely(__pyx_t_10)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
+        __Pyx_INCREF(__pyx_t_10);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_9, function);
+        __pyx_t_11 = 1;
+      }
+    }
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_9)) {
+      PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_name, __pyx_t_7};
+      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(25, 52, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
+      PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_name, __pyx_t_7};
+      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(25, 52, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    } else
+    #endif
+    {
+      __pyx_t_12 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(25, 52, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_12);
+      if (__pyx_t_10) {
+        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
+      }
+      __Pyx_INCREF(__pyx_v_name);
+      __Pyx_GIVEREF(__pyx_v_name);
+      PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_v_name);
+      __Pyx_GIVEREF(__pyx_t_7);
+      PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_7);
+      __pyx_t_7 = 0;
+      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(25, 52, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":51
+ *             name = name.decode(self.settings._encoding)
+ * 
+ *             result.append(             # <<<<<<<<<<<<<<
+ *                 apg_types.Attribute(name,
+ *                     apg_types.Type(oid, codec.name, codec.kind, codec.schema)))
+ */
+    __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(25, 51, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":41
+ * 
+ *         result = []
+ *         for d in self.row_desc:             # <<<<<<<<<<<<<<
+ *             name = d[0]
+ *             oid = d[3]
+ */
+  }
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":55
+ *                     apg_types.Type(oid, codec.name, codec.kind, codec.schema)))
+ * 
+ *         return tuple(result)             # <<<<<<<<<<<<<<
+ * 
+ *     def _init_types(self):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyList_AsTuple(__pyx_v_result); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 55, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":37
+ *         return tuple(result)
+ * 
+ *     def _get_attributes(self):             # <<<<<<<<<<<<<<
+ *         cdef Codec codec
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_XDECREF(__pyx_t_12);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.PreparedStatementState._get_attributes", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
+  __Pyx_XDECREF(__pyx_v_result);
+  __Pyx_XDECREF(__pyx_v_d);
+  __Pyx_XDECREF(__pyx_v_name);
+  __Pyx_XDECREF(__pyx_v_oid);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/prepared_stmt.pyx":57
+ *         return tuple(result)
+ * 
+ *     def _init_types(self):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             Codec codec
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_7_init_types(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_7_init_types(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("_init_types (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_6_init_types(((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_6_init_types(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_codec = 0;
+  PyObject *__pyx_v_result = 0;
+  PyObject *__pyx_v_p_oid = NULL;
+  PyObject *__pyx_v_rdesc = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  Py_ssize_t __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  uint32_t __pyx_t_5;
+  int __pyx_t_6;
+  int __pyx_t_7;
+  int __pyx_t_8;
+  __Pyx_RefNannySetupContext("_init_types", 0);
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":60
+ *         cdef:
+ *             Codec codec
+ *             set result = set()             # <<<<<<<<<<<<<<
+ * 
+ *         if self.parameters_desc:
+ */
+  __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 60, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_result = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":62
+ *             set result = set()
+ * 
+ *         if self.parameters_desc:             # <<<<<<<<<<<<<<
+ *             for p_oid in self.parameters_desc:
+ *                 codec = self.settings.get_data_codec(<uint32_t>p_oid)
+ */
+  __pyx_t_2 = (__pyx_v_self->parameters_desc != Py_None) && (PyList_GET_SIZE(__pyx_v_self->parameters_desc) != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":63
+ * 
+ *         if self.parameters_desc:
+ *             for p_oid in self.parameters_desc:             # <<<<<<<<<<<<<<
+ *                 codec = self.settings.get_data_codec(<uint32_t>p_oid)
+ *                 if codec is None or not codec.has_encoder():
+ */
+    if (unlikely(__pyx_v_self->parameters_desc == Py_None)) {
+      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
+      __PYX_ERR(25, 63, __pyx_L1_error)
+    }
+    __pyx_t_1 = __pyx_v_self->parameters_desc; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
+    for (;;) {
+      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
+      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(25, 63, __pyx_L1_error)
+      #else
+      __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 63, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      #endif
+      __Pyx_XDECREF_SET(__pyx_v_p_oid, __pyx_t_4);
+      __pyx_t_4 = 0;
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":64
+ *         if self.parameters_desc:
+ *             for p_oid in self.parameters_desc:
+ *                 codec = self.settings.get_data_codec(<uint32_t>p_oid)             # <<<<<<<<<<<<<<
+ *                 if codec is None or not codec.has_encoder():
+ *                     result.add(p_oid)
+ */
+      __pyx_t_5 = __Pyx_PyInt_As_uint32_t(__pyx_v_p_oid); if (unlikely((__pyx_t_5 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(25, 64, __pyx_L1_error)
+      __pyx_t_4 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_data_codec(__pyx_v_self->settings, ((uint32_t)__pyx_t_5), 0, NULL)); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 64, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_XDECREF_SET(__pyx_v_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_4));
+      __pyx_t_4 = 0;
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":65
+ *             for p_oid in self.parameters_desc:
+ *                 codec = self.settings.get_data_codec(<uint32_t>p_oid)
+ *                 if codec is None or not codec.has_encoder():             # <<<<<<<<<<<<<<
+ *                     result.add(p_oid)
+ * 
+ */
+      __pyx_t_6 = (((PyObject *)__pyx_v_codec) == Py_None);
+      __pyx_t_7 = (__pyx_t_6 != 0);
+      if (!__pyx_t_7) {
+      } else {
+        __pyx_t_2 = __pyx_t_7;
+        goto __pyx_L7_bool_binop_done;
+      }
+      __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_has_encoder(__pyx_v_codec); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 65, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(25, 65, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __pyx_t_6 = ((!__pyx_t_7) != 0);
+      __pyx_t_2 = __pyx_t_6;
+      __pyx_L7_bool_binop_done:;
+      if (__pyx_t_2) {
+
+        /* "asyncpg/protocol/prepared_stmt.pyx":66
+ *                 codec = self.settings.get_data_codec(<uint32_t>p_oid)
+ *                 if codec is None or not codec.has_encoder():
+ *                     result.add(p_oid)             # <<<<<<<<<<<<<<
+ * 
+ *         if self.row_desc:
+ */
+        __pyx_t_8 = PySet_Add(__pyx_v_result, __pyx_v_p_oid); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(25, 66, __pyx_L1_error)
+
+        /* "asyncpg/protocol/prepared_stmt.pyx":65
+ *             for p_oid in self.parameters_desc:
+ *                 codec = self.settings.get_data_codec(<uint32_t>p_oid)
+ *                 if codec is None or not codec.has_encoder():             # <<<<<<<<<<<<<<
+ *                     result.add(p_oid)
+ * 
+ */
+      }
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":63
+ * 
+ *         if self.parameters_desc:
+ *             for p_oid in self.parameters_desc:             # <<<<<<<<<<<<<<
+ *                 codec = self.settings.get_data_codec(<uint32_t>p_oid)
+ *                 if codec is None or not codec.has_encoder():
+ */
+    }
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":62
+ *             set result = set()
+ * 
+ *         if self.parameters_desc:             # <<<<<<<<<<<<<<
+ *             for p_oid in self.parameters_desc:
+ *                 codec = self.settings.get_data_codec(<uint32_t>p_oid)
+ */
+  }
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":68
+ *                     result.add(p_oid)
+ * 
+ *         if self.row_desc:             # <<<<<<<<<<<<<<
+ *             for rdesc in self.row_desc:
+ *                 codec = self.settings.get_data_codec(<uint32_t>(rdesc[3]))
+ */
+  __pyx_t_2 = (__pyx_v_self->row_desc != Py_None) && (PyList_GET_SIZE(__pyx_v_self->row_desc) != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":69
+ * 
+ *         if self.row_desc:
+ *             for rdesc in self.row_desc:             # <<<<<<<<<<<<<<
+ *                 codec = self.settings.get_data_codec(<uint32_t>(rdesc[3]))
+ *                 if codec is None or not codec.has_decoder():
+ */
+    if (unlikely(__pyx_v_self->row_desc == Py_None)) {
+      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
+      __PYX_ERR(25, 69, __pyx_L1_error)
+    }
+    __pyx_t_1 = __pyx_v_self->row_desc; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
+    for (;;) {
+      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
+      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(25, 69, __pyx_L1_error)
+      #else
+      __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 69, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      #endif
+      __Pyx_XDECREF_SET(__pyx_v_rdesc, __pyx_t_4);
+      __pyx_t_4 = 0;
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":70
+ *         if self.row_desc:
+ *             for rdesc in self.row_desc:
+ *                 codec = self.settings.get_data_codec(<uint32_t>(rdesc[3]))             # <<<<<<<<<<<<<<
+ *                 if codec is None or not codec.has_decoder():
+ *                     result.add(rdesc[3])
+ */
+      __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_rdesc, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 70, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_5 = __Pyx_PyInt_As_uint32_t(__pyx_t_4); if (unlikely((__pyx_t_5 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(25, 70, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __pyx_t_4 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_data_codec(__pyx_v_self->settings, ((uint32_t)__pyx_t_5), 0, NULL)); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 70, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_XDECREF_SET(__pyx_v_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_4));
+      __pyx_t_4 = 0;
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":71
+ *             for rdesc in self.row_desc:
+ *                 codec = self.settings.get_data_codec(<uint32_t>(rdesc[3]))
+ *                 if codec is None or not codec.has_decoder():             # <<<<<<<<<<<<<<
+ *                     result.add(rdesc[3])
+ * 
+ */
+      __pyx_t_6 = (((PyObject *)__pyx_v_codec) == Py_None);
+      __pyx_t_7 = (__pyx_t_6 != 0);
+      if (!__pyx_t_7) {
+      } else {
+        __pyx_t_2 = __pyx_t_7;
+        goto __pyx_L13_bool_binop_done;
+      }
+      __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_has_decoder(__pyx_v_codec); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 71, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(25, 71, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __pyx_t_6 = ((!__pyx_t_7) != 0);
+      __pyx_t_2 = __pyx_t_6;
+      __pyx_L13_bool_binop_done:;
+      if (__pyx_t_2) {
+
+        /* "asyncpg/protocol/prepared_stmt.pyx":72
+ *                 codec = self.settings.get_data_codec(<uint32_t>(rdesc[3]))
+ *                 if codec is None or not codec.has_decoder():
+ *                     result.add(rdesc[3])             # <<<<<<<<<<<<<<
+ * 
+ *         if len(result):
+ */
+        __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_rdesc, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 72, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        __pyx_t_8 = PySet_Add(__pyx_v_result, __pyx_t_4); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(25, 72, __pyx_L1_error)
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+        /* "asyncpg/protocol/prepared_stmt.pyx":71
+ *             for rdesc in self.row_desc:
+ *                 codec = self.settings.get_data_codec(<uint32_t>(rdesc[3]))
+ *                 if codec is None or not codec.has_decoder():             # <<<<<<<<<<<<<<
+ *                     result.add(rdesc[3])
+ * 
+ */
+      }
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":69
+ * 
+ *         if self.row_desc:
+ *             for rdesc in self.row_desc:             # <<<<<<<<<<<<<<
+ *                 codec = self.settings.get_data_codec(<uint32_t>(rdesc[3]))
+ *                 if codec is None or not codec.has_decoder():
+ */
+    }
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":68
+ *                     result.add(p_oid)
+ * 
+ *         if self.row_desc:             # <<<<<<<<<<<<<<
+ *             for rdesc in self.row_desc:
+ *                 codec = self.settings.get_data_codec(<uint32_t>(rdesc[3]))
+ */
+  }
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":74
+ *                     result.add(rdesc[3])
+ * 
+ *         if len(result):             # <<<<<<<<<<<<<<
+ *             return result
+ *         else:
+ */
+  __pyx_t_3 = PySet_GET_SIZE(__pyx_v_result); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(25, 74, __pyx_L1_error)
+  __pyx_t_2 = (__pyx_t_3 != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":75
+ * 
+ *         if len(result):
+ *             return result             # <<<<<<<<<<<<<<
+ *         else:
+ *             return True
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(__pyx_v_result);
+    __pyx_r = __pyx_v_result;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":74
+ *                     result.add(rdesc[3])
+ * 
+ *         if len(result):             # <<<<<<<<<<<<<<
+ *             return result
+ *         else:
+ */
+  }
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":77
+ *             return result
+ *         else:
+ *             return True             # <<<<<<<<<<<<<<
+ * 
+ *     def attach(self):
+ */
+  /*else*/ {
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(Py_True);
+    __pyx_r = Py_True;
+    goto __pyx_L0;
+  }
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":57
+ *         return tuple(result)
+ * 
+ *     def _init_types(self):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             Codec codec
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.PreparedStatementState._init_types", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
+  __Pyx_XDECREF(__pyx_v_result);
+  __Pyx_XDECREF(__pyx_v_p_oid);
+  __Pyx_XDECREF(__pyx_v_rdesc);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/prepared_stmt.pyx":79
+ *             return True
+ * 
+ *     def attach(self):             # <<<<<<<<<<<<<<
+ *         self.refs += 1
+ * 
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_9attach(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_9attach(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("attach (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_8attach(((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_8attach(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("attach", 0);
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":80
+ * 
+ *     def attach(self):
+ *         self.refs += 1             # <<<<<<<<<<<<<<
+ * 
+ *     def detach(self):
+ */
+  __pyx_v_self->refs = (__pyx_v_self->refs + 1);
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":79
+ *             return True
+ * 
+ *     def attach(self):             # <<<<<<<<<<<<<<
+ *         self.refs += 1
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/prepared_stmt.pyx":82
+ *         self.refs += 1
+ * 
+ *     def detach(self):             # <<<<<<<<<<<<<<
+ *         self.refs -= 1
+ * 
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_11detach(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_11detach(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("detach (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_10detach(((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_10detach(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("detach", 0);
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":83
+ * 
+ *     def detach(self):
+ *         self.refs -= 1             # <<<<<<<<<<<<<<
+ * 
+ *     def mark_closed(self):
+ */
+  __pyx_v_self->refs = (__pyx_v_self->refs - 1);
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":82
+ *         self.refs += 1
+ * 
+ *     def detach(self):             # <<<<<<<<<<<<<<
+ *         self.refs -= 1
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/prepared_stmt.pyx":85
+ *         self.refs -= 1
+ * 
+ *     def mark_closed(self):             # <<<<<<<<<<<<<<
+ *         self.closed = True
+ * 
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_13mark_closed(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_13mark_closed(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("mark_closed (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_12mark_closed(((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_12mark_closed(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("mark_closed", 0);
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":86
+ * 
+ *     def mark_closed(self):
+ *         self.closed = True             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _encode_bind_msg(self, args):
+ */
+  __pyx_v_self->closed = 1;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":85
+ *         self.refs -= 1
+ * 
+ *     def mark_closed(self):             # <<<<<<<<<<<<<<
+ *         self.closed = True
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/prepared_stmt.pyx":88
+ *         self.closed = True
+ * 
+ *     cdef _encode_bind_msg(self, args):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             int idx
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__encode_bind_msg(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self, PyObject *__pyx_v_args) {
+  int __pyx_v_idx;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_writer = 0;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_codec = 0;
+  PyObject *__pyx_v_arg = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  Py_ssize_t __pyx_t_2;
+  int __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  int __pyx_t_8;
+  PyObject *__pyx_t_9 = NULL;
+  int16_t __pyx_t_10;
+  int __pyx_t_11;
+  __Pyx_RefNannySetupContext("_encode_bind_msg", 0);
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":94
+ *             Codec codec
+ * 
+ *         self._ensure_args_encoder()             # <<<<<<<<<<<<<<
+ *         self._ensure_rows_decoder()
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__ensure_args_encoder(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 94, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":95
+ * 
+ *         self._ensure_args_encoder()
+ *         self._ensure_rows_decoder()             # <<<<<<<<<<<<<<
+ * 
+ *         writer = WriteBuffer.new()
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__ensure_rows_decoder(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 95, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":97
+ *         self._ensure_rows_decoder()
+ * 
+ *         writer = WriteBuffer.new()             # <<<<<<<<<<<<<<
+ * 
+ *         if self.args_num != len(args):
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new()); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 97, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_writer = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":99
+ *         writer = WriteBuffer.new()
+ * 
+ *         if self.args_num != len(args):             # <<<<<<<<<<<<<<
+ *             raise ValueError(
+ *                 'number of arguments ({}) does not match '
+ */
+  __pyx_t_2 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(25, 99, __pyx_L1_error)
+  __pyx_t_3 = ((__pyx_v_self->args_num != __pyx_t_2) != 0);
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":102
+ *             raise ValueError(
+ *                 'number of arguments ({}) does not match '
+ *                 'number of parameters ({})'.format(             # <<<<<<<<<<<<<<
+ *                     len(args), self.args_num))
+ * 
+ */
+    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_number_of_arguments_does_not_mat, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 102, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":103
+ *                 'number of arguments ({}) does not match '
+ *                 'number of parameters ({})'.format(
+ *                     len(args), self.args_num))             # <<<<<<<<<<<<<<
+ * 
+ *         if self.have_text_args:
+ */
+    __pyx_t_2 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(25, 103, __pyx_L1_error)
+    __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(25, 103, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = __Pyx_PyInt_From_int16_t(__pyx_v_self->args_num); if (unlikely(!__pyx_t_6)) __PYX_ERR(25, 103, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_7 = NULL;
+    __pyx_t_8 = 0;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
+      if (likely(__pyx_t_7)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+        __Pyx_INCREF(__pyx_t_7);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_4, function);
+        __pyx_t_8 = 1;
+      }
+    }
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_4)) {
+      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_5, __pyx_t_6};
+      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 102, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
+      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_5, __pyx_t_6};
+      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 102, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    } else
+    #endif
+    {
+      __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(25, 102, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_9);
+      if (__pyx_t_7) {
+        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
+      }
+      __Pyx_GIVEREF(__pyx_t_5);
+      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_5);
+      __Pyx_GIVEREF(__pyx_t_6);
+      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_6);
+      __pyx_t_5 = 0;
+      __pyx_t_6 = 0;
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 102, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":100
+ * 
+ *         if self.args_num != len(args):
+ *             raise ValueError(             # <<<<<<<<<<<<<<
+ *                 'number of arguments ({}) does not match '
+ *                 'number of parameters ({})'.format(
+ */
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 100, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_1);
+    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
+    __pyx_t_1 = 0;
+    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 100, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __PYX_ERR(25, 100, __pyx_L1_error)
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":99
+ *         writer = WriteBuffer.new()
+ * 
+ *         if self.args_num != len(args):             # <<<<<<<<<<<<<<
+ *             raise ValueError(
+ *                 'number of arguments ({}) does not match '
+ */
+  }
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":105
+ *                     len(args), self.args_num))
+ * 
+ *         if self.have_text_args:             # <<<<<<<<<<<<<<
+ *             writer.write_int16(self.args_num)
+ *             for idx from 0 <= idx < self.args_num:
+ */
+  __pyx_t_3 = (__pyx_v_self->have_text_args != 0);
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":106
+ * 
+ *         if self.have_text_args:
+ *             writer.write_int16(self.args_num)             # <<<<<<<<<<<<<<
+ *             for idx from 0 <= idx < self.args_num:
+ *                 codec = <Codec>(self.args_codecs[idx])
+ */
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int16(__pyx_v_writer, __pyx_v_self->args_num); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 106, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":107
+ *         if self.have_text_args:
+ *             writer.write_int16(self.args_num)
+ *             for idx from 0 <= idx < self.args_num:             # <<<<<<<<<<<<<<
+ *                 codec = <Codec>(self.args_codecs[idx])
+ *                 writer.write_int16(codec.format)
+ */
+    __pyx_t_10 = __pyx_v_self->args_num;
+    for (__pyx_v_idx = 0; __pyx_v_idx < __pyx_t_10; __pyx_v_idx++) {
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":108
+ *             writer.write_int16(self.args_num)
+ *             for idx from 0 <= idx < self.args_num:
+ *                 codec = <Codec>(self.args_codecs[idx])             # <<<<<<<<<<<<<<
+ *                 writer.write_int16(codec.format)
+ *         else:
+ */
+      if (unlikely(__pyx_v_self->args_codecs == Py_None)) {
+        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+        __PYX_ERR(25, 108, __pyx_L1_error)
+      }
+      __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_self->args_codecs, __pyx_v_idx, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 108, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_4 = __pyx_t_1;
+      __Pyx_INCREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_XDECREF_SET(__pyx_v_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_4));
+      __pyx_t_4 = 0;
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":109
+ *             for idx from 0 <= idx < self.args_num:
+ *                 codec = <Codec>(self.args_codecs[idx])
+ *                 writer.write_int16(codec.format)             # <<<<<<<<<<<<<<
+ *         else:
+ *             # All arguments are in binary format
+ */
+      __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int16(__pyx_v_writer, __pyx_v_codec->format); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 109, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    }
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":105
+ *                     len(args), self.args_num))
+ * 
+ *         if self.have_text_args:             # <<<<<<<<<<<<<<
+ *             writer.write_int16(self.args_num)
+ *             for idx from 0 <= idx < self.args_num:
+ */
+    goto __pyx_L4;
+  }
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":112
+ *         else:
+ *             # All arguments are in binary format
+ *             writer.write_int32(0x00010001)             # <<<<<<<<<<<<<<
+ * 
+ *         writer.write_int16(self.args_num)
+ */
+  /*else*/ {
+    __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_writer, 0x00010001); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 112, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  }
+  __pyx_L4:;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":114
+ *             writer.write_int32(0x00010001)
+ * 
+ *         writer.write_int16(self.args_num)             # <<<<<<<<<<<<<<
+ * 
+ *         for idx from 0 <= idx < self.args_num:
+ */
+  __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int16(__pyx_v_writer, __pyx_v_self->args_num); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 114, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":116
+ *         writer.write_int16(self.args_num)
+ * 
+ *         for idx from 0 <= idx < self.args_num:             # <<<<<<<<<<<<<<
+ *             arg = args[idx]
+ *             if arg is None:
+ */
+  __pyx_t_10 = __pyx_v_self->args_num;
+  for (__pyx_v_idx = 0; __pyx_v_idx < __pyx_t_10; __pyx_v_idx++) {
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":117
+ * 
+ *         for idx from 0 <= idx < self.args_num:
+ *             arg = args[idx]             # <<<<<<<<<<<<<<
+ *             if arg is None:
+ *                 writer.write_int32(-1)
+ */
+    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_args, __pyx_v_idx, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 117, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_XDECREF_SET(__pyx_v_arg, __pyx_t_4);
+    __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":118
+ *         for idx from 0 <= idx < self.args_num:
+ *             arg = args[idx]
+ *             if arg is None:             # <<<<<<<<<<<<<<
+ *                 writer.write_int32(-1)
+ *             else:
+ */
+    __pyx_t_3 = (__pyx_v_arg == Py_None);
+    __pyx_t_11 = (__pyx_t_3 != 0);
+    if (__pyx_t_11) {
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":119
+ *             arg = args[idx]
+ *             if arg is None:
+ *                 writer.write_int32(-1)             # <<<<<<<<<<<<<<
+ *             else:
+ *                 codec = <Codec>(self.args_codecs[idx])
+ */
+      __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_writer, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 119, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":118
+ *         for idx from 0 <= idx < self.args_num:
+ *             arg = args[idx]
+ *             if arg is None:             # <<<<<<<<<<<<<<
+ *                 writer.write_int32(-1)
+ *             else:
+ */
+      goto __pyx_L9;
+    }
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":121
+ *                 writer.write_int32(-1)
+ *             else:
+ *                 codec = <Codec>(self.args_codecs[idx])             # <<<<<<<<<<<<<<
+ *                 codec.encode(self.settings, writer, arg)
+ * 
+ */
+    /*else*/ {
+      if (unlikely(__pyx_v_self->args_codecs == Py_None)) {
+        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+        __PYX_ERR(25, 121, __pyx_L1_error)
+      }
+      __pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_v_self->args_codecs, __pyx_v_idx, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 121, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_1 = __pyx_t_4;
+      __Pyx_INCREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_XDECREF_SET(__pyx_v_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_1));
+      __pyx_t_1 = 0;
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":122
+ *             else:
+ *                 codec = <Codec>(self.args_codecs[idx])
+ *                 codec.encode(self.settings, writer, arg)             # <<<<<<<<<<<<<<
+ * 
+ *         if self.have_text_cols:
+ */
+      __pyx_t_1 = ((PyObject *)__pyx_v_self->settings);
+      __Pyx_INCREF(__pyx_t_1);
+      __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode(__pyx_v_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *)__pyx_t_1), __pyx_v_writer, __pyx_v_arg); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 122, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    }
+    __pyx_L9:;
+  }
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":124
+ *                 codec.encode(self.settings, writer, arg)
+ * 
+ *         if self.have_text_cols:             # <<<<<<<<<<<<<<
+ *             writer.write_int16(self.cols_num)
+ *             for idx from 0 <= idx < self.cols_num:
+ */
+  __pyx_t_11 = (__pyx_v_self->have_text_cols != 0);
+  if (__pyx_t_11) {
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":125
+ * 
+ *         if self.have_text_cols:
+ *             writer.write_int16(self.cols_num)             # <<<<<<<<<<<<<<
+ *             for idx from 0 <= idx < self.cols_num:
+ *                 codec = <Codec>(self.rows_codecs[idx])
+ */
+    __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int16(__pyx_v_writer, __pyx_v_self->cols_num); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 125, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":126
+ *         if self.have_text_cols:
+ *             writer.write_int16(self.cols_num)
+ *             for idx from 0 <= idx < self.cols_num:             # <<<<<<<<<<<<<<
+ *                 codec = <Codec>(self.rows_codecs[idx])
+ *                 writer.write_int16(codec.format)
+ */
+    __pyx_t_10 = __pyx_v_self->cols_num;
+    for (__pyx_v_idx = 0; __pyx_v_idx < __pyx_t_10; __pyx_v_idx++) {
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":127
+ *             writer.write_int16(self.cols_num)
+ *             for idx from 0 <= idx < self.cols_num:
+ *                 codec = <Codec>(self.rows_codecs[idx])             # <<<<<<<<<<<<<<
+ *                 writer.write_int16(codec.format)
+ *         else:
+ */
+      if (unlikely(__pyx_v_self->rows_codecs == Py_None)) {
+        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+        __PYX_ERR(25, 127, __pyx_L1_error)
+      }
+      __pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_v_self->rows_codecs, __pyx_v_idx, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 127, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_1 = __pyx_t_4;
+      __Pyx_INCREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_XDECREF_SET(__pyx_v_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_1));
+      __pyx_t_1 = 0;
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":128
+ *             for idx from 0 <= idx < self.cols_num:
+ *                 codec = <Codec>(self.rows_codecs[idx])
+ *                 writer.write_int16(codec.format)             # <<<<<<<<<<<<<<
+ *         else:
+ *             # All columns are in binary format
+ */
+      __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int16(__pyx_v_writer, __pyx_v_codec->format); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 128, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    }
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":124
+ *                 codec.encode(self.settings, writer, arg)
+ * 
+ *         if self.have_text_cols:             # <<<<<<<<<<<<<<
+ *             writer.write_int16(self.cols_num)
+ *             for idx from 0 <= idx < self.cols_num:
+ */
+    goto __pyx_L10;
+  }
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":131
+ *         else:
+ *             # All columns are in binary format
+ *             writer.write_int32(0x00010001)             # <<<<<<<<<<<<<<
+ * 
+ *         return writer
+ */
+  /*else*/ {
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_writer, 0x00010001); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 131, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  }
+  __pyx_L10:;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":133
+ *             writer.write_int32(0x00010001)
+ * 
+ *         return writer             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _ensure_rows_decoder(self):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(((PyObject *)__pyx_v_writer));
+  __pyx_r = ((PyObject *)__pyx_v_writer);
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":88
+ *         self.closed = True
+ * 
+ *     cdef _encode_bind_msg(self, args):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             int idx
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.PreparedStatementState._encode_bind_msg", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_writer);
+  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
+  __Pyx_XDECREF(__pyx_v_arg);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/prepared_stmt.pyx":135
+ *         return writer
+ * 
+ *     cdef _ensure_rows_decoder(self):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             list cols_names
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__ensure_rows_decoder(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self) {
+  PyObject *__pyx_v_cols_names = 0;
+  PyObject *__pyx_v_cols_mapping = 0;
+  PyObject *__pyx_v_row = 0;
+  int __pyx_v_oid;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_codec = 0;
+  PyObject *__pyx_v_codecs = 0;
+  long __pyx_v_i;
+  PyObject *__pyx_v_col_name = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  int16_t __pyx_t_6;
+  PyObject *__pyx_t_7 = NULL;
+  int __pyx_t_8;
+  int __pyx_t_9;
+  int __pyx_t_10;
+  PyObject *__pyx_t_11 = NULL;
+  __Pyx_RefNannySetupContext("_ensure_rows_decoder", 0);
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":144
+ *             list codecs
+ * 
+ *         if self.cols_desc is not None:             # <<<<<<<<<<<<<<
+ *             return
+ * 
+ */
+  __pyx_t_1 = (__pyx_v_self->cols_desc != Py_None);
+  __pyx_t_2 = (__pyx_t_1 != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":145
+ * 
+ *         if self.cols_desc is not None:
+ *             return             # <<<<<<<<<<<<<<
+ * 
+ *         if self.cols_num == 0:
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":144
+ *             list codecs
+ * 
+ *         if self.cols_desc is not None:             # <<<<<<<<<<<<<<
+ *             return
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":147
+ *             return
+ * 
+ *         if self.cols_num == 0:             # <<<<<<<<<<<<<<
+ *             self.cols_desc = record.ApgRecordDesc_New({}, ())
+ *             return
+ */
+  __pyx_t_2 = ((__pyx_v_self->cols_num == 0) != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":148
+ * 
+ *         if self.cols_num == 0:
+ *             self.cols_desc = record.ApgRecordDesc_New({}, ())             # <<<<<<<<<<<<<<
+ *             return
+ * 
+ */
+    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(25, 148, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_4 = ApgRecordDesc_New(__pyx_t_3, __pyx_empty_tuple); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 148, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_GIVEREF(__pyx_t_4);
+    __Pyx_GOTREF(__pyx_v_self->cols_desc);
+    __Pyx_DECREF(__pyx_v_self->cols_desc);
+    __pyx_v_self->cols_desc = __pyx_t_4;
+    __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":149
+ *         if self.cols_num == 0:
+ *             self.cols_desc = record.ApgRecordDesc_New({}, ())
+ *             return             # <<<<<<<<<<<<<<
+ * 
+ *         cols_mapping = collections.OrderedDict()
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":147
+ *             return
+ * 
+ *         if self.cols_num == 0:             # <<<<<<<<<<<<<<
+ *             self.cols_desc = record.ApgRecordDesc_New({}, ())
+ *             return
+ */
+  }
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":151
+ *             return
+ * 
+ *         cols_mapping = collections.OrderedDict()             # <<<<<<<<<<<<<<
+ *         cols_names = []
+ *         codecs = []
+ */
+  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_collections); if (unlikely(!__pyx_t_3)) __PYX_ERR(25, 151, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_OrderedDict); if (unlikely(!__pyx_t_5)) __PYX_ERR(25, 151, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = NULL;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_5, function);
+    }
+  }
+  if (__pyx_t_3) {
+    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 151, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  } else {
+    __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 151, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __pyx_v_cols_mapping = __pyx_t_4;
+  __pyx_t_4 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":152
+ * 
+ *         cols_mapping = collections.OrderedDict()
+ *         cols_names = []             # <<<<<<<<<<<<<<
+ *         codecs = []
+ *         for i from 0 <= i < self.cols_num:
+ */
+  __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 152, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_v_cols_names = ((PyObject*)__pyx_t_4);
+  __pyx_t_4 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":153
+ *         cols_mapping = collections.OrderedDict()
+ *         cols_names = []
+ *         codecs = []             # <<<<<<<<<<<<<<
+ *         for i from 0 <= i < self.cols_num:
+ *             row = self.row_desc[i]
+ */
+  __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 153, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_v_codecs = ((PyObject*)__pyx_t_4);
+  __pyx_t_4 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":154
+ *         cols_names = []
+ *         codecs = []
+ *         for i from 0 <= i < self.cols_num:             # <<<<<<<<<<<<<<
+ *             row = self.row_desc[i]
+ *             col_name = row[0].decode(self.settings._encoding)
+ */
+  __pyx_t_6 = __pyx_v_self->cols_num;
+  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_6; __pyx_v_i++) {
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":155
+ *         codecs = []
+ *         for i from 0 <= i < self.cols_num:
+ *             row = self.row_desc[i]             # <<<<<<<<<<<<<<
+ *             col_name = row[0].decode(self.settings._encoding)
+ *             cols_mapping[col_name] = i
+ */
+    if (unlikely(__pyx_v_self->row_desc == Py_None)) {
+      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+      __PYX_ERR(25, 155, __pyx_L1_error)
+    }
+    __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_v_self->row_desc, __pyx_v_i, long, 1, __Pyx_PyInt_From_long, 1, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 155, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    if (!(likely(PyTuple_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(25, 155, __pyx_L1_error)
+    __Pyx_XDECREF_SET(__pyx_v_row, ((PyObject*)__pyx_t_4));
+    __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":156
+ *         for i from 0 <= i < self.cols_num:
+ *             row = self.row_desc[i]
+ *             col_name = row[0].decode(self.settings._encoding)             # <<<<<<<<<<<<<<
+ *             cols_mapping[col_name] = i
+ *             cols_names.append(col_name)
+ */
+    if (unlikely(__pyx_v_row == Py_None)) {
+      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+      __PYX_ERR(25, 156, __pyx_L1_error)
+    }
+    __pyx_t_5 = __Pyx_GetItemInt_Tuple(__pyx_v_row, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(25, 156, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_decode); if (unlikely(!__pyx_t_3)) __PYX_ERR(25, 156, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_5 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
+      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
+      if (likely(__pyx_t_5)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+        __Pyx_INCREF(__pyx_t_5);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_3, function);
+      }
+    }
+    if (!__pyx_t_5) {
+      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->settings->_encoding); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 156, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_3)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_self->settings->_encoding};
+        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 156, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_GOTREF(__pyx_t_4);
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_self->settings->_encoding};
+        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 156, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_GOTREF(__pyx_t_4);
+      } else
+      #endif
+      {
+        __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(25, 156, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
+        __Pyx_INCREF(__pyx_v_self->settings->_encoding);
+        __Pyx_GIVEREF(__pyx_v_self->settings->_encoding);
+        PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_self->settings->_encoding);
+        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 156, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_XDECREF_SET(__pyx_v_col_name, __pyx_t_4);
+    __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":157
+ *             row = self.row_desc[i]
+ *             col_name = row[0].decode(self.settings._encoding)
+ *             cols_mapping[col_name] = i             # <<<<<<<<<<<<<<
+ *             cols_names.append(col_name)
+ *             oid = row[3]
+ */
+    __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 157, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    if (unlikely(PyObject_SetItem(__pyx_v_cols_mapping, __pyx_v_col_name, __pyx_t_4) < 0)) __PYX_ERR(25, 157, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":158
+ *             col_name = row[0].decode(self.settings._encoding)
+ *             cols_mapping[col_name] = i
+ *             cols_names.append(col_name)             # <<<<<<<<<<<<<<
+ *             oid = row[3]
+ *             codec = self.settings.get_data_codec(<uint32_t>oid)
+ */
+    __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_cols_names, __pyx_v_col_name); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(25, 158, __pyx_L1_error)
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":159
+ *             cols_mapping[col_name] = i
+ *             cols_names.append(col_name)
+ *             oid = row[3]             # <<<<<<<<<<<<<<
+ *             codec = self.settings.get_data_codec(<uint32_t>oid)
+ *             if codec is None or not codec.has_decoder():
+ */
+    if (unlikely(__pyx_v_row == Py_None)) {
+      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+      __PYX_ERR(25, 159, __pyx_L1_error)
+    }
+    __pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_v_row, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 159, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(25, 159, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_v_oid = __pyx_t_9;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":160
+ *             cols_names.append(col_name)
+ *             oid = row[3]
+ *             codec = self.settings.get_data_codec(<uint32_t>oid)             # <<<<<<<<<<<<<<
+ *             if codec is None or not codec.has_decoder():
+ *                 raise RuntimeError('no decoder for OID {}'.format(oid))
+ */
+    __pyx_t_4 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_data_codec(__pyx_v_self->settings, ((uint32_t)__pyx_v_oid), 0, NULL)); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 160, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_XDECREF_SET(__pyx_v_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_4));
+    __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":161
+ *             oid = row[3]
+ *             codec = self.settings.get_data_codec(<uint32_t>oid)
+ *             if codec is None or not codec.has_decoder():             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError('no decoder for OID {}'.format(oid))
+ *             if not codec.is_binary():
+ */
+    __pyx_t_1 = (((PyObject *)__pyx_v_codec) == Py_None);
+    __pyx_t_10 = (__pyx_t_1 != 0);
+    if (!__pyx_t_10) {
+    } else {
+      __pyx_t_2 = __pyx_t_10;
+      goto __pyx_L8_bool_binop_done;
+    }
+    __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_has_decoder(__pyx_v_codec); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 161, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(25, 161, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_1 = ((!__pyx_t_10) != 0);
+    __pyx_t_2 = __pyx_t_1;
+    __pyx_L8_bool_binop_done:;
+    if (__pyx_t_2) {
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":162
+ *             codec = self.settings.get_data_codec(<uint32_t>oid)
+ *             if codec is None or not codec.has_decoder():
+ *                 raise RuntimeError('no decoder for OID {}'.format(oid))             # <<<<<<<<<<<<<<
+ *             if not codec.is_binary():
+ *                 self.have_text_cols = True
+ */
+      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_no_decoder_for_OID, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(25, 162, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_oid); if (unlikely(!__pyx_t_7)) __PYX_ERR(25, 162, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_7);
+      __pyx_t_5 = NULL;
+      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
+        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
+        if (likely(__pyx_t_5)) {
+          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+          __Pyx_INCREF(__pyx_t_5);
+          __Pyx_INCREF(function);
+          __Pyx_DECREF_SET(__pyx_t_3, function);
+        }
+      }
+      if (!__pyx_t_5) {
+        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 162, __pyx_L1_error)
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __Pyx_GOTREF(__pyx_t_4);
+      } else {
+        #if CYTHON_FAST_PYCALL
+        if (PyFunction_Check(__pyx_t_3)) {
+          PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_7};
+          __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 162, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+          __Pyx_GOTREF(__pyx_t_4);
+          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        } else
+        #endif
+        #if CYTHON_FAST_PYCCALL
+        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
+          PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_7};
+          __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 162, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+          __Pyx_GOTREF(__pyx_t_4);
+          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        } else
+        #endif
+        {
+          __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(25, 162, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_11);
+          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_5); __pyx_t_5 = NULL;
+          __Pyx_GIVEREF(__pyx_t_7);
+          PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_7);
+          __pyx_t_7 = 0;
+          __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 162, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_4);
+          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+        }
+      }
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(25, 162, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_GIVEREF(__pyx_t_4);
+      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
+      __pyx_t_4 = 0;
+      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 162, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __PYX_ERR(25, 162, __pyx_L1_error)
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":161
+ *             oid = row[3]
+ *             codec = self.settings.get_data_codec(<uint32_t>oid)
+ *             if codec is None or not codec.has_decoder():             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError('no decoder for OID {}'.format(oid))
+ *             if not codec.is_binary():
+ */
+    }
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":163
+ *             if codec is None or not codec.has_decoder():
+ *                 raise RuntimeError('no decoder for OID {}'.format(oid))
+ *             if not codec.is_binary():             # <<<<<<<<<<<<<<
+ *                 self.have_text_cols = True
+ * 
+ */
+    __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_is_binary(__pyx_v_codec); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 163, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(25, 163, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_1 = ((!__pyx_t_2) != 0);
+    if (__pyx_t_1) {
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":164
+ *                 raise RuntimeError('no decoder for OID {}'.format(oid))
+ *             if not codec.is_binary():
+ *                 self.have_text_cols = True             # <<<<<<<<<<<<<<
+ * 
+ *             codecs.append(codec)
+ */
+      __pyx_v_self->have_text_cols = 1;
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":163
+ *             if codec is None or not codec.has_decoder():
+ *                 raise RuntimeError('no decoder for OID {}'.format(oid))
+ *             if not codec.is_binary():             # <<<<<<<<<<<<<<
+ *                 self.have_text_cols = True
+ * 
+ */
+    }
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":166
+ *                 self.have_text_cols = True
+ * 
+ *             codecs.append(codec)             # <<<<<<<<<<<<<<
+ * 
+ *         self.cols_desc = record.ApgRecordDesc_New(
+ */
+    __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_codecs, ((PyObject *)__pyx_v_codec)); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(25, 166, __pyx_L1_error)
+  }
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":169
+ * 
+ *         self.cols_desc = record.ApgRecordDesc_New(
+ *             cols_mapping, tuple(cols_names))             # <<<<<<<<<<<<<<
+ * 
+ *         self.rows_codecs = tuple(codecs)
+ */
+  __pyx_t_4 = PyList_AsTuple(__pyx_v_cols_names); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 169, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":168
+ *             codecs.append(codec)
+ * 
+ *         self.cols_desc = record.ApgRecordDesc_New(             # <<<<<<<<<<<<<<
+ *             cols_mapping, tuple(cols_names))
+ * 
+ */
+  __pyx_t_3 = ApgRecordDesc_New(__pyx_v_cols_mapping, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(25, 168, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __Pyx_GIVEREF(__pyx_t_3);
+  __Pyx_GOTREF(__pyx_v_self->cols_desc);
+  __Pyx_DECREF(__pyx_v_self->cols_desc);
+  __pyx_v_self->cols_desc = __pyx_t_3;
+  __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":171
+ *             cols_mapping, tuple(cols_names))
+ * 
+ *         self.rows_codecs = tuple(codecs)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _ensure_args_encoder(self):
+ */
+  __pyx_t_3 = PyList_AsTuple(__pyx_v_codecs); if (unlikely(!__pyx_t_3)) __PYX_ERR(25, 171, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_3);
+  __Pyx_GOTREF(__pyx_v_self->rows_codecs);
+  __Pyx_DECREF(__pyx_v_self->rows_codecs);
+  __pyx_v_self->rows_codecs = ((PyObject*)__pyx_t_3);
+  __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":135
+ *         return writer
+ * 
+ *     cdef _ensure_rows_decoder(self):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             list cols_names
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_11);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.PreparedStatementState._ensure_rows_decoder", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_cols_names);
+  __Pyx_XDECREF(__pyx_v_cols_mapping);
+  __Pyx_XDECREF(__pyx_v_row);
+  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
+  __Pyx_XDECREF(__pyx_v_codecs);
+  __Pyx_XDECREF(__pyx_v_col_name);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/prepared_stmt.pyx":173
+ *         self.rows_codecs = tuple(codecs)
+ * 
+ *     cdef _ensure_args_encoder(self):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             int p_oid
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__ensure_args_encoder(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self) {
+  int __pyx_v_p_oid;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_codec = 0;
+  PyObject *__pyx_v_codecs = 0;
+  long __pyx_v_i;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  int __pyx_t_3;
+  int __pyx_t_4;
+  int16_t __pyx_t_5;
+  int __pyx_t_6;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  PyObject *__pyx_t_10 = NULL;
+  int __pyx_t_11;
+  __Pyx_RefNannySetupContext("_ensure_args_encoder", 0);
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":177
+ *             int p_oid
+ *             Codec codec
+ *             list codecs = []             # <<<<<<<<<<<<<<
+ * 
+ *         if self.args_num == 0 or self.args_codecs is not None:
+ */
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 177, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_codecs = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":179
+ *             list codecs = []
+ * 
+ *         if self.args_num == 0 or self.args_codecs is not None:             # <<<<<<<<<<<<<<
+ *             return
+ * 
+ */
+  __pyx_t_3 = ((__pyx_v_self->args_num == 0) != 0);
+  if (!__pyx_t_3) {
+  } else {
+    __pyx_t_2 = __pyx_t_3;
+    goto __pyx_L4_bool_binop_done;
+  }
+  __pyx_t_3 = (__pyx_v_self->args_codecs != ((PyObject*)Py_None));
+  __pyx_t_4 = (__pyx_t_3 != 0);
+  __pyx_t_2 = __pyx_t_4;
+  __pyx_L4_bool_binop_done:;
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":180
+ * 
+ *         if self.args_num == 0 or self.args_codecs is not None:
+ *             return             # <<<<<<<<<<<<<<
+ * 
+ *         for i from 0 <= i < self.args_num:
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":179
+ *             list codecs = []
+ * 
+ *         if self.args_num == 0 or self.args_codecs is not None:             # <<<<<<<<<<<<<<
+ *             return
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":182
+ *             return
+ * 
+ *         for i from 0 <= i < self.args_num:             # <<<<<<<<<<<<<<
+ *             p_oid = self.parameters_desc[i]
+ *             codec = self.settings.get_data_codec(<uint32_t>p_oid)
+ */
+  __pyx_t_5 = __pyx_v_self->args_num;
+  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_5; __pyx_v_i++) {
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":183
+ * 
+ *         for i from 0 <= i < self.args_num:
+ *             p_oid = self.parameters_desc[i]             # <<<<<<<<<<<<<<
+ *             codec = self.settings.get_data_codec(<uint32_t>p_oid)
+ *             if codec is None or not codec.has_encoder():
+ */
+    if (unlikely(__pyx_v_self->parameters_desc == Py_None)) {
+      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+      __PYX_ERR(25, 183, __pyx_L1_error)
+    }
+    __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_self->parameters_desc, __pyx_v_i, long, 1, __Pyx_PyInt_From_long, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 183, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(25, 183, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_v_p_oid = __pyx_t_6;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":184
+ *         for i from 0 <= i < self.args_num:
+ *             p_oid = self.parameters_desc[i]
+ *             codec = self.settings.get_data_codec(<uint32_t>p_oid)             # <<<<<<<<<<<<<<
+ *             if codec is None or not codec.has_encoder():
+ *                 raise RuntimeError('no encoder for OID {}'.format(p_oid))
+ */
+    __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_data_codec(__pyx_v_self->settings, ((uint32_t)__pyx_v_p_oid), 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 184, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_XDECREF_SET(__pyx_v_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_1));
+    __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":185
+ *             p_oid = self.parameters_desc[i]
+ *             codec = self.settings.get_data_codec(<uint32_t>p_oid)
+ *             if codec is None or not codec.has_encoder():             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError('no encoder for OID {}'.format(p_oid))
+ *             if codec.type not in {}:
+ */
+    __pyx_t_4 = (((PyObject *)__pyx_v_codec) == Py_None);
+    __pyx_t_3 = (__pyx_t_4 != 0);
+    if (!__pyx_t_3) {
+    } else {
+      __pyx_t_2 = __pyx_t_3;
+      goto __pyx_L9_bool_binop_done;
+    }
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_has_encoder(__pyx_v_codec); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 185, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(25, 185, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_4 = ((!__pyx_t_3) != 0);
+    __pyx_t_2 = __pyx_t_4;
+    __pyx_L9_bool_binop_done:;
+    if (__pyx_t_2) {
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":186
+ *             codec = self.settings.get_data_codec(<uint32_t>p_oid)
+ *             if codec is None or not codec.has_encoder():
+ *                 raise RuntimeError('no encoder for OID {}'.format(p_oid))             # <<<<<<<<<<<<<<
+ *             if codec.type not in {}:
+ *                 self.have_text_args = True
+ */
+      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_no_encoder_for_OID, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(25, 186, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_7);
+      __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_p_oid); if (unlikely(!__pyx_t_8)) __PYX_ERR(25, 186, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_8);
+      __pyx_t_9 = NULL;
+      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
+        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7);
+        if (likely(__pyx_t_9)) {
+          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
+          __Pyx_INCREF(__pyx_t_9);
+          __Pyx_INCREF(function);
+          __Pyx_DECREF_SET(__pyx_t_7, function);
+        }
+      }
+      if (!__pyx_t_9) {
+        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 186, __pyx_L1_error)
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        __Pyx_GOTREF(__pyx_t_1);
+      } else {
+        #if CYTHON_FAST_PYCALL
+        if (PyFunction_Check(__pyx_t_7)) {
+          PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_8};
+          __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 186, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
+          __Pyx_GOTREF(__pyx_t_1);
+          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        } else
+        #endif
+        #if CYTHON_FAST_PYCCALL
+        if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
+          PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_8};
+          __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 186, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
+          __Pyx_GOTREF(__pyx_t_1);
+          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        } else
+        #endif
+        {
+          __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(25, 186, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_10);
+          __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
+          __Pyx_GIVEREF(__pyx_t_8);
+          PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_8);
+          __pyx_t_8 = 0;
+          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 186, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_1);
+          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        }
+      }
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(25, 186, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_GIVEREF(__pyx_t_1);
+      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
+      __pyx_t_1 = 0;
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 186, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __PYX_ERR(25, 186, __pyx_L1_error)
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":185
+ *             p_oid = self.parameters_desc[i]
+ *             codec = self.settings.get_data_codec(<uint32_t>p_oid)
+ *             if codec is None or not codec.has_encoder():             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError('no encoder for OID {}'.format(p_oid))
+ *             if codec.type not in {}:
+ */
+    }
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":187
+ *             if codec is None or not codec.has_encoder():
+ *                 raise RuntimeError('no encoder for OID {}'.format(p_oid))
+ *             if codec.type not in {}:             # <<<<<<<<<<<<<<
+ *                 self.have_text_args = True
+ * 
+ */
+    __pyx_t_1 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_CodecType(__pyx_v_codec->type); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 187, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(25, 187, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_7);
+    __pyx_t_2 = (__Pyx_PyDict_ContainsTF(__pyx_t_1, __pyx_t_7, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(25, 187, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __pyx_t_4 = (__pyx_t_2 != 0);
+    if (__pyx_t_4) {
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":188
+ *                 raise RuntimeError('no encoder for OID {}'.format(p_oid))
+ *             if codec.type not in {}:
+ *                 self.have_text_args = True             # <<<<<<<<<<<<<<
+ * 
+ *             codecs.append(codec)
+ */
+      __pyx_v_self->have_text_args = 1;
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":187
+ *             if codec is None or not codec.has_encoder():
+ *                 raise RuntimeError('no encoder for OID {}'.format(p_oid))
+ *             if codec.type not in {}:             # <<<<<<<<<<<<<<
+ *                 self.have_text_args = True
+ * 
+ */
+    }
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":190
+ *                 self.have_text_args = True
+ * 
+ *             codecs.append(codec)             # <<<<<<<<<<<<<<
+ * 
+ *         self.args_codecs = tuple(codecs)
+ */
+    __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_codecs, ((PyObject *)__pyx_v_codec)); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(25, 190, __pyx_L1_error)
+  }
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":192
+ *             codecs.append(codec)
+ * 
+ *         self.args_codecs = tuple(codecs)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _set_row_desc(self, object desc):
+ */
+  __pyx_t_7 = PyList_AsTuple(__pyx_v_codecs); if (unlikely(!__pyx_t_7)) __PYX_ERR(25, 192, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_7);
+  __Pyx_GIVEREF(__pyx_t_7);
+  __Pyx_GOTREF(__pyx_v_self->args_codecs);
+  __Pyx_DECREF(__pyx_v_self->args_codecs);
+  __pyx_v_self->args_codecs = ((PyObject*)__pyx_t_7);
+  __pyx_t_7 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":173
+ *         self.rows_codecs = tuple(codecs)
+ * 
+ *     cdef _ensure_args_encoder(self):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             int p_oid
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.PreparedStatementState._ensure_args_encoder", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
+  __Pyx_XDECREF(__pyx_v_codecs);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/prepared_stmt.pyx":194
+ *         self.args_codecs = tuple(codecs)
+ * 
+ *     cdef _set_row_desc(self, object desc):             # <<<<<<<<<<<<<<
+ *         self.row_desc = _decode_row_desc(desc)
+ *         self.cols_num = <int16_t>(len(self.row_desc))
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__set_row_desc(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self, PyObject *__pyx_v_desc) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  Py_ssize_t __pyx_t_2;
+  __Pyx_RefNannySetupContext("_set_row_desc", 0);
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":195
+ * 
+ *     cdef _set_row_desc(self, object desc):
+ *         self.row_desc = _decode_row_desc(desc)             # <<<<<<<<<<<<<<
+ *         self.cols_num = <int16_t>(len(self.row_desc))
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol__decode_row_desc(__pyx_v_desc); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 195, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(25, 195, __pyx_L1_error)
+  __Pyx_GIVEREF(__pyx_t_1);
+  __Pyx_GOTREF(__pyx_v_self->row_desc);
+  __Pyx_DECREF(__pyx_v_self->row_desc);
+  __pyx_v_self->row_desc = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":196
+ *     cdef _set_row_desc(self, object desc):
+ *         self.row_desc = _decode_row_desc(desc)
+ *         self.cols_num = <int16_t>(len(self.row_desc))             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _set_args_desc(self, object desc):
+ */
+  __pyx_t_1 = __pyx_v_self->row_desc;
+  __Pyx_INCREF(__pyx_t_1);
+  if (unlikely(__pyx_t_1 == Py_None)) {
+    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
+    __PYX_ERR(25, 196, __pyx_L1_error)
+  }
+  __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(25, 196, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_self->cols_num = ((int16_t)__pyx_t_2);
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":194
+ *         self.args_codecs = tuple(codecs)
+ * 
+ *     cdef _set_row_desc(self, object desc):             # <<<<<<<<<<<<<<
+ *         self.row_desc = _decode_row_desc(desc)
+ *         self.cols_num = <int16_t>(len(self.row_desc))
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.PreparedStatementState._set_row_desc", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/prepared_stmt.pyx":198
+ *         self.cols_num = <int16_t>(len(self.row_desc))
+ * 
+ *     cdef _set_args_desc(self, object desc):             # <<<<<<<<<<<<<<
+ *         self.parameters_desc = _decode_parameters_desc(desc)
+ *         self.args_num = <int16_t>(len(self.parameters_desc))
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__set_args_desc(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self, PyObject *__pyx_v_desc) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  Py_ssize_t __pyx_t_2;
+  __Pyx_RefNannySetupContext("_set_args_desc", 0);
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":199
+ * 
+ *     cdef _set_args_desc(self, object desc):
+ *         self.parameters_desc = _decode_parameters_desc(desc)             # <<<<<<<<<<<<<<
+ *         self.args_num = <int16_t>(len(self.parameters_desc))
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol__decode_parameters_desc(__pyx_v_desc); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 199, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(25, 199, __pyx_L1_error)
+  __Pyx_GIVEREF(__pyx_t_1);
+  __Pyx_GOTREF(__pyx_v_self->parameters_desc);
+  __Pyx_DECREF(__pyx_v_self->parameters_desc);
+  __pyx_v_self->parameters_desc = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":200
+ *     cdef _set_args_desc(self, object desc):
+ *         self.parameters_desc = _decode_parameters_desc(desc)
+ *         self.args_num = <int16_t>(len(self.parameters_desc))             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _decode_row(self, const char* cbuf, ssize_t buf_len):
+ */
+  __pyx_t_1 = __pyx_v_self->parameters_desc;
+  __Pyx_INCREF(__pyx_t_1);
+  if (unlikely(__pyx_t_1 == Py_None)) {
+    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
+    __PYX_ERR(25, 200, __pyx_L1_error)
+  }
+  __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(25, 200, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_self->args_num = ((int16_t)__pyx_t_2);
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":198
+ *         self.cols_num = <int16_t>(len(self.row_desc))
+ * 
+ *     cdef _set_args_desc(self, object desc):             # <<<<<<<<<<<<<<
+ *         self.parameters_desc = _decode_parameters_desc(desc)
+ *         self.args_num = <int16_t>(len(self.parameters_desc))
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.PreparedStatementState._set_args_desc", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/prepared_stmt.pyx":202
+ *         self.args_num = <int16_t>(len(self.parameters_desc))
+ * 
+ *     cdef _decode_row(self, const char* cbuf, ssize_t buf_len):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             Codec codec
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__decode_row(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self, char const *__pyx_v_cbuf, Py_ssize_t __pyx_v_buf_len) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_codec = 0;
+  int16_t __pyx_v_fnum;
+  int32_t __pyx_v_flen;
+  PyObject *__pyx_v_dec_row = 0;
+  PyObject *__pyx_v_rows_codecs = 0;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings = 0;
+  int32_t __pyx_v_i;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_rbuf = 0;
+  Py_ssize_t __pyx_v_bl;
+  PyObject *__pyx_v_val = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  char const *__pyx_t_2;
+  int __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  int __pyx_t_8;
+  PyObject *__pyx_t_9 = NULL;
+  int __pyx_t_10;
+  int __pyx_t_11;
+  Py_ssize_t __pyx_t_12;
+  int16_t __pyx_t_13;
+  int32_t __pyx_t_14;
+  Py_ssize_t __pyx_t_15;
+  PyObject *__pyx_t_16;
+  PyObject *__pyx_t_17 = NULL;
+  __Pyx_RefNannySetupContext("_decode_row", 0);
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":208
+ *             int32_t flen
+ *             object dec_row
+ *             tuple rows_codecs = self.rows_codecs             # <<<<<<<<<<<<<<
+ *             ConnectionSettings settings = self.settings
+ *             int32_t i
+ */
+  __pyx_t_1 = __pyx_v_self->rows_codecs;
+  __Pyx_INCREF(__pyx_t_1);
+  __pyx_v_rows_codecs = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":209
+ *             object dec_row
+ *             tuple rows_codecs = self.rows_codecs
+ *             ConnectionSettings settings = self.settings             # <<<<<<<<<<<<<<
+ *             int32_t i
+ *             FastReadBuffer rbuf = self.buffer
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_v_self->settings);
+  __Pyx_INCREF(__pyx_t_1);
+  __pyx_v_settings = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":211
+ *             ConnectionSettings settings = self.settings
+ *             int32_t i
+ *             FastReadBuffer rbuf = self.buffer             # <<<<<<<<<<<<<<
+ *             ssize_t bl
+ * 
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_v_self->buffer);
+  __Pyx_INCREF(__pyx_t_1);
+  __pyx_v_rbuf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":214
+ *             ssize_t bl
+ * 
+ *         rbuf.buf = cbuf             # <<<<<<<<<<<<<<
+ *         rbuf.len = buf_len
+ * 
+ */
+  __pyx_v_rbuf->buf = __pyx_v_cbuf;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":215
+ * 
+ *         rbuf.buf = cbuf
+ *         rbuf.len = buf_len             # <<<<<<<<<<<<<<
+ * 
+ *         fnum = hton.unpack_int16(rbuf.read(2))
+ */
+  __pyx_v_rbuf->len = __pyx_v_buf_len;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":217
+ *         rbuf.len = buf_len
+ * 
+ *         fnum = hton.unpack_int16(rbuf.read(2))             # <<<<<<<<<<<<<<
+ * 
+ *         if fnum != self.cols_num:
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_rbuf, 2); if (unlikely(__pyx_t_2 == NULL)) __PYX_ERR(25, 217, __pyx_L1_error)
+  __pyx_v_fnum = __pyx_f_7asyncpg_8protocol_4hton_unpack_int16(__pyx_t_2);
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":219
+ *         fnum = hton.unpack_int16(rbuf.read(2))
+ * 
+ *         if fnum != self.cols_num:             # <<<<<<<<<<<<<<
+ *             raise RuntimeError(
+ *                 'number of columns in result ({}) is '
+ */
+  __pyx_t_3 = ((__pyx_v_fnum != __pyx_v_self->cols_num) != 0);
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":222
+ *             raise RuntimeError(
+ *                 'number of columns in result ({}) is '
+ *                 'different from what was described ({})'.format(             # <<<<<<<<<<<<<<
+ *                     fnum, self.cols_num))
+ * 
+ */
+    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_number_of_columns_in_result_is_d, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 222, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":223
+ *                 'number of columns in result ({}) is '
+ *                 'different from what was described ({})'.format(
+ *                     fnum, self.cols_num))             # <<<<<<<<<<<<<<
+ * 
+ *         if rows_codecs is None or len(rows_codecs) < fnum:
+ */
+    __pyx_t_5 = __Pyx_PyInt_From_int16_t(__pyx_v_fnum); if (unlikely(!__pyx_t_5)) __PYX_ERR(25, 223, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = __Pyx_PyInt_From_int16_t(__pyx_v_self->cols_num); if (unlikely(!__pyx_t_6)) __PYX_ERR(25, 223, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_7 = NULL;
+    __pyx_t_8 = 0;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
+      if (likely(__pyx_t_7)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+        __Pyx_INCREF(__pyx_t_7);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_4, function);
+        __pyx_t_8 = 1;
+      }
+    }
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_4)) {
+      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_5, __pyx_t_6};
+      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 222, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
+      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_5, __pyx_t_6};
+      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 222, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    } else
+    #endif
+    {
+      __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(25, 222, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_9);
+      if (__pyx_t_7) {
+        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
+      }
+      __Pyx_GIVEREF(__pyx_t_5);
+      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_5);
+      __Pyx_GIVEREF(__pyx_t_6);
+      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_6);
+      __pyx_t_5 = 0;
+      __pyx_t_6 = 0;
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 222, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":220
+ * 
+ *         if fnum != self.cols_num:
+ *             raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                 'number of columns in result ({}) is '
+ *                 'different from what was described ({})'.format(
+ */
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 220, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_1);
+    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
+    __pyx_t_1 = 0;
+    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 220, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __PYX_ERR(25, 220, __pyx_L1_error)
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":219
+ *         fnum = hton.unpack_int16(rbuf.read(2))
+ * 
+ *         if fnum != self.cols_num:             # <<<<<<<<<<<<<<
+ *             raise RuntimeError(
+ *                 'number of columns in result ({}) is '
+ */
+  }
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":225
+ *                     fnum, self.cols_num))
+ * 
+ *         if rows_codecs is None or len(rows_codecs) < fnum:             # <<<<<<<<<<<<<<
+ *             if fnum > 0:
+ *                 # It's OK to have no rows_codecs for empty records
+ */
+  __pyx_t_10 = (__pyx_v_rows_codecs == ((PyObject*)Py_None));
+  __pyx_t_11 = (__pyx_t_10 != 0);
+  if (!__pyx_t_11) {
+  } else {
+    __pyx_t_3 = __pyx_t_11;
+    goto __pyx_L5_bool_binop_done;
+  }
+  if (unlikely(__pyx_v_rows_codecs == Py_None)) {
+    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
+    __PYX_ERR(25, 225, __pyx_L1_error)
+  }
+  __pyx_t_12 = PyTuple_GET_SIZE(__pyx_v_rows_codecs); if (unlikely(__pyx_t_12 == -1)) __PYX_ERR(25, 225, __pyx_L1_error)
+  __pyx_t_11 = ((__pyx_t_12 < __pyx_v_fnum) != 0);
+  __pyx_t_3 = __pyx_t_11;
+  __pyx_L5_bool_binop_done:;
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":226
+ * 
+ *         if rows_codecs is None or len(rows_codecs) < fnum:
+ *             if fnum > 0:             # <<<<<<<<<<<<<<
+ *                 # It's OK to have no rows_codecs for empty records
+ *                 raise RuntimeError('invalid rows_codecs')
+ */
+    __pyx_t_3 = ((__pyx_v_fnum > 0) != 0);
+    if (__pyx_t_3) {
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":228
+ *             if fnum > 0:
+ *                 # It's OK to have no rows_codecs for empty records
+ *                 raise RuntimeError('invalid rows_codecs')             # <<<<<<<<<<<<<<
+ * 
+ *         dec_row = record.ApgRecord_New(self.cols_desc, fnum)
+ */
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__69, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 228, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __PYX_ERR(25, 228, __pyx_L1_error)
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":226
+ * 
+ *         if rows_codecs is None or len(rows_codecs) < fnum:
+ *             if fnum > 0:             # <<<<<<<<<<<<<<
+ *                 # It's OK to have no rows_codecs for empty records
+ *                 raise RuntimeError('invalid rows_codecs')
+ */
+    }
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":225
+ *                     fnum, self.cols_num))
+ * 
+ *         if rows_codecs is None or len(rows_codecs) < fnum:             # <<<<<<<<<<<<<<
+ *             if fnum > 0:
+ *                 # It's OK to have no rows_codecs for empty records
+ */
+  }
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":230
+ *                 raise RuntimeError('invalid rows_codecs')
+ * 
+ *         dec_row = record.ApgRecord_New(self.cols_desc, fnum)             # <<<<<<<<<<<<<<
+ *         for i in range(fnum):
+ *             flen = hton.unpack_int32(rbuf.read(4))
+ */
+  __pyx_t_1 = __pyx_v_self->cols_desc;
+  __Pyx_INCREF(__pyx_t_1);
+  __pyx_t_4 = ApgRecord_New(__pyx_t_1, __pyx_v_fnum); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 230, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_dec_row = __pyx_t_4;
+  __pyx_t_4 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":231
+ * 
+ *         dec_row = record.ApgRecord_New(self.cols_desc, fnum)
+ *         for i in range(fnum):             # <<<<<<<<<<<<<<
+ *             flen = hton.unpack_int32(rbuf.read(4))
+ * 
+ */
+  __pyx_t_13 = __pyx_v_fnum;
+  for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) {
+    __pyx_v_i = __pyx_t_14;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":232
+ *         dec_row = record.ApgRecord_New(self.cols_desc, fnum)
+ *         for i in range(fnum):
+ *             flen = hton.unpack_int32(rbuf.read(4))             # <<<<<<<<<<<<<<
+ * 
+ *             if flen == -1:
+ */
+    __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_rbuf, 4); if (unlikely(__pyx_t_2 == NULL)) __PYX_ERR(25, 232, __pyx_L1_error)
+    __pyx_v_flen = __pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_t_2);
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":234
+ *             flen = hton.unpack_int32(rbuf.read(4))
+ * 
+ *             if flen == -1:             # <<<<<<<<<<<<<<
+ *                 val = None
+ *             else:
+ */
+    __pyx_t_3 = ((__pyx_v_flen == -1L) != 0);
+    if (__pyx_t_3) {
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":235
+ * 
+ *             if flen == -1:
+ *                 val = None             # <<<<<<<<<<<<<<
+ *             else:
+ *                 # Clamp buffer size to that of the reported field length
+ */
+      __Pyx_INCREF(Py_None);
+      __Pyx_XDECREF_SET(__pyx_v_val, Py_None);
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":234
+ *             flen = hton.unpack_int32(rbuf.read(4))
+ * 
+ *             if flen == -1:             # <<<<<<<<<<<<<<
+ *                 val = None
+ *             else:
+ */
+      goto __pyx_L10;
+    }
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":240
+ *                 # to make sure that codecs can rely on read_all() working
+ *                 # properly.
+ *                 bl = rbuf.len             # <<<<<<<<<<<<<<
+ *                 if flen > bl:
+ *                     # Check for overflow
+ */
+    /*else*/ {
+      __pyx_t_15 = __pyx_v_rbuf->len;
+      __pyx_v_bl = __pyx_t_15;
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":241
+ *                 # properly.
+ *                 bl = rbuf.len
+ *                 if flen > bl:             # <<<<<<<<<<<<<<
+ *                     # Check for overflow
+ *                     rbuf._raise_ins_err(flen, bl)
+ */
+      __pyx_t_3 = ((__pyx_v_flen > __pyx_v_bl) != 0);
+      if (__pyx_t_3) {
+
+        /* "asyncpg/protocol/prepared_stmt.pyx":243
+ *                 if flen > bl:
+ *                     # Check for overflow
+ *                     rbuf._raise_ins_err(flen, bl)             # <<<<<<<<<<<<<<
+ *                 rbuf.len = flen
+ *                 codec = <Codec>cpython.PyTuple_GET_ITEM(rows_codecs, i)
+ */
+        __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer__raise_ins_err(__pyx_v_rbuf, __pyx_v_flen, __pyx_v_bl); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 243, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+        /* "asyncpg/protocol/prepared_stmt.pyx":241
+ *                 # properly.
+ *                 bl = rbuf.len
+ *                 if flen > bl:             # <<<<<<<<<<<<<<
+ *                     # Check for overflow
+ *                     rbuf._raise_ins_err(flen, bl)
+ */
+      }
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":244
+ *                     # Check for overflow
+ *                     rbuf._raise_ins_err(flen, bl)
+ *                 rbuf.len = flen             # <<<<<<<<<<<<<<
+ *                 codec = <Codec>cpython.PyTuple_GET_ITEM(rows_codecs, i)
+ *                 val = codec.decode(settings, rbuf)
+ */
+      __pyx_v_rbuf->len = __pyx_v_flen;
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":245
+ *                     rbuf._raise_ins_err(flen, bl)
+ *                 rbuf.len = flen
+ *                 codec = <Codec>cpython.PyTuple_GET_ITEM(rows_codecs, i)             # <<<<<<<<<<<<<<
+ *                 val = codec.decode(settings, rbuf)
+ *                 if rbuf.len != 0:
+ */
+      __pyx_t_16 = PyTuple_GET_ITEM(__pyx_v_rows_codecs, __pyx_v_i);
+      __pyx_t_4 = ((PyObject *)__pyx_t_16);
+      __Pyx_INCREF(__pyx_t_4);
+      __Pyx_XDECREF_SET(__pyx_v_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_4));
+      __pyx_t_4 = 0;
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":246
+ *                 rbuf.len = flen
+ *                 codec = <Codec>cpython.PyTuple_GET_ITEM(rows_codecs, i)
+ *                 val = codec.decode(settings, rbuf)             # <<<<<<<<<<<<<<
+ *                 if rbuf.len != 0:
+ *                     raise BufferError(
+ */
+      __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode(__pyx_v_codec, __pyx_v_settings, __pyx_v_rbuf); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 246, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_XDECREF_SET(__pyx_v_val, __pyx_t_4);
+      __pyx_t_4 = 0;
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":247
+ *                 codec = <Codec>cpython.PyTuple_GET_ITEM(rows_codecs, i)
+ *                 val = codec.decode(settings, rbuf)
+ *                 if rbuf.len != 0:             # <<<<<<<<<<<<<<
+ *                     raise BufferError(
+ *                         'unexpected trailing {} bytes in buffer'.format(
+ */
+      __pyx_t_3 = ((__pyx_v_rbuf->len != 0) != 0);
+      if (__pyx_t_3) {
+
+        /* "asyncpg/protocol/prepared_stmt.pyx":248
+ *                 val = codec.decode(settings, rbuf)
+ *                 if rbuf.len != 0:
+ *                     raise BufferError(             # <<<<<<<<<<<<<<
+ *                         'unexpected trailing {} bytes in buffer'.format(
+ *                             rbuf.len))
+ */
+        __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_BufferError); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 248, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_1);
+
+        /* "asyncpg/protocol/prepared_stmt.pyx":249
+ *                 if rbuf.len != 0:
+ *                     raise BufferError(
+ *                         'unexpected trailing {} bytes in buffer'.format(             # <<<<<<<<<<<<<<
+ *                             rbuf.len))
+ *                 rbuf.len = bl - flen
+ */
+        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_unexpected_trailing_bytes_in_buf, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(25, 249, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_6);
+
+        /* "asyncpg/protocol/prepared_stmt.pyx":250
+ *                     raise BufferError(
+ *                         'unexpected trailing {} bytes in buffer'.format(
+ *                             rbuf.len))             # <<<<<<<<<<<<<<
+ *                 rbuf.len = bl - flen
+ * 
+ */
+        __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_rbuf->len); if (unlikely(!__pyx_t_5)) __PYX_ERR(25, 250, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_5);
+        __pyx_t_7 = NULL;
+        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
+          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
+          if (likely(__pyx_t_7)) {
+            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
+            __Pyx_INCREF(__pyx_t_7);
+            __Pyx_INCREF(function);
+            __Pyx_DECREF_SET(__pyx_t_6, function);
+          }
+        }
+        if (!__pyx_t_7) {
+          __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(25, 249, __pyx_L1_error)
+          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+          __Pyx_GOTREF(__pyx_t_9);
+        } else {
+          #if CYTHON_FAST_PYCALL
+          if (PyFunction_Check(__pyx_t_6)) {
+            PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_5};
+            __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(25, 249, __pyx_L1_error)
+            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+            __Pyx_GOTREF(__pyx_t_9);
+            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+          } else
+          #endif
+          #if CYTHON_FAST_PYCCALL
+          if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
+            PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_5};
+            __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(25, 249, __pyx_L1_error)
+            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+            __Pyx_GOTREF(__pyx_t_9);
+            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+          } else
+          #endif
+          {
+            __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(25, 249, __pyx_L1_error)
+            __Pyx_GOTREF(__pyx_t_17);
+            __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_7); __pyx_t_7 = NULL;
+            __Pyx_GIVEREF(__pyx_t_5);
+            PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_t_5);
+            __pyx_t_5 = 0;
+            __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_17, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(25, 249, __pyx_L1_error)
+            __Pyx_GOTREF(__pyx_t_9);
+            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
+          }
+        }
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __pyx_t_6 = NULL;
+        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
+          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
+          if (likely(__pyx_t_6)) {
+            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
+            __Pyx_INCREF(__pyx_t_6);
+            __Pyx_INCREF(function);
+            __Pyx_DECREF_SET(__pyx_t_1, function);
+          }
+        }
+        if (!__pyx_t_6) {
+          __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 248, __pyx_L1_error)
+          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+          __Pyx_GOTREF(__pyx_t_4);
+        } else {
+          #if CYTHON_FAST_PYCALL
+          if (PyFunction_Check(__pyx_t_1)) {
+            PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_9};
+            __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 248, __pyx_L1_error)
+            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+            __Pyx_GOTREF(__pyx_t_4);
+            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+          } else
+          #endif
+          #if CYTHON_FAST_PYCCALL
+          if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
+            PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_9};
+            __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 248, __pyx_L1_error)
+            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+            __Pyx_GOTREF(__pyx_t_4);
+            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+          } else
+          #endif
+          {
+            __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(25, 248, __pyx_L1_error)
+            __Pyx_GOTREF(__pyx_t_17);
+            __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_6); __pyx_t_6 = NULL;
+            __Pyx_GIVEREF(__pyx_t_9);
+            PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_t_9);
+            __pyx_t_9 = 0;
+            __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_17, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 248, __pyx_L1_error)
+            __Pyx_GOTREF(__pyx_t_4);
+            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
+          }
+        }
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __PYX_ERR(25, 248, __pyx_L1_error)
+
+        /* "asyncpg/protocol/prepared_stmt.pyx":247
+ *                 codec = <Codec>cpython.PyTuple_GET_ITEM(rows_codecs, i)
+ *                 val = codec.decode(settings, rbuf)
+ *                 if rbuf.len != 0:             # <<<<<<<<<<<<<<
+ *                     raise BufferError(
+ *                         'unexpected trailing {} bytes in buffer'.format(
+ */
+      }
+
+      /* "asyncpg/protocol/prepared_stmt.pyx":251
+ *                         'unexpected trailing {} bytes in buffer'.format(
+ *                             rbuf.len))
+ *                 rbuf.len = bl - flen             # <<<<<<<<<<<<<<
+ * 
+ *             cpython.Py_INCREF(val)
+ */
+      __pyx_v_rbuf->len = (__pyx_v_bl - __pyx_v_flen);
+    }
+    __pyx_L10:;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":253
+ *                 rbuf.len = bl - flen
+ * 
+ *             cpython.Py_INCREF(val)             # <<<<<<<<<<<<<<
+ *             record.ApgRecord_SET_ITEM(dec_row, i, val)
+ * 
+ */
+    Py_INCREF(__pyx_v_val);
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":254
+ * 
+ *             cpython.Py_INCREF(val)
+ *             record.ApgRecord_SET_ITEM(dec_row, i, val)             # <<<<<<<<<<<<<<
+ * 
+ *         if rbuf.len != 0:
+ */
+    ApgRecord_SET_ITEM(__pyx_v_dec_row, __pyx_v_i, __pyx_v_val);
+  }
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":256
+ *             record.ApgRecord_SET_ITEM(dec_row, i, val)
+ * 
+ *         if rbuf.len != 0:             # <<<<<<<<<<<<<<
+ *             raise BufferError('unexpected trailing {} bytes in buffer'.format(
+ *                 rbuf.len))
+ */
+  __pyx_t_3 = ((__pyx_v_rbuf->len != 0) != 0);
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":257
+ * 
+ *         if rbuf.len != 0:
+ *             raise BufferError('unexpected trailing {} bytes in buffer'.format(             # <<<<<<<<<<<<<<
+ *                 rbuf.len))
+ * 
+ */
+    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_BufferError); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 257, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_unexpected_trailing_bytes_in_buf, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(25, 257, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_9);
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":258
+ *         if rbuf.len != 0:
+ *             raise BufferError('unexpected trailing {} bytes in buffer'.format(
+ *                 rbuf.len))             # <<<<<<<<<<<<<<
+ * 
+ *         return dec_row
+ */
+    __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_rbuf->len); if (unlikely(!__pyx_t_6)) __PYX_ERR(25, 258, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_5 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
+      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_9);
+      if (likely(__pyx_t_5)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
+        __Pyx_INCREF(__pyx_t_5);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_9, function);
+      }
+    }
+    if (!__pyx_t_5) {
+      __pyx_t_17 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_6); if (unlikely(!__pyx_t_17)) __PYX_ERR(25, 257, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_GOTREF(__pyx_t_17);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_9)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_6};
+        __pyx_t_17 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(25, 257, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_GOTREF(__pyx_t_17);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_6};
+        __pyx_t_17 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(25, 257, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_GOTREF(__pyx_t_17);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(25, 257, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
+        __Pyx_GIVEREF(__pyx_t_6);
+        PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_6);
+        __pyx_t_6 = 0;
+        __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_7, NULL); if (unlikely(!__pyx_t_17)) __PYX_ERR(25, 257, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_17);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+    __pyx_t_9 = NULL;
+    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
+      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
+      if (likely(__pyx_t_9)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
+        __Pyx_INCREF(__pyx_t_9);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_1, function);
+      }
+    }
+    if (!__pyx_t_9) {
+      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_17); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 257, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
+      __Pyx_GOTREF(__pyx_t_4);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_1)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_17};
+        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 257, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_17};
+        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 257, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(25, 257, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_9); __pyx_t_9 = NULL;
+        __Pyx_GIVEREF(__pyx_t_17);
+        PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_17);
+        __pyx_t_17 = 0;
+        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(25, 257, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __PYX_ERR(25, 257, __pyx_L1_error)
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":256
+ *             record.ApgRecord_SET_ITEM(dec_row, i, val)
+ * 
+ *         if rbuf.len != 0:             # <<<<<<<<<<<<<<
+ *             raise BufferError('unexpected trailing {} bytes in buffer'.format(
+ *                 rbuf.len))
+ */
+  }
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":260
+ *                 rbuf.len))
+ * 
+ *         return dec_row             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_dec_row);
+  __pyx_r = __pyx_v_dec_row;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":202
+ *         self.args_num = <int16_t>(len(self.parameters_desc))
+ * 
+ *     cdef _decode_row(self, const char* cbuf, ssize_t buf_len):             # <<<<<<<<<<<<<<
+ *         cdef:
+ *             Codec codec
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_17);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.PreparedStatementState._decode_row", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
+  __Pyx_XDECREF(__pyx_v_dec_row);
+  __Pyx_XDECREF(__pyx_v_rows_codecs);
+  __Pyx_XDECREF((PyObject *)__pyx_v_settings);
+  __Pyx_XDECREF((PyObject *)__pyx_v_rbuf);
+  __Pyx_XDECREF(__pyx_v_val);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/prepared_stmt.pxd":10
+ * cdef class PreparedStatementState:
+ *     cdef:
+ *         readonly str name             # <<<<<<<<<<<<<<
+ *         readonly str query
+ *         readonly bint closed
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_4name_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_4name_1__get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_4name___get__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_4name___get__(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__get__", 0);
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_self->name);
+  __pyx_r = __pyx_v_self->name;
+  goto __pyx_L0;
+
+  /* function exit code */
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/prepared_stmt.pxd":11
+ *     cdef:
+ *         readonly str name
+ *         readonly str query             # <<<<<<<<<<<<<<
+ *         readonly bint closed
+ *         readonly int refs
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_5query_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_5query_1__get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_5query___get__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_5query___get__(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__get__", 0);
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_self->query);
+  __pyx_r = __pyx_v_self->query;
+  goto __pyx_L0;
+
+  /* function exit code */
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/prepared_stmt.pxd":12
+ *         readonly str name
+ *         readonly str query
+ *         readonly bint closed             # <<<<<<<<<<<<<<
+ *         readonly int refs
+ * 
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_6closed_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_6closed_1__get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_6closed___get__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_6closed___get__(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("__get__", 0);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->closed); if (unlikely(!__pyx_t_1)) __PYX_ERR(26, 12, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.PreparedStatementState.closed.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/prepared_stmt.pxd":13
+ *         readonly str query
+ *         readonly bint closed
+ *         readonly int refs             # <<<<<<<<<<<<<<
+ * 
+ *         FastReadBuffer buffer
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_4refs_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_4refs_1__get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_4refs___get__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_4refs___get__(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("__get__", 0);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->refs); if (unlikely(!__pyx_t_1)) __PYX_ERR(26, 13, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.PreparedStatementState.refs.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/prepared_stmt.pyx":263
+ * 
+ * 
+ * cdef _decode_parameters_desc(object desc):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         ReadBuffer reader
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol__decode_parameters_desc(PyObject *__pyx_v_desc) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_reader = 0;
+  int16_t __pyx_v_nparams;
+  int32_t __pyx_v_p_oid;
+  PyObject *__pyx_v_result = 0;
+  CYTHON_UNUSED long __pyx_v_i;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int16_t __pyx_t_2;
+  int32_t __pyx_t_3;
+  int __pyx_t_4;
+  __Pyx_RefNannySetupContext("_decode_parameters_desc", 0);
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":268
+ *         int16_t nparams
+ *         int32_t p_oid
+ *         list result = []             # <<<<<<<<<<<<<<
+ * 
+ *     reader = ReadBuffer.new_message_parser(desc)
+ */
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 268, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_result = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":270
+ *         list result = []
+ * 
+ *     reader = ReadBuffer.new_message_parser(desc)             # <<<<<<<<<<<<<<
+ *     nparams = reader.read_int16()
+ * 
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_new_message_parser(__pyx_v_desc)); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 270, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_reader = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":271
+ * 
+ *     reader = ReadBuffer.new_message_parser(desc)
+ *     nparams = reader.read_int16()             # <<<<<<<<<<<<<<
+ * 
+ *     for i from 0 <= i < nparams:
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_int16(__pyx_v_reader); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 271, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyInt_As_int16_t(__pyx_t_1); if (unlikely((__pyx_t_2 == ((int16_t)-1)) && PyErr_Occurred())) __PYX_ERR(25, 271, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_nparams = __pyx_t_2;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":273
+ *     nparams = reader.read_int16()
+ * 
+ *     for i from 0 <= i < nparams:             # <<<<<<<<<<<<<<
+ *         p_oid = reader.read_int32()
+ *         result.append(p_oid)
+ */
+  __pyx_t_2 = __pyx_v_nparams;
+  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":274
+ * 
+ *     for i from 0 <= i < nparams:
+ *         p_oid = reader.read_int32()             # <<<<<<<<<<<<<<
+ *         result.append(p_oid)
+ * 
+ */
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_int32(__pyx_v_reader); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 274, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_3 = __Pyx_PyInt_As_int32_t(__pyx_t_1); if (unlikely((__pyx_t_3 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(25, 274, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_v_p_oid = __pyx_t_3;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":275
+ *     for i from 0 <= i < nparams:
+ *         p_oid = reader.read_int32()
+ *         result.append(p_oid)             # <<<<<<<<<<<<<<
+ * 
+ *     return result
+ */
+    __pyx_t_1 = __Pyx_PyInt_From_int32_t(__pyx_v_p_oid); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 275, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_4 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(25, 275, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  }
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":277
+ *         result.append(p_oid)
+ * 
+ *     return result             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_result);
+  __pyx_r = __pyx_v_result;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":263
+ * 
+ * 
+ * cdef _decode_parameters_desc(object desc):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         ReadBuffer reader
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol._decode_parameters_desc", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_reader);
+  __Pyx_XDECREF(__pyx_v_result);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/prepared_stmt.pyx":280
+ * 
+ * 
+ * cdef _decode_row_desc(object desc):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         ReadBuffer reader
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol__decode_row_desc(PyObject *__pyx_v_desc) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_reader = 0;
+  int16_t __pyx_v_nfields;
+  PyObject *__pyx_v_f_name = 0;
+  int32_t __pyx_v_f_table_oid;
+  int16_t __pyx_v_f_column_num;
+  int32_t __pyx_v_f_dt_oid;
+  int16_t __pyx_v_f_dt_size;
+  int32_t __pyx_v_f_dt_mod;
+  int16_t __pyx_v_f_format;
+  PyObject *__pyx_v_result = 0;
+  CYTHON_UNUSED long __pyx_v_i;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int16_t __pyx_t_2;
+  int32_t __pyx_t_3;
+  int16_t __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  PyObject *__pyx_t_10 = NULL;
+  int __pyx_t_11;
+  __Pyx_RefNannySetupContext("_decode_row_desc", 0);
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":296
+ *         list result
+ * 
+ *     reader = ReadBuffer.new_message_parser(desc)             # <<<<<<<<<<<<<<
+ *     nfields = reader.read_int16()
+ *     result = []
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_new_message_parser(__pyx_v_desc)); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 296, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_reader = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":297
+ * 
+ *     reader = ReadBuffer.new_message_parser(desc)
+ *     nfields = reader.read_int16()             # <<<<<<<<<<<<<<
+ *     result = []
+ * 
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_int16(__pyx_v_reader); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 297, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyInt_As_int16_t(__pyx_t_1); if (unlikely((__pyx_t_2 == ((int16_t)-1)) && PyErr_Occurred())) __PYX_ERR(25, 297, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_nfields = __pyx_t_2;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":298
+ *     reader = ReadBuffer.new_message_parser(desc)
+ *     nfields = reader.read_int16()
+ *     result = []             # <<<<<<<<<<<<<<
+ * 
+ *     for i from 0 <= i < nfields:
+ */
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 298, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_v_result = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":300
+ *     result = []
+ * 
+ *     for i from 0 <= i < nfields:             # <<<<<<<<<<<<<<
+ *         f_name = reader.read_cstr()
+ *         f_table_oid = reader.read_int32()
+ */
+  __pyx_t_2 = __pyx_v_nfields;
+  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":301
+ * 
+ *     for i from 0 <= i < nfields:
+ *         f_name = reader.read_cstr()             # <<<<<<<<<<<<<<
+ *         f_table_oid = reader.read_int32()
+ *         f_column_num = reader.read_int16()
+ */
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_cstr(__pyx_v_reader); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 301, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(25, 301, __pyx_L1_error)
+    __Pyx_XDECREF_SET(__pyx_v_f_name, ((PyObject*)__pyx_t_1));
+    __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":302
+ *     for i from 0 <= i < nfields:
+ *         f_name = reader.read_cstr()
+ *         f_table_oid = reader.read_int32()             # <<<<<<<<<<<<<<
+ *         f_column_num = reader.read_int16()
+ *         f_dt_oid = reader.read_int32()
+ */
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_int32(__pyx_v_reader); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 302, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_3 = __Pyx_PyInt_As_int32_t(__pyx_t_1); if (unlikely((__pyx_t_3 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(25, 302, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_v_f_table_oid = __pyx_t_3;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":303
+ *         f_name = reader.read_cstr()
+ *         f_table_oid = reader.read_int32()
+ *         f_column_num = reader.read_int16()             # <<<<<<<<<<<<<<
+ *         f_dt_oid = reader.read_int32()
+ *         f_dt_size = reader.read_int16()
+ */
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_int16(__pyx_v_reader); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 303, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_4 = __Pyx_PyInt_As_int16_t(__pyx_t_1); if (unlikely((__pyx_t_4 == ((int16_t)-1)) && PyErr_Occurred())) __PYX_ERR(25, 303, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_v_f_column_num = __pyx_t_4;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":304
+ *         f_table_oid = reader.read_int32()
+ *         f_column_num = reader.read_int16()
+ *         f_dt_oid = reader.read_int32()             # <<<<<<<<<<<<<<
+ *         f_dt_size = reader.read_int16()
+ *         f_dt_mod = reader.read_int32()
+ */
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_int32(__pyx_v_reader); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 304, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_3 = __Pyx_PyInt_As_int32_t(__pyx_t_1); if (unlikely((__pyx_t_3 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(25, 304, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_v_f_dt_oid = __pyx_t_3;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":305
+ *         f_column_num = reader.read_int16()
+ *         f_dt_oid = reader.read_int32()
+ *         f_dt_size = reader.read_int16()             # <<<<<<<<<<<<<<
+ *         f_dt_mod = reader.read_int32()
+ *         f_format = reader.read_int16()
+ */
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_int16(__pyx_v_reader); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 305, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_4 = __Pyx_PyInt_As_int16_t(__pyx_t_1); if (unlikely((__pyx_t_4 == ((int16_t)-1)) && PyErr_Occurred())) __PYX_ERR(25, 305, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_v_f_dt_size = __pyx_t_4;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":306
+ *         f_dt_oid = reader.read_int32()
+ *         f_dt_size = reader.read_int16()
+ *         f_dt_mod = reader.read_int32()             # <<<<<<<<<<<<<<
+ *         f_format = reader.read_int16()
+ * 
+ */
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_int32(__pyx_v_reader); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 306, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_3 = __Pyx_PyInt_As_int32_t(__pyx_t_1); if (unlikely((__pyx_t_3 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(25, 306, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_v_f_dt_mod = __pyx_t_3;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":307
+ *         f_dt_size = reader.read_int16()
+ *         f_dt_mod = reader.read_int32()
+ *         f_format = reader.read_int16()             # <<<<<<<<<<<<<<
+ * 
+ *         result.append(
+ */
+    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_int16(__pyx_v_reader); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 307, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_4 = __Pyx_PyInt_As_int16_t(__pyx_t_1); if (unlikely((__pyx_t_4 == ((int16_t)-1)) && PyErr_Occurred())) __PYX_ERR(25, 307, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_v_f_format = __pyx_t_4;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":310
+ * 
+ *         result.append(
+ *             (f_name, f_table_oid, f_column_num, f_dt_oid,             # <<<<<<<<<<<<<<
+ *              f_dt_size, f_dt_mod, f_format))
+ * 
+ */
+    __pyx_t_1 = __Pyx_PyInt_From_int32_t(__pyx_v_f_table_oid); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 310, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_5 = __Pyx_PyInt_From_int16_t(__pyx_v_f_column_num); if (unlikely(!__pyx_t_5)) __PYX_ERR(25, 310, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = __Pyx_PyInt_From_int32_t(__pyx_v_f_dt_oid); if (unlikely(!__pyx_t_6)) __PYX_ERR(25, 310, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_6);
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":311
+ *         result.append(
+ *             (f_name, f_table_oid, f_column_num, f_dt_oid,
+ *              f_dt_size, f_dt_mod, f_format))             # <<<<<<<<<<<<<<
+ * 
+ *     return result
+ */
+    __pyx_t_7 = __Pyx_PyInt_From_int16_t(__pyx_v_f_dt_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(25, 311, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_7);
+    __pyx_t_8 = __Pyx_PyInt_From_int32_t(__pyx_v_f_dt_mod); if (unlikely(!__pyx_t_8)) __PYX_ERR(25, 311, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_8);
+    __pyx_t_9 = __Pyx_PyInt_From_int16_t(__pyx_v_f_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(25, 311, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_9);
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":310
+ * 
+ *         result.append(
+ *             (f_name, f_table_oid, f_column_num, f_dt_oid,             # <<<<<<<<<<<<<<
+ *              f_dt_size, f_dt_mod, f_format))
+ * 
+ */
+    __pyx_t_10 = PyTuple_New(7); if (unlikely(!__pyx_t_10)) __PYX_ERR(25, 310, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_10);
+    __Pyx_INCREF(__pyx_v_f_name);
+    __Pyx_GIVEREF(__pyx_v_f_name);
+    PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_f_name);
+    __Pyx_GIVEREF(__pyx_t_1);
+    PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_1);
+    __Pyx_GIVEREF(__pyx_t_5);
+    PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_5);
+    __Pyx_GIVEREF(__pyx_t_6);
+    PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_6);
+    __Pyx_GIVEREF(__pyx_t_7);
+    PyTuple_SET_ITEM(__pyx_t_10, 4, __pyx_t_7);
+    __Pyx_GIVEREF(__pyx_t_8);
+    PyTuple_SET_ITEM(__pyx_t_10, 5, __pyx_t_8);
+    __Pyx_GIVEREF(__pyx_t_9);
+    PyTuple_SET_ITEM(__pyx_t_10, 6, __pyx_t_9);
+    __pyx_t_1 = 0;
+    __pyx_t_5 = 0;
+    __pyx_t_6 = 0;
+    __pyx_t_7 = 0;
+    __pyx_t_8 = 0;
+    __pyx_t_9 = 0;
+
+    /* "asyncpg/protocol/prepared_stmt.pyx":309
+ *         f_format = reader.read_int16()
+ * 
+ *         result.append(             # <<<<<<<<<<<<<<
+ *             (f_name, f_table_oid, f_column_num, f_dt_oid,
+ *              f_dt_size, f_dt_mod, f_format))
+ */
+    __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_10); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(25, 309, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+  }
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":313
+ *              f_dt_size, f_dt_mod, f_format))
+ * 
+ *     return result             # <<<<<<<<<<<<<<
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_result);
+  __pyx_r = __pyx_v_result;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":280
+ * 
+ * 
+ * cdef _decode_row_desc(object desc):             # <<<<<<<<<<<<<<
+ *     cdef:
+ *         ReadBuffer reader
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol._decode_row_desc", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_reader);
+  __Pyx_XDECREF(__pyx_v_f_name);
+  __Pyx_XDECREF(__pyx_v_result);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":83
+ * 
+ * cdef class BaseProtocol(CoreProtocol):
+ *     def __init__(self, addr, connected_fut, con_args, loop):             # <<<<<<<<<<<<<<
+ *         CoreProtocol.__init__(self, con_args)
+ * 
+ */
+
+/* Python wrapper */
+static int __pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_addr = 0;
+  PyObject *__pyx_v_connected_fut = 0;
+  PyObject *__pyx_v_con_args = 0;
+  PyObject *__pyx_v_loop = 0;
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_addr,&__pyx_n_s_connected_fut,&__pyx_n_s_con_args,&__pyx_n_s_loop,0};
+    PyObject* values[4] = {0,0,0,0};
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_addr)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+        case  1:
+        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_connected_fut)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 1); __PYX_ERR(27, 83, __pyx_L3_error)
+        }
+        case  2:
+        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_con_args)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 2); __PYX_ERR(27, 83, __pyx_L3_error)
+        }
+        case  3:
+        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 3); __PYX_ERR(27, 83, __pyx_L3_error)
+        }
+      }
+      if (unlikely(kw_args > 0)) {
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(27, 83, __pyx_L3_error)
+      }
+    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
+      goto __pyx_L5_argtuple_error;
+    } else {
+      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+    }
+    __pyx_v_addr = values[0];
+    __pyx_v_connected_fut = values[1];
+    __pyx_v_con_args = values[2];
+    __pyx_v_loop = values[3];
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(27, 83, __pyx_L3_error)
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return -1;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol___init__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self), __pyx_v_addr, __pyx_v_connected_fut, __pyx_v_con_args, __pyx_v_loop);
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static int __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol___init__(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_addr, PyObject *__pyx_v_connected_fut, PyObject *__pyx_v_con_args, PyObject *__pyx_v_loop) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  __Pyx_RefNannySetupContext("__init__", 0);
+
+  /* "asyncpg/protocol/protocol.pyx":84
+ * cdef class BaseProtocol(CoreProtocol):
+ *     def __init__(self, addr, connected_fut, con_args, loop):
+ *         CoreProtocol.__init__(self, con_args)             # <<<<<<<<<<<<<<
+ * 
+ *         self.loop = loop
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_CoreProtocol), __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 84, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = NULL;
+  __pyx_t_4 = 0;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+      __pyx_t_4 = 1;
+    }
+  }
+  #if CYTHON_FAST_PYCALL
+  if (PyFunction_Check(__pyx_t_2)) {
+    PyObject *__pyx_temp[3] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_con_args};
+    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 84, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+  } else
+  #endif
+  #if CYTHON_FAST_PYCCALL
+  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+    PyObject *__pyx_temp[3] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_con_args};
+    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 84, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+  } else
+  #endif
+  {
+    __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 84, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    if (__pyx_t_3) {
+      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
+    }
+    __Pyx_INCREF(((PyObject *)__pyx_v_self));
+    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
+    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, ((PyObject *)__pyx_v_self));
+    __Pyx_INCREF(__pyx_v_con_args);
+    __Pyx_GIVEREF(__pyx_v_con_args);
+    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_con_args);
+    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 84, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":86
+ *         CoreProtocol.__init__(self, con_args)
+ * 
+ *         self.loop = loop             # <<<<<<<<<<<<<<
+ *         self.waiter = connected_fut
+ *         self.cancel_waiter = None
+ */
+  __Pyx_INCREF(__pyx_v_loop);
+  __Pyx_GIVEREF(__pyx_v_loop);
+  __Pyx_GOTREF(__pyx_v_self->loop);
+  __Pyx_DECREF(__pyx_v_self->loop);
+  __pyx_v_self->loop = __pyx_v_loop;
+
+  /* "asyncpg/protocol/protocol.pyx":87
+ * 
+ *         self.loop = loop
+ *         self.waiter = connected_fut             # <<<<<<<<<<<<<<
+ *         self.cancel_waiter = None
+ *         self.cancel_sent_waiter = None
+ */
+  __Pyx_INCREF(__pyx_v_connected_fut);
+  __Pyx_GIVEREF(__pyx_v_connected_fut);
+  __Pyx_GOTREF(__pyx_v_self->waiter);
+  __Pyx_DECREF(__pyx_v_self->waiter);
+  __pyx_v_self->waiter = __pyx_v_connected_fut;
+
+  /* "asyncpg/protocol/protocol.pyx":88
+ *         self.loop = loop
+ *         self.waiter = connected_fut
+ *         self.cancel_waiter = None             # <<<<<<<<<<<<<<
+ *         self.cancel_sent_waiter = None
+ * 
+ */
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->cancel_waiter);
+  __Pyx_DECREF(__pyx_v_self->cancel_waiter);
+  __pyx_v_self->cancel_waiter = Py_None;
+
+  /* "asyncpg/protocol/protocol.pyx":89
+ *         self.waiter = connected_fut
+ *         self.cancel_waiter = None
+ *         self.cancel_sent_waiter = None             # <<<<<<<<<<<<<<
+ * 
+ *         self.address = addr
+ */
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->cancel_sent_waiter);
+  __Pyx_DECREF(__pyx_v_self->cancel_sent_waiter);
+  __pyx_v_self->cancel_sent_waiter = Py_None;
+
+  /* "asyncpg/protocol/protocol.pyx":91
+ *         self.cancel_sent_waiter = None
+ * 
+ *         self.address = addr             # <<<<<<<<<<<<<<
+ *         self.settings = ConnectionSettings(
+ *             (self.address, con_args.get('database')))
+ */
+  __Pyx_INCREF(__pyx_v_addr);
+  __Pyx_GIVEREF(__pyx_v_addr);
+  __Pyx_GOTREF(__pyx_v_self->address);
+  __Pyx_DECREF(__pyx_v_self->address);
+  __pyx_v_self->address = __pyx_v_addr;
+
+  /* "asyncpg/protocol/protocol.pyx":93
+ *         self.address = addr
+ *         self.settings = ConnectionSettings(
+ *             (self.address, con_args.get('database')))             # <<<<<<<<<<<<<<
+ * 
+ *         self.uid_counter = 0
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_con_args, __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 93, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__70, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 93, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 93, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(__pyx_v_self->address);
+  __Pyx_GIVEREF(__pyx_v_self->address);
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->address);
+  __Pyx_GIVEREF(__pyx_t_2);
+  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
+  __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":92
+ * 
+ *         self.address = addr
+ *         self.settings = ConnectionSettings(             # <<<<<<<<<<<<<<
+ *             (self.address, con_args.get('database')))
+ * 
+ */
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 92, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
+  __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_ConnectionSettings), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 92, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_GIVEREF(__pyx_t_1);
+  __Pyx_GOTREF(__pyx_v_self->settings);
+  __Pyx_DECREF(((PyObject *)__pyx_v_self->settings));
+  __pyx_v_self->settings = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":95
+ *             (self.address, con_args.get('database')))
+ * 
+ *         self.uid_counter = 0             # <<<<<<<<<<<<<<
+ *         self.statement = None
+ *         self.return_extra = False
+ */
+  __pyx_v_self->uid_counter = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":96
+ * 
+ *         self.uid_counter = 0
+ *         self.statement = None             # <<<<<<<<<<<<<<
+ *         self.return_extra = False
+ * 
+ */
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->statement);
+  __Pyx_DECREF(((PyObject *)__pyx_v_self->statement));
+  __pyx_v_self->statement = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)Py_None);
+
+  /* "asyncpg/protocol/protocol.pyx":97
+ *         self.uid_counter = 0
+ *         self.statement = None
+ *         self.return_extra = False             # <<<<<<<<<<<<<<
+ * 
+ *         self.last_query = None
+ */
+  __pyx_v_self->return_extra = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":99
+ *         self.return_extra = False
+ * 
+ *         self.last_query = None             # <<<<<<<<<<<<<<
+ * 
+ *         self.closing = False
+ */
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->last_query);
+  __Pyx_DECREF(__pyx_v_self->last_query);
+  __pyx_v_self->last_query = ((PyObject*)Py_None);
+
+  /* "asyncpg/protocol/protocol.pyx":101
+ *         self.last_query = None
+ * 
+ *         self.closing = False             # <<<<<<<<<<<<<<
+ * 
+ *         self.timeout_handle = None
+ */
+  __pyx_v_self->closing = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":103
+ *         self.closing = False
+ * 
+ *         self.timeout_handle = None             # <<<<<<<<<<<<<<
+ *         self.timeout_callback = self._on_timeout
+ *         self.completed_callback = self._on_waiter_completed
+ */
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->timeout_handle);
+  __Pyx_DECREF(__pyx_v_self->timeout_handle);
+  __pyx_v_self->timeout_handle = Py_None;
+
+  /* "asyncpg/protocol/protocol.pyx":104
+ * 
+ *         self.timeout_handle = None
+ *         self.timeout_callback = self._on_timeout             # <<<<<<<<<<<<<<
+ *         self.completed_callback = self._on_waiter_completed
+ * 
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_timeout); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 104, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  __Pyx_GOTREF(__pyx_v_self->timeout_callback);
+  __Pyx_DECREF(__pyx_v_self->timeout_callback);
+  __pyx_v_self->timeout_callback = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":105
+ *         self.timeout_handle = None
+ *         self.timeout_callback = self._on_timeout
+ *         self.completed_callback = self._on_waiter_completed             # <<<<<<<<<<<<<<
+ * 
+ *         self.queries_count = 0
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_waiter_completed); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 105, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  __Pyx_GOTREF(__pyx_v_self->completed_callback);
+  __Pyx_DECREF(__pyx_v_self->completed_callback);
+  __pyx_v_self->completed_callback = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":107
+ *         self.completed_callback = self._on_waiter_completed
+ * 
+ *         self.queries_count = 0             # <<<<<<<<<<<<<<
+ * 
+ *         try:
+ */
+  __pyx_v_self->queries_count = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":109
+ *         self.queries_count = 0
+ * 
+ *         try:             # <<<<<<<<<<<<<<
+ *             self.create_future = loop.create_future
+ *         except AttributeError:
+ */
+  {
+    __Pyx_PyThreadState_declare
+    __Pyx_PyThreadState_assign
+    __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
+    __Pyx_XGOTREF(__pyx_t_6);
+    __Pyx_XGOTREF(__pyx_t_7);
+    __Pyx_XGOTREF(__pyx_t_8);
+    /*try:*/ {
+
+      /* "asyncpg/protocol/protocol.pyx":110
+ * 
+ *         try:
+ *             self.create_future = loop.create_future             # <<<<<<<<<<<<<<
+ *         except AttributeError:
+ *             self.create_future = self._create_future_fallback
+ */
+      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_loop, __pyx_n_s_create_future); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 110, __pyx_L3_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_GIVEREF(__pyx_t_1);
+      __Pyx_GOTREF(__pyx_v_self->create_future);
+      __Pyx_DECREF(__pyx_v_self->create_future);
+      __pyx_v_self->create_future = __pyx_t_1;
+      __pyx_t_1 = 0;
+
+      /* "asyncpg/protocol/protocol.pyx":109
+ *         self.queries_count = 0
+ * 
+ *         try:             # <<<<<<<<<<<<<<
+ *             self.create_future = loop.create_future
+ *         except AttributeError:
+ */
+    }
+    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+    goto __pyx_L10_try_end;
+    __pyx_L3_error:;
+    __Pyx_PyThreadState_assign
+    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/protocol.pyx":111
+ *         try:
+ *             self.create_future = loop.create_future
+ *         except AttributeError:             # <<<<<<<<<<<<<<
+ *             self.create_future = self._create_future_fallback
+ * 
+ */
+    __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
+    if (__pyx_t_4) {
+      __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_5) < 0) __PYX_ERR(27, 111, __pyx_L5_except_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_GOTREF(__pyx_t_5);
+
+      /* "asyncpg/protocol/protocol.pyx":112
+ *             self.create_future = loop.create_future
+ *         except AttributeError:
+ *             self.create_future = self._create_future_fallback             # <<<<<<<<<<<<<<
+ * 
+ *     def set_connection(self, connection):
+ */
+      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_create_future_fallback); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 112, __pyx_L5_except_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_GIVEREF(__pyx_t_3);
+      __Pyx_GOTREF(__pyx_v_self->create_future);
+      __Pyx_DECREF(__pyx_v_self->create_future);
+      __pyx_v_self->create_future = __pyx_t_3;
+      __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      goto __pyx_L4_exception_handled;
+    }
+    goto __pyx_L5_except_error;
+    __pyx_L5_except_error:;
+
+    /* "asyncpg/protocol/protocol.pyx":109
+ *         self.queries_count = 0
+ * 
+ *         try:             # <<<<<<<<<<<<<<
+ *             self.create_future = loop.create_future
+ *         except AttributeError:
+ */
+    __Pyx_PyThreadState_assign
+    __Pyx_XGIVEREF(__pyx_t_6);
+    __Pyx_XGIVEREF(__pyx_t_7);
+    __Pyx_XGIVEREF(__pyx_t_8);
+    __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
+    goto __pyx_L1_error;
+    __pyx_L4_exception_handled:;
+    __Pyx_PyThreadState_assign
+    __Pyx_XGIVEREF(__pyx_t_6);
+    __Pyx_XGIVEREF(__pyx_t_7);
+    __Pyx_XGIVEREF(__pyx_t_8);
+    __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
+    __pyx_L10_try_end:;
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":83
+ * 
+ * cdef class BaseProtocol(CoreProtocol):
+ *     def __init__(self, addr, connected_fut, con_args, loop):             # <<<<<<<<<<<<<<
+ *         CoreProtocol.__init__(self, con_args)
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":114
+ *             self.create_future = self._create_future_fallback
+ * 
+ *     def set_connection(self, connection):             # <<<<<<<<<<<<<<
+ *         self.connection = connection
+ * 
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_3set_connection(PyObject *__pyx_v_self, PyObject *__pyx_v_connection); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_3set_connection(PyObject *__pyx_v_self, PyObject *__pyx_v_connection) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("set_connection (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_2set_connection(((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self), ((PyObject *)__pyx_v_connection));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_2set_connection(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_connection) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("set_connection", 0);
+
+  /* "asyncpg/protocol/protocol.pyx":115
+ * 
+ *     def set_connection(self, connection):
+ *         self.connection = connection             # <<<<<<<<<<<<<<
+ * 
+ *     def get_server_pid(self):
+ */
+  __Pyx_INCREF(__pyx_v_connection);
+  __Pyx_GIVEREF(__pyx_v_connection);
+  __Pyx_GOTREF(__pyx_v_self->connection);
+  __Pyx_DECREF(__pyx_v_self->connection);
+  __pyx_v_self->connection = __pyx_v_connection;
+
+  /* "asyncpg/protocol/protocol.pyx":114
+ *             self.create_future = self._create_future_fallback
+ * 
+ *     def set_connection(self, connection):             # <<<<<<<<<<<<<<
+ *         self.connection = connection
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":117
+ *         self.connection = connection
+ * 
+ *     def get_server_pid(self):             # <<<<<<<<<<<<<<
+ *         return self.backend_pid
+ * 
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_5get_server_pid(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_5get_server_pid(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("get_server_pid (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_4get_server_pid(((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_4get_server_pid(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("get_server_pid", 0);
+
+  /* "asyncpg/protocol/protocol.pyx":118
+ * 
+ *     def get_server_pid(self):
+ *         return self.backend_pid             # <<<<<<<<<<<<<<
+ * 
+ *     def get_settings(self):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __Pyx_PyInt_From_int32_t(__pyx_v_self->__pyx_base.backend_pid); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 118, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/protocol.pyx":117
+ *         self.connection = connection
+ * 
+ *     def get_server_pid(self):             # <<<<<<<<<<<<<<
+ *         return self.backend_pid
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.get_server_pid", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":120
+ *         return self.backend_pid
+ * 
+ *     def get_settings(self):             # <<<<<<<<<<<<<<
+ *         return self.settings
+ * 
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_7get_settings(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_7get_settings(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("get_settings (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_6get_settings(((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_6get_settings(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("get_settings", 0);
+
+  /* "asyncpg/protocol/protocol.pyx":121
+ * 
+ *     def get_settings(self):
+ *         return self.settings             # <<<<<<<<<<<<<<
+ * 
+ *     async def prepare(self, stmt_name, query, timeout):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(((PyObject *)__pyx_v_self->settings));
+  __pyx_r = ((PyObject *)__pyx_v_self->settings);
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/protocol.pyx":120
+ *         return self.backend_pid
+ * 
+ *     def get_settings(self):             # <<<<<<<<<<<<<<
+ *         return self.settings
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_10generator(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
+
+/* "asyncpg/protocol/protocol.pyx":123
+ *         return self.settings
+ * 
+ *     async def prepare(self, stmt_name, query, timeout):             # <<<<<<<<<<<<<<
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_9prepare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_9prepare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_stmt_name = 0;
+  PyObject *__pyx_v_query = 0;
+  PyObject *__pyx_v_timeout = 0;
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("prepare (wrapper)", 0);
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_stmt_name,&__pyx_n_s_query,&__pyx_n_s_timeout,0};
+    PyObject* values[3] = {0,0,0};
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_stmt_name)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+        case  1:
+        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_query)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("prepare", 1, 3, 3, 1); __PYX_ERR(27, 123, __pyx_L3_error)
+        }
+        case  2:
+        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_timeout)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("prepare", 1, 3, 3, 2); __PYX_ERR(27, 123, __pyx_L3_error)
+        }
+      }
+      if (unlikely(kw_args > 0)) {
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "prepare") < 0)) __PYX_ERR(27, 123, __pyx_L3_error)
+      }
+    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
+      goto __pyx_L5_argtuple_error;
+    } else {
+      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+    }
+    __pyx_v_stmt_name = values[0];
+    __pyx_v_query = values[1];
+    __pyx_v_timeout = values[2];
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("prepare", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(27, 123, __pyx_L3_error)
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.prepare", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_8prepare(((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self), __pyx_v_stmt_name, __pyx_v_query, __pyx_v_timeout);
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_8prepare(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_stmt_name, PyObject *__pyx_v_query, PyObject *__pyx_v_timeout) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare *__pyx_cur_scope;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("prepare", 0);
+  __pyx_cur_scope = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare *)__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare(__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare, __pyx_empty_tuple, NULL);
+  if (unlikely(!__pyx_cur_scope)) {
+    __pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare *)Py_None);
+    __Pyx_INCREF(Py_None);
+    __PYX_ERR(27, 123, __pyx_L1_error)
+  } else {
+    __Pyx_GOTREF(__pyx_cur_scope);
+  }
+  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
+  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
+  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
+  __pyx_cur_scope->__pyx_v_stmt_name = __pyx_v_stmt_name;
+  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_stmt_name);
+  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_stmt_name);
+  __pyx_cur_scope->__pyx_v_query = __pyx_v_query;
+  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_query);
+  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_query);
+  __pyx_cur_scope->__pyx_v_timeout = __pyx_v_timeout;
+  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_timeout);
+  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_timeout);
+  {
+    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_10generator, (PyObject *) __pyx_cur_scope, __pyx_n_s_prepare, __pyx_n_s_BaseProtocol_prepare, __pyx_n_s_asyncpg_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(27, 123, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_cur_scope);
+    __Pyx_RefNannyFinishContext();
+    return (PyObject *) gen;
+  }
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.prepare", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_10generator(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
+{
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare *__pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare *)__pyx_generator->closure);
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("None", 0);
+  switch (__pyx_generator->resume_label) {
+    case 0: goto __pyx_L3_first_run;
+    case 1: goto __pyx_L5_resume_from_yield;
+    case 2: goto __pyx_L7_resume_from_yield;
+    case 3: goto __pyx_L9_resume_from_yield;
+    default: /* CPython raises the right error here */
+    __Pyx_RefNannyFinishContext();
+    return NULL;
+  }
+  __pyx_L3_first_run:;
+  if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 123, __pyx_L1_error)
+
+  /* "asyncpg/protocol/protocol.pyx":124
+ * 
+ *     async def prepare(self, stmt_name, query, timeout):
+ *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:
+ */
+  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_self->cancel_waiter != Py_None);
+  __pyx_t_2 = (__pyx_t_1 != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/protocol.pyx":125
+ *     async def prepare(self, stmt_name, query, timeout):
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter             # <<<<<<<<<<<<<<
+ *         if self.cancel_sent_waiter is not None:
+ *             await self.cancel_sent_waiter
+ */
+    __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_cur_scope->__pyx_v_self->cancel_waiter);
+    __Pyx_XGOTREF(__pyx_r);
+    if (likely(__pyx_r)) {
+      __Pyx_XGIVEREF(__pyx_r);
+      __Pyx_RefNannyFinishContext();
+      /* return from generator, yielding value */
+      __pyx_generator->resume_label = 1;
+      return __pyx_r;
+      __pyx_L5_resume_from_yield:;
+      if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 125, __pyx_L1_error)
+    } else {
+      PyObject* exc_type = PyErr_Occurred();
+      if (exc_type) {
+        if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+        else __PYX_ERR(27, 125, __pyx_L1_error)
+      }
+    }
+
+    /* "asyncpg/protocol/protocol.pyx":124
+ * 
+ *     async def prepare(self, stmt_name, query, timeout):
+ *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":126
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_sent_waiter
+ *             self.cancel_sent_waiter = None
+ */
+  __pyx_t_2 = (__pyx_cur_scope->__pyx_v_self->cancel_sent_waiter != Py_None);
+  __pyx_t_1 = (__pyx_t_2 != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/protocol.pyx":127
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:
+ *             await self.cancel_sent_waiter             # <<<<<<<<<<<<<<
+ *             self.cancel_sent_waiter = None
+ * 
+ */
+    __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_cur_scope->__pyx_v_self->cancel_sent_waiter);
+    __Pyx_XGOTREF(__pyx_r);
+    if (likely(__pyx_r)) {
+      __Pyx_XGIVEREF(__pyx_r);
+      __Pyx_RefNannyFinishContext();
+      /* return from generator, yielding value */
+      __pyx_generator->resume_label = 2;
+      return __pyx_r;
+      __pyx_L7_resume_from_yield:;
+      if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 127, __pyx_L1_error)
+    } else {
+      PyObject* exc_type = PyErr_Occurred();
+      if (exc_type) {
+        if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+        else __PYX_ERR(27, 127, __pyx_L1_error)
+      }
+    }
+
+    /* "asyncpg/protocol/protocol.pyx":128
+ *         if self.cancel_sent_waiter is not None:
+ *             await self.cancel_sent_waiter
+ *             self.cancel_sent_waiter = None             # <<<<<<<<<<<<<<
+ * 
+ *         self._ensure_clear_state()
+ */
+    __Pyx_INCREF(Py_None);
+    __Pyx_GIVEREF(Py_None);
+    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->cancel_sent_waiter);
+    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->cancel_sent_waiter);
+    __pyx_cur_scope->__pyx_v_self->cancel_sent_waiter = Py_None;
+
+    /* "asyncpg/protocol/protocol.pyx":126
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_sent_waiter
+ *             self.cancel_sent_waiter = None
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":130
+ *             self.cancel_sent_waiter = None
+ * 
+ *         self._ensure_clear_state()             # <<<<<<<<<<<<<<
+ * 
+ *         if stmt_name is None:
+ */
+  __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_ensure_clear_state(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 130, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":132
+ *         self._ensure_clear_state()
+ * 
+ *         if stmt_name is None:             # <<<<<<<<<<<<<<
+ *             self.uid_counter += 1
+ *             stmt_name = 'stmt_{}'.format(self.uid_counter)
+ */
+  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_stmt_name == Py_None);
+  __pyx_t_2 = (__pyx_t_1 != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/protocol.pyx":133
+ * 
+ *         if stmt_name is None:
+ *             self.uid_counter += 1             # <<<<<<<<<<<<<<
+ *             stmt_name = 'stmt_{}'.format(self.uid_counter)
+ * 
+ */
+    __pyx_cur_scope->__pyx_v_self->uid_counter = (__pyx_cur_scope->__pyx_v_self->uid_counter + 1);
+
+    /* "asyncpg/protocol/protocol.pyx":134
+ *         if stmt_name is None:
+ *             self.uid_counter += 1
+ *             stmt_name = 'stmt_{}'.format(self.uid_counter)             # <<<<<<<<<<<<<<
+ * 
+ *         self._prepare(stmt_name, query)
+ */
+    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_stmt, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 134, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_self->uid_counter); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 134, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
+      if (likely(__pyx_t_6)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+        __Pyx_INCREF(__pyx_t_6);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_4, function);
+      }
+    }
+    if (!__pyx_t_6) {
+      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 134, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_4)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
+        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 134, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
+        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 134, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(27, 134, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
+        __Pyx_GIVEREF(__pyx_t_5);
+        PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5);
+        __pyx_t_5 = 0;
+        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 134, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_stmt_name);
+    __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_stmt_name, __pyx_t_3);
+    __Pyx_GIVEREF(__pyx_t_3);
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/protocol.pyx":132
+ *         self._ensure_clear_state()
+ * 
+ *         if stmt_name is None:             # <<<<<<<<<<<<<<
+ *             self.uid_counter += 1
+ *             stmt_name = 'stmt_{}'.format(self.uid_counter)
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":136
+ *             stmt_name = 'stmt_{}'.format(self.uid_counter)
+ * 
+ *         self._prepare(stmt_name, query)             # <<<<<<<<<<<<<<
+ *         self.last_query = query
+ *         self.statement = PreparedStatementState(stmt_name, query, self)
+ */
+  if (!(likely(PyUnicode_CheckExact(__pyx_cur_scope->__pyx_v_stmt_name))||((__pyx_cur_scope->__pyx_v_stmt_name) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_cur_scope->__pyx_v_stmt_name)->tp_name), 0))) __PYX_ERR(27, 136, __pyx_L1_error)
+  if (!(likely(PyUnicode_CheckExact(__pyx_cur_scope->__pyx_v_query))||((__pyx_cur_scope->__pyx_v_query) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_cur_scope->__pyx_v_query)->tp_name), 0))) __PYX_ERR(27, 136, __pyx_L1_error)
+  __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._prepare(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_cur_scope->__pyx_v_self), ((PyObject*)__pyx_cur_scope->__pyx_v_stmt_name), ((PyObject*)__pyx_cur_scope->__pyx_v_query)); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 136, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":137
+ * 
+ *         self._prepare(stmt_name, query)
+ *         self.last_query = query             # <<<<<<<<<<<<<<
+ *         self.statement = PreparedStatementState(stmt_name, query, self)
+ * 
+ */
+  if (!(likely(PyUnicode_CheckExact(__pyx_cur_scope->__pyx_v_query))||((__pyx_cur_scope->__pyx_v_query) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_cur_scope->__pyx_v_query)->tp_name), 0))) __PYX_ERR(27, 137, __pyx_L1_error)
+  __pyx_t_3 = __pyx_cur_scope->__pyx_v_query;
+  __Pyx_INCREF(__pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_3);
+  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->last_query);
+  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->last_query);
+  __pyx_cur_scope->__pyx_v_self->last_query = ((PyObject*)__pyx_t_3);
+  __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":138
+ *         self._prepare(stmt_name, query)
+ *         self.last_query = query
+ *         self.statement = PreparedStatementState(stmt_name, query, self)             # <<<<<<<<<<<<<<
+ * 
+ *         return await self._new_waiter(timeout)
+ */
+  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 138, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_stmt_name);
+  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_stmt_name);
+  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_cur_scope->__pyx_v_stmt_name);
+  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_query);
+  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_query);
+  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_cur_scope->__pyx_v_query);
+  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_self));
+  __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_self));
+  PyTuple_SET_ITEM(__pyx_t_3, 2, ((PyObject *)__pyx_cur_scope->__pyx_v_self));
+  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_PreparedStatementState), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 138, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_GIVEREF(__pyx_t_4);
+  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->statement);
+  __Pyx_DECREF(((PyObject *)__pyx_cur_scope->__pyx_v_self->statement));
+  __pyx_cur_scope->__pyx_v_self->statement = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)__pyx_t_4);
+  __pyx_t_4 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":140
+ *         self.statement = PreparedStatementState(stmt_name, query, self)
+ * 
+ *         return await self._new_waiter(timeout)             # <<<<<<<<<<<<<<
+ * 
+ *     async def bind_execute(self, PreparedStatementState state, args,
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_4 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_new_waiter(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_timeout); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 140, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __Pyx_XGOTREF(__pyx_r);
+  if (likely(__pyx_r)) {
+    __Pyx_XGIVEREF(__pyx_r);
+    __Pyx_RefNannyFinishContext();
+    /* return from generator, yielding value */
+    __pyx_generator->resume_label = 3;
+    return __pyx_r;
+    __pyx_L9_resume_from_yield:;
+    if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 140, __pyx_L1_error)
+    __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
+  } else {
+    __pyx_t_4 = NULL;
+    if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_4) < 0) __PYX_ERR(27, 140, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+  }
+  __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = 0;
+  goto __pyx_L0;
+  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
+
+  /* "asyncpg/protocol/protocol.pyx":123
+ *         return self.settings
+ * 
+ *     async def prepare(self, stmt_name, query, timeout):             # <<<<<<<<<<<<<<
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_AddTraceback("prepare", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
+  __pyx_generator->resume_label = -1;
+  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_13generator1(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
+
+/* "asyncpg/protocol/protocol.pyx":142
+ *         return await self._new_waiter(timeout)
+ * 
+ *     async def bind_execute(self, PreparedStatementState state, args,             # <<<<<<<<<<<<<<
+ *                            str portal_name, int limit, return_extra,
+ *                            timeout):
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_12bind_execute(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_12bind_execute(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_state = 0;
+  PyObject *__pyx_v_args = 0;
+  PyObject *__pyx_v_portal_name = 0;
+  int __pyx_v_limit;
+  PyObject *__pyx_v_return_extra = 0;
+  PyObject *__pyx_v_timeout = 0;
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("bind_execute (wrapper)", 0);
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_state,&__pyx_n_s_args,&__pyx_n_s_portal_name,&__pyx_n_s_limit,&__pyx_n_s_return_extra,&__pyx_n_s_timeout,0};
+    PyObject* values[6] = {0,0,0,0,0,0};
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
+        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_state)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+        case  1:
+        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("bind_execute", 1, 6, 6, 1); __PYX_ERR(27, 142, __pyx_L3_error)
+        }
+        case  2:
+        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_portal_name)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("bind_execute", 1, 6, 6, 2); __PYX_ERR(27, 142, __pyx_L3_error)
+        }
+        case  3:
+        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_limit)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("bind_execute", 1, 6, 6, 3); __PYX_ERR(27, 142, __pyx_L3_error)
+        }
+        case  4:
+        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_return_extra)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("bind_execute", 1, 6, 6, 4); __PYX_ERR(27, 142, __pyx_L3_error)
+        }
+        case  5:
+        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_timeout)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("bind_execute", 1, 6, 6, 5); __PYX_ERR(27, 142, __pyx_L3_error)
+        }
+      }
+      if (unlikely(kw_args > 0)) {
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "bind_execute") < 0)) __PYX_ERR(27, 142, __pyx_L3_error)
+      }
+    } else if (PyTuple_GET_SIZE(__pyx_args) != 6) {
+      goto __pyx_L5_argtuple_error;
+    } else {
+      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
+    }
+    __pyx_v_state = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)values[0]);
+    __pyx_v_args = values[1];
+    __pyx_v_portal_name = ((PyObject*)values[2]);
+    __pyx_v_limit = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_limit == (int)-1) && PyErr_Occurred())) __PYX_ERR(27, 143, __pyx_L3_error)
+    __pyx_v_return_extra = values[4];
+    __pyx_v_timeout = values[5];
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("bind_execute", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(27, 142, __pyx_L3_error)
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.bind_execute", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state), __pyx_ptype_7asyncpg_8protocol_8protocol_PreparedStatementState, 1, "state", 0))) __PYX_ERR(27, 142, __pyx_L1_error)
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_portal_name), (&PyUnicode_Type), 1, "portal_name", 1))) __PYX_ERR(27, 143, __pyx_L1_error)
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_11bind_execute(((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self), __pyx_v_state, __pyx_v_args, __pyx_v_portal_name, __pyx_v_limit, __pyx_v_return_extra, __pyx_v_timeout);
+
+  /* function exit code */
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_11bind_execute(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_state, PyObject *__pyx_v_args, PyObject *__pyx_v_portal_name, int __pyx_v_limit, PyObject *__pyx_v_return_extra, PyObject *__pyx_v_timeout) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute *__pyx_cur_scope;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("bind_execute", 0);
+  __pyx_cur_scope = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute *)__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute(__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute, __pyx_empty_tuple, NULL);
+  if (unlikely(!__pyx_cur_scope)) {
+    __pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute *)Py_None);
+    __Pyx_INCREF(Py_None);
+    __PYX_ERR(27, 142, __pyx_L1_error)
+  } else {
+    __Pyx_GOTREF(__pyx_cur_scope);
+  }
+  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
+  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
+  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
+  __pyx_cur_scope->__pyx_v_state = __pyx_v_state;
+  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_state);
+  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_state);
+  __pyx_cur_scope->__pyx_v_args = __pyx_v_args;
+  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_args);
+  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_args);
+  __pyx_cur_scope->__pyx_v_portal_name = __pyx_v_portal_name;
+  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_portal_name);
+  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_portal_name);
+  __pyx_cur_scope->__pyx_v_limit = __pyx_v_limit;
+  __pyx_cur_scope->__pyx_v_return_extra = __pyx_v_return_extra;
+  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_return_extra);
+  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_return_extra);
+  __pyx_cur_scope->__pyx_v_timeout = __pyx_v_timeout;
+  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_timeout);
+  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_timeout);
+  {
+    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_13generator1, (PyObject *) __pyx_cur_scope, __pyx_n_s_bind_execute, __pyx_n_s_BaseProtocol_bind_execute, __pyx_n_s_asyncpg_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(27, 142, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_cur_scope);
+    __Pyx_RefNannyFinishContext();
+    return (PyObject *) gen;
+  }
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.bind_execute", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_13generator1(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
+{
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute *__pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute *)__pyx_generator->closure);
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("None", 0);
+  switch (__pyx_generator->resume_label) {
+    case 0: goto __pyx_L3_first_run;
+    case 1: goto __pyx_L5_resume_from_yield;
+    case 2: goto __pyx_L7_resume_from_yield;
+    case 3: goto __pyx_L8_resume_from_yield;
+    default: /* CPython raises the right error here */
+    __Pyx_RefNannyFinishContext();
+    return NULL;
+  }
+  __pyx_L3_first_run:;
+  if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 142, __pyx_L1_error)
+
+  /* "asyncpg/protocol/protocol.pyx":146
+ *                            timeout):
+ * 
+ *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:
+ */
+  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_self->cancel_waiter != Py_None);
+  __pyx_t_2 = (__pyx_t_1 != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/protocol.pyx":147
+ * 
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter             # <<<<<<<<<<<<<<
+ *         if self.cancel_sent_waiter is not None:
+ *             await self.cancel_sent_waiter
+ */
+    __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_cur_scope->__pyx_v_self->cancel_waiter);
+    __Pyx_XGOTREF(__pyx_r);
+    if (likely(__pyx_r)) {
+      __Pyx_XGIVEREF(__pyx_r);
+      __Pyx_RefNannyFinishContext();
+      /* return from generator, yielding value */
+      __pyx_generator->resume_label = 1;
+      return __pyx_r;
+      __pyx_L5_resume_from_yield:;
+      if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 147, __pyx_L1_error)
+    } else {
+      PyObject* exc_type = PyErr_Occurred();
+      if (exc_type) {
+        if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+        else __PYX_ERR(27, 147, __pyx_L1_error)
+      }
+    }
+
+    /* "asyncpg/protocol/protocol.pyx":146
+ *                            timeout):
+ * 
+ *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":148
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_sent_waiter
+ *             self.cancel_sent_waiter = None
+ */
+  __pyx_t_2 = (__pyx_cur_scope->__pyx_v_self->cancel_sent_waiter != Py_None);
+  __pyx_t_1 = (__pyx_t_2 != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/protocol.pyx":149
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:
+ *             await self.cancel_sent_waiter             # <<<<<<<<<<<<<<
+ *             self.cancel_sent_waiter = None
+ * 
+ */
+    __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_cur_scope->__pyx_v_self->cancel_sent_waiter);
+    __Pyx_XGOTREF(__pyx_r);
+    if (likely(__pyx_r)) {
+      __Pyx_XGIVEREF(__pyx_r);
+      __Pyx_RefNannyFinishContext();
+      /* return from generator, yielding value */
+      __pyx_generator->resume_label = 2;
+      return __pyx_r;
+      __pyx_L7_resume_from_yield:;
+      if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 149, __pyx_L1_error)
+    } else {
+      PyObject* exc_type = PyErr_Occurred();
+      if (exc_type) {
+        if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+        else __PYX_ERR(27, 149, __pyx_L1_error)
+      }
+    }
+
+    /* "asyncpg/protocol/protocol.pyx":150
+ *         if self.cancel_sent_waiter is not None:
+ *             await self.cancel_sent_waiter
+ *             self.cancel_sent_waiter = None             # <<<<<<<<<<<<<<
+ * 
+ *         self._ensure_clear_state()
+ */
+    __Pyx_INCREF(Py_None);
+    __Pyx_GIVEREF(Py_None);
+    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->cancel_sent_waiter);
+    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->cancel_sent_waiter);
+    __pyx_cur_scope->__pyx_v_self->cancel_sent_waiter = Py_None;
+
+    /* "asyncpg/protocol/protocol.pyx":148
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_sent_waiter
+ *             self.cancel_sent_waiter = None
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":152
+ *             self.cancel_sent_waiter = None
+ * 
+ *         self._ensure_clear_state()             # <<<<<<<<<<<<<<
+ * 
+ *         self._bind_execute(
+ */
+  __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_ensure_clear_state(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 152, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":156
+ *         self._bind_execute(
+ *             portal_name,
+ *             state.name,             # <<<<<<<<<<<<<<
+ *             state._encode_bind_msg(args),
+ *             limit)
+ */
+  __pyx_t_3 = __pyx_cur_scope->__pyx_v_state->name;
+  __Pyx_INCREF(__pyx_t_3);
+
+  /* "asyncpg/protocol/protocol.pyx":157
+ *             portal_name,
+ *             state.name,
+ *             state._encode_bind_msg(args),             # <<<<<<<<<<<<<<
+ *             limit)
+ * 
+ */
+  __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__encode_bind_msg(__pyx_cur_scope->__pyx_v_state, __pyx_cur_scope->__pyx_v_args); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 157, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_7asyncpg_8protocol_8protocol_WriteBuffer))))) __PYX_ERR(27, 157, __pyx_L1_error)
+
+  /* "asyncpg/protocol/protocol.pyx":154
+ *         self._ensure_clear_state()
+ * 
+ *         self._bind_execute(             # <<<<<<<<<<<<<<
+ *             portal_name,
+ *             state.name,
+ */
+  __pyx_t_5 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._bind_execute(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_portal_name, ((PyObject*)__pyx_t_3), ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_4), __pyx_cur_scope->__pyx_v_limit); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 154, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":160
+ *             limit)
+ * 
+ *         self.last_query = state.query             # <<<<<<<<<<<<<<
+ *         self.statement = state
+ *         self.return_extra = return_extra
+ */
+  __pyx_t_5 = __pyx_cur_scope->__pyx_v_state->query;
+  __Pyx_INCREF(__pyx_t_5);
+  __Pyx_GIVEREF(__pyx_t_5);
+  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->last_query);
+  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->last_query);
+  __pyx_cur_scope->__pyx_v_self->last_query = ((PyObject*)__pyx_t_5);
+  __pyx_t_5 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":161
+ * 
+ *         self.last_query = state.query
+ *         self.statement = state             # <<<<<<<<<<<<<<
+ *         self.return_extra = return_extra
+ *         self.queries_count += 1
+ */
+  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_state));
+  __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_state));
+  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->statement);
+  __Pyx_DECREF(((PyObject *)__pyx_cur_scope->__pyx_v_self->statement));
+  __pyx_cur_scope->__pyx_v_self->statement = __pyx_cur_scope->__pyx_v_state;
+
+  /* "asyncpg/protocol/protocol.pyx":162
+ *         self.last_query = state.query
+ *         self.statement = state
+ *         self.return_extra = return_extra             # <<<<<<<<<<<<<<
+ *         self.queries_count += 1
+ * 
+ */
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_return_extra); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(27, 162, __pyx_L1_error)
+  __pyx_cur_scope->__pyx_v_self->return_extra = __pyx_t_1;
+
+  /* "asyncpg/protocol/protocol.pyx":163
+ *         self.statement = state
+ *         self.return_extra = return_extra
+ *         self.queries_count += 1             # <<<<<<<<<<<<<<
+ * 
+ *         return await self._new_waiter(timeout)
+ */
+  __pyx_cur_scope->__pyx_v_self->queries_count = (__pyx_cur_scope->__pyx_v_self->queries_count + 1);
+
+  /* "asyncpg/protocol/protocol.pyx":165
+ *         self.queries_count += 1
+ * 
+ *         return await self._new_waiter(timeout)             # <<<<<<<<<<<<<<
+ * 
+ *     async def bind_execute_many(self, PreparedStatementState state, args,
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_5 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_new_waiter(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_timeout); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 165, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5);
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __Pyx_XGOTREF(__pyx_r);
+  if (likely(__pyx_r)) {
+    __Pyx_XGIVEREF(__pyx_r);
+    __Pyx_RefNannyFinishContext();
+    /* return from generator, yielding value */
+    __pyx_generator->resume_label = 3;
+    return __pyx_r;
+    __pyx_L8_resume_from_yield:;
+    if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 165, __pyx_L1_error)
+    __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
+  } else {
+    __pyx_t_5 = NULL;
+    if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_5) < 0) __PYX_ERR(27, 165, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+  }
+  __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __pyx_t_5 = 0;
+  goto __pyx_L0;
+  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
+
+  /* "asyncpg/protocol/protocol.pyx":142
+ *         return await self._new_waiter(timeout)
+ * 
+ *     async def bind_execute(self, PreparedStatementState state, args,             # <<<<<<<<<<<<<<
+ *                            str portal_name, int limit, return_extra,
+ *                            timeout):
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("bind_execute", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
+  __pyx_generator->resume_label = -1;
+  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_16generator2(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
+
+/* "asyncpg/protocol/protocol.pyx":167
+ *         return await self._new_waiter(timeout)
+ * 
+ *     async def bind_execute_many(self, PreparedStatementState state, args,             # <<<<<<<<<<<<<<
+ *                                 str portal_name, timeout):
+ * 
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_15bind_execute_many(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_15bind_execute_many(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_state = 0;
+  PyObject *__pyx_v_args = 0;
+  PyObject *__pyx_v_portal_name = 0;
+  PyObject *__pyx_v_timeout = 0;
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("bind_execute_many (wrapper)", 0);
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_state,&__pyx_n_s_args,&__pyx_n_s_portal_name,&__pyx_n_s_timeout,0};
+    PyObject* values[4] = {0,0,0,0};
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_state)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+        case  1:
+        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("bind_execute_many", 1, 4, 4, 1); __PYX_ERR(27, 167, __pyx_L3_error)
+        }
+        case  2:
+        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_portal_name)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("bind_execute_many", 1, 4, 4, 2); __PYX_ERR(27, 167, __pyx_L3_error)
+        }
+        case  3:
+        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_timeout)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("bind_execute_many", 1, 4, 4, 3); __PYX_ERR(27, 167, __pyx_L3_error)
+        }
+      }
+      if (unlikely(kw_args > 0)) {
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "bind_execute_many") < 0)) __PYX_ERR(27, 167, __pyx_L3_error)
+      }
+    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
+      goto __pyx_L5_argtuple_error;
+    } else {
+      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+    }
+    __pyx_v_state = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)values[0]);
+    __pyx_v_args = values[1];
+    __pyx_v_portal_name = ((PyObject*)values[2]);
+    __pyx_v_timeout = values[3];
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("bind_execute_many", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(27, 167, __pyx_L3_error)
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.bind_execute_many", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state), __pyx_ptype_7asyncpg_8protocol_8protocol_PreparedStatementState, 1, "state", 0))) __PYX_ERR(27, 167, __pyx_L1_error)
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_portal_name), (&PyUnicode_Type), 1, "portal_name", 1))) __PYX_ERR(27, 168, __pyx_L1_error)
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_14bind_execute_many(((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self), __pyx_v_state, __pyx_v_args, __pyx_v_portal_name, __pyx_v_timeout);
+
+  /* function exit code */
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_17bind_execute_many_2generator8(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
+
+/* "asyncpg/protocol/protocol.pyx":181
+ *         # this generator expression to keep the memory pressure under
+ *         # control.
+ *         data_gen = (state._encode_bind_msg(b) for b in args)             # <<<<<<<<<<<<<<
+ *         arg_bufs = iter(data_gen)
+ * 
+ */
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_17bind_execute_many_genexpr(PyObject *__pyx_self) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr *__pyx_cur_scope;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("genexpr", 0);
+  __pyx_cur_scope = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr *)__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr(__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr, __pyx_empty_tuple, NULL);
+  if (unlikely(!__pyx_cur_scope)) {
+    __pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr *)Py_None);
+    __Pyx_INCREF(Py_None);
+    __PYX_ERR(27, 181, __pyx_L1_error)
+  } else {
+    __Pyx_GOTREF(__pyx_cur_scope);
+  }
+  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many *) __pyx_self;
+  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
+  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
+  {
+    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_17bind_execute_many_2generator8, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_bind_execute_many_locals_genexpr, __pyx_n_s_asyncpg_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(27, 181, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_cur_scope);
+    __Pyx_RefNannyFinishContext();
+    return (PyObject *) gen;
+  }
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.bind_execute_many.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_17bind_execute_many_2generator8(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
+{
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr *__pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr *)__pyx_generator->closure);
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  Py_ssize_t __pyx_t_2;
+  PyObject *(*__pyx_t_3)(PyObject *);
+  PyObject *__pyx_t_4 = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("None", 0);
+  switch (__pyx_generator->resume_label) {
+    case 0: goto __pyx_L3_first_run;
+    case 1: goto __pyx_L6_resume_from_yield;
+    default: /* CPython raises the right error here */
+    __Pyx_RefNannyFinishContext();
+    return NULL;
+  }
+  __pyx_L3_first_run:;
+  if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 181, __pyx_L1_error)
+  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_args)) { __Pyx_RaiseClosureNameError("args"); __PYX_ERR(27, 181, __pyx_L1_error) }
+  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_args)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_args)) {
+    __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_args; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
+    __pyx_t_3 = NULL;
+  } else {
+    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 181, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 181, __pyx_L1_error)
+  }
+  for (;;) {
+    if (likely(!__pyx_t_3)) {
+      if (likely(PyList_CheckExact(__pyx_t_1))) {
+        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
+        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(27, 181, __pyx_L1_error)
+        #else
+        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 181, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        #endif
+      } else {
+        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(27, 181, __pyx_L1_error)
+        #else
+        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 181, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        #endif
+      }
+    } else {
+      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
+      if (unlikely(!__pyx_t_4)) {
+        PyObject* exc_type = PyErr_Occurred();
+        if (exc_type) {
+          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+          else __PYX_ERR(27, 181, __pyx_L1_error)
+        }
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_4);
+    }
+    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_b);
+    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_b, __pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_4);
+    __pyx_t_4 = 0;
+    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_state)) { __Pyx_RaiseClosureNameError("state"); __PYX_ERR(27, 181, __pyx_L1_error) }
+    __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__encode_bind_msg(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_state, __pyx_cur_scope->__pyx_v_b); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 181, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_r = __pyx_t_4;
+    __pyx_t_4 = 0;
+    __Pyx_XGIVEREF(__pyx_t_1);
+    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
+    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
+    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
+    __Pyx_XGIVEREF(__pyx_r);
+    __Pyx_RefNannyFinishContext();
+    /* return from generator, yielding value */
+    __pyx_generator->resume_label = 1;
+    return __pyx_r;
+    __pyx_L6_resume_from_yield:;
+    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
+    __pyx_cur_scope->__pyx_t_0 = 0;
+    __Pyx_XGOTREF(__pyx_t_1);
+    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
+    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
+    if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 181, __pyx_L1_error)
+  }
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
+
+  /* function exit code */
+  PyErr_SetNone(PyExc_StopIteration);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
+  __pyx_generator->resume_label = -1;
+  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":167
+ *         return await self._new_waiter(timeout)
+ * 
+ *     async def bind_execute_many(self, PreparedStatementState state, args,             # <<<<<<<<<<<<<<
+ *                                 str portal_name, timeout):
+ * 
+ */
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_14bind_execute_many(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_state, PyObject *__pyx_v_args, PyObject *__pyx_v_portal_name, PyObject *__pyx_v_timeout) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many *__pyx_cur_scope;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("bind_execute_many", 0);
+  __pyx_cur_scope = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many *)__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many(__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many, __pyx_empty_tuple, NULL);
+  if (unlikely(!__pyx_cur_scope)) {
+    __pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many *)Py_None);
+    __Pyx_INCREF(Py_None);
+    __PYX_ERR(27, 167, __pyx_L1_error)
+  } else {
+    __Pyx_GOTREF(__pyx_cur_scope);
+  }
+  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
+  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
+  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
+  __pyx_cur_scope->__pyx_v_state = __pyx_v_state;
+  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_state);
+  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_state);
+  __pyx_cur_scope->__pyx_v_args = __pyx_v_args;
+  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_args);
+  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_args);
+  __pyx_cur_scope->__pyx_v_portal_name = __pyx_v_portal_name;
+  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_portal_name);
+  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_portal_name);
+  __pyx_cur_scope->__pyx_v_timeout = __pyx_v_timeout;
+  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_timeout);
+  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_timeout);
+  {
+    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_16generator2, (PyObject *) __pyx_cur_scope, __pyx_n_s_bind_execute_many, __pyx_n_s_BaseProtocol_bind_execute_many, __pyx_n_s_asyncpg_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(27, 167, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_cur_scope);
+    __Pyx_RefNannyFinishContext();
+    return (PyObject *) gen;
+  }
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.bind_execute_many", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_16generator2(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
+{
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many *__pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many *)__pyx_generator->closure);
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("None", 0);
+  switch (__pyx_generator->resume_label) {
+    case 0: goto __pyx_L3_first_run;
+    case 1: goto __pyx_L5_resume_from_yield;
+    case 2: goto __pyx_L7_resume_from_yield;
+    case 3: goto __pyx_L8_resume_from_yield;
+    default: /* CPython raises the right error here */
+    __Pyx_RefNannyFinishContext();
+    return NULL;
+  }
+  __pyx_L3_first_run:;
+  if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 167, __pyx_L1_error)
+
+  /* "asyncpg/protocol/protocol.pyx":170
+ *                                 str portal_name, timeout):
+ * 
+ *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:
+ */
+  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_self->cancel_waiter != Py_None);
+  __pyx_t_2 = (__pyx_t_1 != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/protocol.pyx":171
+ * 
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter             # <<<<<<<<<<<<<<
+ *         if self.cancel_sent_waiter is not None:
+ *             await self.cancel_sent_waiter
+ */
+    __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_cur_scope->__pyx_v_self->cancel_waiter);
+    __Pyx_XGOTREF(__pyx_r);
+    if (likely(__pyx_r)) {
+      __Pyx_XGIVEREF(__pyx_r);
+      __Pyx_RefNannyFinishContext();
+      /* return from generator, yielding value */
+      __pyx_generator->resume_label = 1;
+      return __pyx_r;
+      __pyx_L5_resume_from_yield:;
+      if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 171, __pyx_L1_error)
+    } else {
+      PyObject* exc_type = PyErr_Occurred();
+      if (exc_type) {
+        if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+        else __PYX_ERR(27, 171, __pyx_L1_error)
+      }
+    }
+
+    /* "asyncpg/protocol/protocol.pyx":170
+ *                                 str portal_name, timeout):
+ * 
+ *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":172
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_sent_waiter
+ *             self.cancel_sent_waiter = None
+ */
+  __pyx_t_2 = (__pyx_cur_scope->__pyx_v_self->cancel_sent_waiter != Py_None);
+  __pyx_t_1 = (__pyx_t_2 != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/protocol.pyx":173
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:
+ *             await self.cancel_sent_waiter             # <<<<<<<<<<<<<<
+ *             self.cancel_sent_waiter = None
+ * 
+ */
+    __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_cur_scope->__pyx_v_self->cancel_sent_waiter);
+    __Pyx_XGOTREF(__pyx_r);
+    if (likely(__pyx_r)) {
+      __Pyx_XGIVEREF(__pyx_r);
+      __Pyx_RefNannyFinishContext();
+      /* return from generator, yielding value */
+      __pyx_generator->resume_label = 2;
+      return __pyx_r;
+      __pyx_L7_resume_from_yield:;
+      if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 173, __pyx_L1_error)
+    } else {
+      PyObject* exc_type = PyErr_Occurred();
+      if (exc_type) {
+        if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+        else __PYX_ERR(27, 173, __pyx_L1_error)
+      }
+    }
+
+    /* "asyncpg/protocol/protocol.pyx":174
+ *         if self.cancel_sent_waiter is not None:
+ *             await self.cancel_sent_waiter
+ *             self.cancel_sent_waiter = None             # <<<<<<<<<<<<<<
+ * 
+ *         self._ensure_clear_state()
+ */
+    __Pyx_INCREF(Py_None);
+    __Pyx_GIVEREF(Py_None);
+    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->cancel_sent_waiter);
+    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->cancel_sent_waiter);
+    __pyx_cur_scope->__pyx_v_self->cancel_sent_waiter = Py_None;
+
+    /* "asyncpg/protocol/protocol.pyx":172
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_sent_waiter
+ *             self.cancel_sent_waiter = None
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":176
+ *             self.cancel_sent_waiter = None
+ * 
+ *         self._ensure_clear_state()             # <<<<<<<<<<<<<<
+ * 
+ *         # Make sure the argument sequence is encoded lazily with
+ */
+  __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_ensure_clear_state(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 176, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":181
+ *         # this generator expression to keep the memory pressure under
+ *         # control.
+ *         data_gen = (state._encode_bind_msg(b) for b in args)             # <<<<<<<<<<<<<<
+ *         arg_bufs = iter(data_gen)
+ * 
+ */
+  __pyx_t_3 = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_17bind_execute_many_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 181, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_3);
+  __pyx_cur_scope->__pyx_v_data_gen = __pyx_t_3;
+  __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":182
+ *         # control.
+ *         data_gen = (state._encode_bind_msg(b) for b in args)
+ *         arg_bufs = iter(data_gen)             # <<<<<<<<<<<<<<
+ * 
+ *         waiter = self._new_waiter(timeout)
+ */
+  __pyx_t_3 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_data_gen); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 182, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_3);
+  __pyx_cur_scope->__pyx_v_arg_bufs = __pyx_t_3;
+  __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":184
+ *         arg_bufs = iter(data_gen)
+ * 
+ *         waiter = self._new_waiter(timeout)             # <<<<<<<<<<<<<<
+ * 
+ *         self._bind_execute_many(
+ */
+  __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_new_waiter(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_timeout); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 184, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_3);
+  __pyx_cur_scope->__pyx_v_waiter = __pyx_t_3;
+  __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":188
+ *         self._bind_execute_many(
+ *             portal_name,
+ *             state.name,             # <<<<<<<<<<<<<<
+ *             arg_bufs)
+ * 
+ */
+  __pyx_t_3 = __pyx_cur_scope->__pyx_v_state->name;
+  __Pyx_INCREF(__pyx_t_3);
+
+  /* "asyncpg/protocol/protocol.pyx":186
+ *         waiter = self._new_waiter(timeout)
+ * 
+ *         self._bind_execute_many(             # <<<<<<<<<<<<<<
+ *             portal_name,
+ *             state.name,
+ */
+  __pyx_t_4 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._bind_execute_many(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_portal_name, ((PyObject*)__pyx_t_3), __pyx_cur_scope->__pyx_v_arg_bufs); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 186, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":191
+ *             arg_bufs)
+ * 
+ *         self.last_query = state.query             # <<<<<<<<<<<<<<
+ *         self.statement = state
+ *         self.return_extra = False
+ */
+  __pyx_t_4 = __pyx_cur_scope->__pyx_v_state->query;
+  __Pyx_INCREF(__pyx_t_4);
+  __Pyx_GIVEREF(__pyx_t_4);
+  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->last_query);
+  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->last_query);
+  __pyx_cur_scope->__pyx_v_self->last_query = ((PyObject*)__pyx_t_4);
+  __pyx_t_4 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":192
+ * 
+ *         self.last_query = state.query
+ *         self.statement = state             # <<<<<<<<<<<<<<
+ *         self.return_extra = False
+ *         self.queries_count += 1
+ */
+  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_state));
+  __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_state));
+  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->statement);
+  __Pyx_DECREF(((PyObject *)__pyx_cur_scope->__pyx_v_self->statement));
+  __pyx_cur_scope->__pyx_v_self->statement = __pyx_cur_scope->__pyx_v_state;
+
+  /* "asyncpg/protocol/protocol.pyx":193
+ *         self.last_query = state.query
+ *         self.statement = state
+ *         self.return_extra = False             # <<<<<<<<<<<<<<
+ *         self.queries_count += 1
+ * 
+ */
+  __pyx_cur_scope->__pyx_v_self->return_extra = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":194
+ *         self.statement = state
+ *         self.return_extra = False
+ *         self.queries_count += 1             # <<<<<<<<<<<<<<
+ * 
+ *         return await waiter
+ */
+  __pyx_cur_scope->__pyx_v_self->queries_count = (__pyx_cur_scope->__pyx_v_self->queries_count + 1);
+
+  /* "asyncpg/protocol/protocol.pyx":196
+ *         self.queries_count += 1
+ * 
+ *         return await waiter             # <<<<<<<<<<<<<<
+ * 
+ *     async def bind(self, PreparedStatementState state, args,
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_cur_scope->__pyx_v_waiter);
+  __Pyx_XGOTREF(__pyx_r);
+  if (likely(__pyx_r)) {
+    __Pyx_XGIVEREF(__pyx_r);
+    __Pyx_RefNannyFinishContext();
+    /* return from generator, yielding value */
+    __pyx_generator->resume_label = 3;
+    return __pyx_r;
+    __pyx_L8_resume_from_yield:;
+    if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 196, __pyx_L1_error)
+    __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
+  } else {
+    __pyx_t_4 = NULL;
+    if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_4) < 0) __PYX_ERR(27, 196, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+  }
+  __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = 0;
+  goto __pyx_L0;
+  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
+
+  /* "asyncpg/protocol/protocol.pyx":167
+ *         return await self._new_waiter(timeout)
+ * 
+ *     async def bind_execute_many(self, PreparedStatementState state, args,             # <<<<<<<<<<<<<<
+ *                                 str portal_name, timeout):
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("bind_execute_many", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
+  __pyx_generator->resume_label = -1;
+  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_19generator3(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
+
+/* "asyncpg/protocol/protocol.pyx":198
+ *         return await waiter
+ * 
+ *     async def bind(self, PreparedStatementState state, args,             # <<<<<<<<<<<<<<
+ *                    str portal_name, timeout):
+ * 
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_18bind(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_18bind(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_state = 0;
+  PyObject *__pyx_v_args = 0;
+  PyObject *__pyx_v_portal_name = 0;
+  PyObject *__pyx_v_timeout = 0;
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("bind (wrapper)", 0);
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_state,&__pyx_n_s_args,&__pyx_n_s_portal_name,&__pyx_n_s_timeout,0};
+    PyObject* values[4] = {0,0,0,0};
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_state)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+        case  1:
+        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("bind", 1, 4, 4, 1); __PYX_ERR(27, 198, __pyx_L3_error)
+        }
+        case  2:
+        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_portal_name)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("bind", 1, 4, 4, 2); __PYX_ERR(27, 198, __pyx_L3_error)
+        }
+        case  3:
+        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_timeout)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("bind", 1, 4, 4, 3); __PYX_ERR(27, 198, __pyx_L3_error)
+        }
+      }
+      if (unlikely(kw_args > 0)) {
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "bind") < 0)) __PYX_ERR(27, 198, __pyx_L3_error)
+      }
+    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
+      goto __pyx_L5_argtuple_error;
+    } else {
+      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+    }
+    __pyx_v_state = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)values[0]);
+    __pyx_v_args = values[1];
+    __pyx_v_portal_name = ((PyObject*)values[2]);
+    __pyx_v_timeout = values[3];
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("bind", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(27, 198, __pyx_L3_error)
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.bind", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state), __pyx_ptype_7asyncpg_8protocol_8protocol_PreparedStatementState, 1, "state", 0))) __PYX_ERR(27, 198, __pyx_L1_error)
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_portal_name), (&PyUnicode_Type), 1, "portal_name", 1))) __PYX_ERR(27, 199, __pyx_L1_error)
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_17bind(((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self), __pyx_v_state, __pyx_v_args, __pyx_v_portal_name, __pyx_v_timeout);
+
+  /* function exit code */
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_17bind(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_state, PyObject *__pyx_v_args, PyObject *__pyx_v_portal_name, PyObject *__pyx_v_timeout) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind *__pyx_cur_scope;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("bind", 0);
+  __pyx_cur_scope = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind *)__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind(__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind, __pyx_empty_tuple, NULL);
+  if (unlikely(!__pyx_cur_scope)) {
+    __pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind *)Py_None);
+    __Pyx_INCREF(Py_None);
+    __PYX_ERR(27, 198, __pyx_L1_error)
+  } else {
+    __Pyx_GOTREF(__pyx_cur_scope);
+  }
+  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
+  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
+  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
+  __pyx_cur_scope->__pyx_v_state = __pyx_v_state;
+  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_state);
+  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_state);
+  __pyx_cur_scope->__pyx_v_args = __pyx_v_args;
+  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_args);
+  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_args);
+  __pyx_cur_scope->__pyx_v_portal_name = __pyx_v_portal_name;
+  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_portal_name);
+  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_portal_name);
+  __pyx_cur_scope->__pyx_v_timeout = __pyx_v_timeout;
+  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_timeout);
+  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_timeout);
+  {
+    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_19generator3, (PyObject *) __pyx_cur_scope, __pyx_n_s_bind, __pyx_n_s_BaseProtocol_bind, __pyx_n_s_asyncpg_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(27, 198, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_cur_scope);
+    __Pyx_RefNannyFinishContext();
+    return (PyObject *) gen;
+  }
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.bind", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_19generator3(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
+{
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind *__pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind *)__pyx_generator->closure);
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("None", 0);
+  switch (__pyx_generator->resume_label) {
+    case 0: goto __pyx_L3_first_run;
+    case 1: goto __pyx_L5_resume_from_yield;
+    case 2: goto __pyx_L7_resume_from_yield;
+    case 3: goto __pyx_L8_resume_from_yield;
+    default: /* CPython raises the right error here */
+    __Pyx_RefNannyFinishContext();
+    return NULL;
+  }
+  __pyx_L3_first_run:;
+  if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 198, __pyx_L1_error)
+
+  /* "asyncpg/protocol/protocol.pyx":201
+ *                    str portal_name, timeout):
+ * 
+ *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:
+ */
+  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_self->cancel_waiter != Py_None);
+  __pyx_t_2 = (__pyx_t_1 != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/protocol.pyx":202
+ * 
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter             # <<<<<<<<<<<<<<
+ *         if self.cancel_sent_waiter is not None:
+ *             await self.cancel_sent_waiter
+ */
+    __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_cur_scope->__pyx_v_self->cancel_waiter);
+    __Pyx_XGOTREF(__pyx_r);
+    if (likely(__pyx_r)) {
+      __Pyx_XGIVEREF(__pyx_r);
+      __Pyx_RefNannyFinishContext();
+      /* return from generator, yielding value */
+      __pyx_generator->resume_label = 1;
+      return __pyx_r;
+      __pyx_L5_resume_from_yield:;
+      if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 202, __pyx_L1_error)
+    } else {
+      PyObject* exc_type = PyErr_Occurred();
+      if (exc_type) {
+        if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+        else __PYX_ERR(27, 202, __pyx_L1_error)
+      }
+    }
+
+    /* "asyncpg/protocol/protocol.pyx":201
+ *                    str portal_name, timeout):
+ * 
+ *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":203
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_sent_waiter
+ *             self.cancel_sent_waiter = None
+ */
+  __pyx_t_2 = (__pyx_cur_scope->__pyx_v_self->cancel_sent_waiter != Py_None);
+  __pyx_t_1 = (__pyx_t_2 != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/protocol.pyx":204
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:
+ *             await self.cancel_sent_waiter             # <<<<<<<<<<<<<<
+ *             self.cancel_sent_waiter = None
+ * 
+ */
+    __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_cur_scope->__pyx_v_self->cancel_sent_waiter);
+    __Pyx_XGOTREF(__pyx_r);
+    if (likely(__pyx_r)) {
+      __Pyx_XGIVEREF(__pyx_r);
+      __Pyx_RefNannyFinishContext();
+      /* return from generator, yielding value */
+      __pyx_generator->resume_label = 2;
+      return __pyx_r;
+      __pyx_L7_resume_from_yield:;
+      if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 204, __pyx_L1_error)
+    } else {
+      PyObject* exc_type = PyErr_Occurred();
+      if (exc_type) {
+        if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+        else __PYX_ERR(27, 204, __pyx_L1_error)
+      }
+    }
+
+    /* "asyncpg/protocol/protocol.pyx":205
+ *         if self.cancel_sent_waiter is not None:
+ *             await self.cancel_sent_waiter
+ *             self.cancel_sent_waiter = None             # <<<<<<<<<<<<<<
+ * 
+ *         self._ensure_clear_state()
+ */
+    __Pyx_INCREF(Py_None);
+    __Pyx_GIVEREF(Py_None);
+    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->cancel_sent_waiter);
+    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->cancel_sent_waiter);
+    __pyx_cur_scope->__pyx_v_self->cancel_sent_waiter = Py_None;
+
+    /* "asyncpg/protocol/protocol.pyx":203
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_sent_waiter
+ *             self.cancel_sent_waiter = None
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":207
+ *             self.cancel_sent_waiter = None
+ * 
+ *         self._ensure_clear_state()             # <<<<<<<<<<<<<<
+ * 
+ *         self._bind(
+ */
+  __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_ensure_clear_state(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 207, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":211
+ *         self._bind(
+ *             portal_name,
+ *             state.name,             # <<<<<<<<<<<<<<
+ *             state._encode_bind_msg(args))
+ * 
+ */
+  __pyx_t_3 = __pyx_cur_scope->__pyx_v_state->name;
+  __Pyx_INCREF(__pyx_t_3);
+
+  /* "asyncpg/protocol/protocol.pyx":212
+ *             portal_name,
+ *             state.name,
+ *             state._encode_bind_msg(args))             # <<<<<<<<<<<<<<
+ * 
+ *         self.last_query = state.query
+ */
+  __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__encode_bind_msg(__pyx_cur_scope->__pyx_v_state, __pyx_cur_scope->__pyx_v_args); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 212, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_7asyncpg_8protocol_8protocol_WriteBuffer))))) __PYX_ERR(27, 212, __pyx_L1_error)
+
+  /* "asyncpg/protocol/protocol.pyx":209
+ *         self._ensure_clear_state()
+ * 
+ *         self._bind(             # <<<<<<<<<<<<<<
+ *             portal_name,
+ *             state.name,
+ */
+  __pyx_t_5 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._bind(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_portal_name, ((PyObject*)__pyx_t_3), ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_4)); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 209, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":214
+ *             state._encode_bind_msg(args))
+ * 
+ *         self.last_query = state.query             # <<<<<<<<<<<<<<
+ *         self.statement = state
+ * 
+ */
+  __pyx_t_5 = __pyx_cur_scope->__pyx_v_state->query;
+  __Pyx_INCREF(__pyx_t_5);
+  __Pyx_GIVEREF(__pyx_t_5);
+  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->last_query);
+  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->last_query);
+  __pyx_cur_scope->__pyx_v_self->last_query = ((PyObject*)__pyx_t_5);
+  __pyx_t_5 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":215
+ * 
+ *         self.last_query = state.query
+ *         self.statement = state             # <<<<<<<<<<<<<<
+ * 
+ *         return await self._new_waiter(timeout)
+ */
+  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_state));
+  __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_state));
+  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->statement);
+  __Pyx_DECREF(((PyObject *)__pyx_cur_scope->__pyx_v_self->statement));
+  __pyx_cur_scope->__pyx_v_self->statement = __pyx_cur_scope->__pyx_v_state;
+
+  /* "asyncpg/protocol/protocol.pyx":217
+ *         self.statement = state
+ * 
+ *         return await self._new_waiter(timeout)             # <<<<<<<<<<<<<<
+ * 
+ *     async def execute(self, PreparedStatementState state,
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_5 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_new_waiter(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_timeout); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 217, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5);
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __Pyx_XGOTREF(__pyx_r);
+  if (likely(__pyx_r)) {
+    __Pyx_XGIVEREF(__pyx_r);
+    __Pyx_RefNannyFinishContext();
+    /* return from generator, yielding value */
+    __pyx_generator->resume_label = 3;
+    return __pyx_r;
+    __pyx_L8_resume_from_yield:;
+    if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 217, __pyx_L1_error)
+    __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
+  } else {
+    __pyx_t_5 = NULL;
+    if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_5) < 0) __PYX_ERR(27, 217, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+  }
+  __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __pyx_t_5 = 0;
+  goto __pyx_L0;
+  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
+
+  /* "asyncpg/protocol/protocol.pyx":198
+ *         return await waiter
+ * 
+ *     async def bind(self, PreparedStatementState state, args,             # <<<<<<<<<<<<<<
+ *                    str portal_name, timeout):
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("bind", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
+  __pyx_generator->resume_label = -1;
+  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_22generator4(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
+
+/* "asyncpg/protocol/protocol.pyx":219
+ *         return await self._new_waiter(timeout)
+ * 
+ *     async def execute(self, PreparedStatementState state,             # <<<<<<<<<<<<<<
+ *                       str portal_name, int limit, return_extra,
+ *                       timeout):
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_21execute(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_21execute(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_state = 0;
+  PyObject *__pyx_v_portal_name = 0;
+  int __pyx_v_limit;
+  PyObject *__pyx_v_return_extra = 0;
+  PyObject *__pyx_v_timeout = 0;
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("execute (wrapper)", 0);
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_state,&__pyx_n_s_portal_name,&__pyx_n_s_limit,&__pyx_n_s_return_extra,&__pyx_n_s_timeout,0};
+    PyObject* values[5] = {0,0,0,0,0};
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_state)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+        case  1:
+        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_portal_name)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("execute", 1, 5, 5, 1); __PYX_ERR(27, 219, __pyx_L3_error)
+        }
+        case  2:
+        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_limit)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("execute", 1, 5, 5, 2); __PYX_ERR(27, 219, __pyx_L3_error)
+        }
+        case  3:
+        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_return_extra)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("execute", 1, 5, 5, 3); __PYX_ERR(27, 219, __pyx_L3_error)
+        }
+        case  4:
+        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_timeout)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("execute", 1, 5, 5, 4); __PYX_ERR(27, 219, __pyx_L3_error)
+        }
+      }
+      if (unlikely(kw_args > 0)) {
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "execute") < 0)) __PYX_ERR(27, 219, __pyx_L3_error)
+      }
+    } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
+      goto __pyx_L5_argtuple_error;
+    } else {
+      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+    }
+    __pyx_v_state = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)values[0]);
+    __pyx_v_portal_name = ((PyObject*)values[1]);
+    __pyx_v_limit = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_limit == (int)-1) && PyErr_Occurred())) __PYX_ERR(27, 220, __pyx_L3_error)
+    __pyx_v_return_extra = values[3];
+    __pyx_v_timeout = values[4];
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("execute", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(27, 219, __pyx_L3_error)
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.execute", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state), __pyx_ptype_7asyncpg_8protocol_8protocol_PreparedStatementState, 1, "state", 0))) __PYX_ERR(27, 219, __pyx_L1_error)
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_portal_name), (&PyUnicode_Type), 1, "portal_name", 1))) __PYX_ERR(27, 220, __pyx_L1_error)
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_20execute(((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self), __pyx_v_state, __pyx_v_portal_name, __pyx_v_limit, __pyx_v_return_extra, __pyx_v_timeout);
+
+  /* function exit code */
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_20execute(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_state, PyObject *__pyx_v_portal_name, int __pyx_v_limit, PyObject *__pyx_v_return_extra, PyObject *__pyx_v_timeout) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute *__pyx_cur_scope;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("execute", 0);
+  __pyx_cur_scope = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute *)__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute(__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute, __pyx_empty_tuple, NULL);
+  if (unlikely(!__pyx_cur_scope)) {
+    __pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute *)Py_None);
+    __Pyx_INCREF(Py_None);
+    __PYX_ERR(27, 219, __pyx_L1_error)
+  } else {
+    __Pyx_GOTREF(__pyx_cur_scope);
+  }
+  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
+  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
+  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
+  __pyx_cur_scope->__pyx_v_state = __pyx_v_state;
+  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_state);
+  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_state);
+  __pyx_cur_scope->__pyx_v_portal_name = __pyx_v_portal_name;
+  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_portal_name);
+  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_portal_name);
+  __pyx_cur_scope->__pyx_v_limit = __pyx_v_limit;
+  __pyx_cur_scope->__pyx_v_return_extra = __pyx_v_return_extra;
+  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_return_extra);
+  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_return_extra);
+  __pyx_cur_scope->__pyx_v_timeout = __pyx_v_timeout;
+  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_timeout);
+  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_timeout);
+  {
+    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_22generator4, (PyObject *) __pyx_cur_scope, __pyx_n_s_execute, __pyx_n_s_BaseProtocol_execute, __pyx_n_s_asyncpg_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(27, 219, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_cur_scope);
+    __Pyx_RefNannyFinishContext();
+    return (PyObject *) gen;
+  }
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.execute", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_22generator4(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
+{
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute *__pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute *)__pyx_generator->closure);
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("None", 0);
+  switch (__pyx_generator->resume_label) {
+    case 0: goto __pyx_L3_first_run;
+    case 1: goto __pyx_L5_resume_from_yield;
+    case 2: goto __pyx_L7_resume_from_yield;
+    case 3: goto __pyx_L8_resume_from_yield;
+    default: /* CPython raises the right error here */
+    __Pyx_RefNannyFinishContext();
+    return NULL;
+  }
+  __pyx_L3_first_run:;
+  if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 219, __pyx_L1_error)
+
+  /* "asyncpg/protocol/protocol.pyx":223
+ *                       timeout):
+ * 
+ *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:
+ */
+  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_self->cancel_waiter != Py_None);
+  __pyx_t_2 = (__pyx_t_1 != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/protocol.pyx":224
+ * 
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter             # <<<<<<<<<<<<<<
+ *         if self.cancel_sent_waiter is not None:
+ *             await self.cancel_sent_waiter
+ */
+    __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_cur_scope->__pyx_v_self->cancel_waiter);
+    __Pyx_XGOTREF(__pyx_r);
+    if (likely(__pyx_r)) {
+      __Pyx_XGIVEREF(__pyx_r);
+      __Pyx_RefNannyFinishContext();
+      /* return from generator, yielding value */
+      __pyx_generator->resume_label = 1;
+      return __pyx_r;
+      __pyx_L5_resume_from_yield:;
+      if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 224, __pyx_L1_error)
+    } else {
+      PyObject* exc_type = PyErr_Occurred();
+      if (exc_type) {
+        if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+        else __PYX_ERR(27, 224, __pyx_L1_error)
+      }
+    }
+
+    /* "asyncpg/protocol/protocol.pyx":223
+ *                       timeout):
+ * 
+ *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":225
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_sent_waiter
+ *             self.cancel_sent_waiter = None
+ */
+  __pyx_t_2 = (__pyx_cur_scope->__pyx_v_self->cancel_sent_waiter != Py_None);
+  __pyx_t_1 = (__pyx_t_2 != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/protocol.pyx":226
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:
+ *             await self.cancel_sent_waiter             # <<<<<<<<<<<<<<
+ *             self.cancel_sent_waiter = None
+ * 
+ */
+    __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_cur_scope->__pyx_v_self->cancel_sent_waiter);
+    __Pyx_XGOTREF(__pyx_r);
+    if (likely(__pyx_r)) {
+      __Pyx_XGIVEREF(__pyx_r);
+      __Pyx_RefNannyFinishContext();
+      /* return from generator, yielding value */
+      __pyx_generator->resume_label = 2;
+      return __pyx_r;
+      __pyx_L7_resume_from_yield:;
+      if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 226, __pyx_L1_error)
+    } else {
+      PyObject* exc_type = PyErr_Occurred();
+      if (exc_type) {
+        if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+        else __PYX_ERR(27, 226, __pyx_L1_error)
+      }
+    }
+
+    /* "asyncpg/protocol/protocol.pyx":227
+ *         if self.cancel_sent_waiter is not None:
+ *             await self.cancel_sent_waiter
+ *             self.cancel_sent_waiter = None             # <<<<<<<<<<<<<<
+ * 
+ *         self._ensure_clear_state()
+ */
+    __Pyx_INCREF(Py_None);
+    __Pyx_GIVEREF(Py_None);
+    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->cancel_sent_waiter);
+    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->cancel_sent_waiter);
+    __pyx_cur_scope->__pyx_v_self->cancel_sent_waiter = Py_None;
+
+    /* "asyncpg/protocol/protocol.pyx":225
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_sent_waiter
+ *             self.cancel_sent_waiter = None
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":229
+ *             self.cancel_sent_waiter = None
+ * 
+ *         self._ensure_clear_state()             # <<<<<<<<<<<<<<
+ * 
+ *         self._execute(
+ */
+  __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_ensure_clear_state(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 229, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":231
+ *         self._ensure_clear_state()
+ * 
+ *         self._execute(             # <<<<<<<<<<<<<<
+ *             portal_name,
+ *             limit)
+ */
+  __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._execute(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_portal_name, __pyx_cur_scope->__pyx_v_limit); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 231, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":235
+ *             limit)
+ * 
+ *         self.last_query = state.query             # <<<<<<<<<<<<<<
+ *         self.statement = state
+ *         self.return_extra = return_extra
+ */
+  __pyx_t_3 = __pyx_cur_scope->__pyx_v_state->query;
+  __Pyx_INCREF(__pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_3);
+  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->last_query);
+  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->last_query);
+  __pyx_cur_scope->__pyx_v_self->last_query = ((PyObject*)__pyx_t_3);
+  __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":236
+ * 
+ *         self.last_query = state.query
+ *         self.statement = state             # <<<<<<<<<<<<<<
+ *         self.return_extra = return_extra
+ *         self.queries_count += 1
+ */
+  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_state));
+  __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_state));
+  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->statement);
+  __Pyx_DECREF(((PyObject *)__pyx_cur_scope->__pyx_v_self->statement));
+  __pyx_cur_scope->__pyx_v_self->statement = __pyx_cur_scope->__pyx_v_state;
+
+  /* "asyncpg/protocol/protocol.pyx":237
+ *         self.last_query = state.query
+ *         self.statement = state
+ *         self.return_extra = return_extra             # <<<<<<<<<<<<<<
+ *         self.queries_count += 1
+ * 
+ */
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_return_extra); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(27, 237, __pyx_L1_error)
+  __pyx_cur_scope->__pyx_v_self->return_extra = __pyx_t_1;
+
+  /* "asyncpg/protocol/protocol.pyx":238
+ *         self.statement = state
+ *         self.return_extra = return_extra
+ *         self.queries_count += 1             # <<<<<<<<<<<<<<
+ * 
+ *         return await self._new_waiter(timeout)
+ */
+  __pyx_cur_scope->__pyx_v_self->queries_count = (__pyx_cur_scope->__pyx_v_self->queries_count + 1);
+
+  /* "asyncpg/protocol/protocol.pyx":240
+ *         self.queries_count += 1
+ * 
+ *         return await self._new_waiter(timeout)             # <<<<<<<<<<<<<<
+ * 
+ *     async def query(self, query, timeout):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_new_waiter(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_timeout); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 240, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_XGOTREF(__pyx_r);
+  if (likely(__pyx_r)) {
+    __Pyx_XGIVEREF(__pyx_r);
+    __Pyx_RefNannyFinishContext();
+    /* return from generator, yielding value */
+    __pyx_generator->resume_label = 3;
+    return __pyx_r;
+    __pyx_L8_resume_from_yield:;
+    if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 240, __pyx_L1_error)
+    __pyx_t_3 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_3);
+  } else {
+    __pyx_t_3 = NULL;
+    if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_3) < 0) __PYX_ERR(27, 240, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+  }
+  __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = 0;
+  goto __pyx_L0;
+  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
+
+  /* "asyncpg/protocol/protocol.pyx":219
+ *         return await self._new_waiter(timeout)
+ * 
+ *     async def execute(self, PreparedStatementState state,             # <<<<<<<<<<<<<<
+ *                       str portal_name, int limit, return_extra,
+ *                       timeout):
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("execute", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
+  __pyx_generator->resume_label = -1;
+  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_25generator5(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
+
+/* "asyncpg/protocol/protocol.pyx":242
+ *         return await self._new_waiter(timeout)
+ * 
+ *     async def query(self, query, timeout):             # <<<<<<<<<<<<<<
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_24query(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_24query(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_query = 0;
+  PyObject *__pyx_v_timeout = 0;
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("query (wrapper)", 0);
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_query,&__pyx_n_s_timeout,0};
+    PyObject* values[2] = {0,0};
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_query)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+        case  1:
+        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_timeout)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("query", 1, 2, 2, 1); __PYX_ERR(27, 242, __pyx_L3_error)
+        }
+      }
+      if (unlikely(kw_args > 0)) {
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "query") < 0)) __PYX_ERR(27, 242, __pyx_L3_error)
+      }
+    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+      goto __pyx_L5_argtuple_error;
+    } else {
+      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+    }
+    __pyx_v_query = values[0];
+    __pyx_v_timeout = values[1];
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("query", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(27, 242, __pyx_L3_error)
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.query", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_23query(((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self), __pyx_v_query, __pyx_v_timeout);
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_23query(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_query, PyObject *__pyx_v_timeout) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query *__pyx_cur_scope;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("query", 0);
+  __pyx_cur_scope = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query *)__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query(__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query, __pyx_empty_tuple, NULL);
+  if (unlikely(!__pyx_cur_scope)) {
+    __pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query *)Py_None);
+    __Pyx_INCREF(Py_None);
+    __PYX_ERR(27, 242, __pyx_L1_error)
+  } else {
+    __Pyx_GOTREF(__pyx_cur_scope);
+  }
+  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
+  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
+  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
+  __pyx_cur_scope->__pyx_v_query = __pyx_v_query;
+  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_query);
+  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_query);
+  __pyx_cur_scope->__pyx_v_timeout = __pyx_v_timeout;
+  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_timeout);
+  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_timeout);
+  {
+    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_25generator5, (PyObject *) __pyx_cur_scope, __pyx_n_s_query, __pyx_n_s_BaseProtocol_query, __pyx_n_s_asyncpg_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(27, 242, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_cur_scope);
+    __Pyx_RefNannyFinishContext();
+    return (PyObject *) gen;
+  }
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.query", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_25generator5(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
+{
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query *__pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query *)__pyx_generator->closure);
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("None", 0);
+  switch (__pyx_generator->resume_label) {
+    case 0: goto __pyx_L3_first_run;
+    case 1: goto __pyx_L5_resume_from_yield;
+    case 2: goto __pyx_L7_resume_from_yield;
+    case 3: goto __pyx_L8_resume_from_yield;
+    default: /* CPython raises the right error here */
+    __Pyx_RefNannyFinishContext();
+    return NULL;
+  }
+  __pyx_L3_first_run:;
+  if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 242, __pyx_L1_error)
+
+  /* "asyncpg/protocol/protocol.pyx":243
+ * 
+ *     async def query(self, query, timeout):
+ *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:
+ */
+  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_self->cancel_waiter != Py_None);
+  __pyx_t_2 = (__pyx_t_1 != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/protocol.pyx":244
+ *     async def query(self, query, timeout):
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter             # <<<<<<<<<<<<<<
+ *         if self.cancel_sent_waiter is not None:
+ *             await self.cancel_sent_waiter
+ */
+    __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_cur_scope->__pyx_v_self->cancel_waiter);
+    __Pyx_XGOTREF(__pyx_r);
+    if (likely(__pyx_r)) {
+      __Pyx_XGIVEREF(__pyx_r);
+      __Pyx_RefNannyFinishContext();
+      /* return from generator, yielding value */
+      __pyx_generator->resume_label = 1;
+      return __pyx_r;
+      __pyx_L5_resume_from_yield:;
+      if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 244, __pyx_L1_error)
+    } else {
+      PyObject* exc_type = PyErr_Occurred();
+      if (exc_type) {
+        if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+        else __PYX_ERR(27, 244, __pyx_L1_error)
+      }
+    }
+
+    /* "asyncpg/protocol/protocol.pyx":243
+ * 
+ *     async def query(self, query, timeout):
+ *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":245
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_sent_waiter
+ *             self.cancel_sent_waiter = None
+ */
+  __pyx_t_2 = (__pyx_cur_scope->__pyx_v_self->cancel_sent_waiter != Py_None);
+  __pyx_t_1 = (__pyx_t_2 != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/protocol.pyx":246
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:
+ *             await self.cancel_sent_waiter             # <<<<<<<<<<<<<<
+ *             self.cancel_sent_waiter = None
+ * 
+ */
+    __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_cur_scope->__pyx_v_self->cancel_sent_waiter);
+    __Pyx_XGOTREF(__pyx_r);
+    if (likely(__pyx_r)) {
+      __Pyx_XGIVEREF(__pyx_r);
+      __Pyx_RefNannyFinishContext();
+      /* return from generator, yielding value */
+      __pyx_generator->resume_label = 2;
+      return __pyx_r;
+      __pyx_L7_resume_from_yield:;
+      if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 246, __pyx_L1_error)
+    } else {
+      PyObject* exc_type = PyErr_Occurred();
+      if (exc_type) {
+        if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+        else __PYX_ERR(27, 246, __pyx_L1_error)
+      }
+    }
+
+    /* "asyncpg/protocol/protocol.pyx":247
+ *         if self.cancel_sent_waiter is not None:
+ *             await self.cancel_sent_waiter
+ *             self.cancel_sent_waiter = None             # <<<<<<<<<<<<<<
+ * 
+ *         self._ensure_clear_state()
+ */
+    __Pyx_INCREF(Py_None);
+    __Pyx_GIVEREF(Py_None);
+    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->cancel_sent_waiter);
+    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->cancel_sent_waiter);
+    __pyx_cur_scope->__pyx_v_self->cancel_sent_waiter = Py_None;
+
+    /* "asyncpg/protocol/protocol.pyx":245
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_sent_waiter
+ *             self.cancel_sent_waiter = None
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":249
+ *             self.cancel_sent_waiter = None
+ * 
+ *         self._ensure_clear_state()             # <<<<<<<<<<<<<<
+ * 
+ *         self._simple_query(query)
+ */
+  __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_ensure_clear_state(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 249, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":251
+ *         self._ensure_clear_state()
+ * 
+ *         self._simple_query(query)             # <<<<<<<<<<<<<<
+ *         self.last_query = query
+ *         self.queries_count += 1
+ */
+  if (!(likely(PyUnicode_CheckExact(__pyx_cur_scope->__pyx_v_query))||((__pyx_cur_scope->__pyx_v_query) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_cur_scope->__pyx_v_query)->tp_name), 0))) __PYX_ERR(27, 251, __pyx_L1_error)
+  __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._simple_query(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_cur_scope->__pyx_v_self), ((PyObject*)__pyx_cur_scope->__pyx_v_query)); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 251, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":252
+ * 
+ *         self._simple_query(query)
+ *         self.last_query = query             # <<<<<<<<<<<<<<
+ *         self.queries_count += 1
+ * 
+ */
+  if (!(likely(PyUnicode_CheckExact(__pyx_cur_scope->__pyx_v_query))||((__pyx_cur_scope->__pyx_v_query) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_cur_scope->__pyx_v_query)->tp_name), 0))) __PYX_ERR(27, 252, __pyx_L1_error)
+  __pyx_t_3 = __pyx_cur_scope->__pyx_v_query;
+  __Pyx_INCREF(__pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_3);
+  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->last_query);
+  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->last_query);
+  __pyx_cur_scope->__pyx_v_self->last_query = ((PyObject*)__pyx_t_3);
+  __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":253
+ *         self._simple_query(query)
+ *         self.last_query = query
+ *         self.queries_count += 1             # <<<<<<<<<<<<<<
+ * 
+ *         return await self._new_waiter(timeout)
+ */
+  __pyx_cur_scope->__pyx_v_self->queries_count = (__pyx_cur_scope->__pyx_v_self->queries_count + 1);
+
+  /* "asyncpg/protocol/protocol.pyx":255
+ *         self.queries_count += 1
+ * 
+ *         return await self._new_waiter(timeout)             # <<<<<<<<<<<<<<
+ * 
+ *     async def close_statement(self, PreparedStatementState state, timeout):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_new_waiter(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_timeout); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 255, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_XGOTREF(__pyx_r);
+  if (likely(__pyx_r)) {
+    __Pyx_XGIVEREF(__pyx_r);
+    __Pyx_RefNannyFinishContext();
+    /* return from generator, yielding value */
+    __pyx_generator->resume_label = 3;
+    return __pyx_r;
+    __pyx_L8_resume_from_yield:;
+    if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 255, __pyx_L1_error)
+    __pyx_t_3 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_3);
+  } else {
+    __pyx_t_3 = NULL;
+    if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_3) < 0) __PYX_ERR(27, 255, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+  }
+  __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = 0;
+  goto __pyx_L0;
+  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
+
+  /* "asyncpg/protocol/protocol.pyx":242
+ *         return await self._new_waiter(timeout)
+ * 
+ *     async def query(self, query, timeout):             # <<<<<<<<<<<<<<
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("query", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
+  __pyx_generator->resume_label = -1;
+  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_28generator6(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
+
+/* "asyncpg/protocol/protocol.pyx":257
+ *         return await self._new_waiter(timeout)
+ * 
+ *     async def close_statement(self, PreparedStatementState state, timeout):             # <<<<<<<<<<<<<<
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_27close_statement(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_27close_statement(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_state = 0;
+  PyObject *__pyx_v_timeout = 0;
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("close_statement (wrapper)", 0);
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_state,&__pyx_n_s_timeout,0};
+    PyObject* values[2] = {0,0};
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_state)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+        case  1:
+        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_timeout)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("close_statement", 1, 2, 2, 1); __PYX_ERR(27, 257, __pyx_L3_error)
+        }
+      }
+      if (unlikely(kw_args > 0)) {
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "close_statement") < 0)) __PYX_ERR(27, 257, __pyx_L3_error)
+      }
+    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+      goto __pyx_L5_argtuple_error;
+    } else {
+      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+    }
+    __pyx_v_state = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)values[0]);
+    __pyx_v_timeout = values[1];
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("close_statement", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(27, 257, __pyx_L3_error)
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.close_statement", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state), __pyx_ptype_7asyncpg_8protocol_8protocol_PreparedStatementState, 1, "state", 0))) __PYX_ERR(27, 257, __pyx_L1_error)
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_26close_statement(((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self), __pyx_v_state, __pyx_v_timeout);
+
+  /* function exit code */
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_26close_statement(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_state, PyObject *__pyx_v_timeout) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement *__pyx_cur_scope;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("close_statement", 0);
+  __pyx_cur_scope = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement *)__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement(__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement, __pyx_empty_tuple, NULL);
+  if (unlikely(!__pyx_cur_scope)) {
+    __pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement *)Py_None);
+    __Pyx_INCREF(Py_None);
+    __PYX_ERR(27, 257, __pyx_L1_error)
+  } else {
+    __Pyx_GOTREF(__pyx_cur_scope);
+  }
+  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
+  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
+  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
+  __pyx_cur_scope->__pyx_v_state = __pyx_v_state;
+  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_state);
+  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_state);
+  __pyx_cur_scope->__pyx_v_timeout = __pyx_v_timeout;
+  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_timeout);
+  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_timeout);
+  {
+    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_28generator6, (PyObject *) __pyx_cur_scope, __pyx_n_s_close_statement, __pyx_n_s_BaseProtocol_close_statement, __pyx_n_s_asyncpg_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(27, 257, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_cur_scope);
+    __Pyx_RefNannyFinishContext();
+    return (PyObject *) gen;
+  }
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.close_statement", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_28generator6(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
+{
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement *__pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement *)__pyx_generator->closure);
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("None", 0);
+  switch (__pyx_generator->resume_label) {
+    case 0: goto __pyx_L3_first_run;
+    case 1: goto __pyx_L5_resume_from_yield;
+    case 2: goto __pyx_L7_resume_from_yield;
+    case 3: goto __pyx_L9_resume_from_yield;
+    default: /* CPython raises the right error here */
+    __Pyx_RefNannyFinishContext();
+    return NULL;
+  }
+  __pyx_L3_first_run:;
+  if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 257, __pyx_L1_error)
+
+  /* "asyncpg/protocol/protocol.pyx":258
+ * 
+ *     async def close_statement(self, PreparedStatementState state, timeout):
+ *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:
+ */
+  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_self->cancel_waiter != Py_None);
+  __pyx_t_2 = (__pyx_t_1 != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/protocol.pyx":259
+ *     async def close_statement(self, PreparedStatementState state, timeout):
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter             # <<<<<<<<<<<<<<
+ *         if self.cancel_sent_waiter is not None:
+ *             await self.cancel_sent_waiter
+ */
+    __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_cur_scope->__pyx_v_self->cancel_waiter);
+    __Pyx_XGOTREF(__pyx_r);
+    if (likely(__pyx_r)) {
+      __Pyx_XGIVEREF(__pyx_r);
+      __Pyx_RefNannyFinishContext();
+      /* return from generator, yielding value */
+      __pyx_generator->resume_label = 1;
+      return __pyx_r;
+      __pyx_L5_resume_from_yield:;
+      if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 259, __pyx_L1_error)
+    } else {
+      PyObject* exc_type = PyErr_Occurred();
+      if (exc_type) {
+        if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+        else __PYX_ERR(27, 259, __pyx_L1_error)
+      }
+    }
+
+    /* "asyncpg/protocol/protocol.pyx":258
+ * 
+ *     async def close_statement(self, PreparedStatementState state, timeout):
+ *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":260
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_sent_waiter
+ *             self.cancel_sent_waiter = None
+ */
+  __pyx_t_2 = (__pyx_cur_scope->__pyx_v_self->cancel_sent_waiter != Py_None);
+  __pyx_t_1 = (__pyx_t_2 != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/protocol.pyx":261
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:
+ *             await self.cancel_sent_waiter             # <<<<<<<<<<<<<<
+ *             self.cancel_sent_waiter = None
+ * 
+ */
+    __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_cur_scope->__pyx_v_self->cancel_sent_waiter);
+    __Pyx_XGOTREF(__pyx_r);
+    if (likely(__pyx_r)) {
+      __Pyx_XGIVEREF(__pyx_r);
+      __Pyx_RefNannyFinishContext();
+      /* return from generator, yielding value */
+      __pyx_generator->resume_label = 2;
+      return __pyx_r;
+      __pyx_L7_resume_from_yield:;
+      if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 261, __pyx_L1_error)
+    } else {
+      PyObject* exc_type = PyErr_Occurred();
+      if (exc_type) {
+        if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+        else __PYX_ERR(27, 261, __pyx_L1_error)
+      }
+    }
+
+    /* "asyncpg/protocol/protocol.pyx":262
+ *         if self.cancel_sent_waiter is not None:
+ *             await self.cancel_sent_waiter
+ *             self.cancel_sent_waiter = None             # <<<<<<<<<<<<<<
+ * 
+ *         self._ensure_clear_state()
+ */
+    __Pyx_INCREF(Py_None);
+    __Pyx_GIVEREF(Py_None);
+    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->cancel_sent_waiter);
+    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->cancel_sent_waiter);
+    __pyx_cur_scope->__pyx_v_self->cancel_sent_waiter = Py_None;
+
+    /* "asyncpg/protocol/protocol.pyx":260
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_sent_waiter
+ *             self.cancel_sent_waiter = None
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":264
+ *             self.cancel_sent_waiter = None
+ * 
+ *         self._ensure_clear_state()             # <<<<<<<<<<<<<<
+ * 
+ *         if state.refs != 0:
+ */
+  __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_ensure_clear_state(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 264, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":266
+ *         self._ensure_clear_state()
+ * 
+ *         if state.refs != 0:             # <<<<<<<<<<<<<<
+ *             raise RuntimeError(
+ *                 'cannot close prepared statement; refs == {} != 0'.format(
+ */
+  __pyx_t_1 = ((__pyx_cur_scope->__pyx_v_state->refs != 0) != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/protocol.pyx":268
+ *         if state.refs != 0:
+ *             raise RuntimeError(
+ *                 'cannot close prepared statement; refs == {} != 0'.format(             # <<<<<<<<<<<<<<
+ *                     state.refs))
+ * 
+ */
+    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_cannot_close_prepared_statement, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 268, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+
+    /* "asyncpg/protocol/protocol.pyx":269
+ *             raise RuntimeError(
+ *                 'cannot close prepared statement; refs == {} != 0'.format(
+ *                     state.refs))             # <<<<<<<<<<<<<<
+ * 
+ *         self._close(state.name, False)
+ */
+    __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_state->refs); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 269, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
+      if (likely(__pyx_t_6)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+        __Pyx_INCREF(__pyx_t_6);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_4, function);
+      }
+    }
+    if (!__pyx_t_6) {
+      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 268, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_4)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
+        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 268, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
+        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 268, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(27, 268, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
+        __Pyx_GIVEREF(__pyx_t_5);
+        PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5);
+        __pyx_t_5 = 0;
+        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 268, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/protocol.pyx":267
+ * 
+ *         if state.refs != 0:
+ *             raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                 'cannot close prepared statement; refs == {} != 0'.format(
+ *                     state.refs))
+ */
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 267, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_3);
+    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
+    __pyx_t_3 = 0;
+    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 267, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __PYX_ERR(27, 267, __pyx_L1_error)
+
+    /* "asyncpg/protocol/protocol.pyx":266
+ *         self._ensure_clear_state()
+ * 
+ *         if state.refs != 0:             # <<<<<<<<<<<<<<
+ *             raise RuntimeError(
+ *                 'cannot close prepared statement; refs == {} != 0'.format(
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":271
+ *                     state.refs))
+ * 
+ *         self._close(state.name, False)             # <<<<<<<<<<<<<<
+ *         state.closed = True
+ *         return await self._new_waiter(timeout)
+ */
+  __pyx_t_3 = __pyx_cur_scope->__pyx_v_state->name;
+  __Pyx_INCREF(__pyx_t_3);
+  __pyx_t_4 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._close(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_cur_scope->__pyx_v_self), ((PyObject*)__pyx_t_3), 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 271, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":272
+ * 
+ *         self._close(state.name, False)
+ *         state.closed = True             # <<<<<<<<<<<<<<
+ *         return await self._new_waiter(timeout)
+ * 
+ */
+  __pyx_cur_scope->__pyx_v_state->closed = 1;
+
+  /* "asyncpg/protocol/protocol.pyx":273
+ *         self._close(state.name, False)
+ *         state.closed = True
+ *         return await self._new_waiter(timeout)             # <<<<<<<<<<<<<<
+ * 
+ *     def is_closed(self):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_4 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_new_waiter(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_timeout); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 273, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __Pyx_XGOTREF(__pyx_r);
+  if (likely(__pyx_r)) {
+    __Pyx_XGIVEREF(__pyx_r);
+    __Pyx_RefNannyFinishContext();
+    /* return from generator, yielding value */
+    __pyx_generator->resume_label = 3;
+    return __pyx_r;
+    __pyx_L9_resume_from_yield:;
+    if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 273, __pyx_L1_error)
+    __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
+  } else {
+    __pyx_t_4 = NULL;
+    if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_4) < 0) __PYX_ERR(27, 273, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+  }
+  __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = 0;
+  goto __pyx_L0;
+  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
+
+  /* "asyncpg/protocol/protocol.pyx":257
+ *         return await self._new_waiter(timeout)
+ * 
+ *     async def close_statement(self, PreparedStatementState state, timeout):             # <<<<<<<<<<<<<<
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_AddTraceback("close_statement", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
+  __pyx_generator->resume_label = -1;
+  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":275
+ *         return await self._new_waiter(timeout)
+ * 
+ *     def is_closed(self):             # <<<<<<<<<<<<<<
+ *         return self.closing
+ * 
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_30is_closed(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_30is_closed(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("is_closed (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_29is_closed(((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_29is_closed(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("is_closed", 0);
+
+  /* "asyncpg/protocol/protocol.pyx":276
+ * 
+ *     def is_closed(self):
+ *         return self.closing             # <<<<<<<<<<<<<<
+ * 
+ *     def is_connected(self):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->closing); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 276, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/protocol.pyx":275
+ *         return await self._new_waiter(timeout)
+ * 
+ *     def is_closed(self):             # <<<<<<<<<<<<<<
+ *         return self.closing
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.is_closed", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":278
+ *         return self.closing
+ * 
+ *     def is_connected(self):             # <<<<<<<<<<<<<<
+ *         return not self.closing and self.con_status == CONNECTION_OK
+ * 
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_32is_connected(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_32is_connected(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("is_connected (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_31is_connected(((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_31is_connected(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("is_connected", 0);
+
+  /* "asyncpg/protocol/protocol.pyx":279
+ * 
+ *     def is_connected(self):
+ *         return not self.closing and self.con_status == CONNECTION_OK             # <<<<<<<<<<<<<<
+ * 
+ *     def abort(self):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_2 = (!(__pyx_v_self->closing != 0));
+  if (__pyx_t_2) {
+  } else {
+    __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 279, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_1 = __pyx_t_3;
+    __pyx_t_3 = 0;
+    goto __pyx_L3_bool_binop_done;
+  }
+  __pyx_t_2 = (__pyx_v_self->__pyx_base.con_status == __pyx_e_7asyncpg_8protocol_8protocol_CONNECTION_OK);
+  __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 279, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_1 = __pyx_t_3;
+  __pyx_t_3 = 0;
+  __pyx_L3_bool_binop_done:;
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/protocol.pyx":278
+ *         return self.closing
+ * 
+ *     def is_connected(self):             # <<<<<<<<<<<<<<
+ *         return not self.closing and self.con_status == CONNECTION_OK
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.is_connected", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":281
+ *         return not self.closing and self.con_status == CONNECTION_OK
+ * 
+ *     def abort(self):             # <<<<<<<<<<<<<<
+ *         if self.closing:
+ *             return
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_34abort(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_34abort(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("abort (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_33abort(((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_33abort(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  __Pyx_RefNannySetupContext("abort", 0);
+
+  /* "asyncpg/protocol/protocol.pyx":282
+ * 
+ *     def abort(self):
+ *         if self.closing:             # <<<<<<<<<<<<<<
+ *             return
+ *         self.closing = True
+ */
+  __pyx_t_1 = (__pyx_v_self->closing != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/protocol.pyx":283
+ *     def abort(self):
+ *         if self.closing:
+ *             return             # <<<<<<<<<<<<<<
+ *         self.closing = True
+ *         self._handle_waiter_on_connection_lost(None)
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/protocol.pyx":282
+ * 
+ *     def abort(self):
+ *         if self.closing:             # <<<<<<<<<<<<<<
+ *             return
+ *         self.closing = True
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":284
+ *         if self.closing:
+ *             return
+ *         self.closing = True             # <<<<<<<<<<<<<<
+ *         self._handle_waiter_on_connection_lost(None)
+ *         self._terminate()
+ */
+  __pyx_v_self->closing = 1;
+
+  /* "asyncpg/protocol/protocol.pyx":285
+ *             return
+ *         self.closing = True
+ *         self._handle_waiter_on_connection_lost(None)             # <<<<<<<<<<<<<<
+ *         self._terminate()
+ *         self.transport.abort()
+ */
+  __pyx_t_2 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self->__pyx_base.__pyx_vtab)->_handle_waiter_on_connection_lost(__pyx_v_self, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 285, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":286
+ *         self.closing = True
+ *         self._handle_waiter_on_connection_lost(None)
+ *         self._terminate()             # <<<<<<<<<<<<<<
+ *         self.transport.abort()
+ * 
+ */
+  __pyx_t_2 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._terminate(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 286, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":287
+ *         self._handle_waiter_on_connection_lost(None)
+ *         self._terminate()
+ *         self.transport.abort()             # <<<<<<<<<<<<<<
+ * 
+ *     async def close(self):
+ */
+  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.transport, __pyx_n_s_abort); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 287, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
+    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
+    if (likely(__pyx_t_4)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+      __Pyx_INCREF(__pyx_t_4);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_3, function);
+    }
+  }
+  if (__pyx_t_4) {
+    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 287, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  } else {
+    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 287, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":281
+ *         return not self.closing and self.con_status == CONNECTION_OK
+ * 
+ *     def abort(self):             # <<<<<<<<<<<<<<
+ *         if self.closing:
+ *             return
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.abort", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_37generator7(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
+
+/* "asyncpg/protocol/protocol.pyx":289
+ *         self.transport.abort()
+ * 
+ *     async def close(self):             # <<<<<<<<<<<<<<
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_36close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_36close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("close (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_35close(((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_35close(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close *__pyx_cur_scope;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("close", 0);
+  __pyx_cur_scope = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close *)__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close(__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close, __pyx_empty_tuple, NULL);
+  if (unlikely(!__pyx_cur_scope)) {
+    __pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close *)Py_None);
+    __Pyx_INCREF(Py_None);
+    __PYX_ERR(27, 289, __pyx_L1_error)
+  } else {
+    __Pyx_GOTREF(__pyx_cur_scope);
+  }
+  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
+  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
+  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
+  {
+    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_37generator7, (PyObject *) __pyx_cur_scope, __pyx_n_s_close, __pyx_n_s_BaseProtocol_close, __pyx_n_s_asyncpg_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(27, 289, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_cur_scope);
+    __Pyx_RefNannyFinishContext();
+    return (PyObject *) gen;
+  }
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.close", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_37generator7(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
+{
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close *__pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close *)__pyx_generator->closure);
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("None", 0);
+  switch (__pyx_generator->resume_label) {
+    case 0: goto __pyx_L3_first_run;
+    case 1: goto __pyx_L5_resume_from_yield;
+    case 2: goto __pyx_L7_resume_from_yield;
+    case 3: goto __pyx_L9_resume_from_yield;
+    default: /* CPython raises the right error here */
+    __Pyx_RefNannyFinishContext();
+    return NULL;
+  }
+  __pyx_L3_first_run:;
+  if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 289, __pyx_L1_error)
+
+  /* "asyncpg/protocol/protocol.pyx":290
+ * 
+ *     async def close(self):
+ *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:
+ */
+  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_self->cancel_waiter != Py_None);
+  __pyx_t_2 = (__pyx_t_1 != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/protocol.pyx":291
+ *     async def close(self):
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter             # <<<<<<<<<<<<<<
+ *         if self.cancel_sent_waiter is not None:
+ *             await self.cancel_sent_waiter
+ */
+    __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_cur_scope->__pyx_v_self->cancel_waiter);
+    __Pyx_XGOTREF(__pyx_r);
+    if (likely(__pyx_r)) {
+      __Pyx_XGIVEREF(__pyx_r);
+      __Pyx_RefNannyFinishContext();
+      /* return from generator, yielding value */
+      __pyx_generator->resume_label = 1;
+      return __pyx_r;
+      __pyx_L5_resume_from_yield:;
+      if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 291, __pyx_L1_error)
+    } else {
+      PyObject* exc_type = PyErr_Occurred();
+      if (exc_type) {
+        if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+        else __PYX_ERR(27, 291, __pyx_L1_error)
+      }
+    }
+
+    /* "asyncpg/protocol/protocol.pyx":290
+ * 
+ *     async def close(self):
+ *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":292
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_sent_waiter
+ *             self.cancel_sent_waiter = None
+ */
+  __pyx_t_2 = (__pyx_cur_scope->__pyx_v_self->cancel_sent_waiter != Py_None);
+  __pyx_t_1 = (__pyx_t_2 != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/protocol.pyx":293
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:
+ *             await self.cancel_sent_waiter             # <<<<<<<<<<<<<<
+ *             self.cancel_sent_waiter = None
+ * 
+ */
+    __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_cur_scope->__pyx_v_self->cancel_sent_waiter);
+    __Pyx_XGOTREF(__pyx_r);
+    if (likely(__pyx_r)) {
+      __Pyx_XGIVEREF(__pyx_r);
+      __Pyx_RefNannyFinishContext();
+      /* return from generator, yielding value */
+      __pyx_generator->resume_label = 2;
+      return __pyx_r;
+      __pyx_L7_resume_from_yield:;
+      if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 293, __pyx_L1_error)
+    } else {
+      PyObject* exc_type = PyErr_Occurred();
+      if (exc_type) {
+        if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+        else __PYX_ERR(27, 293, __pyx_L1_error)
+      }
+    }
+
+    /* "asyncpg/protocol/protocol.pyx":294
+ *         if self.cancel_sent_waiter is not None:
+ *             await self.cancel_sent_waiter
+ *             self.cancel_sent_waiter = None             # <<<<<<<<<<<<<<
+ * 
+ *         self._handle_waiter_on_connection_lost(None)
+ */
+    __Pyx_INCREF(Py_None);
+    __Pyx_GIVEREF(Py_None);
+    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->cancel_sent_waiter);
+    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->cancel_sent_waiter);
+    __pyx_cur_scope->__pyx_v_self->cancel_sent_waiter = Py_None;
+
+    /* "asyncpg/protocol/protocol.pyx":292
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ *         if self.cancel_sent_waiter is not None:             # <<<<<<<<<<<<<<
+ *             await self.cancel_sent_waiter
+ *             self.cancel_sent_waiter = None
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":296
+ *             self.cancel_sent_waiter = None
+ * 
+ *         self._handle_waiter_on_connection_lost(None)             # <<<<<<<<<<<<<<
+ *         assert self.waiter is None
+ * 
+ */
+  __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_handle_waiter_on_connection_lost(__pyx_cur_scope->__pyx_v_self, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 296, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":297
+ * 
+ *         self._handle_waiter_on_connection_lost(None)
+ *         assert self.waiter is None             # <<<<<<<<<<<<<<
+ * 
+ *         if self.closing:
+ */
+  #ifndef CYTHON_WITHOUT_ASSERTIONS
+  if (unlikely(!Py_OptimizeFlag)) {
+    __pyx_t_1 = (__pyx_cur_scope->__pyx_v_self->waiter == Py_None);
+    if (unlikely(!(__pyx_t_1 != 0))) {
+      PyErr_SetNone(PyExc_AssertionError);
+      __PYX_ERR(27, 297, __pyx_L1_error)
+    }
+  }
+  #endif
+
+  /* "asyncpg/protocol/protocol.pyx":299
+ *         assert self.waiter is None
+ * 
+ *         if self.closing:             # <<<<<<<<<<<<<<
+ *             return
+ * 
+ */
+  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_self->closing != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/protocol.pyx":300
+ * 
+ *         if self.closing:
+ *             return             # <<<<<<<<<<<<<<
+ * 
+ *         self._terminate()
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = NULL;
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/protocol.pyx":299
+ *         assert self.waiter is None
+ * 
+ *         if self.closing:             # <<<<<<<<<<<<<<
+ *             return
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":302
+ *             return
+ * 
+ *         self._terminate()             # <<<<<<<<<<<<<<
+ *         self.waiter = self.create_future()
+ *         self.closing = True
+ */
+  __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._terminate(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_cur_scope->__pyx_v_self)); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 302, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":303
+ * 
+ *         self._terminate()
+ *         self.waiter = self.create_future()             # <<<<<<<<<<<<<<
+ *         self.closing = True
+ *         self.transport.abort()
+ */
+  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self->create_future);
+  __pyx_t_4 = __pyx_cur_scope->__pyx_v_self->create_future; __pyx_t_5 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
+    if (likely(__pyx_t_5)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+      __Pyx_INCREF(__pyx_t_5);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_4, function);
+    }
+  }
+  if (__pyx_t_5) {
+    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 303, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  } else {
+    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 303, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __Pyx_GIVEREF(__pyx_t_3);
+  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->waiter);
+  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->waiter);
+  __pyx_cur_scope->__pyx_v_self->waiter = __pyx_t_3;
+  __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":304
+ *         self._terminate()
+ *         self.waiter = self.create_future()
+ *         self.closing = True             # <<<<<<<<<<<<<<
+ *         self.transport.abort()
+ *         return await self.waiter
+ */
+  __pyx_cur_scope->__pyx_v_self->closing = 1;
+
+  /* "asyncpg/protocol/protocol.pyx":305
+ *         self.waiter = self.create_future()
+ *         self.closing = True
+ *         self.transport.abort()             # <<<<<<<<<<<<<<
+ *         return await self.waiter
+ * 
+ */
+  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->__pyx_base.transport, __pyx_n_s_abort); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 305, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_5 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
+    if (likely(__pyx_t_5)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+      __Pyx_INCREF(__pyx_t_5);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_4, function);
+    }
+  }
+  if (__pyx_t_5) {
+    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 305, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  } else {
+    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 305, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":306
+ *         self.closing = True
+ *         self.transport.abort()
+ *         return await self.waiter             # <<<<<<<<<<<<<<
+ * 
+ *     def _request_cancel(self):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_cur_scope->__pyx_v_self->waiter);
+  __Pyx_XGOTREF(__pyx_r);
+  if (likely(__pyx_r)) {
+    __Pyx_XGIVEREF(__pyx_r);
+    __Pyx_RefNannyFinishContext();
+    /* return from generator, yielding value */
+    __pyx_generator->resume_label = 3;
+    return __pyx_r;
+    __pyx_L9_resume_from_yield:;
+    if (unlikely(!__pyx_sent_value)) __PYX_ERR(27, 306, __pyx_L1_error)
+    __pyx_t_3 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_3);
+  } else {
+    __pyx_t_3 = NULL;
+    if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_3) < 0) __PYX_ERR(27, 306, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+  }
+  __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = 0;
+  goto __pyx_L0;
+  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
+
+  /* "asyncpg/protocol/protocol.pyx":289
+ *         self.transport.abort()
+ * 
+ *     async def close(self):             # <<<<<<<<<<<<<<
+ *         if self.cancel_waiter is not None:
+ *             await self.cancel_waiter
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("close", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
+  __pyx_generator->resume_label = -1;
+  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":308
+ *         return await self.waiter
+ * 
+ *     def _request_cancel(self):             # <<<<<<<<<<<<<<
+ *         self.cancel_waiter = self.create_future()
+ *         self.cancel_sent_waiter = self.create_future()
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_39_request_cancel(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_39_request_cancel(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("_request_cancel (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_38_request_cancel(((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_38_request_cancel(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  __Pyx_RefNannySetupContext("_request_cancel", 0);
+
+  /* "asyncpg/protocol/protocol.pyx":309
+ * 
+ *     def _request_cancel(self):
+ *         self.cancel_waiter = self.create_future()             # <<<<<<<<<<<<<<
+ *         self.cancel_sent_waiter = self.create_future()
+ *         self.connection._cancel_current_command(self.cancel_sent_waiter)
+ */
+  __Pyx_INCREF(__pyx_v_self->create_future);
+  __pyx_t_2 = __pyx_v_self->create_future; __pyx_t_3 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (__pyx_t_3) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 309, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  } else {
+    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 309, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_GIVEREF(__pyx_t_1);
+  __Pyx_GOTREF(__pyx_v_self->cancel_waiter);
+  __Pyx_DECREF(__pyx_v_self->cancel_waiter);
+  __pyx_v_self->cancel_waiter = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":310
+ *     def _request_cancel(self):
+ *         self.cancel_waiter = self.create_future()
+ *         self.cancel_sent_waiter = self.create_future()             # <<<<<<<<<<<<<<
+ *         self.connection._cancel_current_command(self.cancel_sent_waiter)
+ * 
+ */
+  __Pyx_INCREF(__pyx_v_self->create_future);
+  __pyx_t_2 = __pyx_v_self->create_future; __pyx_t_3 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (__pyx_t_3) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 310, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  } else {
+    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 310, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_GIVEREF(__pyx_t_1);
+  __Pyx_GOTREF(__pyx_v_self->cancel_sent_waiter);
+  __Pyx_DECREF(__pyx_v_self->cancel_sent_waiter);
+  __pyx_v_self->cancel_sent_waiter = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":311
+ *         self.cancel_waiter = self.create_future()
+ *         self.cancel_sent_waiter = self.create_future()
+ *         self.connection._cancel_current_command(self.cancel_sent_waiter)             # <<<<<<<<<<<<<<
+ * 
+ *     def _on_timeout(self, fut):
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->connection, __pyx_n_s_cancel_current_command); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 311, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (!__pyx_t_3) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_self->cancel_sent_waiter); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 311, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_self->cancel_sent_waiter};
+      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 311, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_self->cancel_sent_waiter};
+      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 311, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else
+    #endif
+    {
+      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 311, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
+      __Pyx_INCREF(__pyx_v_self->cancel_sent_waiter);
+      __Pyx_GIVEREF(__pyx_v_self->cancel_sent_waiter);
+      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self->cancel_sent_waiter);
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 311, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":308
+ *         return await self.waiter
+ * 
+ *     def _request_cancel(self):             # <<<<<<<<<<<<<<
+ *         self.cancel_waiter = self.create_future()
+ *         self.cancel_sent_waiter = self.create_future()
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._request_cancel", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":313
+ *         self.connection._cancel_current_command(self.cancel_sent_waiter)
+ * 
+ *     def _on_timeout(self, fut):             # <<<<<<<<<<<<<<
+ *         if self.waiter is not fut or fut.done() or \
+ *                 self.cancel_waiter is not None or \
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_41_on_timeout(PyObject *__pyx_v_self, PyObject *__pyx_v_fut); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_41_on_timeout(PyObject *__pyx_v_self, PyObject *__pyx_v_fut) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("_on_timeout (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_40_on_timeout(((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self), ((PyObject *)__pyx_v_fut));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_40_on_timeout(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_fut) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  int __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  __Pyx_RefNannySetupContext("_on_timeout", 0);
+
+  /* "asyncpg/protocol/protocol.pyx":314
+ * 
+ *     def _on_timeout(self, fut):
+ *         if self.waiter is not fut or fut.done() or \             # <<<<<<<<<<<<<<
+ *                 self.cancel_waiter is not None or \
+ *                 self.timeout_handle is None:
+ */
+  __pyx_t_2 = (__pyx_v_self->waiter != __pyx_v_fut);
+  __pyx_t_3 = (__pyx_t_2 != 0);
+  if (!__pyx_t_3) {
+  } else {
+    __pyx_t_1 = __pyx_t_3;
+    goto __pyx_L4_bool_binop_done;
+  }
+  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_fut, __pyx_n_s_done); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 314, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_6 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
+    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
+    if (likely(__pyx_t_6)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+      __Pyx_INCREF(__pyx_t_6);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_5, function);
+    }
+  }
+  if (__pyx_t_6) {
+    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 314, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  } else {
+    __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 314, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(27, 314, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (!__pyx_t_3) {
+  } else {
+    __pyx_t_1 = __pyx_t_3;
+    goto __pyx_L4_bool_binop_done;
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":315
+ *     def _on_timeout(self, fut):
+ *         if self.waiter is not fut or fut.done() or \
+ *                 self.cancel_waiter is not None or \             # <<<<<<<<<<<<<<
+ *                 self.timeout_handle is None:
+ *             return
+ */
+  __pyx_t_3 = (__pyx_v_self->cancel_waiter != Py_None);
+  __pyx_t_2 = (__pyx_t_3 != 0);
+  if (!__pyx_t_2) {
+  } else {
+    __pyx_t_1 = __pyx_t_2;
+    goto __pyx_L4_bool_binop_done;
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":316
+ *         if self.waiter is not fut or fut.done() or \
+ *                 self.cancel_waiter is not None or \
+ *                 self.timeout_handle is None:             # <<<<<<<<<<<<<<
+ *             return
+ *         self._request_cancel()
+ */
+  __pyx_t_2 = (__pyx_v_self->timeout_handle == Py_None);
+  __pyx_t_3 = (__pyx_t_2 != 0);
+  __pyx_t_1 = __pyx_t_3;
+  __pyx_L4_bool_binop_done:;
+
+  /* "asyncpg/protocol/protocol.pyx":314
+ * 
+ *     def _on_timeout(self, fut):
+ *         if self.waiter is not fut or fut.done() or \             # <<<<<<<<<<<<<<
+ *                 self.cancel_waiter is not None or \
+ *                 self.timeout_handle is None:
+ */
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/protocol.pyx":317
+ *                 self.cancel_waiter is not None or \
+ *                 self.timeout_handle is None:
+ *             return             # <<<<<<<<<<<<<<
+ *         self._request_cancel()
+ *         self.waiter.set_exception(asyncio.TimeoutError())
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/protocol.pyx":314
+ * 
+ *     def _on_timeout(self, fut):
+ *         if self.waiter is not fut or fut.done() or \             # <<<<<<<<<<<<<<
+ *                 self.cancel_waiter is not None or \
+ *                 self.timeout_handle is None:
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":318
+ *                 self.timeout_handle is None:
+ *             return
+ *         self._request_cancel()             # <<<<<<<<<<<<<<
+ *         self.waiter.set_exception(asyncio.TimeoutError())
+ * 
+ */
+  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_request_cancel); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 318, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_6 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
+    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
+    if (likely(__pyx_t_6)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+      __Pyx_INCREF(__pyx_t_6);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_5, function);
+    }
+  }
+  if (__pyx_t_6) {
+    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 318, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  } else {
+    __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 318, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":319
+ *             return
+ *         self._request_cancel()
+ *         self.waiter.set_exception(asyncio.TimeoutError())             # <<<<<<<<<<<<<<
+ * 
+ *     def _on_waiter_completed(self, fut):
+ */
+  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->waiter, __pyx_n_s_set_exception); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 319, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_asyncio); if (unlikely(!__pyx_t_7)) __PYX_ERR(27, 319, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_7);
+  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_TimeoutError); if (unlikely(!__pyx_t_8)) __PYX_ERR(27, 319, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_8);
+  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+  __pyx_t_7 = NULL;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
+    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
+    if (likely(__pyx_t_7)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
+      __Pyx_INCREF(__pyx_t_7);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_8, function);
+    }
+  }
+  if (__pyx_t_7) {
+    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 319, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+  } else {
+    __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 319, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_6);
+  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+  __pyx_t_8 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
+    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5);
+    if (likely(__pyx_t_8)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+      __Pyx_INCREF(__pyx_t_8);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_5, function);
+    }
+  }
+  if (!__pyx_t_8) {
+    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 319, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __Pyx_GOTREF(__pyx_t_4);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_5)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
+      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 319, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
+      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 319, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    } else
+    #endif
+    {
+      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(27, 319, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = NULL;
+      __Pyx_GIVEREF(__pyx_t_6);
+      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_6);
+      __pyx_t_6 = 0;
+      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 319, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":313
+ *         self.connection._cancel_current_command(self.cancel_sent_waiter)
+ * 
+ *     def _on_timeout(self, fut):             # <<<<<<<<<<<<<<
+ *         if self.waiter is not fut or fut.done() or \
+ *                 self.cancel_waiter is not None or \
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._on_timeout", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":321
+ *         self.waiter.set_exception(asyncio.TimeoutError())
+ * 
+ *     def _on_waiter_completed(self, fut):             # <<<<<<<<<<<<<<
+ *         if fut is not self.waiter or self.cancel_waiter is not None:
+ *             return
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_43_on_waiter_completed(PyObject *__pyx_v_self, PyObject *__pyx_v_fut); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_43_on_waiter_completed(PyObject *__pyx_v_self, PyObject *__pyx_v_fut) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("_on_waiter_completed (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_42_on_waiter_completed(((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self), ((PyObject *)__pyx_v_fut));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_42_on_waiter_completed(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_fut) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  int __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  __Pyx_RefNannySetupContext("_on_waiter_completed", 0);
+
+  /* "asyncpg/protocol/protocol.pyx":322
+ * 
+ *     def _on_waiter_completed(self, fut):
+ *         if fut is not self.waiter or self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
+ *             return
+ *         if fut.cancelled():
+ */
+  __pyx_t_2 = (__pyx_v_fut != __pyx_v_self->waiter);
+  __pyx_t_3 = (__pyx_t_2 != 0);
+  if (!__pyx_t_3) {
+  } else {
+    __pyx_t_1 = __pyx_t_3;
+    goto __pyx_L4_bool_binop_done;
+  }
+  __pyx_t_3 = (__pyx_v_self->cancel_waiter != Py_None);
+  __pyx_t_2 = (__pyx_t_3 != 0);
+  __pyx_t_1 = __pyx_t_2;
+  __pyx_L4_bool_binop_done:;
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/protocol.pyx":323
+ *     def _on_waiter_completed(self, fut):
+ *         if fut is not self.waiter or self.cancel_waiter is not None:
+ *             return             # <<<<<<<<<<<<<<
+ *         if fut.cancelled():
+ *             if self.timeout_handle:
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/protocol.pyx":322
+ * 
+ *     def _on_waiter_completed(self, fut):
+ *         if fut is not self.waiter or self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
+ *             return
+ *         if fut.cancelled():
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":324
+ *         if fut is not self.waiter or self.cancel_waiter is not None:
+ *             return
+ *         if fut.cancelled():             # <<<<<<<<<<<<<<
+ *             if self.timeout_handle:
+ *                 self.timeout_handle.cancel()
+ */
+  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_fut, __pyx_n_s_cancelled); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 324, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_6 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
+    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
+    if (likely(__pyx_t_6)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+      __Pyx_INCREF(__pyx_t_6);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_5, function);
+    }
+  }
+  if (__pyx_t_6) {
+    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 324, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  } else {
+    __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 324, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(27, 324, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/protocol.pyx":325
+ *             return
+ *         if fut.cancelled():
+ *             if self.timeout_handle:             # <<<<<<<<<<<<<<
+ *                 self.timeout_handle.cancel()
+ *                 self.timeout_handle = None
+ */
+    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->timeout_handle); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(27, 325, __pyx_L1_error)
+    if (__pyx_t_1) {
+
+      /* "asyncpg/protocol/protocol.pyx":326
+ *         if fut.cancelled():
+ *             if self.timeout_handle:
+ *                 self.timeout_handle.cancel()             # <<<<<<<<<<<<<<
+ *                 self.timeout_handle = None
+ *             self._request_cancel()
+ */
+      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->timeout_handle, __pyx_n_s_cancel); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 326, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_5);
+      __pyx_t_6 = NULL;
+      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
+        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
+        if (likely(__pyx_t_6)) {
+          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+          __Pyx_INCREF(__pyx_t_6);
+          __Pyx_INCREF(function);
+          __Pyx_DECREF_SET(__pyx_t_5, function);
+        }
+      }
+      if (__pyx_t_6) {
+        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 326, __pyx_L1_error)
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      } else {
+        __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 326, __pyx_L1_error)
+      }
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+      /* "asyncpg/protocol/protocol.pyx":327
+ *             if self.timeout_handle:
+ *                 self.timeout_handle.cancel()
+ *                 self.timeout_handle = None             # <<<<<<<<<<<<<<
+ *             self._request_cancel()
+ * 
+ */
+      __Pyx_INCREF(Py_None);
+      __Pyx_GIVEREF(Py_None);
+      __Pyx_GOTREF(__pyx_v_self->timeout_handle);
+      __Pyx_DECREF(__pyx_v_self->timeout_handle);
+      __pyx_v_self->timeout_handle = Py_None;
+
+      /* "asyncpg/protocol/protocol.pyx":325
+ *             return
+ *         if fut.cancelled():
+ *             if self.timeout_handle:             # <<<<<<<<<<<<<<
+ *                 self.timeout_handle.cancel()
+ *                 self.timeout_handle = None
+ */
+    }
+
+    /* "asyncpg/protocol/protocol.pyx":328
+ *                 self.timeout_handle.cancel()
+ *                 self.timeout_handle = None
+ *             self._request_cancel()             # <<<<<<<<<<<<<<
+ * 
+ *     def _create_future_fallback(self):
+ */
+    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_request_cancel); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 328, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
+      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
+      if (likely(__pyx_t_6)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+        __Pyx_INCREF(__pyx_t_6);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_5, function);
+      }
+    }
+    if (__pyx_t_6) {
+      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 328, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    } else {
+      __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 328, __pyx_L1_error)
+    }
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/protocol.pyx":324
+ *         if fut is not self.waiter or self.cancel_waiter is not None:
+ *             return
+ *         if fut.cancelled():             # <<<<<<<<<<<<<<
+ *             if self.timeout_handle:
+ *                 self.timeout_handle.cancel()
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":321
+ *         self.waiter.set_exception(asyncio.TimeoutError())
+ * 
+ *     def _on_waiter_completed(self, fut):             # <<<<<<<<<<<<<<
+ *         if fut is not self.waiter or self.cancel_waiter is not None:
+ *             return
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._on_waiter_completed", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":330
+ *             self._request_cancel()
+ * 
+ *     def _create_future_fallback(self):             # <<<<<<<<<<<<<<
+ *         return asyncio.Future(loop=self.loop)
+ * 
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_45_create_future_fallback(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_45_create_future_fallback(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("_create_future_fallback (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_44_create_future_fallback(((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_44_create_future_fallback(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("_create_future_fallback", 0);
+
+  /* "asyncpg/protocol/protocol.pyx":331
+ * 
+ *     def _create_future_fallback(self):
+ *         return asyncio.Future(loop=self.loop)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _handle_waiter_on_connection_lost(self, cause):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_asyncio); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 331, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Future); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 331, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 331, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_loop, __pyx_v_self->loop) < 0) __PYX_ERR(27, 331, __pyx_L1_error)
+  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 331, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_r = __pyx_t_3;
+  __pyx_t_3 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/protocol.pyx":330
+ *             self._request_cancel()
+ * 
+ *     def _create_future_fallback(self):             # <<<<<<<<<<<<<<
+ *         return asyncio.Future(loop=self.loop)
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._create_future_fallback", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":333
+ *         return asyncio.Future(loop=self.loop)
+ * 
+ *     cdef _handle_waiter_on_connection_lost(self, cause):             # <<<<<<<<<<<<<<
+ *         if self.waiter is not None and not self.waiter.done():
+ *             exc = apg_exc.ConnectionDoesNotExistError(
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__handle_waiter_on_connection_lost(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_cause) {
+  PyObject *__pyx_v_exc = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  int __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  __Pyx_RefNannySetupContext("_handle_waiter_on_connection_lost", 0);
+
+  /* "asyncpg/protocol/protocol.pyx":334
+ * 
+ *     cdef _handle_waiter_on_connection_lost(self, cause):
+ *         if self.waiter is not None and not self.waiter.done():             # <<<<<<<<<<<<<<
+ *             exc = apg_exc.ConnectionDoesNotExistError(
+ *                 'connection was closed in the middle of '
+ */
+  __pyx_t_2 = (__pyx_v_self->waiter != Py_None);
+  __pyx_t_3 = (__pyx_t_2 != 0);
+  if (__pyx_t_3) {
+  } else {
+    __pyx_t_1 = __pyx_t_3;
+    goto __pyx_L4_bool_binop_done;
+  }
+  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->waiter, __pyx_n_s_done); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 334, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_6 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
+    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
+    if (likely(__pyx_t_6)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+      __Pyx_INCREF(__pyx_t_6);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_5, function);
+    }
+  }
+  if (__pyx_t_6) {
+    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 334, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  } else {
+    __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 334, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(27, 334, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_2 = ((!__pyx_t_3) != 0);
+  __pyx_t_1 = __pyx_t_2;
+  __pyx_L4_bool_binop_done:;
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/protocol.pyx":335
+ *     cdef _handle_waiter_on_connection_lost(self, cause):
+ *         if self.waiter is not None and not self.waiter.done():
+ *             exc = apg_exc.ConnectionDoesNotExistError(             # <<<<<<<<<<<<<<
+ *                 'connection was closed in the middle of '
+ *                 'operation')
+ */
+    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 335, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ConnectionDoesNotExistError); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 335, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__71, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 335, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_v_exc = __pyx_t_4;
+    __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/protocol.pyx":338
+ *                 'connection was closed in the middle of '
+ *                 'operation')
+ *             if cause is not None:             # <<<<<<<<<<<<<<
+ *                 exc.__cause__ = cause
+ *             self.waiter.set_exception(exc)
+ */
+    __pyx_t_1 = (__pyx_v_cause != Py_None);
+    __pyx_t_2 = (__pyx_t_1 != 0);
+    if (__pyx_t_2) {
+
+      /* "asyncpg/protocol/protocol.pyx":339
+ *                 'operation')
+ *             if cause is not None:
+ *                 exc.__cause__ = cause             # <<<<<<<<<<<<<<
+ *             self.waiter.set_exception(exc)
+ *         self.waiter = None
+ */
+      if (__Pyx_PyObject_SetAttrStr(__pyx_v_exc, __pyx_n_s_cause, __pyx_v_cause) < 0) __PYX_ERR(27, 339, __pyx_L1_error)
+
+      /* "asyncpg/protocol/protocol.pyx":338
+ *                 'connection was closed in the middle of '
+ *                 'operation')
+ *             if cause is not None:             # <<<<<<<<<<<<<<
+ *                 exc.__cause__ = cause
+ *             self.waiter.set_exception(exc)
+ */
+    }
+
+    /* "asyncpg/protocol/protocol.pyx":340
+ *             if cause is not None:
+ *                 exc.__cause__ = cause
+ *             self.waiter.set_exception(exc)             # <<<<<<<<<<<<<<
+ *         self.waiter = None
+ * 
+ */
+    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->waiter, __pyx_n_s_set_exception); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 340, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
+      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
+      if (likely(__pyx_t_6)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+        __Pyx_INCREF(__pyx_t_6);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_5, function);
+      }
+    }
+    if (!__pyx_t_6) {
+      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_exc); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 340, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_5)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_exc};
+        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 340, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_GOTREF(__pyx_t_4);
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_exc};
+        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 340, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_GOTREF(__pyx_t_4);
+      } else
+      #endif
+      {
+        __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(27, 340, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
+        __Pyx_INCREF(__pyx_v_exc);
+        __Pyx_GIVEREF(__pyx_v_exc);
+        PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_exc);
+        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 340, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/protocol.pyx":334
+ * 
+ *     cdef _handle_waiter_on_connection_lost(self, cause):
+ *         if self.waiter is not None and not self.waiter.done():             # <<<<<<<<<<<<<<
+ *             exc = apg_exc.ConnectionDoesNotExistError(
+ *                 'connection was closed in the middle of '
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":341
+ *                 exc.__cause__ = cause
+ *             self.waiter.set_exception(exc)
+ *         self.waiter = None             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _set_server_parameter(self, name, val):
+ */
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->waiter);
+  __Pyx_DECREF(__pyx_v_self->waiter);
+  __pyx_v_self->waiter = Py_None;
+
+  /* "asyncpg/protocol/protocol.pyx":333
+ *         return asyncio.Future(loop=self.loop)
+ * 
+ *     cdef _handle_waiter_on_connection_lost(self, cause):             # <<<<<<<<<<<<<<
+ *         if self.waiter is not None and not self.waiter.done():
+ *             exc = apg_exc.ConnectionDoesNotExistError(
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._handle_waiter_on_connection_lost", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_exc);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":343
+ *         self.waiter = None
+ * 
+ *     cdef _set_server_parameter(self, name, val):             # <<<<<<<<<<<<<<
+ *         self.settings.add_setting(name, val)
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__set_server_parameter(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_val) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("_set_server_parameter", 0);
+
+  /* "asyncpg/protocol/protocol.pyx":344
+ * 
+ *     cdef _set_server_parameter(self, name, val):
+ *         self.settings.add_setting(name, val)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _ensure_clear_state(self):
+ */
+  if (!(likely(PyUnicode_CheckExact(__pyx_v_name))||((__pyx_v_name) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_v_name)->tp_name), 0))) __PYX_ERR(27, 344, __pyx_L1_error)
+  if (!(likely(PyUnicode_CheckExact(__pyx_v_val))||((__pyx_v_val) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_v_val)->tp_name), 0))) __PYX_ERR(27, 344, __pyx_L1_error)
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_add_setting(__pyx_v_self->settings, ((PyObject*)__pyx_v_name), ((PyObject*)__pyx_v_val)); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 344, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":343
+ *         self.waiter = None
+ * 
+ *     cdef _set_server_parameter(self, name, val):             # <<<<<<<<<<<<<<
+ *         self.settings.add_setting(name, val)
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._set_server_parameter", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":346
+ *         self.settings.add_setting(name, val)
+ * 
+ *     cdef _ensure_clear_state(self):             # <<<<<<<<<<<<<<
+ *         if self.cancel_waiter is not None:
+ *             raise apg_exc.InterfaceError(
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__ensure_clear_state(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  int __pyx_t_5;
+  __Pyx_RefNannySetupContext("_ensure_clear_state", 0);
+
+  /* "asyncpg/protocol/protocol.pyx":347
+ * 
+ *     cdef _ensure_clear_state(self):
+ *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
+ *             raise apg_exc.InterfaceError(
+ *                 'cannot perform operation: another operation is cancelling')
+ */
+  __pyx_t_1 = (__pyx_v_self->cancel_waiter != Py_None);
+  __pyx_t_2 = (__pyx_t_1 != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/protocol.pyx":348
+ *     cdef _ensure_clear_state(self):
+ *         if self.cancel_waiter is not None:
+ *             raise apg_exc.InterfaceError(             # <<<<<<<<<<<<<<
+ *                 'cannot perform operation: another operation is cancelling')
+ *         if self.closing:
+ */
+    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 348, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_InterfaceError); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 348, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__72, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 348, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __PYX_ERR(27, 348, __pyx_L1_error)
+
+    /* "asyncpg/protocol/protocol.pyx":347
+ * 
+ *     cdef _ensure_clear_state(self):
+ *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
+ *             raise apg_exc.InterfaceError(
+ *                 'cannot perform operation: another operation is cancelling')
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":350
+ *             raise apg_exc.InterfaceError(
+ *                 'cannot perform operation: another operation is cancelling')
+ *         if self.closing:             # <<<<<<<<<<<<<<
+ *             raise apg_exc.InterfaceError(
+ *                 'cannot perform operation: connection is closed')
+ */
+  __pyx_t_2 = (__pyx_v_self->closing != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/protocol.pyx":351
+ *                 'cannot perform operation: another operation is cancelling')
+ *         if self.closing:
+ *             raise apg_exc.InterfaceError(             # <<<<<<<<<<<<<<
+ *                 'cannot perform operation: connection is closed')
+ *         if self.waiter is not None or self.timeout_handle is not None:
+ */
+    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 351, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_InterfaceError); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 351, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__73, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 351, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __PYX_ERR(27, 351, __pyx_L1_error)
+
+    /* "asyncpg/protocol/protocol.pyx":350
+ *             raise apg_exc.InterfaceError(
+ *                 'cannot perform operation: another operation is cancelling')
+ *         if self.closing:             # <<<<<<<<<<<<<<
+ *             raise apg_exc.InterfaceError(
+ *                 'cannot perform operation: connection is closed')
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":353
+ *             raise apg_exc.InterfaceError(
+ *                 'cannot perform operation: connection is closed')
+ *         if self.waiter is not None or self.timeout_handle is not None:             # <<<<<<<<<<<<<<
+ *             raise apg_exc.InterfaceError(
+ *                 'cannot perform operation: another operation is in progress')
+ */
+  __pyx_t_1 = (__pyx_v_self->waiter != Py_None);
+  __pyx_t_5 = (__pyx_t_1 != 0);
+  if (!__pyx_t_5) {
+  } else {
+    __pyx_t_2 = __pyx_t_5;
+    goto __pyx_L6_bool_binop_done;
+  }
+  __pyx_t_5 = (__pyx_v_self->timeout_handle != Py_None);
+  __pyx_t_1 = (__pyx_t_5 != 0);
+  __pyx_t_2 = __pyx_t_1;
+  __pyx_L6_bool_binop_done:;
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/protocol.pyx":354
+ *                 'cannot perform operation: connection is closed')
+ *         if self.waiter is not None or self.timeout_handle is not None:
+ *             raise apg_exc.InterfaceError(             # <<<<<<<<<<<<<<
+ *                 'cannot perform operation: another operation is in progress')
+ * 
+ */
+    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 354, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_InterfaceError); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 354, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__74, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 354, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __PYX_ERR(27, 354, __pyx_L1_error)
+
+    /* "asyncpg/protocol/protocol.pyx":353
+ *             raise apg_exc.InterfaceError(
+ *                 'cannot perform operation: connection is closed')
+ *         if self.waiter is not None or self.timeout_handle is not None:             # <<<<<<<<<<<<<<
+ *             raise apg_exc.InterfaceError(
+ *                 'cannot perform operation: another operation is in progress')
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":346
+ *         self.settings.add_setting(name, val)
+ * 
+ *     cdef _ensure_clear_state(self):             # <<<<<<<<<<<<<<
+ *         if self.cancel_waiter is not None:
+ *             raise apg_exc.InterfaceError(
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._ensure_clear_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":357
+ *                 'cannot perform operation: another operation is in progress')
+ * 
+ *     cdef _new_waiter(self, timeout):             # <<<<<<<<<<<<<<
+ *         self.waiter = self.create_future()
+ *         if timeout is not False:
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__new_waiter(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_timeout) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  int __pyx_t_5;
+  int __pyx_t_6;
+  int __pyx_t_7;
+  PyObject *__pyx_t_8 = NULL;
+  __Pyx_RefNannySetupContext("_new_waiter", 0);
+  __Pyx_INCREF(__pyx_v_timeout);
+
+  /* "asyncpg/protocol/protocol.pyx":358
+ * 
+ *     cdef _new_waiter(self, timeout):
+ *         self.waiter = self.create_future()             # <<<<<<<<<<<<<<
+ *         if timeout is not False:
+ *             timeout = timeout or self.connection._command_timeout
+ */
+  __Pyx_INCREF(__pyx_v_self->create_future);
+  __pyx_t_2 = __pyx_v_self->create_future; __pyx_t_3 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (__pyx_t_3) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 358, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  } else {
+    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 358, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_GIVEREF(__pyx_t_1);
+  __Pyx_GOTREF(__pyx_v_self->waiter);
+  __Pyx_DECREF(__pyx_v_self->waiter);
+  __pyx_v_self->waiter = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":359
+ *     cdef _new_waiter(self, timeout):
+ *         self.waiter = self.create_future()
+ *         if timeout is not False:             # <<<<<<<<<<<<<<
+ *             timeout = timeout or self.connection._command_timeout
+ *             if timeout is not None and timeout > 0:
+ */
+  __pyx_t_4 = (__pyx_v_timeout != Py_False);
+  __pyx_t_5 = (__pyx_t_4 != 0);
+  if (__pyx_t_5) {
+
+    /* "asyncpg/protocol/protocol.pyx":360
+ *         self.waiter = self.create_future()
+ *         if timeout is not False:
+ *             timeout = timeout or self.connection._command_timeout             # <<<<<<<<<<<<<<
+ *             if timeout is not None and timeout > 0:
+ *                 self.timeout_handle = self.connection._loop.call_later(
+ */
+    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_timeout); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(27, 360, __pyx_L1_error)
+    if (!__pyx_t_5) {
+    } else {
+      __Pyx_INCREF(__pyx_v_timeout);
+      __pyx_t_1 = __pyx_v_timeout;
+      goto __pyx_L4_bool_binop_done;
+    }
+    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->connection, __pyx_n_s_command_timeout); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 360, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(__pyx_t_2);
+    __pyx_t_1 = __pyx_t_2;
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_L4_bool_binop_done:;
+    __Pyx_DECREF_SET(__pyx_v_timeout, __pyx_t_1);
+    __pyx_t_1 = 0;
+
+    /* "asyncpg/protocol/protocol.pyx":361
+ *         if timeout is not False:
+ *             timeout = timeout or self.connection._command_timeout
+ *             if timeout is not None and timeout > 0:             # <<<<<<<<<<<<<<
+ *                 self.timeout_handle = self.connection._loop.call_later(
+ *                     timeout, self.timeout_callback, self.waiter)
+ */
+    __pyx_t_4 = (__pyx_v_timeout != Py_None);
+    __pyx_t_6 = (__pyx_t_4 != 0);
+    if (__pyx_t_6) {
+    } else {
+      __pyx_t_5 = __pyx_t_6;
+      goto __pyx_L7_bool_binop_done;
+    }
+    __pyx_t_1 = PyObject_RichCompare(__pyx_v_timeout, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 361, __pyx_L1_error)
+    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(27, 361, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_5 = __pyx_t_6;
+    __pyx_L7_bool_binop_done:;
+    if (__pyx_t_5) {
+
+      /* "asyncpg/protocol/protocol.pyx":362
+ *             timeout = timeout or self.connection._command_timeout
+ *             if timeout is not None and timeout > 0:
+ *                 self.timeout_handle = self.connection._loop.call_later(             # <<<<<<<<<<<<<<
+ *                     timeout, self.timeout_callback, self.waiter)
+ *         self.waiter.add_done_callback(self.completed_callback)
+ */
+      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->connection, __pyx_n_s_loop_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 362, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_call_later); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 362, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+      /* "asyncpg/protocol/protocol.pyx":363
+ *             if timeout is not None and timeout > 0:
+ *                 self.timeout_handle = self.connection._loop.call_later(
+ *                     timeout, self.timeout_callback, self.waiter)             # <<<<<<<<<<<<<<
+ *         self.waiter.add_done_callback(self.completed_callback)
+ *         return self.waiter
+ */
+      __pyx_t_2 = NULL;
+      __pyx_t_7 = 0;
+      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
+        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
+        if (likely(__pyx_t_2)) {
+          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+          __Pyx_INCREF(__pyx_t_2);
+          __Pyx_INCREF(function);
+          __Pyx_DECREF_SET(__pyx_t_3, function);
+          __pyx_t_7 = 1;
+        }
+      }
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_3)) {
+        PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_v_timeout, __pyx_v_self->timeout_callback, __pyx_v_self->waiter};
+        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 362, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __Pyx_GOTREF(__pyx_t_1);
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
+        PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_v_timeout, __pyx_v_self->timeout_callback, __pyx_v_self->waiter};
+        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 362, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __Pyx_GOTREF(__pyx_t_1);
+      } else
+      #endif
+      {
+        __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(27, 362, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_8);
+        if (__pyx_t_2) {
+          __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2); __pyx_t_2 = NULL;
+        }
+        __Pyx_INCREF(__pyx_v_timeout);
+        __Pyx_GIVEREF(__pyx_v_timeout);
+        PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_v_timeout);
+        __Pyx_INCREF(__pyx_v_self->timeout_callback);
+        __Pyx_GIVEREF(__pyx_v_self->timeout_callback);
+        PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_self->timeout_callback);
+        __Pyx_INCREF(__pyx_v_self->waiter);
+        __Pyx_GIVEREF(__pyx_v_self->waiter);
+        PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_v_self->waiter);
+        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 362, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+      }
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+      /* "asyncpg/protocol/protocol.pyx":362
+ *             timeout = timeout or self.connection._command_timeout
+ *             if timeout is not None and timeout > 0:
+ *                 self.timeout_handle = self.connection._loop.call_later(             # <<<<<<<<<<<<<<
+ *                     timeout, self.timeout_callback, self.waiter)
+ *         self.waiter.add_done_callback(self.completed_callback)
+ */
+      __Pyx_GIVEREF(__pyx_t_1);
+      __Pyx_GOTREF(__pyx_v_self->timeout_handle);
+      __Pyx_DECREF(__pyx_v_self->timeout_handle);
+      __pyx_v_self->timeout_handle = __pyx_t_1;
+      __pyx_t_1 = 0;
+
+      /* "asyncpg/protocol/protocol.pyx":361
+ *         if timeout is not False:
+ *             timeout = timeout or self.connection._command_timeout
+ *             if timeout is not None and timeout > 0:             # <<<<<<<<<<<<<<
+ *                 self.timeout_handle = self.connection._loop.call_later(
+ *                     timeout, self.timeout_callback, self.waiter)
+ */
+    }
+
+    /* "asyncpg/protocol/protocol.pyx":359
+ *     cdef _new_waiter(self, timeout):
+ *         self.waiter = self.create_future()
+ *         if timeout is not False:             # <<<<<<<<<<<<<<
+ *             timeout = timeout or self.connection._command_timeout
+ *             if timeout is not None and timeout > 0:
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":364
+ *                 self.timeout_handle = self.connection._loop.call_later(
+ *                     timeout, self.timeout_callback, self.waiter)
+ *         self.waiter.add_done_callback(self.completed_callback)             # <<<<<<<<<<<<<<
+ *         return self.waiter
+ * 
+ */
+  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->waiter, __pyx_n_s_add_done_callback); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 364, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_8 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
+    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
+    if (likely(__pyx_t_8)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+      __Pyx_INCREF(__pyx_t_8);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_3, function);
+    }
+  }
+  if (!__pyx_t_8) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->completed_callback); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 364, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_3)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_self->completed_callback};
+      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 364, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_self->completed_callback};
+      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 364, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else
+    #endif
+    {
+      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 364, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_8); __pyx_t_8 = NULL;
+      __Pyx_INCREF(__pyx_v_self->completed_callback);
+      __Pyx_GIVEREF(__pyx_v_self->completed_callback);
+      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_self->completed_callback);
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 364, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":365
+ *                     timeout, self.timeout_callback, self.waiter)
+ *         self.waiter.add_done_callback(self.completed_callback)
+ *         return self.waiter             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _on_result__connect(self, object waiter):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_self->waiter);
+  __pyx_r = __pyx_v_self->waiter;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/protocol.pyx":357
+ *                 'cannot perform operation: another operation is in progress')
+ * 
+ *     cdef _new_waiter(self, timeout):             # <<<<<<<<<<<<<<
+ *         self.waiter = self.create_future()
+ *         if timeout is not False:
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._new_waiter", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_timeout);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":367
+ *         return self.waiter
+ * 
+ *     cdef _on_result__connect(self, object waiter):             # <<<<<<<<<<<<<<
+ *         waiter.set_result(True)
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_result__connect(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_waiter) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("_on_result__connect", 0);
+
+  /* "asyncpg/protocol/protocol.pyx":368
+ * 
+ *     cdef _on_result__connect(self, object waiter):
+ *         waiter.set_result(True)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _on_result__prepare(self, object waiter):
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_waiter, __pyx_n_s_set_result); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 368, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__75, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 368, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":367
+ *         return self.waiter
+ * 
+ *     cdef _on_result__connect(self, object waiter):             # <<<<<<<<<<<<<<
+ *         waiter.set_result(True)
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._on_result__connect", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":370
+ *         waiter.set_result(True)
+ * 
+ *     cdef _on_result__prepare(self, object waiter):             # <<<<<<<<<<<<<<
+ *         if ASYNCPG_DEBUG:
+ *             if self.statement is None:
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_result__prepare(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_waiter) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  __Pyx_RefNannySetupContext("_on_result__prepare", 0);
+
+  /* "asyncpg/protocol/protocol.pyx":371
+ * 
+ *     cdef _on_result__prepare(self, object waiter):
+ *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
+ *             if self.statement is None:
+ *                 raise RuntimeError(
+ */
+  __pyx_t_1 = (ASYNCPG_DEBUG != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/protocol.pyx":372
+ *     cdef _on_result__prepare(self, object waiter):
+ *         if ASYNCPG_DEBUG:
+ *             if self.statement is None:             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError(
+ *                     '_on_result__prepare: statement is None')
+ */
+    __pyx_t_1 = (((PyObject *)__pyx_v_self->statement) == Py_None);
+    __pyx_t_2 = (__pyx_t_1 != 0);
+    if (__pyx_t_2) {
+
+      /* "asyncpg/protocol/protocol.pyx":373
+ *         if ASYNCPG_DEBUG:
+ *             if self.statement is None:
+ *                 raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                     '_on_result__prepare: statement is None')
+ * 
+ */
+      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__76, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 373, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __PYX_ERR(27, 373, __pyx_L1_error)
+
+      /* "asyncpg/protocol/protocol.pyx":372
+ *     cdef _on_result__prepare(self, object waiter):
+ *         if ASYNCPG_DEBUG:
+ *             if self.statement is None:             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError(
+ *                     '_on_result__prepare: statement is None')
+ */
+    }
+
+    /* "asyncpg/protocol/protocol.pyx":371
+ * 
+ *     cdef _on_result__prepare(self, object waiter):
+ *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
+ *             if self.statement is None:
+ *                 raise RuntimeError(
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":376
+ *                     '_on_result__prepare: statement is None')
+ * 
+ *         if self.result_param_desc is not None:             # <<<<<<<<<<<<<<
+ *             self.statement._set_args_desc(self.result_param_desc)
+ *         if self.result_row_desc is not None:
+ */
+  __pyx_t_2 = (__pyx_v_self->__pyx_base.result_param_desc != ((PyObject*)Py_None));
+  __pyx_t_1 = (__pyx_t_2 != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/protocol.pyx":377
+ * 
+ *         if self.result_param_desc is not None:
+ *             self.statement._set_args_desc(self.result_param_desc)             # <<<<<<<<<<<<<<
+ *         if self.result_row_desc is not None:
+ *             self.statement._set_row_desc(self.result_row_desc)
+ */
+    __pyx_t_3 = __pyx_v_self->__pyx_base.result_param_desc;
+    __Pyx_INCREF(__pyx_t_3);
+    __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__set_args_desc(__pyx_v_self->statement, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 377, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/protocol.pyx":376
+ *                     '_on_result__prepare: statement is None')
+ * 
+ *         if self.result_param_desc is not None:             # <<<<<<<<<<<<<<
+ *             self.statement._set_args_desc(self.result_param_desc)
+ *         if self.result_row_desc is not None:
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":378
+ *         if self.result_param_desc is not None:
+ *             self.statement._set_args_desc(self.result_param_desc)
+ *         if self.result_row_desc is not None:             # <<<<<<<<<<<<<<
+ *             self.statement._set_row_desc(self.result_row_desc)
+ *         waiter.set_result(self.statement)
+ */
+  __pyx_t_1 = (__pyx_v_self->__pyx_base.result_row_desc != ((PyObject*)Py_None));
+  __pyx_t_2 = (__pyx_t_1 != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/protocol.pyx":379
+ *             self.statement._set_args_desc(self.result_param_desc)
+ *         if self.result_row_desc is not None:
+ *             self.statement._set_row_desc(self.result_row_desc)             # <<<<<<<<<<<<<<
+ *         waiter.set_result(self.statement)
+ * 
+ */
+    __pyx_t_4 = __pyx_v_self->__pyx_base.result_row_desc;
+    __Pyx_INCREF(__pyx_t_4);
+    __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__set_row_desc(__pyx_v_self->statement, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 379, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/protocol.pyx":378
+ *         if self.result_param_desc is not None:
+ *             self.statement._set_args_desc(self.result_param_desc)
+ *         if self.result_row_desc is not None:             # <<<<<<<<<<<<<<
+ *             self.statement._set_row_desc(self.result_row_desc)
+ *         waiter.set_result(self.statement)
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":380
+ *         if self.result_row_desc is not None:
+ *             self.statement._set_row_desc(self.result_row_desc)
+ *         waiter.set_result(self.statement)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _on_result__bind_and_exec(self, object waiter):
+ */
+  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_waiter, __pyx_n_s_set_result); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 380, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_5 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
+    if (likely(__pyx_t_5)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+      __Pyx_INCREF(__pyx_t_5);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_4, function);
+    }
+  }
+  if (!__pyx_t_5) {
+    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_self->statement)); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 380, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_4)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_5, ((PyObject *)__pyx_v_self->statement)};
+      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 380, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_5, ((PyObject *)__pyx_v_self->statement)};
+      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 380, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+    } else
+    #endif
+    {
+      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 380, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
+      __Pyx_INCREF(((PyObject *)__pyx_v_self->statement));
+      __Pyx_GIVEREF(((PyObject *)__pyx_v_self->statement));
+      PyTuple_SET_ITEM(__pyx_t_6, 0+1, ((PyObject *)__pyx_v_self->statement));
+      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 380, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":370
+ *         waiter.set_result(True)
+ * 
+ *     cdef _on_result__prepare(self, object waiter):             # <<<<<<<<<<<<<<
+ *         if ASYNCPG_DEBUG:
+ *             if self.statement is None:
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._on_result__prepare", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":382
+ *         waiter.set_result(self.statement)
+ * 
+ *     cdef _on_result__bind_and_exec(self, object waiter):             # <<<<<<<<<<<<<<
+ *         if self.return_extra:
+ *             waiter.set_result((
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_result__bind_and_exec(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_waiter) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  __Pyx_RefNannySetupContext("_on_result__bind_and_exec", 0);
+
+  /* "asyncpg/protocol/protocol.pyx":383
+ * 
+ *     cdef _on_result__bind_and_exec(self, object waiter):
+ *         if self.return_extra:             # <<<<<<<<<<<<<<
+ *             waiter.set_result((
+ *                 self.result,
+ */
+  __pyx_t_1 = (__pyx_v_self->return_extra != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/protocol.pyx":384
+ *     cdef _on_result__bind_and_exec(self, object waiter):
+ *         if self.return_extra:
+ *             waiter.set_result((             # <<<<<<<<<<<<<<
+ *                 self.result,
+ *                 self.result_status_msg,
+ */
+    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_waiter, __pyx_n_s_set_result); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 384, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+
+    /* "asyncpg/protocol/protocol.pyx":387
+ *                 self.result,
+ *                 self.result_status_msg,
+ *                 self.result_execute_completed))             # <<<<<<<<<<<<<<
+ *         else:
+ *             waiter.set_result(self.result)
+ */
+    __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_self->__pyx_base.result_execute_completed); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 387, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+
+    /* "asyncpg/protocol/protocol.pyx":385
+ *         if self.return_extra:
+ *             waiter.set_result((
+ *                 self.result,             # <<<<<<<<<<<<<<
+ *                 self.result_status_msg,
+ *                 self.result_execute_completed))
+ */
+    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 385, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_INCREF(__pyx_v_self->__pyx_base.result);
+    __Pyx_GIVEREF(__pyx_v_self->__pyx_base.result);
+    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_self->__pyx_base.result);
+    __Pyx_INCREF(__pyx_v_self->__pyx_base.result_status_msg);
+    __Pyx_GIVEREF(__pyx_v_self->__pyx_base.result_status_msg);
+    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_self->__pyx_base.result_status_msg);
+    __Pyx_GIVEREF(__pyx_t_4);
+    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
+    __pyx_t_4 = 0;
+    __pyx_t_4 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
+      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
+      if (likely(__pyx_t_4)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+        __Pyx_INCREF(__pyx_t_4);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_3, function);
+      }
+    }
+    if (!__pyx_t_4) {
+      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 384, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_GOTREF(__pyx_t_2);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_3)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_5};
+        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 384, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_5};
+        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 384, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      } else
+      #endif
+      {
+        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 384, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_6);
+        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
+        __Pyx_GIVEREF(__pyx_t_5);
+        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_5);
+        __pyx_t_5 = 0;
+        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 384, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "asyncpg/protocol/protocol.pyx":383
+ * 
+ *     cdef _on_result__bind_and_exec(self, object waiter):
+ *         if self.return_extra:             # <<<<<<<<<<<<<<
+ *             waiter.set_result((
+ *                 self.result,
+ */
+    goto __pyx_L3;
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":389
+ *                 self.result_execute_completed))
+ *         else:
+ *             waiter.set_result(self.result)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _on_result__bind(self, object waiter):
+ */
+  /*else*/ {
+    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_waiter, __pyx_n_s_set_result); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 389, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_6 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
+      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
+      if (likely(__pyx_t_6)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+        __Pyx_INCREF(__pyx_t_6);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_3, function);
+      }
+    }
+    if (!__pyx_t_6) {
+      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->__pyx_base.result); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 389, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_2);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_3)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_self->__pyx_base.result};
+        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 389, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_GOTREF(__pyx_t_2);
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_self->__pyx_base.result};
+        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 389, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_GOTREF(__pyx_t_2);
+      } else
+      #endif
+      {
+        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 389, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL;
+        __Pyx_INCREF(__pyx_v_self->__pyx_base.result);
+        __Pyx_GIVEREF(__pyx_v_self->__pyx_base.result);
+        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_self->__pyx_base.result);
+        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 389, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  }
+  __pyx_L3:;
+
+  /* "asyncpg/protocol/protocol.pyx":382
+ *         waiter.set_result(self.statement)
+ * 
+ *     cdef _on_result__bind_and_exec(self, object waiter):             # <<<<<<<<<<<<<<
+ *         if self.return_extra:
+ *             waiter.set_result((
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._on_result__bind_and_exec", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":391
+ *             waiter.set_result(self.result)
+ * 
+ *     cdef _on_result__bind(self, object waiter):             # <<<<<<<<<<<<<<
+ *         waiter.set_result(self.result)
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_result__bind(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_waiter) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  __Pyx_RefNannySetupContext("_on_result__bind", 0);
+
+  /* "asyncpg/protocol/protocol.pyx":392
+ * 
+ *     cdef _on_result__bind(self, object waiter):
+ *         waiter.set_result(self.result)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _on_result__close_stmt_or_portal(self, object waiter):
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_waiter, __pyx_n_s_set_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 392, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (!__pyx_t_3) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_self->__pyx_base.result); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 392, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_self->__pyx_base.result};
+      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 392, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_self->__pyx_base.result};
+      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 392, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else
+    #endif
+    {
+      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 392, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
+      __Pyx_INCREF(__pyx_v_self->__pyx_base.result);
+      __Pyx_GIVEREF(__pyx_v_self->__pyx_base.result);
+      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self->__pyx_base.result);
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 392, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":391
+ *             waiter.set_result(self.result)
+ * 
+ *     cdef _on_result__bind(self, object waiter):             # <<<<<<<<<<<<<<
+ *         waiter.set_result(self.result)
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._on_result__bind", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":394
+ *         waiter.set_result(self.result)
+ * 
+ *     cdef _on_result__close_stmt_or_portal(self, object waiter):             # <<<<<<<<<<<<<<
+ *         waiter.set_result(self.result)
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_result__close_stmt_or_portal(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_waiter) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  __Pyx_RefNannySetupContext("_on_result__close_stmt_or_portal", 0);
+
+  /* "asyncpg/protocol/protocol.pyx":395
+ * 
+ *     cdef _on_result__close_stmt_or_portal(self, object waiter):
+ *         waiter.set_result(self.result)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _on_result__simple_query(self, object waiter):
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_waiter, __pyx_n_s_set_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 395, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (!__pyx_t_3) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_self->__pyx_base.result); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 395, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_self->__pyx_base.result};
+      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 395, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_self->__pyx_base.result};
+      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 395, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+    } else
+    #endif
+    {
+      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 395, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
+      __Pyx_INCREF(__pyx_v_self->__pyx_base.result);
+      __Pyx_GIVEREF(__pyx_v_self->__pyx_base.result);
+      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self->__pyx_base.result);
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 395, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":394
+ *         waiter.set_result(self.result)
+ * 
+ *     cdef _on_result__close_stmt_or_portal(self, object waiter):             # <<<<<<<<<<<<<<
+ *         waiter.set_result(self.result)
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._on_result__close_stmt_or_portal", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":397
+ *         waiter.set_result(self.result)
+ * 
+ *     cdef _on_result__simple_query(self, object waiter):             # <<<<<<<<<<<<<<
+ *         waiter.set_result(self.result_status_msg.decode(self.encoding))
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_result__simple_query(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_waiter) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  __Pyx_RefNannySetupContext("_on_result__simple_query", 0);
+
+  /* "asyncpg/protocol/protocol.pyx":398
+ * 
+ *     cdef _on_result__simple_query(self, object waiter):
+ *         waiter.set_result(self.result_status_msg.decode(self.encoding))             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _decode_row(self, const char* buf, ssize_t buf_len):
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_waiter, __pyx_n_s_set_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 398, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.result_status_msg, __pyx_n_s_decode); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 398, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_5 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
+    if (likely(__pyx_t_5)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+      __Pyx_INCREF(__pyx_t_5);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_4, function);
+    }
+  }
+  if (!__pyx_t_5) {
+    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_self->__pyx_base.encoding); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 398, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_4)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_self->__pyx_base.encoding};
+      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 398, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_self->__pyx_base.encoding};
+      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 398, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+    } else
+    #endif
+    {
+      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 398, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
+      __Pyx_INCREF(__pyx_v_self->__pyx_base.encoding);
+      __Pyx_GIVEREF(__pyx_v_self->__pyx_base.encoding);
+      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_self->__pyx_base.encoding);
+      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 398, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_4)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_4);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (!__pyx_t_4) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 398, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+  } else {
+    #if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
+      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 398, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    } else
+    #endif
+    #if CYTHON_FAST_PYCCALL
+    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
+      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 398, __pyx_L1_error)
+      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    } else
+    #endif
+    {
+      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 398, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
+      __Pyx_GIVEREF(__pyx_t_3);
+      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
+      __pyx_t_3 = 0;
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 398, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    }
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":397
+ *         waiter.set_result(self.result)
+ * 
+ *     cdef _on_result__simple_query(self, object waiter):             # <<<<<<<<<<<<<<
+ *         waiter.set_result(self.result_status_msg.decode(self.encoding))
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._on_result__simple_query", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":400
+ *         waiter.set_result(self.result_status_msg.decode(self.encoding))
+ * 
+ *     cdef _decode_row(self, const char* buf, ssize_t buf_len):             # <<<<<<<<<<<<<<
+ *         if ASYNCPG_DEBUG:
+ *             if self.statement is None:
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__decode_row(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, char const *__pyx_v_buf, Py_ssize_t __pyx_v_buf_len) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("_decode_row", 0);
+
+  /* "asyncpg/protocol/protocol.pyx":401
+ * 
+ *     cdef _decode_row(self, const char* buf, ssize_t buf_len):
+ *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
+ *             if self.statement is None:
+ *                 raise RuntimeError(
+ */
+  __pyx_t_1 = (ASYNCPG_DEBUG != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/protocol.pyx":402
+ *     cdef _decode_row(self, const char* buf, ssize_t buf_len):
+ *         if ASYNCPG_DEBUG:
+ *             if self.statement is None:             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError(
+ *                     '_decode_row: statement is None')
+ */
+    __pyx_t_1 = (((PyObject *)__pyx_v_self->statement) == Py_None);
+    __pyx_t_2 = (__pyx_t_1 != 0);
+    if (__pyx_t_2) {
+
+      /* "asyncpg/protocol/protocol.pyx":403
+ *         if ASYNCPG_DEBUG:
+ *             if self.statement is None:
+ *                 raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                     '_decode_row: statement is None')
+ * 
+ */
+      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__77, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 403, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __PYX_ERR(27, 403, __pyx_L1_error)
+
+      /* "asyncpg/protocol/protocol.pyx":402
+ *     cdef _decode_row(self, const char* buf, ssize_t buf_len):
+ *         if ASYNCPG_DEBUG:
+ *             if self.statement is None:             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError(
+ *                     '_decode_row: statement is None')
+ */
+    }
+
+    /* "asyncpg/protocol/protocol.pyx":401
+ * 
+ *     cdef _decode_row(self, const char* buf, ssize_t buf_len):
+ *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
+ *             if self.statement is None:
+ *                 raise RuntimeError(
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":406
+ *                     '_decode_row: statement is None')
+ * 
+ *         return self.statement._decode_row(buf, buf_len)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _dispatch_result(self):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__decode_row(__pyx_v_self->statement, __pyx_v_buf, __pyx_v_buf_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 406, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_r = __pyx_t_3;
+  __pyx_t_3 = 0;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/protocol.pyx":400
+ *         waiter.set_result(self.result_status_msg.decode(self.encoding))
+ * 
+ *     cdef _decode_row(self, const char* buf, ssize_t buf_len):             # <<<<<<<<<<<<<<
+ *         if ASYNCPG_DEBUG:
+ *             if self.statement is None:
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._decode_row", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":408
+ *         return self.statement._decode_row(buf, buf_len)
+ * 
+ *     cdef _dispatch_result(self):             # <<<<<<<<<<<<<<
+ *         waiter = self.waiter
+ *         self.waiter = None
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__dispatch_result(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self) {
+  PyObject *__pyx_v_waiter = NULL;
+  PyObject *__pyx_v_exc = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  int __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  PyObject *__pyx_t_10 = NULL;
+  int __pyx_t_11;
+  PyObject *__pyx_t_12 = NULL;
+  PyObject *__pyx_t_13 = NULL;
+  int __pyx_t_14;
+  char const *__pyx_t_15;
+  PyObject *__pyx_t_16 = NULL;
+  PyObject *__pyx_t_17 = NULL;
+  PyObject *__pyx_t_18 = NULL;
+  PyObject *__pyx_t_19 = NULL;
+  PyObject *__pyx_t_20 = NULL;
+  PyObject *__pyx_t_21 = NULL;
+  __Pyx_RefNannySetupContext("_dispatch_result", 0);
+
+  /* "asyncpg/protocol/protocol.pyx":409
+ * 
+ *     cdef _dispatch_result(self):
+ *         waiter = self.waiter             # <<<<<<<<<<<<<<
+ *         self.waiter = None
+ * 
+ */
+  __pyx_t_1 = __pyx_v_self->waiter;
+  __Pyx_INCREF(__pyx_t_1);
+  __pyx_v_waiter = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":410
+ *     cdef _dispatch_result(self):
+ *         waiter = self.waiter
+ *         self.waiter = None             # <<<<<<<<<<<<<<
+ * 
+ *         if ASYNCPG_DEBUG:
+ */
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->waiter);
+  __Pyx_DECREF(__pyx_v_self->waiter);
+  __pyx_v_self->waiter = Py_None;
+
+  /* "asyncpg/protocol/protocol.pyx":412
+ *         self.waiter = None
+ * 
+ *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
+ *             if waiter is None:
+ *                 raise RuntimeError('_on_result: waiter is None')
+ */
+  __pyx_t_2 = (ASYNCPG_DEBUG != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/protocol.pyx":413
+ * 
+ *         if ASYNCPG_DEBUG:
+ *             if waiter is None:             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError('_on_result: waiter is None')
+ * 
+ */
+    __pyx_t_2 = (__pyx_v_waiter == Py_None);
+    __pyx_t_3 = (__pyx_t_2 != 0);
+    if (__pyx_t_3) {
+
+      /* "asyncpg/protocol/protocol.pyx":414
+ *         if ASYNCPG_DEBUG:
+ *             if waiter is None:
+ *                 raise RuntimeError('_on_result: waiter is None')             # <<<<<<<<<<<<<<
+ * 
+ *         if waiter.cancelled():
+ */
+      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__78, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 414, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __PYX_ERR(27, 414, __pyx_L1_error)
+
+      /* "asyncpg/protocol/protocol.pyx":413
+ * 
+ *         if ASYNCPG_DEBUG:
+ *             if waiter is None:             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError('_on_result: waiter is None')
+ * 
+ */
+    }
+
+    /* "asyncpg/protocol/protocol.pyx":412
+ *         self.waiter = None
+ * 
+ *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
+ *             if waiter is None:
+ *                 raise RuntimeError('_on_result: waiter is None')
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":416
+ *                 raise RuntimeError('_on_result: waiter is None')
+ * 
+ *         if waiter.cancelled():             # <<<<<<<<<<<<<<
+ *             return
+ * 
+ */
+  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_waiter, __pyx_n_s_cancelled); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 416, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_5 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
+    if (likely(__pyx_t_5)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+      __Pyx_INCREF(__pyx_t_5);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_4, function);
+    }
+  }
+  if (__pyx_t_5) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 416, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  } else {
+    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 416, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(27, 416, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/protocol.pyx":417
+ * 
+ *         if waiter.cancelled():
+ *             return             # <<<<<<<<<<<<<<
+ * 
+ *         if waiter.done():
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/protocol.pyx":416
+ *                 raise RuntimeError('_on_result: waiter is None')
+ * 
+ *         if waiter.cancelled():             # <<<<<<<<<<<<<<
+ *             return
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":419
+ *             return
+ * 
+ *         if waiter.done():             # <<<<<<<<<<<<<<
+ *             raise RuntimeError('_on_result: waiter is done')
+ * 
+ */
+  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_waiter, __pyx_n_s_done); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 419, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_5 = NULL;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
+    if (likely(__pyx_t_5)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+      __Pyx_INCREF(__pyx_t_5);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_4, function);
+    }
+  }
+  if (__pyx_t_5) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 419, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  } else {
+    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 419, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(27, 419, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/protocol.pyx":420
+ * 
+ *         if waiter.done():
+ *             raise RuntimeError('_on_result: waiter is done')             # <<<<<<<<<<<<<<
+ * 
+ *         if self.result_type == RESULT_FAILED:
+ */
+    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__79, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 420, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __PYX_ERR(27, 420, __pyx_L1_error)
+
+    /* "asyncpg/protocol/protocol.pyx":419
+ *             return
+ * 
+ *         if waiter.done():             # <<<<<<<<<<<<<<
+ *             raise RuntimeError('_on_result: waiter is done')
+ * 
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":422
+ *             raise RuntimeError('_on_result: waiter is done')
+ * 
+ *         if self.result_type == RESULT_FAILED:             # <<<<<<<<<<<<<<
+ *             if isinstance(self.result, dict):
+ *                 exc = apg_exc_base.PostgresMessage.new(
+ */
+  __pyx_t_3 = ((__pyx_v_self->__pyx_base.result_type == __pyx_e_7asyncpg_8protocol_8protocol_RESULT_FAILED) != 0);
+  if (__pyx_t_3) {
+
+    /* "asyncpg/protocol/protocol.pyx":423
+ * 
+ *         if self.result_type == RESULT_FAILED:
+ *             if isinstance(self.result, dict):             # <<<<<<<<<<<<<<
+ *                 exc = apg_exc_base.PostgresMessage.new(
+ *                     self.result, query=self.last_query)
+ */
+    __pyx_t_1 = __pyx_v_self->__pyx_base.result;
+    __Pyx_INCREF(__pyx_t_1);
+    __pyx_t_3 = PyDict_Check(__pyx_t_1); 
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_2 = (__pyx_t_3 != 0);
+    if (__pyx_t_2) {
+
+      /* "asyncpg/protocol/protocol.pyx":424
+ *         if self.result_type == RESULT_FAILED:
+ *             if isinstance(self.result, dict):
+ *                 exc = apg_exc_base.PostgresMessage.new(             # <<<<<<<<<<<<<<
+ *                     self.result, query=self.last_query)
+ *             else:
+ */
+      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 424, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_PostgresMessage); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 424, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 424, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+      /* "asyncpg/protocol/protocol.pyx":425
+ *             if isinstance(self.result, dict):
+ *                 exc = apg_exc_base.PostgresMessage.new(
+ *                     self.result, query=self.last_query)             # <<<<<<<<<<<<<<
+ *             else:
+ *                 exc = self.result
+ */
+      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 424, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_INCREF(__pyx_v_self->__pyx_base.result);
+      __Pyx_GIVEREF(__pyx_v_self->__pyx_base.result);
+      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_self->__pyx_base.result);
+      __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 425, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_5);
+      if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_query, __pyx_v_self->last_query) < 0) __PYX_ERR(27, 425, __pyx_L1_error)
+
+      /* "asyncpg/protocol/protocol.pyx":424
+ *         if self.result_type == RESULT_FAILED:
+ *             if isinstance(self.result, dict):
+ *                 exc = apg_exc_base.PostgresMessage.new(             # <<<<<<<<<<<<<<
+ *                     self.result, query=self.last_query)
+ *             else:
+ */
+      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 424, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __pyx_v_exc = __pyx_t_6;
+      __pyx_t_6 = 0;
+
+      /* "asyncpg/protocol/protocol.pyx":423
+ * 
+ *         if self.result_type == RESULT_FAILED:
+ *             if isinstance(self.result, dict):             # <<<<<<<<<<<<<<
+ *                 exc = apg_exc_base.PostgresMessage.new(
+ *                     self.result, query=self.last_query)
+ */
+      goto __pyx_L8;
+    }
+
+    /* "asyncpg/protocol/protocol.pyx":427
+ *                     self.result, query=self.last_query)
+ *             else:
+ *                 exc = self.result             # <<<<<<<<<<<<<<
+ *             waiter.set_exception(exc)
+ *             return
+ */
+    /*else*/ {
+      __pyx_t_6 = __pyx_v_self->__pyx_base.result;
+      __Pyx_INCREF(__pyx_t_6);
+      __pyx_v_exc = __pyx_t_6;
+      __pyx_t_6 = 0;
+    }
+    __pyx_L8:;
+
+    /* "asyncpg/protocol/protocol.pyx":428
+ *             else:
+ *                 exc = self.result
+ *             waiter.set_exception(exc)             # <<<<<<<<<<<<<<
+ *             return
+ * 
+ */
+    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_waiter, __pyx_n_s_set_exception); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 428, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_4 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
+      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
+      if (likely(__pyx_t_4)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+        __Pyx_INCREF(__pyx_t_4);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_5, function);
+      }
+    }
+    if (!__pyx_t_4) {
+      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_exc); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 428, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_6);
+    } else {
+      #if CYTHON_FAST_PYCALL
+      if (PyFunction_Check(__pyx_t_5)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_exc};
+        __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 428, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_GOTREF(__pyx_t_6);
+      } else
+      #endif
+      #if CYTHON_FAST_PYCCALL
+      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
+        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_exc};
+        __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 428, __pyx_L1_error)
+        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_GOTREF(__pyx_t_6);
+      } else
+      #endif
+      {
+        __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 428, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); __pyx_t_4 = NULL;
+        __Pyx_INCREF(__pyx_v_exc);
+        __Pyx_GIVEREF(__pyx_v_exc);
+        PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_v_exc);
+        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 428, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_6);
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+    /* "asyncpg/protocol/protocol.pyx":429
+ *                 exc = self.result
+ *             waiter.set_exception(exc)
+ *             return             # <<<<<<<<<<<<<<
+ * 
+ *         try:
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/protocol.pyx":422
+ *             raise RuntimeError('_on_result: waiter is done')
+ * 
+ *         if self.result_type == RESULT_FAILED:             # <<<<<<<<<<<<<<
+ *             if isinstance(self.result, dict):
+ *                 exc = apg_exc_base.PostgresMessage.new(
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":431
+ *             return
+ * 
+ *         try:             # <<<<<<<<<<<<<<
+ *             if self.state == PROTOCOL_AUTH:
+ *                 self._on_result__connect(waiter)
+ */
+  {
+    __Pyx_PyThreadState_declare
+    __Pyx_PyThreadState_assign
+    __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
+    __Pyx_XGOTREF(__pyx_t_7);
+    __Pyx_XGOTREF(__pyx_t_8);
+    __Pyx_XGOTREF(__pyx_t_9);
+    /*try:*/ {
+
+      /* "asyncpg/protocol/protocol.pyx":432
+ * 
+ *         try:
+ *             if self.state == PROTOCOL_AUTH:             # <<<<<<<<<<<<<<
+ *                 self._on_result__connect(waiter)
+ * 
+ */
+      switch (__pyx_v_self->__pyx_base.state) {
+        case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_AUTH:
+
+        /* "asyncpg/protocol/protocol.pyx":433
+ *         try:
+ *             if self.state == PROTOCOL_AUTH:
+ *                 self._on_result__connect(waiter)             # <<<<<<<<<<<<<<
+ * 
+ *             elif self.state == PROTOCOL_PREPARE:
+ */
+        __pyx_t_6 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self->__pyx_base.__pyx_vtab)->_on_result__connect(__pyx_v_self, __pyx_v_waiter); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 433, __pyx_L9_error)
+        __Pyx_GOTREF(__pyx_t_6);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+        /* "asyncpg/protocol/protocol.pyx":432
+ * 
+ *         try:
+ *             if self.state == PROTOCOL_AUTH:             # <<<<<<<<<<<<<<
+ *                 self._on_result__connect(waiter)
+ * 
+ */
+        break;
+
+        /* "asyncpg/protocol/protocol.pyx":435
+ *                 self._on_result__connect(waiter)
+ * 
+ *             elif self.state == PROTOCOL_PREPARE:             # <<<<<<<<<<<<<<
+ *                 self._on_result__prepare(waiter)
+ * 
+ */
+        case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_PREPARE:
+
+        /* "asyncpg/protocol/protocol.pyx":436
+ * 
+ *             elif self.state == PROTOCOL_PREPARE:
+ *                 self._on_result__prepare(waiter)             # <<<<<<<<<<<<<<
+ * 
+ *             elif self.state == PROTOCOL_BIND_EXECUTE:
+ */
+        __pyx_t_6 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self->__pyx_base.__pyx_vtab)->_on_result__prepare(__pyx_v_self, __pyx_v_waiter); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 436, __pyx_L9_error)
+        __Pyx_GOTREF(__pyx_t_6);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+        /* "asyncpg/protocol/protocol.pyx":435
+ *                 self._on_result__connect(waiter)
+ * 
+ *             elif self.state == PROTOCOL_PREPARE:             # <<<<<<<<<<<<<<
+ *                 self._on_result__prepare(waiter)
+ * 
+ */
+        break;
+
+        /* "asyncpg/protocol/protocol.pyx":438
+ *                 self._on_result__prepare(waiter)
+ * 
+ *             elif self.state == PROTOCOL_BIND_EXECUTE:             # <<<<<<<<<<<<<<
+ *                 self._on_result__bind_and_exec(waiter)
+ * 
+ */
+        case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_BIND_EXECUTE:
+
+        /* "asyncpg/protocol/protocol.pyx":439
+ * 
+ *             elif self.state == PROTOCOL_BIND_EXECUTE:
+ *                 self._on_result__bind_and_exec(waiter)             # <<<<<<<<<<<<<<
+ * 
+ *             elif self.state == PROTOCOL_BIND_EXECUTE_MANY:
+ */
+        __pyx_t_6 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self->__pyx_base.__pyx_vtab)->_on_result__bind_and_exec(__pyx_v_self, __pyx_v_waiter); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 439, __pyx_L9_error)
+        __Pyx_GOTREF(__pyx_t_6);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+        /* "asyncpg/protocol/protocol.pyx":438
+ *                 self._on_result__prepare(waiter)
+ * 
+ *             elif self.state == PROTOCOL_BIND_EXECUTE:             # <<<<<<<<<<<<<<
+ *                 self._on_result__bind_and_exec(waiter)
+ * 
+ */
+        break;
+
+        /* "asyncpg/protocol/protocol.pyx":441
+ *                 self._on_result__bind_and_exec(waiter)
+ * 
+ *             elif self.state == PROTOCOL_BIND_EXECUTE_MANY:             # <<<<<<<<<<<<<<
+ *                 self._on_result__bind_and_exec(waiter)
+ * 
+ */
+        case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_BIND_EXECUTE_MANY:
+
+        /* "asyncpg/protocol/protocol.pyx":442
+ * 
+ *             elif self.state == PROTOCOL_BIND_EXECUTE_MANY:
+ *                 self._on_result__bind_and_exec(waiter)             # <<<<<<<<<<<<<<
+ * 
+ *             elif self.state == PROTOCOL_EXECUTE:
+ */
+        __pyx_t_6 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self->__pyx_base.__pyx_vtab)->_on_result__bind_and_exec(__pyx_v_self, __pyx_v_waiter); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 442, __pyx_L9_error)
+        __Pyx_GOTREF(__pyx_t_6);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+        /* "asyncpg/protocol/protocol.pyx":441
+ *                 self._on_result__bind_and_exec(waiter)
+ * 
+ *             elif self.state == PROTOCOL_BIND_EXECUTE_MANY:             # <<<<<<<<<<<<<<
+ *                 self._on_result__bind_and_exec(waiter)
+ * 
+ */
+        break;
+
+        /* "asyncpg/protocol/protocol.pyx":444
+ *                 self._on_result__bind_and_exec(waiter)
+ * 
+ *             elif self.state == PROTOCOL_EXECUTE:             # <<<<<<<<<<<<<<
+ *                 self._on_result__bind_and_exec(waiter)
+ * 
+ */
+        case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_EXECUTE:
+
+        /* "asyncpg/protocol/protocol.pyx":445
+ * 
+ *             elif self.state == PROTOCOL_EXECUTE:
+ *                 self._on_result__bind_and_exec(waiter)             # <<<<<<<<<<<<<<
+ * 
+ *             elif self.state == PROTOCOL_BIND:
+ */
+        __pyx_t_6 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self->__pyx_base.__pyx_vtab)->_on_result__bind_and_exec(__pyx_v_self, __pyx_v_waiter); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 445, __pyx_L9_error)
+        __Pyx_GOTREF(__pyx_t_6);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+        /* "asyncpg/protocol/protocol.pyx":444
+ *                 self._on_result__bind_and_exec(waiter)
+ * 
+ *             elif self.state == PROTOCOL_EXECUTE:             # <<<<<<<<<<<<<<
+ *                 self._on_result__bind_and_exec(waiter)
+ * 
+ */
+        break;
+
+        /* "asyncpg/protocol/protocol.pyx":447
+ *                 self._on_result__bind_and_exec(waiter)
+ * 
+ *             elif self.state == PROTOCOL_BIND:             # <<<<<<<<<<<<<<
+ *                 self._on_result__bind(waiter)
+ * 
+ */
+        case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_BIND:
+
+        /* "asyncpg/protocol/protocol.pyx":448
+ * 
+ *             elif self.state == PROTOCOL_BIND:
+ *                 self._on_result__bind(waiter)             # <<<<<<<<<<<<<<
+ * 
+ *             elif self.state == PROTOCOL_CLOSE_STMT_PORTAL:
+ */
+        __pyx_t_6 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self->__pyx_base.__pyx_vtab)->_on_result__bind(__pyx_v_self, __pyx_v_waiter); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 448, __pyx_L9_error)
+        __Pyx_GOTREF(__pyx_t_6);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+        /* "asyncpg/protocol/protocol.pyx":447
+ *                 self._on_result__bind_and_exec(waiter)
+ * 
+ *             elif self.state == PROTOCOL_BIND:             # <<<<<<<<<<<<<<
+ *                 self._on_result__bind(waiter)
+ * 
+ */
+        break;
+
+        /* "asyncpg/protocol/protocol.pyx":450
+ *                 self._on_result__bind(waiter)
+ * 
+ *             elif self.state == PROTOCOL_CLOSE_STMT_PORTAL:             # <<<<<<<<<<<<<<
+ *                 self._on_result__close_stmt_or_portal(waiter)
+ * 
+ */
+        case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_CLOSE_STMT_PORTAL:
+
+        /* "asyncpg/protocol/protocol.pyx":451
+ * 
+ *             elif self.state == PROTOCOL_CLOSE_STMT_PORTAL:
+ *                 self._on_result__close_stmt_or_portal(waiter)             # <<<<<<<<<<<<<<
+ * 
+ *             elif self.state == PROTOCOL_SIMPLE_QUERY:
+ */
+        __pyx_t_6 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self->__pyx_base.__pyx_vtab)->_on_result__close_stmt_or_portal(__pyx_v_self, __pyx_v_waiter); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 451, __pyx_L9_error)
+        __Pyx_GOTREF(__pyx_t_6);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+        /* "asyncpg/protocol/protocol.pyx":450
+ *                 self._on_result__bind(waiter)
+ * 
+ *             elif self.state == PROTOCOL_CLOSE_STMT_PORTAL:             # <<<<<<<<<<<<<<
+ *                 self._on_result__close_stmt_or_portal(waiter)
+ * 
+ */
+        break;
+
+        /* "asyncpg/protocol/protocol.pyx":453
+ *                 self._on_result__close_stmt_or_portal(waiter)
+ * 
+ *             elif self.state == PROTOCOL_SIMPLE_QUERY:             # <<<<<<<<<<<<<<
+ *                 self._on_result__simple_query(waiter)
+ * 
+ */
+        case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_SIMPLE_QUERY:
+
+        /* "asyncpg/protocol/protocol.pyx":454
+ * 
+ *             elif self.state == PROTOCOL_SIMPLE_QUERY:
+ *                 self._on_result__simple_query(waiter)             # <<<<<<<<<<<<<<
+ * 
+ *             else:
+ */
+        __pyx_t_6 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self->__pyx_base.__pyx_vtab)->_on_result__simple_query(__pyx_v_self, __pyx_v_waiter); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 454, __pyx_L9_error)
+        __Pyx_GOTREF(__pyx_t_6);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+        /* "asyncpg/protocol/protocol.pyx":453
+ *                 self._on_result__close_stmt_or_portal(waiter)
+ * 
+ *             elif self.state == PROTOCOL_SIMPLE_QUERY:             # <<<<<<<<<<<<<<
+ *                 self._on_result__simple_query(waiter)
+ * 
+ */
+        break;
+        default:
+
+        /* "asyncpg/protocol/protocol.pyx":458
+ *             else:
+ *                 raise RuntimeError(
+ *                     'got result for unknown protocol state {}'.             # <<<<<<<<<<<<<<
+ *                     format(self.state))
+ * 
+ */
+        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_got_result_for_unknown_protocol, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 458, __pyx_L9_error)
+        __Pyx_GOTREF(__pyx_t_5);
+
+        /* "asyncpg/protocol/protocol.pyx":459
+ *                 raise RuntimeError(
+ *                     'got result for unknown protocol state {}'.
+ *                     format(self.state))             # <<<<<<<<<<<<<<
+ * 
+ *         except Exception as exc:
+ */
+        __pyx_t_1 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ProtocolState(__pyx_v_self->__pyx_base.state); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 459, __pyx_L9_error)
+        __Pyx_GOTREF(__pyx_t_1);
+        __pyx_t_4 = NULL;
+        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
+          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
+          if (likely(__pyx_t_4)) {
+            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+            __Pyx_INCREF(__pyx_t_4);
+            __Pyx_INCREF(function);
+            __Pyx_DECREF_SET(__pyx_t_5, function);
+          }
+        }
+        if (!__pyx_t_4) {
+          __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 459, __pyx_L9_error)
+          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+          __Pyx_GOTREF(__pyx_t_6);
+        } else {
+          #if CYTHON_FAST_PYCALL
+          if (PyFunction_Check(__pyx_t_5)) {
+            PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_1};
+            __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 459, __pyx_L9_error)
+            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+            __Pyx_GOTREF(__pyx_t_6);
+            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+          } else
+          #endif
+          #if CYTHON_FAST_PYCCALL
+          if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
+            PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_1};
+            __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 459, __pyx_L9_error)
+            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+            __Pyx_GOTREF(__pyx_t_6);
+            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+          } else
+          #endif
+          {
+            __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(27, 459, __pyx_L9_error)
+            __Pyx_GOTREF(__pyx_t_10);
+            __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_4); __pyx_t_4 = NULL;
+            __Pyx_GIVEREF(__pyx_t_1);
+            PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_1);
+            __pyx_t_1 = 0;
+            __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_10, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 459, __pyx_L9_error)
+            __Pyx_GOTREF(__pyx_t_6);
+            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+          }
+        }
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+        /* "asyncpg/protocol/protocol.pyx":457
+ * 
+ *             else:
+ *                 raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                     'got result for unknown protocol state {}'.
+ *                     format(self.state))
+ */
+        __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 457, __pyx_L9_error)
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_GIVEREF(__pyx_t_6);
+        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
+        __pyx_t_6 = 0;
+        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 457, __pyx_L9_error)
+        __Pyx_GOTREF(__pyx_t_6);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_Raise(__pyx_t_6, 0, 0, 0);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __PYX_ERR(27, 457, __pyx_L9_error)
+        break;
+      }
+
+      /* "asyncpg/protocol/protocol.pyx":431
+ *             return
+ * 
+ *         try:             # <<<<<<<<<<<<<<
+ *             if self.state == PROTOCOL_AUTH:
+ *                 self._on_result__connect(waiter)
+ */
+    }
+    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
+    goto __pyx_L16_try_end;
+    __pyx_L9_error:;
+    __Pyx_PyThreadState_assign
+    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
+    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+    /* "asyncpg/protocol/protocol.pyx":461
+ *                     format(self.state))
+ * 
+ *         except Exception as exc:             # <<<<<<<<<<<<<<
+ *             waiter.set_exception(exc)
+ * 
+ */
+    __pyx_t_11 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
+    if (__pyx_t_11) {
+      __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._dispatch_result", __pyx_clineno, __pyx_lineno, __pyx_filename);
+      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_5, &__pyx_t_10) < 0) __PYX_ERR(27, 461, __pyx_L11_except_error)
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_GOTREF(__pyx_t_10);
+      __Pyx_INCREF(__pyx_t_5);
+      __pyx_v_exc = __pyx_t_5;
+      /*try:*/ {
+
+        /* "asyncpg/protocol/protocol.pyx":462
+ * 
+ *         except Exception as exc:
+ *             waiter.set_exception(exc)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _on_result(self):
+ */
+        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_waiter, __pyx_n_s_set_exception); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 462, __pyx_L22_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        __pyx_t_12 = NULL;
+        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+          __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_4);
+          if (likely(__pyx_t_12)) {
+            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+            __Pyx_INCREF(__pyx_t_12);
+            __Pyx_INCREF(function);
+            __Pyx_DECREF_SET(__pyx_t_4, function);
+          }
+        }
+        if (!__pyx_t_12) {
+          __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_exc); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 462, __pyx_L22_error)
+          __Pyx_GOTREF(__pyx_t_1);
+        } else {
+          #if CYTHON_FAST_PYCALL
+          if (PyFunction_Check(__pyx_t_4)) {
+            PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_v_exc};
+            __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 462, __pyx_L22_error)
+            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
+            __Pyx_GOTREF(__pyx_t_1);
+          } else
+          #endif
+          #if CYTHON_FAST_PYCCALL
+          if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
+            PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_v_exc};
+            __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 462, __pyx_L22_error)
+            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
+            __Pyx_GOTREF(__pyx_t_1);
+          } else
+          #endif
+          {
+            __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(27, 462, __pyx_L22_error)
+            __Pyx_GOTREF(__pyx_t_13);
+            __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_12); __pyx_t_12 = NULL;
+            __Pyx_INCREF(__pyx_v_exc);
+            __Pyx_GIVEREF(__pyx_v_exc);
+            PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_v_exc);
+            __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_13, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 462, __pyx_L22_error)
+            __Pyx_GOTREF(__pyx_t_1);
+            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+          }
+        }
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      }
+
+      /* "asyncpg/protocol/protocol.pyx":461
+ *                     format(self.state))
+ * 
+ *         except Exception as exc:             # <<<<<<<<<<<<<<
+ *             waiter.set_exception(exc)
+ * 
+ */
+      /*finally:*/ {
+        /*normal exit:*/{
+          __Pyx_DECREF(__pyx_v_exc);
+          __pyx_v_exc = NULL;
+          goto __pyx_L23;
+        }
+        /*exception exit:*/{
+          __Pyx_PyThreadState_declare
+          __pyx_L22_error:;
+          __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0;
+          __Pyx_PyThreadState_assign
+          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
+          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
+          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+          if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21);
+          if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18) < 0)) __Pyx_ErrFetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
+          __Pyx_XGOTREF(__pyx_t_16);
+          __Pyx_XGOTREF(__pyx_t_17);
+          __Pyx_XGOTREF(__pyx_t_18);
+          __Pyx_XGOTREF(__pyx_t_19);
+          __Pyx_XGOTREF(__pyx_t_20);
+          __Pyx_XGOTREF(__pyx_t_21);
+          __pyx_t_11 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_15 = __pyx_filename;
+          {
+            __Pyx_DECREF(__pyx_v_exc);
+            __pyx_v_exc = NULL;
+          }
+          __Pyx_PyThreadState_assign
+          if (PY_MAJOR_VERSION >= 3) {
+            __Pyx_XGIVEREF(__pyx_t_19);
+            __Pyx_XGIVEREF(__pyx_t_20);
+            __Pyx_XGIVEREF(__pyx_t_21);
+            __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21);
+          }
+          __Pyx_XGIVEREF(__pyx_t_16);
+          __Pyx_XGIVEREF(__pyx_t_17);
+          __Pyx_XGIVEREF(__pyx_t_18);
+          __Pyx_ErrRestore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
+          __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0;
+          __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_15;
+          goto __pyx_L11_except_error;
+        }
+        __pyx_L23:;
+      }
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      goto __pyx_L10_exception_handled;
+    }
+    goto __pyx_L11_except_error;
+    __pyx_L11_except_error:;
+
+    /* "asyncpg/protocol/protocol.pyx":431
+ *             return
+ * 
+ *         try:             # <<<<<<<<<<<<<<
+ *             if self.state == PROTOCOL_AUTH:
+ *                 self._on_result__connect(waiter)
+ */
+    __Pyx_PyThreadState_assign
+    __Pyx_XGIVEREF(__pyx_t_7);
+    __Pyx_XGIVEREF(__pyx_t_8);
+    __Pyx_XGIVEREF(__pyx_t_9);
+    __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
+    goto __pyx_L1_error;
+    __pyx_L10_exception_handled:;
+    __Pyx_PyThreadState_assign
+    __Pyx_XGIVEREF(__pyx_t_7);
+    __Pyx_XGIVEREF(__pyx_t_8);
+    __Pyx_XGIVEREF(__pyx_t_9);
+    __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
+    __pyx_L16_try_end:;
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":408
+ *         return self.statement._decode_row(buf, buf_len)
+ * 
+ *     cdef _dispatch_result(self):             # <<<<<<<<<<<<<<
+ *         waiter = self.waiter
+ *         self.waiter = None
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_XDECREF(__pyx_t_12);
+  __Pyx_XDECREF(__pyx_t_13);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._dispatch_result", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_waiter);
+  __Pyx_XDECREF(__pyx_v_exc);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":464
+ *             waiter.set_exception(exc)
+ * 
+ *     cdef _on_result(self):             # <<<<<<<<<<<<<<
+ *         if self.timeout_handle is not None:
+ *             self.timeout_handle.cancel()
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_result(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  int __pyx_t_6;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  int __pyx_t_9;
+  int __pyx_t_10;
+  char const *__pyx_t_11;
+  PyObject *__pyx_t_12 = NULL;
+  PyObject *__pyx_t_13 = NULL;
+  PyObject *__pyx_t_14 = NULL;
+  PyObject *__pyx_t_15 = NULL;
+  PyObject *__pyx_t_16 = NULL;
+  PyObject *__pyx_t_17 = NULL;
+  __Pyx_RefNannySetupContext("_on_result", 0);
+
+  /* "asyncpg/protocol/protocol.pyx":465
+ * 
+ *     cdef _on_result(self):
+ *         if self.timeout_handle is not None:             # <<<<<<<<<<<<<<
+ *             self.timeout_handle.cancel()
+ *             self.timeout_handle = None
+ */
+  __pyx_t_1 = (__pyx_v_self->timeout_handle != Py_None);
+  __pyx_t_2 = (__pyx_t_1 != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/protocol.pyx":466
+ *     cdef _on_result(self):
+ *         if self.timeout_handle is not None:
+ *             self.timeout_handle.cancel()             # <<<<<<<<<<<<<<
+ *             self.timeout_handle = None
+ * 
+ */
+    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->timeout_handle, __pyx_n_s_cancel); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 466, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
+      if (likely(__pyx_t_5)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+        __Pyx_INCREF(__pyx_t_5);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_4, function);
+      }
+    }
+    if (__pyx_t_5) {
+      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 466, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    } else {
+      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 466, __pyx_L1_error)
+    }
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/protocol.pyx":467
+ *         if self.timeout_handle is not None:
+ *             self.timeout_handle.cancel()
+ *             self.timeout_handle = None             # <<<<<<<<<<<<<<
+ * 
+ *         if self.cancel_waiter is not None:
+ */
+    __Pyx_INCREF(Py_None);
+    __Pyx_GIVEREF(Py_None);
+    __Pyx_GOTREF(__pyx_v_self->timeout_handle);
+    __Pyx_DECREF(__pyx_v_self->timeout_handle);
+    __pyx_v_self->timeout_handle = Py_None;
+
+    /* "asyncpg/protocol/protocol.pyx":465
+ * 
+ *     cdef _on_result(self):
+ *         if self.timeout_handle is not None:             # <<<<<<<<<<<<<<
+ *             self.timeout_handle.cancel()
+ *             self.timeout_handle = None
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":469
+ *             self.timeout_handle = None
+ * 
+ *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
+ *             if self.waiter is None or not self.waiter.cancelled():
+ *                 self.cancel_waiter.set_result(
+ */
+  __pyx_t_2 = (__pyx_v_self->cancel_waiter != Py_None);
+  __pyx_t_1 = (__pyx_t_2 != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/protocol.pyx":470
+ * 
+ *         if self.cancel_waiter is not None:
+ *             if self.waiter is None or not self.waiter.cancelled():             # <<<<<<<<<<<<<<
+ *                 self.cancel_waiter.set_result(
+ *                     RuntimeError('invalid state after cancellation'))
+ */
+    __pyx_t_2 = (__pyx_v_self->waiter == Py_None);
+    __pyx_t_6 = (__pyx_t_2 != 0);
+    if (!__pyx_t_6) {
+    } else {
+      __pyx_t_1 = __pyx_t_6;
+      goto __pyx_L6_bool_binop_done;
+    }
+    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->waiter, __pyx_n_s_cancelled); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 470, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
+      if (likely(__pyx_t_5)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+        __Pyx_INCREF(__pyx_t_5);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_4, function);
+      }
+    }
+    if (__pyx_t_5) {
+      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 470, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    } else {
+      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 470, __pyx_L1_error)
+    }
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(27, 470, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_2 = ((!__pyx_t_6) != 0);
+    __pyx_t_1 = __pyx_t_2;
+    __pyx_L6_bool_binop_done:;
+    if (__pyx_t_1) {
+
+      /* "asyncpg/protocol/protocol.pyx":471
+ *         if self.cancel_waiter is not None:
+ *             if self.waiter is None or not self.waiter.cancelled():
+ *                 self.cancel_waiter.set_result(             # <<<<<<<<<<<<<<
+ *                     RuntimeError('invalid state after cancellation'))
+ *             else:
+ */
+      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->cancel_waiter, __pyx_n_s_set_result); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 471, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+
+      /* "asyncpg/protocol/protocol.pyx":472
+ *             if self.waiter is None or not self.waiter.cancelled():
+ *                 self.cancel_waiter.set_result(
+ *                     RuntimeError('invalid state after cancellation'))             # <<<<<<<<<<<<<<
+ *             else:
+ *                 self.cancel_waiter.set_result(None)
+ */
+      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__80, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 472, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_5);
+      __pyx_t_7 = NULL;
+      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
+        if (likely(__pyx_t_7)) {
+          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+          __Pyx_INCREF(__pyx_t_7);
+          __Pyx_INCREF(function);
+          __Pyx_DECREF_SET(__pyx_t_4, function);
+        }
+      }
+      if (!__pyx_t_7) {
+        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 471, __pyx_L1_error)
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_GOTREF(__pyx_t_3);
+      } else {
+        #if CYTHON_FAST_PYCALL
+        if (PyFunction_Check(__pyx_t_4)) {
+          PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_5};
+          __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 471, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+          __Pyx_GOTREF(__pyx_t_3);
+          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        } else
+        #endif
+        #if CYTHON_FAST_PYCCALL
+        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
+          PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_5};
+          __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 471, __pyx_L1_error)
+          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+          __Pyx_GOTREF(__pyx_t_3);
+          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        } else
+        #endif
+        {
+          __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(27, 471, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_8);
+          __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
+          __Pyx_GIVEREF(__pyx_t_5);
+          PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_5);
+          __pyx_t_5 = 0;
+          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 471, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_3);
+          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        }
+      }
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+      /* "asyncpg/protocol/protocol.pyx":470
+ * 
+ *         if self.cancel_waiter is not None:
+ *             if self.waiter is None or not self.waiter.cancelled():             # <<<<<<<<<<<<<<
+ *                 self.cancel_waiter.set_result(
+ *                     RuntimeError('invalid state after cancellation'))
+ */
+      goto __pyx_L5;
+    }
+
+    /* "asyncpg/protocol/protocol.pyx":474
+ *                     RuntimeError('invalid state after cancellation'))
+ *             else:
+ *                 self.cancel_waiter.set_result(None)             # <<<<<<<<<<<<<<
+ *             self.cancel_waiter = None
+ *             self.waiter = None
+ */
+    /*else*/ {
+      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->cancel_waiter, __pyx_n_s_set_result); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 474, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__81, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 474, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    }
+    __pyx_L5:;
+
+    /* "asyncpg/protocol/protocol.pyx":475
+ *             else:
+ *                 self.cancel_waiter.set_result(None)
+ *             self.cancel_waiter = None             # <<<<<<<<<<<<<<
+ *             self.waiter = None
+ *             return
+ */
+    __Pyx_INCREF(Py_None);
+    __Pyx_GIVEREF(Py_None);
+    __Pyx_GOTREF(__pyx_v_self->cancel_waiter);
+    __Pyx_DECREF(__pyx_v_self->cancel_waiter);
+    __pyx_v_self->cancel_waiter = Py_None;
+
+    /* "asyncpg/protocol/protocol.pyx":476
+ *                 self.cancel_waiter.set_result(None)
+ *             self.cancel_waiter = None
+ *             self.waiter = None             # <<<<<<<<<<<<<<
+ *             return
+ * 
+ */
+    __Pyx_INCREF(Py_None);
+    __Pyx_GIVEREF(Py_None);
+    __Pyx_GOTREF(__pyx_v_self->waiter);
+    __Pyx_DECREF(__pyx_v_self->waiter);
+    __pyx_v_self->waiter = Py_None;
+
+    /* "asyncpg/protocol/protocol.pyx":477
+ *             self.cancel_waiter = None
+ *             self.waiter = None
+ *             return             # <<<<<<<<<<<<<<
+ * 
+ *         try:
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+    goto __pyx_L0;
+
+    /* "asyncpg/protocol/protocol.pyx":469
+ *             self.timeout_handle = None
+ * 
+ *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
+ *             if self.waiter is None or not self.waiter.cancelled():
+ *                 self.cancel_waiter.set_result(
+ */
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":479
+ *             return
+ * 
+ *         try:             # <<<<<<<<<<<<<<
+ *             self._dispatch_result()
+ *         finally:
+ */
+  /*try:*/ {
+
+    /* "asyncpg/protocol/protocol.pyx":480
+ * 
+ *         try:
+ *             self._dispatch_result()             # <<<<<<<<<<<<<<
+ *         finally:
+ *             self.statement = None
+ */
+    __pyx_t_4 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self->__pyx_base.__pyx_vtab)->_dispatch_result(__pyx_v_self); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 480, __pyx_L9_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":482
+ *             self._dispatch_result()
+ *         finally:
+ *             self.statement = None             # <<<<<<<<<<<<<<
+ *             self.last_query = None
+ *             self.return_extra = False
+ */
+  /*finally:*/ {
+    /*normal exit:*/{
+      __Pyx_INCREF(Py_None);
+      __Pyx_GIVEREF(Py_None);
+      __Pyx_GOTREF(__pyx_v_self->statement);
+      __Pyx_DECREF(((PyObject *)__pyx_v_self->statement));
+      __pyx_v_self->statement = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)Py_None);
+
+      /* "asyncpg/protocol/protocol.pyx":483
+ *         finally:
+ *             self.statement = None
+ *             self.last_query = None             # <<<<<<<<<<<<<<
+ *             self.return_extra = False
+ * 
+ */
+      __Pyx_INCREF(Py_None);
+      __Pyx_GIVEREF(Py_None);
+      __Pyx_GOTREF(__pyx_v_self->last_query);
+      __Pyx_DECREF(__pyx_v_self->last_query);
+      __pyx_v_self->last_query = ((PyObject*)Py_None);
+
+      /* "asyncpg/protocol/protocol.pyx":484
+ *             self.statement = None
+ *             self.last_query = None
+ *             self.return_extra = False             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _on_notification(self, pid, channel, payload):
+ */
+      __pyx_v_self->return_extra = 0;
+      goto __pyx_L10;
+    }
+    /*exception exit:*/{
+      __Pyx_PyThreadState_declare
+      __pyx_L9_error:;
+      __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
+      __Pyx_PyThreadState_assign
+      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
+      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
+      __Pyx_XGOTREF(__pyx_t_12);
+      __Pyx_XGOTREF(__pyx_t_13);
+      __Pyx_XGOTREF(__pyx_t_14);
+      __Pyx_XGOTREF(__pyx_t_15);
+      __Pyx_XGOTREF(__pyx_t_16);
+      __Pyx_XGOTREF(__pyx_t_17);
+      __pyx_t_9 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_11 = __pyx_filename;
+      {
+
+        /* "asyncpg/protocol/protocol.pyx":482
+ *             self._dispatch_result()
+ *         finally:
+ *             self.statement = None             # <<<<<<<<<<<<<<
+ *             self.last_query = None
+ *             self.return_extra = False
+ */
+        __Pyx_INCREF(Py_None);
+        __Pyx_GIVEREF(Py_None);
+        __Pyx_GOTREF(__pyx_v_self->statement);
+        __Pyx_DECREF(((PyObject *)__pyx_v_self->statement));
+        __pyx_v_self->statement = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)Py_None);
+
+        /* "asyncpg/protocol/protocol.pyx":483
+ *         finally:
+ *             self.statement = None
+ *             self.last_query = None             # <<<<<<<<<<<<<<
+ *             self.return_extra = False
+ * 
+ */
+        __Pyx_INCREF(Py_None);
+        __Pyx_GIVEREF(Py_None);
+        __Pyx_GOTREF(__pyx_v_self->last_query);
+        __Pyx_DECREF(__pyx_v_self->last_query);
+        __pyx_v_self->last_query = ((PyObject*)Py_None);
+
+        /* "asyncpg/protocol/protocol.pyx":484
+ *             self.statement = None
+ *             self.last_query = None
+ *             self.return_extra = False             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _on_notification(self, pid, channel, payload):
+ */
+        __pyx_v_self->return_extra = 0;
+      }
+      __Pyx_PyThreadState_assign
+      if (PY_MAJOR_VERSION >= 3) {
+        __Pyx_XGIVEREF(__pyx_t_15);
+        __Pyx_XGIVEREF(__pyx_t_16);
+        __Pyx_XGIVEREF(__pyx_t_17);
+        __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
+      }
+      __Pyx_XGIVEREF(__pyx_t_12);
+      __Pyx_XGIVEREF(__pyx_t_13);
+      __Pyx_XGIVEREF(__pyx_t_14);
+      __Pyx_ErrRestore(__pyx_t_12, __pyx_t_13, __pyx_t_14);
+      __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
+      __pyx_lineno = __pyx_t_9; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_11;
+      goto __pyx_L1_error;
+    }
+    __pyx_L10:;
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":464
+ *             waiter.set_exception(exc)
+ * 
+ *     cdef _on_result(self):             # <<<<<<<<<<<<<<
+ *         if self.timeout_handle is not None:
+ *             self.timeout_handle.cancel()
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._on_result", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":486
+ *             self.return_extra = False
+ * 
+ *     cdef _on_notification(self, pid, channel, payload):             # <<<<<<<<<<<<<<
+ *         self.connection._notify(pid, channel, payload)
+ * 
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_notification(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_pid, PyObject *__pyx_v_channel, PyObject *__pyx_v_payload) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  __Pyx_RefNannySetupContext("_on_notification", 0);
+
+  /* "asyncpg/protocol/protocol.pyx":487
+ * 
+ *     cdef _on_notification(self, pid, channel, payload):
+ *         self.connection._notify(pid, channel, payload)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _on_connection_lost(self, exc):
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->connection, __pyx_n_s_notify); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 487, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = NULL;
+  __pyx_t_4 = 0;
+  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+      __pyx_t_4 = 1;
+    }
+  }
+  #if CYTHON_FAST_PYCALL
+  if (PyFunction_Check(__pyx_t_2)) {
+    PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_v_pid, __pyx_v_channel, __pyx_v_payload};
+    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 487, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+  } else
+  #endif
+  #if CYTHON_FAST_PYCCALL
+  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+    PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_v_pid, __pyx_v_channel, __pyx_v_payload};
+    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 487, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+  } else
+  #endif
+  {
+    __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 487, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    if (__pyx_t_3) {
+      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
+    }
+    __Pyx_INCREF(__pyx_v_pid);
+    __Pyx_GIVEREF(__pyx_v_pid);
+    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_pid);
+    __Pyx_INCREF(__pyx_v_channel);
+    __Pyx_GIVEREF(__pyx_v_channel);
+    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_channel);
+    __Pyx_INCREF(__pyx_v_payload);
+    __Pyx_GIVEREF(__pyx_v_payload);
+    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_payload);
+    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 487, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":486
+ *             self.return_extra = False
+ * 
+ *     cdef _on_notification(self, pid, channel, payload):             # <<<<<<<<<<<<<<
+ *         self.connection._notify(pid, channel, payload)
+ * 
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._on_notification", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":489
+ *         self.connection._notify(pid, channel, payload)
+ * 
+ *     cdef _on_connection_lost(self, exc):             # <<<<<<<<<<<<<<
+ *         if self.closing:
+ *             # The connection was lost because
+ */
+
+static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_connection_lost(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_exc) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  int __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  __Pyx_RefNannySetupContext("_on_connection_lost", 0);
+
+  /* "asyncpg/protocol/protocol.pyx":490
+ * 
+ *     cdef _on_connection_lost(self, exc):
+ *         if self.closing:             # <<<<<<<<<<<<<<
+ *             # The connection was lost because
+ *             # Protocol.close() was called
+ */
+  __pyx_t_1 = (__pyx_v_self->closing != 0);
+  if (__pyx_t_1) {
+
+    /* "asyncpg/protocol/protocol.pyx":493
+ *             # The connection was lost because
+ *             # Protocol.close() was called
+ *             if self.waiter is not None and not self.waiter.done():             # <<<<<<<<<<<<<<
+ *                 if exc is None:
+ *                     self.waiter.set_result(None)
+ */
+    __pyx_t_2 = (__pyx_v_self->waiter != Py_None);
+    __pyx_t_3 = (__pyx_t_2 != 0);
+    if (__pyx_t_3) {
+    } else {
+      __pyx_t_1 = __pyx_t_3;
+      goto __pyx_L5_bool_binop_done;
+    }
+    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->waiter, __pyx_n_s_done); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 493, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = NULL;
+    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
+      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
+      if (likely(__pyx_t_6)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+        __Pyx_INCREF(__pyx_t_6);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_5, function);
+      }
+    }
+    if (__pyx_t_6) {
+      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 493, __pyx_L1_error)
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    } else {
+      __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 493, __pyx_L1_error)
+    }
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(27, 493, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_2 = ((!__pyx_t_3) != 0);
+    __pyx_t_1 = __pyx_t_2;
+    __pyx_L5_bool_binop_done:;
+    if (__pyx_t_1) {
+
+      /* "asyncpg/protocol/protocol.pyx":494
+ *             # Protocol.close() was called
+ *             if self.waiter is not None and not self.waiter.done():
+ *                 if exc is None:             # <<<<<<<<<<<<<<
+ *                     self.waiter.set_result(None)
+ *                 else:
+ */
+      __pyx_t_1 = (__pyx_v_exc == Py_None);
+      __pyx_t_2 = (__pyx_t_1 != 0);
+      if (__pyx_t_2) {
+
+        /* "asyncpg/protocol/protocol.pyx":495
+ *             if self.waiter is not None and not self.waiter.done():
+ *                 if exc is None:
+ *                     self.waiter.set_result(None)             # <<<<<<<<<<<<<<
+ *                 else:
+ *                     self.waiter.set_exception(exc)
+ */
+        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->waiter, __pyx_n_s_set_result); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 495, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__82, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 495, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+        /* "asyncpg/protocol/protocol.pyx":494
+ *             # Protocol.close() was called
+ *             if self.waiter is not None and not self.waiter.done():
+ *                 if exc is None:             # <<<<<<<<<<<<<<
+ *                     self.waiter.set_result(None)
+ *                 else:
+ */
+        goto __pyx_L7;
+      }
+
+      /* "asyncpg/protocol/protocol.pyx":497
+ *                     self.waiter.set_result(None)
+ *                 else:
+ *                     self.waiter.set_exception(exc)             # <<<<<<<<<<<<<<
+ *             self.waiter = None
+ *         else:
+ */
+      /*else*/ {
+        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->waiter, __pyx_n_s_set_exception); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 497, __pyx_L1_error)
+        __Pyx_GOTREF(__pyx_t_4);
+        __pyx_t_6 = NULL;
+        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
+          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
+          if (likely(__pyx_t_6)) {
+            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+            __Pyx_INCREF(__pyx_t_6);
+            __Pyx_INCREF(function);
+            __Pyx_DECREF_SET(__pyx_t_4, function);
+          }
+        }
+        if (!__pyx_t_6) {
+          __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_exc); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 497, __pyx_L1_error)
+          __Pyx_GOTREF(__pyx_t_5);
+        } else {
+          #if CYTHON_FAST_PYCALL
+          if (PyFunction_Check(__pyx_t_4)) {
+            PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_exc};
+            __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 497, __pyx_L1_error)
+            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+            __Pyx_GOTREF(__pyx_t_5);
+          } else
+          #endif
+          #if CYTHON_FAST_PYCCALL
+          if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
+            PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_exc};
+            __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 497, __pyx_L1_error)
+            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+            __Pyx_GOTREF(__pyx_t_5);
+          } else
+          #endif
+          {
+            __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(27, 497, __pyx_L1_error)
+            __Pyx_GOTREF(__pyx_t_7);
+            __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
+            __Pyx_INCREF(__pyx_v_exc);
+            __Pyx_GIVEREF(__pyx_v_exc);
+            PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_exc);
+            __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 497, __pyx_L1_error)
+            __Pyx_GOTREF(__pyx_t_5);
+            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+          }
+        }
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      }
+      __pyx_L7:;
+
+      /* "asyncpg/protocol/protocol.pyx":493
+ *             # The connection was lost because
+ *             # Protocol.close() was called
+ *             if self.waiter is not None and not self.waiter.done():             # <<<<<<<<<<<<<<
+ *                 if exc is None:
+ *                     self.waiter.set_result(None)
+ */
+    }
+
+    /* "asyncpg/protocol/protocol.pyx":498
+ *                 else:
+ *                     self.waiter.set_exception(exc)
+ *             self.waiter = None             # <<<<<<<<<<<<<<
+ *         else:
+ *             # The connection was lost because it was
+ */
+    __Pyx_INCREF(Py_None);
+    __Pyx_GIVEREF(Py_None);
+    __Pyx_GOTREF(__pyx_v_self->waiter);
+    __Pyx_DECREF(__pyx_v_self->waiter);
+    __pyx_v_self->waiter = Py_None;
+
+    /* "asyncpg/protocol/protocol.pyx":490
+ * 
+ *     cdef _on_connection_lost(self, exc):
+ *         if self.closing:             # <<<<<<<<<<<<<<
+ *             # The connection was lost because
+ *             # Protocol.close() was called
+ */
+    goto __pyx_L3;
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":503
+ *             # terminated or due to another error;
+ *             # Throw an error in any awaiting waiter.
+ *             self.closing = True             # <<<<<<<<<<<<<<
+ *             self._handle_waiter_on_connection_lost(exc)
+ * 
+ */
+  /*else*/ {
+    __pyx_v_self->closing = 1;
+
+    /* "asyncpg/protocol/protocol.pyx":504
+ *             # Throw an error in any awaiting waiter.
+ *             self.closing = True
+ *             self._handle_waiter_on_connection_lost(exc)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+    __pyx_t_5 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self->__pyx_base.__pyx_vtab)->_handle_waiter_on_connection_lost(__pyx_v_self, __pyx_v_exc); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 504, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  }
+  __pyx_L3:;
+
+  /* "asyncpg/protocol/protocol.pyx":489
+ *         self.connection._notify(pid, channel, payload)
+ * 
+ *     cdef _on_connection_lost(self, exc):             # <<<<<<<<<<<<<<
+ *         if self.closing:
+ *             # The connection was lost because
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._on_connection_lost", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pxd":46
+ *         bint closing
+ * 
+ *         readonly uint64_t queries_count             # <<<<<<<<<<<<<<
+ * 
+ *         PreparedStatementState statement
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_13queries_count_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_13queries_count_1__get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_13queries_count___get__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_13queries_count___get__(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("__get__", 0);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __Pyx_PyInt_From_uint64_t(__pyx_v_self->queries_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(28, 46, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.queries_count.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "asyncpg/protocol/protocol.pyx":511
+ * 
+ * 
+ * def _create_record(object mapping, tuple elems):             # <<<<<<<<<<<<<<
+ *     # Exposed only for testing purposes.
+ * 
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_1_create_record(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_7asyncpg_8protocol_8protocol_1_create_record = {"_create_record", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_1_create_record, METH_VARARGS|METH_KEYWORDS, 0};
+static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_1_create_record(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_mapping = 0;
+  PyObject *__pyx_v_elems = 0;
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("_create_record (wrapper)", 0);
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_mapping,&__pyx_n_s_elems,0};
+    PyObject* values[2] = {0,0};
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mapping)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+        case  1:
+        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_elems)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("_create_record", 1, 2, 2, 1); __PYX_ERR(27, 511, __pyx_L3_error)
+        }
+      }
+      if (unlikely(kw_args > 0)) {
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_create_record") < 0)) __PYX_ERR(27, 511, __pyx_L3_error)
+      }
+    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+      goto __pyx_L5_argtuple_error;
+    } else {
+      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+    }
+    __pyx_v_mapping = values[0];
+    __pyx_v_elems = ((PyObject*)values[1]);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("_create_record", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(27, 511, __pyx_L3_error)
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("asyncpg.protocol.protocol._create_record", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_elems), (&PyTuple_Type), 1, "elems", 1))) __PYX_ERR(27, 511, __pyx_L1_error)
+  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol__create_record(__pyx_self, __pyx_v_mapping, __pyx_v_elems);
+
+  /* function exit code */
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol__create_record(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_mapping, PyObject *__pyx_v_elems) {
+  PyObject *__pyx_v_rec = 0;
+  int32_t __pyx_v_i;
+  PyObject *__pyx_v_desc = NULL;
+  PyObject *__pyx_v_elem = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  Py_ssize_t __pyx_t_5;
+  int32_t __pyx_t_6;
+  __Pyx_RefNannySetupContext("_create_record", 0);
+
+  /* "asyncpg/protocol/protocol.pyx":518
+ *         int32_t i
+ * 
+ *     if mapping is None:             # <<<<<<<<<<<<<<
+ *         desc = record.ApgRecordDesc_New({}, ())
+ *     else:
+ */
+  __pyx_t_1 = (__pyx_v_mapping == Py_None);
+  __pyx_t_2 = (__pyx_t_1 != 0);
+  if (__pyx_t_2) {
+
+    /* "asyncpg/protocol/protocol.pyx":519
+ * 
+ *     if mapping is None:
+ *         desc = record.ApgRecordDesc_New({}, ())             # <<<<<<<<<<<<<<
+ *     else:
+ *         desc = record.ApgRecordDesc_New(
+ */
+    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 519, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_4 = ApgRecordDesc_New(__pyx_t_3, __pyx_empty_tuple); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 519, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_v_desc = __pyx_t_4;
+    __pyx_t_4 = 0;
+
+    /* "asyncpg/protocol/protocol.pyx":518
+ *         int32_t i
+ * 
+ *     if mapping is None:             # <<<<<<<<<<<<<<
+ *         desc = record.ApgRecordDesc_New({}, ())
+ *     else:
+ */
+    goto __pyx_L3;
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":521
+ *         desc = record.ApgRecordDesc_New({}, ())
+ *     else:
+ *         desc = record.ApgRecordDesc_New(             # <<<<<<<<<<<<<<
+ *             mapping, tuple(mapping) if mapping else ())
+ * 
+ */
+  /*else*/ {
+
+    /* "asyncpg/protocol/protocol.pyx":522
+ *     else:
+ *         desc = record.ApgRecordDesc_New(
+ *             mapping, tuple(mapping) if mapping else ())             # <<<<<<<<<<<<<<
+ * 
+ *     rec = record.ApgRecord_New(desc, len(elems))
+ */
+    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_mapping); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(27, 522, __pyx_L1_error)
+    if (__pyx_t_2) {
+      __pyx_t_3 = PySequence_Tuple(__pyx_v_mapping); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 522, __pyx_L1_error)
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_4 = __pyx_t_3;
+      __pyx_t_3 = 0;
+    } else {
+      __Pyx_INCREF(__pyx_empty_tuple);
+      __pyx_t_4 = __pyx_empty_tuple;
+    }
+
+    /* "asyncpg/protocol/protocol.pyx":521
+ *         desc = record.ApgRecordDesc_New({}, ())
+ *     else:
+ *         desc = record.ApgRecordDesc_New(             # <<<<<<<<<<<<<<
+ *             mapping, tuple(mapping) if mapping else ())
+ * 
+ */
+    __pyx_t_3 = ApgRecordDesc_New(__pyx_v_mapping, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 521, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_v_desc = __pyx_t_3;
+    __pyx_t_3 = 0;
+  }
+  __pyx_L3:;
+
+  /* "asyncpg/protocol/protocol.pyx":524
+ *             mapping, tuple(mapping) if mapping else ())
+ * 
+ *     rec = record.ApgRecord_New(desc, len(elems))             # <<<<<<<<<<<<<<
+ *     for i in range(len(elems)):
+ *         elem = elems[i]
+ */
+  if (unlikely(__pyx_v_elems == Py_None)) {
+    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
+    __PYX_ERR(27, 524, __pyx_L1_error)
+  }
+  __pyx_t_5 = PyTuple_GET_SIZE(__pyx_v_elems); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(27, 524, __pyx_L1_error)
+  __pyx_t_3 = ApgRecord_New(__pyx_v_desc, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 524, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_v_rec = __pyx_t_3;
+  __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":525
+ * 
+ *     rec = record.ApgRecord_New(desc, len(elems))
+ *     for i in range(len(elems)):             # <<<<<<<<<<<<<<
+ *         elem = elems[i]
+ *         cpython.Py_INCREF(elem)
+ */
+  if (unlikely(__pyx_v_elems == Py_None)) {
+    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
+    __PYX_ERR(27, 525, __pyx_L1_error)
+  }
+  __pyx_t_5 = PyTuple_GET_SIZE(__pyx_v_elems); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(27, 525, __pyx_L1_error)
+  for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
+    __pyx_v_i = __pyx_t_6;
+
+    /* "asyncpg/protocol/protocol.pyx":526
+ *     rec = record.ApgRecord_New(desc, len(elems))
+ *     for i in range(len(elems)):
+ *         elem = elems[i]             # <<<<<<<<<<<<<<
+ *         cpython.Py_INCREF(elem)
+ *         record.ApgRecord_SET_ITEM(rec, i, elem)
+ */
+    if (unlikely(__pyx_v_elems == Py_None)) {
+      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+      __PYX_ERR(27, 526, __pyx_L1_error)
+    }
+    __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_elems, __pyx_v_i, int32_t, 1, __Pyx_PyInt_From_int32_t, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 526, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_XDECREF_SET(__pyx_v_elem, __pyx_t_3);
+    __pyx_t_3 = 0;
+
+    /* "asyncpg/protocol/protocol.pyx":527
+ *     for i in range(len(elems)):
+ *         elem = elems[i]
+ *         cpython.Py_INCREF(elem)             # <<<<<<<<<<<<<<
+ *         record.ApgRecord_SET_ITEM(rec, i, elem)
+ *     return rec
+ */
+    Py_INCREF(__pyx_v_elem);
+
+    /* "asyncpg/protocol/protocol.pyx":528
+ *         elem = elems[i]
+ *         cpython.Py_INCREF(elem)
+ *         record.ApgRecord_SET_ITEM(rec, i, elem)             # <<<<<<<<<<<<<<
+ *     return rec
+ * 
+ */
+    ApgRecord_SET_ITEM(__pyx_v_rec, __pyx_v_i, __pyx_v_elem);
+  }
+
+  /* "asyncpg/protocol/protocol.pyx":529
+ *         cpython.Py_INCREF(elem)
+ *         record.ApgRecord_SET_ITEM(rec, i, elem)
+ *     return rec             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_rec);
+  __pyx_r = __pyx_v_rec;
+  goto __pyx_L0;
+
+  /* "asyncpg/protocol/protocol.pyx":511
+ * 
+ * 
+ * def _create_record(object mapping, tuple elems):             # <<<<<<<<<<<<<<
+ *     # Exposed only for testing purposes.
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("asyncpg.protocol.protocol._create_record", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_rec);
+  __Pyx_XDECREF(__pyx_v_desc);
+  __Pyx_XDECREF(__pyx_v_elem);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "hton.pxd":25
+ * 
+ * 
+ * cdef inline void pack_int16(char* buf, int16_t x):             # <<<<<<<<<<<<<<
+ *     (<uint16_t*>buf)[0] = htons(<uint16_t>x)
+ * 
+ */
+
+static CYTHON_INLINE void __pyx_f_7asyncpg_8protocol_4hton_pack_int16(char *__pyx_v_buf, int16_t __pyx_v_x) {
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("pack_int16", 0);
+
+  /* "hton.pxd":26
+ * 
+ * cdef inline void pack_int16(char* buf, int16_t x):
+ *     (<uint16_t*>buf)[0] = htons(<uint16_t>x)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  (((uint16_t *)__pyx_v_buf)[0]) = htons(((uint16_t)__pyx_v_x));
+
+  /* "hton.pxd":25
+ * 
+ * 
+ * cdef inline void pack_int16(char* buf, int16_t x):             # <<<<<<<<<<<<<<
+ *     (<uint16_t*>buf)[0] = htons(<uint16_t>x)
+ * 
+ */
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+}
+
+/* "hton.pxd":29
+ * 
+ * 
+ * cdef inline int16_t unpack_int16(const char* buf):             # <<<<<<<<<<<<<<
+ *     return <int16_t>ntohs((<uint16_t*>buf)[0])
+ * 
+ */
+
+static CYTHON_INLINE int16_t __pyx_f_7asyncpg_8protocol_4hton_unpack_int16(char const *__pyx_v_buf) {
+  int16_t __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("unpack_int16", 0);
+
+  /* "hton.pxd":30
+ * 
+ * cdef inline int16_t unpack_int16(const char* buf):
+ *     return <int16_t>ntohs((<uint16_t*>buf)[0])             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_r = ((int16_t)ntohs((((uint16_t *)__pyx_v_buf)[0])));
+  goto __pyx_L0;
+
+  /* "hton.pxd":29
+ * 
+ * 
+ * cdef inline int16_t unpack_int16(const char* buf):             # <<<<<<<<<<<<<<
+ *     return <int16_t>ntohs((<uint16_t*>buf)[0])
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "hton.pxd":33
+ * 
+ * 
+ * cdef inline void pack_int32(char* buf, int32_t x):             # <<<<<<<<<<<<<<
+ *     (<uint32_t*>buf)[0] = htonl(<uint32_t>x)
+ * 
+ */
+
+static CYTHON_INLINE void __pyx_f_7asyncpg_8protocol_4hton_pack_int32(char *__pyx_v_buf, int32_t __pyx_v_x) {
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("pack_int32", 0);
+
+  /* "hton.pxd":34
+ * 
+ * cdef inline void pack_int32(char* buf, int32_t x):
+ *     (<uint32_t*>buf)[0] = htonl(<uint32_t>x)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  (((uint32_t *)__pyx_v_buf)[0]) = htonl(((uint32_t)__pyx_v_x));
+
+  /* "hton.pxd":33
+ * 
+ * 
+ * cdef inline void pack_int32(char* buf, int32_t x):             # <<<<<<<<<<<<<<
+ *     (<uint32_t*>buf)[0] = htonl(<uint32_t>x)
+ * 
+ */
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+}
+
+/* "hton.pxd":37
+ * 
+ * 
+ * cdef inline int32_t unpack_int32(const char* buf):             # <<<<<<<<<<<<<<
+ *     return <int32_t>ntohl((<uint32_t*>buf)[0])
+ * 
+ */
+
+static CYTHON_INLINE int32_t __pyx_f_7asyncpg_8protocol_4hton_unpack_int32(char const *__pyx_v_buf) {
+  int32_t __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("unpack_int32", 0);
+
+  /* "hton.pxd":38
+ * 
+ * cdef inline int32_t unpack_int32(const char* buf):
+ *     return <int32_t>ntohl((<uint32_t*>buf)[0])             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_r = ((int32_t)ntohl((((uint32_t *)__pyx_v_buf)[0])));
+  goto __pyx_L0;
+
+  /* "hton.pxd":37
+ * 
+ * 
+ * cdef inline int32_t unpack_int32(const char* buf):             # <<<<<<<<<<<<<<
+ *     return <int32_t>ntohl((<uint32_t*>buf)[0])
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "hton.pxd":41
+ * 
+ * 
+ * cdef inline void pack_int64(char* buf, int64_t x):             # <<<<<<<<<<<<<<
+ *     (<uint32_t*>buf)[0] = htonl(<uint32_t>(<uint64_t>(x) >> 32))
+ *     (<uint32_t*>&buf[4])[0] = htonl(<uint32_t>(x))
+ */
+
+static CYTHON_INLINE void __pyx_f_7asyncpg_8protocol_4hton_pack_int64(char *__pyx_v_buf, int64_t __pyx_v_x) {
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("pack_int64", 0);
+
+  /* "hton.pxd":42
+ * 
+ * cdef inline void pack_int64(char* buf, int64_t x):
+ *     (<uint32_t*>buf)[0] = htonl(<uint32_t>(<uint64_t>(x) >> 32))             # <<<<<<<<<<<<<<
+ *     (<uint32_t*>&buf[4])[0] = htonl(<uint32_t>(x))
+ * 
+ */
+  (((uint32_t *)__pyx_v_buf)[0]) = htonl(((uint32_t)(((uint64_t)__pyx_v_x) >> 32)));
+
+  /* "hton.pxd":43
+ * cdef inline void pack_int64(char* buf, int64_t x):
+ *     (<uint32_t*>buf)[0] = htonl(<uint32_t>(<uint64_t>(x) >> 32))
+ *     (<uint32_t*>&buf[4])[0] = htonl(<uint32_t>(x))             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  (((uint32_t *)(&(__pyx_v_buf[4])))[0]) = htonl(((uint32_t)__pyx_v_x));
+
+  /* "hton.pxd":41
+ * 
+ * 
+ * cdef inline void pack_int64(char* buf, int64_t x):             # <<<<<<<<<<<<<<
+ *     (<uint32_t*>buf)[0] = htonl(<uint32_t>(<uint64_t>(x) >> 32))
+ *     (<uint32_t*>&buf[4])[0] = htonl(<uint32_t>(x))
+ */
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+}
+
+/* "hton.pxd":46
+ * 
+ * 
+ * cdef inline int64_t unpack_int64(const char* buf):             # <<<<<<<<<<<<<<
+ *     cdef int64_t hh = unpack_int32(buf)
+ *     cdef uint32_t hl = <uint32_t>unpack_int32(&buf[4])
+ */
+
+static CYTHON_INLINE int64_t __pyx_f_7asyncpg_8protocol_4hton_unpack_int64(char const *__pyx_v_buf) {
+  int64_t __pyx_v_hh;
+  uint32_t __pyx_v_hl;
+  int64_t __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("unpack_int64", 0);
+
+  /* "hton.pxd":47
+ * 
+ * cdef inline int64_t unpack_int64(const char* buf):
+ *     cdef int64_t hh = unpack_int32(buf)             # <<<<<<<<<<<<<<
+ *     cdef uint32_t hl = <uint32_t>unpack_int32(&buf[4])
+ * 
+ */
+  __pyx_v_hh = __pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_v_buf);
+
+  /* "hton.pxd":48
+ * cdef inline int64_t unpack_int64(const char* buf):
+ *     cdef int64_t hh = unpack_int32(buf)
+ *     cdef uint32_t hl = <uint32_t>unpack_int32(&buf[4])             # <<<<<<<<<<<<<<
+ * 
+ *     return (hh << 32) | hl
+ */
+  __pyx_v_hl = ((uint32_t)__pyx_f_7asyncpg_8protocol_4hton_unpack_int32((&(__pyx_v_buf[4]))));
+
+  /* "hton.pxd":50
+ *     cdef uint32_t hl = <uint32_t>unpack_int32(&buf[4])
+ * 
+ *     return (hh << 32) | hl             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_r = ((__pyx_v_hh << 32) | __pyx_v_hl);
+  goto __pyx_L0;
+
+  /* "hton.pxd":46
+ * 
+ * 
+ * cdef inline int64_t unpack_int64(const char* buf):             # <<<<<<<<<<<<<<
+ *     cdef int64_t hh = unpack_int32(buf)
+ *     cdef uint32_t hl = <uint32_t>unpack_int32(&buf[4])
+ */
+
+  /* function exit code */
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "hton.pxd":58
+ * 
+ * 
+ * cdef inline int32_t pack_float(char* buf, float f):             # <<<<<<<<<<<<<<
+ *     cdef _floatconv v
+ *     v.f = f
+ */
+
+static CYTHON_INLINE int32_t __pyx_f_7asyncpg_8protocol_4hton_pack_float(char *__pyx_v_buf, float __pyx_v_f) {
+  union __pyx_t_7asyncpg_8protocol_4hton__floatconv __pyx_v_v;
+  int32_t __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("pack_float", 0);
+
+  /* "hton.pxd":60
+ * cdef inline int32_t pack_float(char* buf, float f):
+ *     cdef _floatconv v
+ *     v.f = f             # <<<<<<<<<<<<<<
+ *     pack_int32(buf, <int32_t>v.i)
+ * 
+ */
+  __pyx_v_v.f = __pyx_v_f;
+
+  /* "hton.pxd":61
+ *     cdef _floatconv v
+ *     v.f = f
+ *     pack_int32(buf, <int32_t>v.i)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_f_7asyncpg_8protocol_4hton_pack_int32(__pyx_v_buf, ((int32_t)__pyx_v_v.i));
+
+  /* "hton.pxd":58
+ * 
+ * 
+ * cdef inline int32_t pack_float(char* buf, float f):             # <<<<<<<<<<<<<<
+ *     cdef _floatconv v
+ *     v.f = f
+ */
+
+  /* function exit code */
+  __pyx_r = 0;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "hton.pxd":64
+ * 
+ * 
+ * cdef inline float unpack_float(const char* buf):             # <<<<<<<<<<<<<<
+ *     cdef _floatconv v
+ *     v.i = <uint32_t>unpack_int32(buf)
+ */
+
+static CYTHON_INLINE float __pyx_f_7asyncpg_8protocol_4hton_unpack_float(char const *__pyx_v_buf) {
+  union __pyx_t_7asyncpg_8protocol_4hton__floatconv __pyx_v_v;
+  float __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("unpack_float", 0);
+
+  /* "hton.pxd":66
+ * cdef inline float unpack_float(const char* buf):
+ *     cdef _floatconv v
+ *     v.i = <uint32_t>unpack_int32(buf)             # <<<<<<<<<<<<<<
+ *     return v.f
+ * 
+ */
+  __pyx_v_v.i = ((uint32_t)__pyx_f_7asyncpg_8protocol_4hton_unpack_int32(__pyx_v_buf));
+
+  /* "hton.pxd":67
+ *     cdef _floatconv v
+ *     v.i = <uint32_t>unpack_int32(buf)
+ *     return v.f             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_r = __pyx_v_v.f;
+  goto __pyx_L0;
+
+  /* "hton.pxd":64
+ * 
+ * 
+ * cdef inline float unpack_float(const char* buf):             # <<<<<<<<<<<<<<
+ *     cdef _floatconv v
+ *     v.i = <uint32_t>unpack_int32(buf)
+ */
+
+  /* function exit code */
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "hton.pxd":75
+ * 
+ * 
+ * cdef inline int64_t pack_double(char* buf, double f):             # <<<<<<<<<<<<<<
+ *     cdef _doubleconv v
+ *     v.f = f
+ */
+
+static CYTHON_INLINE int64_t __pyx_f_7asyncpg_8protocol_4hton_pack_double(char *__pyx_v_buf, double __pyx_v_f) {
+  union __pyx_t_7asyncpg_8protocol_4hton__doubleconv __pyx_v_v;
+  int64_t __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("pack_double", 0);
+
+  /* "hton.pxd":77
+ * cdef inline int64_t pack_double(char* buf, double f):
+ *     cdef _doubleconv v
+ *     v.f = f             # <<<<<<<<<<<<<<
+ *     pack_int64(buf, <int64_t>v.i)
+ * 
+ */
+  __pyx_v_v.f = __pyx_v_f;
+
+  /* "hton.pxd":78
+ *     cdef _doubleconv v
+ *     v.f = f
+ *     pack_int64(buf, <int64_t>v.i)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_f_7asyncpg_8protocol_4hton_pack_int64(__pyx_v_buf, ((int64_t)__pyx_v_v.i));
+
+  /* "hton.pxd":75
+ * 
+ * 
+ * cdef inline int64_t pack_double(char* buf, double f):             # <<<<<<<<<<<<<<
+ *     cdef _doubleconv v
+ *     v.f = f
+ */
+
+  /* function exit code */
+  __pyx_r = 0;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "hton.pxd":81
+ * 
+ * 
+ * cdef inline double unpack_double(const char* buf):             # <<<<<<<<<<<<<<
+ *     cdef _doubleconv v
+ *     v.i = <uint64_t>unpack_int64(buf)
+ */
+
+static CYTHON_INLINE double __pyx_f_7asyncpg_8protocol_4hton_unpack_double(char const *__pyx_v_buf) {
+  union __pyx_t_7asyncpg_8protocol_4hton__doubleconv __pyx_v_v;
+  double __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("unpack_double", 0);
+
+  /* "hton.pxd":83
+ * cdef inline double unpack_double(const char* buf):
+ *     cdef _doubleconv v
+ *     v.i = <uint64_t>unpack_int64(buf)             # <<<<<<<<<<<<<<
+ *     return v.f
+ */
+  __pyx_v_v.i = ((uint64_t)__pyx_f_7asyncpg_8protocol_4hton_unpack_int64(__pyx_v_buf));
+
+  /* "hton.pxd":84
+ *     cdef _doubleconv v
+ *     v.i = <uint64_t>unpack_int64(buf)
+ *     return v.f             # <<<<<<<<<<<<<<
+ */
+  __pyx_r = __pyx_v_v.f;
+  goto __pyx_L0;
+
+  /* "hton.pxd":81
+ * 
+ * 
+ * cdef inline double unpack_double(const char* buf):             # <<<<<<<<<<<<<<
+ *     cdef _doubleconv v
+ *     v.i = <uint64_t>unpack_int64(buf)
+ */
+
+  /* function exit code */
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+static struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_Memory __pyx_vtable_7asyncpg_8protocol_8protocol_Memory;
+
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *__pyx_freelist_7asyncpg_8protocol_8protocol_Memory[1024];
+static int __pyx_freecount_7asyncpg_8protocol_8protocol_Memory = 0;
+
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol_Memory(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *p;
+  PyObject *o;
+  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_7asyncpg_8protocol_8protocol_Memory > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory)))) {
+    o = (PyObject*)__pyx_freelist_7asyncpg_8protocol_8protocol_Memory[--__pyx_freecount_7asyncpg_8protocol_8protocol_Memory];
+    memset(o, 0, sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory));
+    (void) PyObject_INIT(o, t);
+    PyObject_GC_Track(o);
+  } else {
+    o = (*t->tp_alloc)(t, 0);
+    if (unlikely(!o)) return 0;
+  }
+  p = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *)o);
+  p->__pyx_vtab = __pyx_vtabptr_7asyncpg_8protocol_8protocol_Memory;
+  p->owner = Py_None; Py_INCREF(Py_None);
+  return o;
+}
+
+static void __pyx_tp_dealloc_7asyncpg_8protocol_8protocol_Memory(PyObject *o) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *)o;
+  PyObject_GC_UnTrack(o);
+  Py_CLEAR(p->owner);
+  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7asyncpg_8protocol_8protocol_Memory < 1024) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory)))) {
+    __pyx_freelist_7asyncpg_8protocol_8protocol_Memory[__pyx_freecount_7asyncpg_8protocol_8protocol_Memory++] = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *)o);
+  } else {
+    (*Py_TYPE(o)->tp_free)(o);
+  }
+}
+
+static int __pyx_tp_traverse_7asyncpg_8protocol_8protocol_Memory(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *)o;
+  if (p->owner) {
+    e = (*v)(p->owner, a); if (e) return e;
+  }
+  return 0;
+}
+
+static PyTypeObject __pyx_type_7asyncpg_8protocol_8protocol_Memory = {
+  PyVarObject_HEAD_INIT(0, 0)
+  "asyncpg.protocol.protocol.Memory", /*tp_name*/
+  sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_7asyncpg_8protocol_8protocol_Memory, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #endif
+  #if PY_MAJOR_VERSION >= 3
+  0, /*tp_as_async*/
+  #endif
+  0, /*tp_repr*/
+  0, /*tp_as_number*/
+  0, /*tp_as_sequence*/
+  0, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  0, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  0, /*tp_doc*/
+  __pyx_tp_traverse_7asyncpg_8protocol_8protocol_Memory, /*tp_traverse*/
+  0, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  0, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_7asyncpg_8protocol_8protocol_Memory, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  0, /*tp_version_tag*/
+  #if PY_VERSION_HEX >= 0x030400a1
+  0, /*tp_finalize*/
+  #endif
+};
+static struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_WriteBuffer __pyx_vtable_7asyncpg_8protocol_8protocol_WriteBuffer;
+
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_freelist_7asyncpg_8protocol_8protocol_WriteBuffer[256];
+static int __pyx_freecount_7asyncpg_8protocol_8protocol_WriteBuffer = 0;
+
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol_WriteBuffer(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *p;
+  PyObject *o;
+  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_7asyncpg_8protocol_8protocol_WriteBuffer > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer)))) {
+    o = (PyObject*)__pyx_freelist_7asyncpg_8protocol_8protocol_WriteBuffer[--__pyx_freecount_7asyncpg_8protocol_8protocol_WriteBuffer];
+    memset(o, 0, sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer));
+    (void) PyObject_INIT(o, t);
+  } else {
+    o = (*t->tp_alloc)(t, 0);
+    if (unlikely(!o)) return 0;
+  }
+  p = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)o);
+  p->__pyx_vtab = __pyx_vtabptr_7asyncpg_8protocol_8protocol_WriteBuffer;
+  if (unlikely(__pyx_pw_7asyncpg_8protocol_8protocol_11WriteBuffer_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) goto bad;
+  return o;
+  bad:
+  Py_DECREF(o); o = 0;
+  return NULL;
+}
+
+static void __pyx_tp_dealloc_7asyncpg_8protocol_8protocol_WriteBuffer(PyObject *o) {
+  {
+    PyObject *etype, *eval, *etb;
+    PyErr_Fetch(&etype, &eval, &etb);
+    ++Py_REFCNT(o);
+    __pyx_pw_7asyncpg_8protocol_8protocol_11WriteBuffer_3__dealloc__(o);
+    --Py_REFCNT(o);
+    PyErr_Restore(etype, eval, etb);
+  }
+  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7asyncpg_8protocol_8protocol_WriteBuffer < 256) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer)))) {
+    __pyx_freelist_7asyncpg_8protocol_8protocol_WriteBuffer[__pyx_freecount_7asyncpg_8protocol_8protocol_WriteBuffer++] = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)o);
+  } else {
+    (*Py_TYPE(o)->tp_free)(o);
+  }
+}
+
+static PyMethodDef __pyx_methods_7asyncpg_8protocol_8protocol_WriteBuffer[] = {
+  {0, 0, 0, 0}
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_WriteBuffer = {
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getreadbuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getwritebuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getsegcount*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getcharbuffer*/
+  #endif
+  __pyx_pw_7asyncpg_8protocol_8protocol_11WriteBuffer_5__getbuffer__, /*bf_getbuffer*/
+  __pyx_pw_7asyncpg_8protocol_8protocol_11WriteBuffer_7__releasebuffer__, /*bf_releasebuffer*/
+};
+
+static PyTypeObject __pyx_type_7asyncpg_8protocol_8protocol_WriteBuffer = {
+  PyVarObject_HEAD_INIT(0, 0)
+  "asyncpg.protocol.protocol.WriteBuffer", /*tp_name*/
+  sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_7asyncpg_8protocol_8protocol_WriteBuffer, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #endif
+  #if PY_MAJOR_VERSION >= 3
+  0, /*tp_as_async*/
+  #endif
+  0, /*tp_repr*/
+  0, /*tp_as_number*/
+  0, /*tp_as_sequence*/
+  0, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_WriteBuffer, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
+  0, /*tp_doc*/
+  0, /*tp_traverse*/
+  0, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_7asyncpg_8protocol_8protocol_WriteBuffer, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_7asyncpg_8protocol_8protocol_WriteBuffer, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  0, /*tp_version_tag*/
+  #if PY_VERSION_HEX >= 0x030400a1
+  0, /*tp_finalize*/
+  #endif
+};
+static struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_ReadBuffer __pyx_vtable_7asyncpg_8protocol_8protocol_ReadBuffer;
+
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_freelist_7asyncpg_8protocol_8protocol_ReadBuffer[256];
+static int __pyx_freecount_7asyncpg_8protocol_8protocol_ReadBuffer = 0;
+
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol_ReadBuffer(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *p;
+  PyObject *o;
+  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_7asyncpg_8protocol_8protocol_ReadBuffer > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer)))) {
+    o = (PyObject*)__pyx_freelist_7asyncpg_8protocol_8protocol_ReadBuffer[--__pyx_freecount_7asyncpg_8protocol_8protocol_ReadBuffer];
+    memset(o, 0, sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer));
+    (void) PyObject_INIT(o, t);
+    PyObject_GC_Track(o);
+  } else {
+    o = (*t->tp_alloc)(t, 0);
+    if (unlikely(!o)) return 0;
+  }
+  p = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *)o);
+  p->__pyx_vtab = __pyx_vtabptr_7asyncpg_8protocol_8protocol_ReadBuffer;
+  p->_bufs = Py_None; Py_INCREF(Py_None);
+  p->_bufs_append = Py_None; Py_INCREF(Py_None);
+  p->_bufs_popleft = Py_None; Py_INCREF(Py_None);
+  p->_buf0 = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  p->_buf0_prev = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  if (unlikely(__pyx_pw_7asyncpg_8protocol_8protocol_10ReadBuffer_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) goto bad;
+  return o;
+  bad:
+  Py_DECREF(o); o = 0;
+  return NULL;
+}
+
+static void __pyx_tp_dealloc_7asyncpg_8protocol_8protocol_ReadBuffer(PyObject *o) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *)o;
+  PyObject_GC_UnTrack(o);
+  Py_CLEAR(p->_bufs);
+  Py_CLEAR(p->_bufs_append);
+  Py_CLEAR(p->_bufs_popleft);
+  Py_CLEAR(p->_buf0);
+  Py_CLEAR(p->_buf0_prev);
+  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7asyncpg_8protocol_8protocol_ReadBuffer < 256) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer)))) {
+    __pyx_freelist_7asyncpg_8protocol_8protocol_ReadBuffer[__pyx_freecount_7asyncpg_8protocol_8protocol_ReadBuffer++] = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *)o);
+  } else {
+    (*Py_TYPE(o)->tp_free)(o);
+  }
+}
+
+static int __pyx_tp_traverse_7asyncpg_8protocol_8protocol_ReadBuffer(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *)o;
+  if (p->_bufs) {
+    e = (*v)(p->_bufs, a); if (e) return e;
+  }
+  if (p->_bufs_append) {
+    e = (*v)(p->_bufs_append, a); if (e) return e;
+  }
+  if (p->_bufs_popleft) {
+    e = (*v)(p->_bufs_popleft, a); if (e) return e;
+  }
+  return 0;
+}
+
+static PyMethodDef __pyx_methods_7asyncpg_8protocol_8protocol_ReadBuffer[] = {
+  {0, 0, 0, 0}
+};
+
+static PyTypeObject __pyx_type_7asyncpg_8protocol_8protocol_ReadBuffer = {
+  PyVarObject_HEAD_INIT(0, 0)
+  "asyncpg.protocol.protocol.ReadBuffer", /*tp_name*/
+  sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_7asyncpg_8protocol_8protocol_ReadBuffer, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #endif
+  #if PY_MAJOR_VERSION >= 3
+  0, /*tp_as_async*/
+  #endif
+  0, /*tp_repr*/
+  0, /*tp_as_number*/
+  0, /*tp_as_sequence*/
+  0, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  0, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  0, /*tp_doc*/
+  __pyx_tp_traverse_7asyncpg_8protocol_8protocol_ReadBuffer, /*tp_traverse*/
+  0, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_7asyncpg_8protocol_8protocol_ReadBuffer, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_7asyncpg_8protocol_8protocol_ReadBuffer, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  0, /*tp_version_tag*/
+  #if PY_VERSION_HEX >= 0x030400a1
+  0, /*tp_finalize*/
+  #endif
+};
+static struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_FastReadBuffer __pyx_vtable_7asyncpg_8protocol_8protocol_FastReadBuffer;
+
+static struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_freelist_7asyncpg_8protocol_8protocol_FastReadBuffer[256];
+static int __pyx_freecount_7asyncpg_8protocol_8protocol_FastReadBuffer = 0;
+
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol_FastReadBuffer(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *p;
+  PyObject *o;
+  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_7asyncpg_8protocol_8protocol_FastReadBuffer > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer)))) {
+    o = (PyObject*)__pyx_freelist_7asyncpg_8protocol_8protocol_FastReadBuffer[--__pyx_freecount_7asyncpg_8protocol_8protocol_FastReadBuffer];
+    memset(o, 0, sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer));
+    (void) PyObject_INIT(o, t);
+  } else {
+    o = (*t->tp_alloc)(t, 0);
+    if (unlikely(!o)) return 0;
+  }
+  p = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *)o);
+  p->__pyx_vtab = __pyx_vtabptr_7asyncpg_8protocol_8protocol_FastReadBuffer;
+  return o;
+}
+
+static void __pyx_tp_dealloc_7asyncpg_8protocol_8protocol_FastReadBuffer(PyObject *o) {
+  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7asyncpg_8protocol_8protocol_FastReadBuffer < 256) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer)))) {
+    __pyx_freelist_7asyncpg_8protocol_8protocol_FastReadBuffer[__pyx_freecount_7asyncpg_8protocol_8protocol_FastReadBuffer++] = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *)o);
+  } else {
+    (*Py_TYPE(o)->tp_free)(o);
+  }
+}
+
+static PyTypeObject __pyx_type_7asyncpg_8protocol_8protocol_FastReadBuffer = {
+  PyVarObject_HEAD_INIT(0, 0)
+  "asyncpg.protocol.protocol.FastReadBuffer", /*tp_name*/
+  sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_7asyncpg_8protocol_8protocol_FastReadBuffer, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #endif
+  #if PY_MAJOR_VERSION >= 3
+  0, /*tp_as_async*/
+  #endif
+  0, /*tp_repr*/
+  0, /*tp_as_number*/
+  0, /*tp_as_sequence*/
+  0, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  0, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
+  0, /*tp_doc*/
+  0, /*tp_traverse*/
+  0, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  0, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_7asyncpg_8protocol_8protocol_FastReadBuffer, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  0, /*tp_version_tag*/
+  #if PY_VERSION_HEX >= 0x030400a1
+  0, /*tp_finalize*/
+  #endif
+};
+static struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_Codec __pyx_vtable_7asyncpg_8protocol_8protocol_Codec;
+
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol_Codec(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *p;
+  PyObject *o;
+  o = (*t->tp_alloc)(t, 0);
+  if (unlikely(!o)) return 0;
+  p = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)o);
+  p->__pyx_vtab = __pyx_vtabptr_7asyncpg_8protocol_8protocol_Codec;
+  p->name = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  p->schema = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  p->kind = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  p->py_encoder = Py_None; Py_INCREF(Py_None);
+  p->py_decoder = Py_None; Py_INCREF(Py_None);
+  p->element_codec = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)Py_None); Py_INCREF(Py_None);
+  p->element_type_oids = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  p->element_names = Py_None; Py_INCREF(Py_None);
+  p->element_codecs = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  if (unlikely(__pyx_pw_7asyncpg_8protocol_8protocol_5Codec_1__cinit__(o, a, k) < 0)) goto bad;
+  return o;
+  bad:
+  Py_DECREF(o); o = 0;
+  return NULL;
+}
+
+static void __pyx_tp_dealloc_7asyncpg_8protocol_8protocol_Codec(PyObject *o) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)o;
+  PyObject_GC_UnTrack(o);
+  Py_CLEAR(p->name);
+  Py_CLEAR(p->schema);
+  Py_CLEAR(p->kind);
+  Py_CLEAR(p->py_encoder);
+  Py_CLEAR(p->py_decoder);
+  Py_CLEAR(p->element_codec);
+  Py_CLEAR(p->element_type_oids);
+  Py_CLEAR(p->element_names);
+  Py_CLEAR(p->element_codecs);
+  (*Py_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_7asyncpg_8protocol_8protocol_Codec(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)o;
+  if (p->py_encoder) {
+    e = (*v)(p->py_encoder, a); if (e) return e;
+  }
+  if (p->py_decoder) {
+    e = (*v)(p->py_decoder, a); if (e) return e;
+  }
+  if (p->element_codec) {
+    e = (*v)(((PyObject*)p->element_codec), a); if (e) return e;
+  }
+  if (p->element_type_oids) {
+    e = (*v)(p->element_type_oids, a); if (e) return e;
+  }
+  if (p->element_names) {
+    e = (*v)(p->element_names, a); if (e) return e;
+  }
+  if (p->element_codecs) {
+    e = (*v)(p->element_codecs, a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_7asyncpg_8protocol_8protocol_Codec(PyObject *o) {
+  PyObject* tmp;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)o;
+  tmp = ((PyObject*)p->py_encoder);
+  p->py_encoder = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->py_decoder);
+  p->py_decoder = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->element_codec);
+  p->element_codec = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->element_type_oids);
+  p->element_type_oids = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->element_names);
+  p->element_names = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->element_codecs);
+  p->element_codecs = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+
+static PyMethodDef __pyx_methods_7asyncpg_8protocol_8protocol_Codec[] = {
+  {0, 0, 0, 0}
+};
+
+static PyTypeObject __pyx_type_7asyncpg_8protocol_8protocol_Codec = {
+  PyVarObject_HEAD_INIT(0, 0)
+  "asyncpg.protocol.protocol.Codec", /*tp_name*/
+  sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_7asyncpg_8protocol_8protocol_Codec, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #endif
+  #if PY_MAJOR_VERSION >= 3
+  0, /*tp_as_async*/
+  #endif
+  __pyx_pw_7asyncpg_8protocol_8protocol_5Codec_3__repr__, /*tp_repr*/
+  0, /*tp_as_number*/
+  0, /*tp_as_sequence*/
+  0, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  0, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  0, /*tp_doc*/
+  __pyx_tp_traverse_7asyncpg_8protocol_8protocol_Codec, /*tp_traverse*/
+  __pyx_tp_clear_7asyncpg_8protocol_8protocol_Codec, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_7asyncpg_8protocol_8protocol_Codec, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_7asyncpg_8protocol_8protocol_Codec, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  0, /*tp_version_tag*/
+  #if PY_VERSION_HEX >= 0x030400a1
+  0, /*tp_finalize*/
+  #endif
+};
+static struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_DataCodecConfig __pyx_vtable_7asyncpg_8protocol_8protocol_DataCodecConfig;
+
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol_DataCodecConfig(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *p;
+  PyObject *o;
+  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
+    o = (*t->tp_alloc)(t, 0);
+  } else {
+    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
+  }
+  if (unlikely(!o)) return 0;
+  p = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *)o);
+  p->__pyx_vtab = __pyx_vtabptr_7asyncpg_8protocol_8protocol_DataCodecConfig;
+  p->_type_codecs_cache = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  p->_local_type_codecs = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  return o;
+}
+
+static void __pyx_tp_dealloc_7asyncpg_8protocol_8protocol_DataCodecConfig(PyObject *o) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *)o;
+  #if PY_VERSION_HEX >= 0x030400a1
+  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
+    if (PyObject_CallFinalizerFromDealloc(o)) return;
+  }
+  #endif
+  PyObject_GC_UnTrack(o);
+  Py_CLEAR(p->_type_codecs_cache);
+  Py_CLEAR(p->_local_type_codecs);
+  (*Py_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_7asyncpg_8protocol_8protocol_DataCodecConfig(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *)o;
+  if (p->_type_codecs_cache) {
+    e = (*v)(p->_type_codecs_cache, a); if (e) return e;
+  }
+  if (p->_local_type_codecs) {
+    e = (*v)(p->_local_type_codecs, a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_7asyncpg_8protocol_8protocol_DataCodecConfig(PyObject *o) {
+  PyObject* tmp;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *)o;
+  tmp = ((PyObject*)p->_type_codecs_cache);
+  p->_type_codecs_cache = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->_local_type_codecs);
+  p->_local_type_codecs = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+
+static PyMethodDef __pyx_methods_7asyncpg_8protocol_8protocol_DataCodecConfig[] = {
+  {"add_types", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_3add_types, METH_O, 0},
+  {"add_python_codec", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_5add_python_codec, METH_VARARGS|METH_KEYWORDS, 0},
+  {"set_builtin_type_codec", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_7set_builtin_type_codec, METH_VARARGS|METH_KEYWORDS, 0},
+  {"clear_type_cache", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_9clear_type_cache, METH_NOARGS, 0},
+  {0, 0, 0, 0}
+};
+
+static PyTypeObject __pyx_type_7asyncpg_8protocol_8protocol_DataCodecConfig = {
+  PyVarObject_HEAD_INIT(0, 0)
+  "asyncpg.protocol.protocol.DataCodecConfig", /*tp_name*/
+  sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_7asyncpg_8protocol_8protocol_DataCodecConfig, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #endif
+  #if PY_MAJOR_VERSION >= 3
+  0, /*tp_as_async*/
+  #endif
+  0, /*tp_repr*/
+  0, /*tp_as_number*/
+  0, /*tp_as_sequence*/
+  0, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  0, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  0, /*tp_doc*/
+  __pyx_tp_traverse_7asyncpg_8protocol_8protocol_DataCodecConfig, /*tp_traverse*/
+  __pyx_tp_clear_7asyncpg_8protocol_8protocol_DataCodecConfig, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_7asyncpg_8protocol_8protocol_DataCodecConfig, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  __pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_1__init__, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_7asyncpg_8protocol_8protocol_DataCodecConfig, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  0, /*tp_version_tag*/
+  #if PY_VERSION_HEX >= 0x030400a1
+  0, /*tp_finalize*/
+  #endif
+};
+static struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_ConnectionSettings __pyx_vtable_7asyncpg_8protocol_8protocol_ConnectionSettings;
+
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol_ConnectionSettings(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *p;
+  PyObject *o;
+  o = (*t->tp_alloc)(t, 0);
+  if (unlikely(!o)) return 0;
+  p = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *)o);
+  p->__pyx_vtab = __pyx_vtabptr_7asyncpg_8protocol_8protocol_ConnectionSettings;
+  p->_encoding = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  p->_codec = Py_None; Py_INCREF(Py_None);
+  p->_settings = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  p->_data_codecs = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *)Py_None); Py_INCREF(Py_None);
+  if (unlikely(__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_1__cinit__(o, a, k) < 0)) goto bad;
+  return o;
+  bad:
+  Py_DECREF(o); o = 0;
+  return NULL;
+}
+
+static void __pyx_tp_dealloc_7asyncpg_8protocol_8protocol_ConnectionSettings(PyObject *o) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *)o;
+  PyObject_GC_UnTrack(o);
+  Py_CLEAR(p->_encoding);
+  Py_CLEAR(p->_codec);
+  Py_CLEAR(p->_settings);
+  Py_CLEAR(p->_data_codecs);
+  (*Py_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_7asyncpg_8protocol_8protocol_ConnectionSettings(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *)o;
+  if (p->_codec) {
+    e = (*v)(p->_codec, a); if (e) return e;
+  }
+  if (p->_settings) {
+    e = (*v)(p->_settings, a); if (e) return e;
+  }
+  if (p->_data_codecs) {
+    e = (*v)(((PyObject*)p->_data_codecs), a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_7asyncpg_8protocol_8protocol_ConnectionSettings(PyObject *o) {
+  PyObject* tmp;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *)o;
+  tmp = ((PyObject*)p->_codec);
+  p->_codec = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->_settings);
+  p->_settings = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->_data_codecs);
+  p->_data_codecs = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+
+static PyObject *__pyx_tp_getattro_7asyncpg_8protocol_8protocol_ConnectionSettings(PyObject *o, PyObject *n) {
+  PyObject *v = PyObject_GenericGetAttr(o, n);
+  if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) {
+    PyErr_Clear();
+    v = __pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_13__getattr__(o, n);
+  }
+  return v;
+}
+
+static PyMethodDef __pyx_methods_7asyncpg_8protocol_8protocol_ConnectionSettings[] = {
+  {"get_text_codec", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_3get_text_codec, METH_NOARGS, 0},
+  {"register_data_types", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_5register_data_types, METH_O, 0},
+  {"add_python_codec", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_7add_python_codec, METH_VARARGS|METH_KEYWORDS, 0},
+  {"set_builtin_type_codec", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_9set_builtin_type_codec, METH_VARARGS|METH_KEYWORDS, 0},
+  {"get_data_codec", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_11get_data_codec, METH_VARARGS|METH_KEYWORDS, 0},
+  {"__getattr__", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_13__getattr__, METH_O|METH_COEXIST, 0},
+  {0, 0, 0, 0}
+};
+
+static PyTypeObject __pyx_type_7asyncpg_8protocol_8protocol_ConnectionSettings = {
+  PyVarObject_HEAD_INIT(0, 0)
+  "asyncpg.protocol.protocol.ConnectionSettings", /*tp_name*/
+  sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_7asyncpg_8protocol_8protocol_ConnectionSettings, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #endif
+  #if PY_MAJOR_VERSION >= 3
+  0, /*tp_as_async*/
+  #endif
+  0, /*tp_repr*/
+  0, /*tp_as_number*/
+  0, /*tp_as_sequence*/
+  0, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  __pyx_tp_getattro_7asyncpg_8protocol_8protocol_ConnectionSettings, /*tp_getattro*/
+  0, /*tp_setattro*/
+  0, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  0, /*tp_doc*/
+  __pyx_tp_traverse_7asyncpg_8protocol_8protocol_ConnectionSettings, /*tp_traverse*/
+  __pyx_tp_clear_7asyncpg_8protocol_8protocol_ConnectionSettings, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_7asyncpg_8protocol_8protocol_ConnectionSettings, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_7asyncpg_8protocol_8protocol_ConnectionSettings, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  0, /*tp_version_tag*/
+  #if PY_VERSION_HEX >= 0x030400a1
+  0, /*tp_finalize*/
+  #endif
+};
+static struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol;
+
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol_CoreProtocol(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *p;
+  PyObject *o;
+  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
+    o = (*t->tp_alloc)(t, 0);
+  } else {
+    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
+  }
+  if (unlikely(!o)) return 0;
+  p = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)o);
+  p->__pyx_vtab = __pyx_vtabptr_7asyncpg_8protocol_8protocol_CoreProtocol;
+  p->buffer = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *)Py_None); Py_INCREF(Py_None);
+  p->_execute_iter = Py_None; Py_INCREF(Py_None);
+  p->_execute_portal_name = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  p->_execute_stmt_name = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  p->encoding = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  p->transport = Py_None; Py_INCREF(Py_None);
+  p->con_args = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  p->result = Py_None; Py_INCREF(Py_None);
+  p->result_param_desc = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  p->result_row_desc = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  p->result_status_msg = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  return o;
+}
+
+static void __pyx_tp_dealloc_7asyncpg_8protocol_8protocol_CoreProtocol(PyObject *o) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)o;
+  #if PY_VERSION_HEX >= 0x030400a1
+  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
+    if (PyObject_CallFinalizerFromDealloc(o)) return;
+  }
+  #endif
+  PyObject_GC_UnTrack(o);
+  Py_CLEAR(p->buffer);
+  Py_CLEAR(p->_execute_iter);
+  Py_CLEAR(p->_execute_portal_name);
+  Py_CLEAR(p->_execute_stmt_name);
+  Py_CLEAR(p->encoding);
+  Py_CLEAR(p->transport);
+  Py_CLEAR(p->con_args);
+  Py_CLEAR(p->result);
+  Py_CLEAR(p->result_param_desc);
+  Py_CLEAR(p->result_row_desc);
+  Py_CLEAR(p->result_status_msg);
+  (*Py_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_7asyncpg_8protocol_8protocol_CoreProtocol(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)o;
+  if (p->buffer) {
+    e = (*v)(((PyObject*)p->buffer), a); if (e) return e;
+  }
+  if (p->_execute_iter) {
+    e = (*v)(p->_execute_iter, a); if (e) return e;
+  }
+  if (p->transport) {
+    e = (*v)(p->transport, a); if (e) return e;
+  }
+  if (p->con_args) {
+    e = (*v)(p->con_args, a); if (e) return e;
+  }
+  if (p->result) {
+    e = (*v)(p->result, a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_7asyncpg_8protocol_8protocol_CoreProtocol(PyObject *o) {
+  PyObject* tmp;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)o;
+  tmp = ((PyObject*)p->buffer);
+  p->buffer = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->_execute_iter);
+  p->_execute_iter = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->transport);
+  p->transport = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->con_args);
+  p->con_args = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->result);
+  p->result = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+
+static PyObject *__pyx_getprop_7asyncpg_8protocol_8protocol_12CoreProtocol_backend_pid(PyObject *o, CYTHON_UNUSED void *x) {
+  return __pyx_pw_7asyncpg_8protocol_8protocol_12CoreProtocol_11backend_pid_1__get__(o);
+}
+
+static PyObject *__pyx_getprop_7asyncpg_8protocol_8protocol_12CoreProtocol_backend_secret(PyObject *o, CYTHON_UNUSED void *x) {
+  return __pyx_pw_7asyncpg_8protocol_8protocol_12CoreProtocol_14backend_secret_1__get__(o);
+}
+
+static PyMethodDef __pyx_methods_7asyncpg_8protocol_8protocol_CoreProtocol[] = {
+  {"data_received", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12CoreProtocol_3data_received, METH_O, 0},
+  {"connection_made", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12CoreProtocol_5connection_made, METH_O, 0},
+  {"connection_lost", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12CoreProtocol_7connection_lost, METH_O, 0},
+  {0, 0, 0, 0}
+};
+
+static struct PyGetSetDef __pyx_getsets_7asyncpg_8protocol_8protocol_CoreProtocol[] = {
+  {(char *)"backend_pid", __pyx_getprop_7asyncpg_8protocol_8protocol_12CoreProtocol_backend_pid, 0, (char *)0, 0},
+  {(char *)"backend_secret", __pyx_getprop_7asyncpg_8protocol_8protocol_12CoreProtocol_backend_secret, 0, (char *)0, 0},
+  {0, 0, 0, 0, 0}
+};
+
+static PyTypeObject __pyx_type_7asyncpg_8protocol_8protocol_CoreProtocol = {
+  PyVarObject_HEAD_INIT(0, 0)
+  "asyncpg.protocol.protocol.CoreProtocol", /*tp_name*/
+  sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_7asyncpg_8protocol_8protocol_CoreProtocol, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #endif
+  #if PY_MAJOR_VERSION >= 3
+  0, /*tp_as_async*/
+  #endif
+  0, /*tp_repr*/
+  0, /*tp_as_number*/
+  0, /*tp_as_sequence*/
+  0, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  0, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  0, /*tp_doc*/
+  __pyx_tp_traverse_7asyncpg_8protocol_8protocol_CoreProtocol, /*tp_traverse*/
+  __pyx_tp_clear_7asyncpg_8protocol_8protocol_CoreProtocol, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_7asyncpg_8protocol_8protocol_CoreProtocol, /*tp_methods*/
+  0, /*tp_members*/
+  __pyx_getsets_7asyncpg_8protocol_8protocol_CoreProtocol, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  __pyx_pw_7asyncpg_8protocol_8protocol_12CoreProtocol_1__init__, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_7asyncpg_8protocol_8protocol_CoreProtocol, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  0, /*tp_version_tag*/
+  #if PY_VERSION_HEX >= 0x030400a1
+  0, /*tp_finalize*/
+  #endif
+};
+static struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_PreparedStatementState __pyx_vtable_7asyncpg_8protocol_8protocol_PreparedStatementState;
+
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol_PreparedStatementState(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *p;
+  PyObject *o;
+  o = (*t->tp_alloc)(t, 0);
+  if (unlikely(!o)) return 0;
+  p = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)o);
+  p->__pyx_vtab = __pyx_vtabptr_7asyncpg_8protocol_8protocol_PreparedStatementState;
+  p->name = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  p->query = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  p->buffer = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *)Py_None); Py_INCREF(Py_None);
+  p->row_desc = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  p->parameters_desc = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  p->protocol = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)Py_None); Py_INCREF(Py_None);
+  p->settings = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *)Py_None); Py_INCREF(Py_None);
+  p->args_codecs = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  p->cols_desc = Py_None; Py_INCREF(Py_None);
+  p->rows_codecs = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  if (unlikely(__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_1__cinit__(o, a, k) < 0)) goto bad;
+  return o;
+  bad:
+  Py_DECREF(o); o = 0;
+  return NULL;
+}
+
+static void __pyx_tp_dealloc_7asyncpg_8protocol_8protocol_PreparedStatementState(PyObject *o) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)o;
+  PyObject_GC_UnTrack(o);
+  Py_CLEAR(p->name);
+  Py_CLEAR(p->query);
+  Py_CLEAR(p->buffer);
+  Py_CLEAR(p->row_desc);
+  Py_CLEAR(p->parameters_desc);
+  Py_CLEAR(p->protocol);
+  Py_CLEAR(p->settings);
+  Py_CLEAR(p->args_codecs);
+  Py_CLEAR(p->cols_desc);
+  Py_CLEAR(p->rows_codecs);
+  (*Py_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_7asyncpg_8protocol_8protocol_PreparedStatementState(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)o;
+  if (p->buffer) {
+    e = (*v)(((PyObject*)p->buffer), a); if (e) return e;
+  }
+  if (p->row_desc) {
+    e = (*v)(p->row_desc, a); if (e) return e;
+  }
+  if (p->parameters_desc) {
+    e = (*v)(p->parameters_desc, a); if (e) return e;
+  }
+  if (p->protocol) {
+    e = (*v)(((PyObject*)p->protocol), a); if (e) return e;
+  }
+  if (p->settings) {
+    e = (*v)(((PyObject*)p->settings), a); if (e) return e;
+  }
+  if (p->args_codecs) {
+    e = (*v)(p->args_codecs, a); if (e) return e;
+  }
+  if (p->cols_desc) {
+    e = (*v)(p->cols_desc, a); if (e) return e;
+  }
+  if (p->rows_codecs) {
+    e = (*v)(p->rows_codecs, a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_7asyncpg_8protocol_8protocol_PreparedStatementState(PyObject *o) {
+  PyObject* tmp;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)o;
+  tmp = ((PyObject*)p->buffer);
+  p->buffer = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->row_desc);
+  p->row_desc = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->parameters_desc);
+  p->parameters_desc = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->protocol);
+  p->protocol = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->settings);
+  p->settings = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->args_codecs);
+  p->args_codecs = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->cols_desc);
+  p->cols_desc = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->rows_codecs);
+  p->rows_codecs = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+
+static PyObject *__pyx_getprop_7asyncpg_8protocol_8protocol_22PreparedStatementState_name(PyObject *o, CYTHON_UNUSED void *x) {
+  return __pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_4name_1__get__(o);
+}
+
+static PyObject *__pyx_getprop_7asyncpg_8protocol_8protocol_22PreparedStatementState_query(PyObject *o, CYTHON_UNUSED void *x) {
+  return __pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_5query_1__get__(o);
+}
+
+static PyObject *__pyx_getprop_7asyncpg_8protocol_8protocol_22PreparedStatementState_closed(PyObject *o, CYTHON_UNUSED void *x) {
+  return __pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_6closed_1__get__(o);
+}
+
+static PyObject *__pyx_getprop_7asyncpg_8protocol_8protocol_22PreparedStatementState_refs(PyObject *o, CYTHON_UNUSED void *x) {
+  return __pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_4refs_1__get__(o);
+}
+
+static PyMethodDef __pyx_methods_7asyncpg_8protocol_8protocol_PreparedStatementState[] = {
+  {"_get_parameters", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_3_get_parameters, METH_NOARGS, 0},
+  {"_get_attributes", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_5_get_attributes, METH_NOARGS, 0},
+  {"_init_types", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_7_init_types, METH_NOARGS, 0},
+  {"attach", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_9attach, METH_NOARGS, 0},
+  {"detach", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_11detach, METH_NOARGS, 0},
+  {"mark_closed", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_13mark_closed, METH_NOARGS, 0},
+  {0, 0, 0, 0}
+};
+
+static struct PyGetSetDef __pyx_getsets_7asyncpg_8protocol_8protocol_PreparedStatementState[] = {
+  {(char *)"name", __pyx_getprop_7asyncpg_8protocol_8protocol_22PreparedStatementState_name, 0, (char *)0, 0},
+  {(char *)"query", __pyx_getprop_7asyncpg_8protocol_8protocol_22PreparedStatementState_query, 0, (char *)0, 0},
+  {(char *)"closed", __pyx_getprop_7asyncpg_8protocol_8protocol_22PreparedStatementState_closed, 0, (char *)0, 0},
+  {(char *)"refs", __pyx_getprop_7asyncpg_8protocol_8protocol_22PreparedStatementState_refs, 0, (char *)0, 0},
+  {0, 0, 0, 0, 0}
+};
+
+static PyTypeObject __pyx_type_7asyncpg_8protocol_8protocol_PreparedStatementState = {
+  PyVarObject_HEAD_INIT(0, 0)
+  "asyncpg.protocol.protocol.PreparedStatementState", /*tp_name*/
+  sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_7asyncpg_8protocol_8protocol_PreparedStatementState, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #endif
+  #if PY_MAJOR_VERSION >= 3
+  0, /*tp_as_async*/
+  #endif
+  0, /*tp_repr*/
+  0, /*tp_as_number*/
+  0, /*tp_as_sequence*/
+  0, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  0, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  0, /*tp_doc*/
+  __pyx_tp_traverse_7asyncpg_8protocol_8protocol_PreparedStatementState, /*tp_traverse*/
+  __pyx_tp_clear_7asyncpg_8protocol_8protocol_PreparedStatementState, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_7asyncpg_8protocol_8protocol_PreparedStatementState, /*tp_methods*/
+  0, /*tp_members*/
+  __pyx_getsets_7asyncpg_8protocol_8protocol_PreparedStatementState, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_7asyncpg_8protocol_8protocol_PreparedStatementState, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  0, /*tp_version_tag*/
+  #if PY_VERSION_HEX >= 0x030400a1
+  0, /*tp_finalize*/
+  #endif
+};
+static struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol __pyx_vtable_7asyncpg_8protocol_8protocol_BaseProtocol;
+
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol_BaseProtocol(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *p;
+  PyObject *o = __pyx_tp_new_7asyncpg_8protocol_8protocol_CoreProtocol(t, a, k);
+  if (unlikely(!o)) return 0;
+  p = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)o);
+  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol*)__pyx_vtabptr_7asyncpg_8protocol_8protocol_BaseProtocol;
+  p->loop = Py_None; Py_INCREF(Py_None);
+  p->address = Py_None; Py_INCREF(Py_None);
+  p->settings = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *)Py_None); Py_INCREF(Py_None);
+  p->cancel_sent_waiter = Py_None; Py_INCREF(Py_None);
+  p->cancel_waiter = Py_None; Py_INCREF(Py_None);
+  p->waiter = Py_None; Py_INCREF(Py_None);
+  p->create_future = Py_None; Py_INCREF(Py_None);
+  p->timeout_handle = Py_None; Py_INCREF(Py_None);
+  p->timeout_callback = Py_None; Py_INCREF(Py_None);
+  p->completed_callback = Py_None; Py_INCREF(Py_None);
+  p->connection = Py_None; Py_INCREF(Py_None);
+  p->last_query = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  p->statement = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)Py_None); Py_INCREF(Py_None);
+  return o;
+}
+
+static void __pyx_tp_dealloc_7asyncpg_8protocol_8protocol_BaseProtocol(PyObject *o) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)o;
+  #if PY_VERSION_HEX >= 0x030400a1
+  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
+    if (PyObject_CallFinalizerFromDealloc(o)) return;
+  }
+  #endif
+  PyObject_GC_UnTrack(o);
+  Py_CLEAR(p->loop);
+  Py_CLEAR(p->address);
+  Py_CLEAR(p->settings);
+  Py_CLEAR(p->cancel_sent_waiter);
+  Py_CLEAR(p->cancel_waiter);
+  Py_CLEAR(p->waiter);
+  Py_CLEAR(p->create_future);
+  Py_CLEAR(p->timeout_handle);
+  Py_CLEAR(p->timeout_callback);
+  Py_CLEAR(p->completed_callback);
+  Py_CLEAR(p->connection);
+  Py_CLEAR(p->last_query);
+  Py_CLEAR(p->statement);
+  PyObject_GC_Track(o);
+  __pyx_tp_dealloc_7asyncpg_8protocol_8protocol_CoreProtocol(o);
+}
+
+static int __pyx_tp_traverse_7asyncpg_8protocol_8protocol_BaseProtocol(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)o;
+  e = __pyx_tp_traverse_7asyncpg_8protocol_8protocol_CoreProtocol(o, v, a); if (e) return e;
+  if (p->loop) {
+    e = (*v)(p->loop, a); if (e) return e;
+  }
+  if (p->address) {
+    e = (*v)(p->address, a); if (e) return e;
+  }
+  if (p->settings) {
+    e = (*v)(((PyObject*)p->settings), a); if (e) return e;
+  }
+  if (p->cancel_sent_waiter) {
+    e = (*v)(p->cancel_sent_waiter, a); if (e) return e;
+  }
+  if (p->cancel_waiter) {
+    e = (*v)(p->cancel_waiter, a); if (e) return e;
+  }
+  if (p->waiter) {
+    e = (*v)(p->waiter, a); if (e) return e;
+  }
+  if (p->create_future) {
+    e = (*v)(p->create_future, a); if (e) return e;
+  }
+  if (p->timeout_handle) {
+    e = (*v)(p->timeout_handle, a); if (e) return e;
+  }
+  if (p->timeout_callback) {
+    e = (*v)(p->timeout_callback, a); if (e) return e;
+  }
+  if (p->completed_callback) {
+    e = (*v)(p->completed_callback, a); if (e) return e;
+  }
+  if (p->connection) {
+    e = (*v)(p->connection, a); if (e) return e;
+  }
+  if (p->statement) {
+    e = (*v)(((PyObject*)p->statement), a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_7asyncpg_8protocol_8protocol_BaseProtocol(PyObject *o) {
+  PyObject* tmp;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)o;
+  __pyx_tp_clear_7asyncpg_8protocol_8protocol_CoreProtocol(o);
+  tmp = ((PyObject*)p->loop);
+  p->loop = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->address);
+  p->address = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->settings);
+  p->settings = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->cancel_sent_waiter);
+  p->cancel_sent_waiter = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->cancel_waiter);
+  p->cancel_waiter = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->waiter);
+  p->waiter = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->create_future);
+  p->create_future = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->timeout_handle);
+  p->timeout_handle = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->timeout_callback);
+  p->timeout_callback = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->completed_callback);
+  p->completed_callback = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->connection);
+  p->connection = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->statement);
+  p->statement = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+
+static PyObject *__pyx_getprop_7asyncpg_8protocol_8protocol_12BaseProtocol_queries_count(PyObject *o, CYTHON_UNUSED void *x) {
+  return __pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_13queries_count_1__get__(o);
+}
+
+static PyMethodDef __pyx_methods_7asyncpg_8protocol_8protocol_BaseProtocol[] = {
+  {"set_connection", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_3set_connection, METH_O, 0},
+  {"get_server_pid", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_5get_server_pid, METH_NOARGS, 0},
+  {"get_settings", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_7get_settings, METH_NOARGS, 0},
+  {"prepare", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_9prepare, METH_VARARGS|METH_KEYWORDS, 0},
+  {"bind_execute", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_12bind_execute, METH_VARARGS|METH_KEYWORDS, 0},
+  {"bind_execute_many", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_15bind_execute_many, METH_VARARGS|METH_KEYWORDS, 0},
+  {"bind", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_18bind, METH_VARARGS|METH_KEYWORDS, 0},
+  {"execute", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_21execute, METH_VARARGS|METH_KEYWORDS, 0},
+  {"query", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_24query, METH_VARARGS|METH_KEYWORDS, 0},
+  {"close_statement", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_27close_statement, METH_VARARGS|METH_KEYWORDS, 0},
+  {"is_closed", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_30is_closed, METH_NOARGS, 0},
+  {"is_connected", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_32is_connected, METH_NOARGS, 0},
+  {"abort", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_34abort, METH_NOARGS, 0},
+  {"close", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_36close, METH_NOARGS, 0},
+  {"_request_cancel", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_39_request_cancel, METH_NOARGS, 0},
+  {"_on_timeout", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_41_on_timeout, METH_O, 0},
+  {"_on_waiter_completed", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_43_on_waiter_completed, METH_O, 0},
+  {"_create_future_fallback", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_45_create_future_fallback, METH_NOARGS, 0},
+  {0, 0, 0, 0}
+};
+
+static struct PyGetSetDef __pyx_getsets_7asyncpg_8protocol_8protocol_BaseProtocol[] = {
+  {(char *)"queries_count", __pyx_getprop_7asyncpg_8protocol_8protocol_12BaseProtocol_queries_count, 0, (char *)0, 0},
+  {0, 0, 0, 0, 0}
+};
+
+static PyTypeObject __pyx_type_7asyncpg_8protocol_8protocol_BaseProtocol = {
+  PyVarObject_HEAD_INIT(0, 0)
+  "asyncpg.protocol.protocol.BaseProtocol", /*tp_name*/
+  sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_7asyncpg_8protocol_8protocol_BaseProtocol, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #endif
+  #if PY_MAJOR_VERSION >= 3
+  0, /*tp_as_async*/
+  #endif
+  0, /*tp_repr*/
+  0, /*tp_as_number*/
+  0, /*tp_as_sequence*/
+  0, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  0, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  0, /*tp_doc*/
+  __pyx_tp_traverse_7asyncpg_8protocol_8protocol_BaseProtocol, /*tp_traverse*/
+  __pyx_tp_clear_7asyncpg_8protocol_8protocol_BaseProtocol, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_7asyncpg_8protocol_8protocol_BaseProtocol, /*tp_methods*/
+  0, /*tp_members*/
+  __pyx_getsets_7asyncpg_8protocol_8protocol_BaseProtocol, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  __pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_1__init__, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_7asyncpg_8protocol_8protocol_BaseProtocol, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  0, /*tp_version_tag*/
+  #if PY_VERSION_HEX >= 0x030400a1
+  0, /*tp_finalize*/
+  #endif
+};
+
+static struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare *__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare[8];
+static int __pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare = 0;
+
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+  PyObject *o;
+  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare)))) {
+    o = (PyObject*)__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare[--__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare];
+    memset(o, 0, sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare));
+    (void) PyObject_INIT(o, t);
+    PyObject_GC_Track(o);
+  } else {
+    o = (*t->tp_alloc)(t, 0);
+    if (unlikely(!o)) return 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare(PyObject *o) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare *)o;
+  PyObject_GC_UnTrack(o);
+  Py_CLEAR(p->__pyx_v_query);
+  Py_CLEAR(p->__pyx_v_self);
+  Py_CLEAR(p->__pyx_v_stmt_name);
+  Py_CLEAR(p->__pyx_v_timeout);
+  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare)))) {
+    __pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare[__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare++] = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare *)o);
+  } else {
+    (*Py_TYPE(o)->tp_free)(o);
+  }
+}
+
+static int __pyx_tp_traverse_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare *)o;
+  if (p->__pyx_v_query) {
+    e = (*v)(p->__pyx_v_query, a); if (e) return e;
+  }
+  if (p->__pyx_v_self) {
+    e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e;
+  }
+  if (p->__pyx_v_stmt_name) {
+    e = (*v)(p->__pyx_v_stmt_name, a); if (e) return e;
+  }
+  if (p->__pyx_v_timeout) {
+    e = (*v)(p->__pyx_v_timeout, a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare(PyObject *o) {
+  PyObject* tmp;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare *)o;
+  tmp = ((PyObject*)p->__pyx_v_query);
+  p->__pyx_v_query = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_self);
+  p->__pyx_v_self = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_stmt_name);
+  p->__pyx_v_stmt_name = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_timeout);
+  p->__pyx_v_timeout = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+
+static PyTypeObject __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare = {
+  PyVarObject_HEAD_INIT(0, 0)
+  "asyncpg.protocol.protocol.__pyx_scope_struct__prepare", /*tp_name*/
+  sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #endif
+  #if PY_MAJOR_VERSION >= 3
+  0, /*tp_as_async*/
+  #endif
+  0, /*tp_repr*/
+  0, /*tp_as_number*/
+  0, /*tp_as_sequence*/
+  0, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  0, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  0, /*tp_doc*/
+  __pyx_tp_traverse_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare, /*tp_traverse*/
+  __pyx_tp_clear_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  0, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  0, /*tp_version_tag*/
+  #if PY_VERSION_HEX >= 0x030400a1
+  0, /*tp_finalize*/
+  #endif
+};
+
+static struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute *__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute[8];
+static int __pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute = 0;
+
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+  PyObject *o;
+  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute)))) {
+    o = (PyObject*)__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute[--__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute];
+    memset(o, 0, sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute));
+    (void) PyObject_INIT(o, t);
+    PyObject_GC_Track(o);
+  } else {
+    o = (*t->tp_alloc)(t, 0);
+    if (unlikely(!o)) return 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute(PyObject *o) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute *)o;
+  PyObject_GC_UnTrack(o);
+  Py_CLEAR(p->__pyx_v_args);
+  Py_CLEAR(p->__pyx_v_portal_name);
+  Py_CLEAR(p->__pyx_v_return_extra);
+  Py_CLEAR(p->__pyx_v_self);
+  Py_CLEAR(p->__pyx_v_state);
+  Py_CLEAR(p->__pyx_v_timeout);
+  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute)))) {
+    __pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute[__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute++] = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute *)o);
+  } else {
+    (*Py_TYPE(o)->tp_free)(o);
+  }
+}
+
+static int __pyx_tp_traverse_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute *)o;
+  if (p->__pyx_v_args) {
+    e = (*v)(p->__pyx_v_args, a); if (e) return e;
+  }
+  if (p->__pyx_v_return_extra) {
+    e = (*v)(p->__pyx_v_return_extra, a); if (e) return e;
+  }
+  if (p->__pyx_v_self) {
+    e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e;
+  }
+  if (p->__pyx_v_state) {
+    e = (*v)(((PyObject*)p->__pyx_v_state), a); if (e) return e;
+  }
+  if (p->__pyx_v_timeout) {
+    e = (*v)(p->__pyx_v_timeout, a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute(PyObject *o) {
+  PyObject* tmp;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute *)o;
+  tmp = ((PyObject*)p->__pyx_v_args);
+  p->__pyx_v_args = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_return_extra);
+  p->__pyx_v_return_extra = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_self);
+  p->__pyx_v_self = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_state);
+  p->__pyx_v_state = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_timeout);
+  p->__pyx_v_timeout = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+
+static PyTypeObject __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute = {
+  PyVarObject_HEAD_INIT(0, 0)
+  "asyncpg.protocol.protocol.__pyx_scope_struct_1_bind_execute", /*tp_name*/
+  sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #endif
+  #if PY_MAJOR_VERSION >= 3
+  0, /*tp_as_async*/
+  #endif
+  0, /*tp_repr*/
+  0, /*tp_as_number*/
+  0, /*tp_as_sequence*/
+  0, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  0, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  0, /*tp_doc*/
+  __pyx_tp_traverse_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute, /*tp_traverse*/
+  __pyx_tp_clear_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  0, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  0, /*tp_version_tag*/
+  #if PY_VERSION_HEX >= 0x030400a1
+  0, /*tp_finalize*/
+  #endif
+};
+
+static struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many *__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many[8];
+static int __pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many = 0;
+
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+  PyObject *o;
+  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many)))) {
+    o = (PyObject*)__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many[--__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many];
+    memset(o, 0, sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many));
+    (void) PyObject_INIT(o, t);
+    PyObject_GC_Track(o);
+  } else {
+    o = (*t->tp_alloc)(t, 0);
+    if (unlikely(!o)) return 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many(PyObject *o) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many *)o;
+  PyObject_GC_UnTrack(o);
+  Py_CLEAR(p->__pyx_v_arg_bufs);
+  Py_CLEAR(p->__pyx_v_args);
+  Py_CLEAR(p->__pyx_v_data_gen);
+  Py_CLEAR(p->__pyx_v_genexpr);
+  Py_CLEAR(p->__pyx_v_portal_name);
+  Py_CLEAR(p->__pyx_v_self);
+  Py_CLEAR(p->__pyx_v_state);
+  Py_CLEAR(p->__pyx_v_timeout);
+  Py_CLEAR(p->__pyx_v_waiter);
+  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many)))) {
+    __pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many[__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many++] = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many *)o);
+  } else {
+    (*Py_TYPE(o)->tp_free)(o);
+  }
+}
+
+static int __pyx_tp_traverse_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many *)o;
+  if (p->__pyx_v_arg_bufs) {
+    e = (*v)(p->__pyx_v_arg_bufs, a); if (e) return e;
+  }
+  if (p->__pyx_v_args) {
+    e = (*v)(p->__pyx_v_args, a); if (e) return e;
+  }
+  if (p->__pyx_v_data_gen) {
+    e = (*v)(p->__pyx_v_data_gen, a); if (e) return e;
+  }
+  if (p->__pyx_v_genexpr) {
+    e = (*v)(p->__pyx_v_genexpr, a); if (e) return e;
+  }
+  if (p->__pyx_v_self) {
+    e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e;
+  }
+  if (p->__pyx_v_state) {
+    e = (*v)(((PyObject*)p->__pyx_v_state), a); if (e) return e;
+  }
+  if (p->__pyx_v_timeout) {
+    e = (*v)(p->__pyx_v_timeout, a); if (e) return e;
+  }
+  if (p->__pyx_v_waiter) {
+    e = (*v)(p->__pyx_v_waiter, a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many(PyObject *o) {
+  PyObject* tmp;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many *)o;
+  tmp = ((PyObject*)p->__pyx_v_arg_bufs);
+  p->__pyx_v_arg_bufs = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_args);
+  p->__pyx_v_args = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_data_gen);
+  p->__pyx_v_data_gen = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_genexpr);
+  p->__pyx_v_genexpr = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_self);
+  p->__pyx_v_self = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_state);
+  p->__pyx_v_state = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_timeout);
+  p->__pyx_v_timeout = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_waiter);
+  p->__pyx_v_waiter = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+
+static PyTypeObject __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many = {
+  PyVarObject_HEAD_INIT(0, 0)
+  "asyncpg.protocol.protocol.__pyx_scope_struct_2_bind_execute_many", /*tp_name*/
+  sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #endif
+  #if PY_MAJOR_VERSION >= 3
+  0, /*tp_as_async*/
+  #endif
+  0, /*tp_repr*/
+  0, /*tp_as_number*/
+  0, /*tp_as_sequence*/
+  0, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  0, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  0, /*tp_doc*/
+  __pyx_tp_traverse_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many, /*tp_traverse*/
+  __pyx_tp_clear_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  0, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  0, /*tp_version_tag*/
+  #if PY_VERSION_HEX >= 0x030400a1
+  0, /*tp_finalize*/
+  #endif
+};
+
+static struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr *__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr[8];
+static int __pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr = 0;
+
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+  PyObject *o;
+  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr)))) {
+    o = (PyObject*)__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr[--__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr];
+    memset(o, 0, sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr));
+    (void) PyObject_INIT(o, t);
+    PyObject_GC_Track(o);
+  } else {
+    o = (*t->tp_alloc)(t, 0);
+    if (unlikely(!o)) return 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr(PyObject *o) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr *)o;
+  PyObject_GC_UnTrack(o);
+  Py_CLEAR(p->__pyx_outer_scope);
+  Py_CLEAR(p->__pyx_v_b);
+  Py_CLEAR(p->__pyx_t_0);
+  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr)))) {
+    __pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr[__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr++] = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr *)o);
+  } else {
+    (*Py_TYPE(o)->tp_free)(o);
+  }
+}
+
+static int __pyx_tp_traverse_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr *)o;
+  if (p->__pyx_outer_scope) {
+    e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e;
+  }
+  if (p->__pyx_v_b) {
+    e = (*v)(p->__pyx_v_b, a); if (e) return e;
+  }
+  if (p->__pyx_t_0) {
+    e = (*v)(p->__pyx_t_0, a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr(PyObject *o) {
+  PyObject* tmp;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr *)o;
+  tmp = ((PyObject*)p->__pyx_outer_scope);
+  p->__pyx_outer_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_b);
+  p->__pyx_v_b = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_t_0);
+  p->__pyx_t_0 = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+
+static PyTypeObject __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr = {
+  PyVarObject_HEAD_INIT(0, 0)
+  "asyncpg.protocol.protocol.__pyx_scope_struct_3_genexpr", /*tp_name*/
+  sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #endif
+  #if PY_MAJOR_VERSION >= 3
+  0, /*tp_as_async*/
+  #endif
+  0, /*tp_repr*/
+  0, /*tp_as_number*/
+  0, /*tp_as_sequence*/
+  0, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  0, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  0, /*tp_doc*/
+  __pyx_tp_traverse_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr, /*tp_traverse*/
+  __pyx_tp_clear_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  0, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  0, /*tp_version_tag*/
+  #if PY_VERSION_HEX >= 0x030400a1
+  0, /*tp_finalize*/
+  #endif
+};
+
+static struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind *__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind[8];
+static int __pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind = 0;
+
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+  PyObject *o;
+  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind)))) {
+    o = (PyObject*)__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind[--__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind];
+    memset(o, 0, sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind));
+    (void) PyObject_INIT(o, t);
+    PyObject_GC_Track(o);
+  } else {
+    o = (*t->tp_alloc)(t, 0);
+    if (unlikely(!o)) return 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind(PyObject *o) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind *)o;
+  PyObject_GC_UnTrack(o);
+  Py_CLEAR(p->__pyx_v_args);
+  Py_CLEAR(p->__pyx_v_portal_name);
+  Py_CLEAR(p->__pyx_v_self);
+  Py_CLEAR(p->__pyx_v_state);
+  Py_CLEAR(p->__pyx_v_timeout);
+  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind)))) {
+    __pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind[__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind++] = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind *)o);
+  } else {
+    (*Py_TYPE(o)->tp_free)(o);
+  }
+}
+
+static int __pyx_tp_traverse_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind *)o;
+  if (p->__pyx_v_args) {
+    e = (*v)(p->__pyx_v_args, a); if (e) return e;
+  }
+  if (p->__pyx_v_self) {
+    e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e;
+  }
+  if (p->__pyx_v_state) {
+    e = (*v)(((PyObject*)p->__pyx_v_state), a); if (e) return e;
+  }
+  if (p->__pyx_v_timeout) {
+    e = (*v)(p->__pyx_v_timeout, a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind(PyObject *o) {
+  PyObject* tmp;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind *)o;
+  tmp = ((PyObject*)p->__pyx_v_args);
+  p->__pyx_v_args = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_self);
+  p->__pyx_v_self = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_state);
+  p->__pyx_v_state = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_timeout);
+  p->__pyx_v_timeout = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+
+static PyTypeObject __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind = {
+  PyVarObject_HEAD_INIT(0, 0)
+  "asyncpg.protocol.protocol.__pyx_scope_struct_4_bind", /*tp_name*/
+  sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #endif
+  #if PY_MAJOR_VERSION >= 3
+  0, /*tp_as_async*/
+  #endif
+  0, /*tp_repr*/
+  0, /*tp_as_number*/
+  0, /*tp_as_sequence*/
+  0, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  0, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  0, /*tp_doc*/
+  __pyx_tp_traverse_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind, /*tp_traverse*/
+  __pyx_tp_clear_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  0, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  0, /*tp_version_tag*/
+  #if PY_VERSION_HEX >= 0x030400a1
+  0, /*tp_finalize*/
+  #endif
+};
+
+static struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute *__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute[8];
+static int __pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute = 0;
+
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+  PyObject *o;
+  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute)))) {
+    o = (PyObject*)__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute[--__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute];
+    memset(o, 0, sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute));
+    (void) PyObject_INIT(o, t);
+    PyObject_GC_Track(o);
+  } else {
+    o = (*t->tp_alloc)(t, 0);
+    if (unlikely(!o)) return 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute(PyObject *o) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute *)o;
+  PyObject_GC_UnTrack(o);
+  Py_CLEAR(p->__pyx_v_portal_name);
+  Py_CLEAR(p->__pyx_v_return_extra);
+  Py_CLEAR(p->__pyx_v_self);
+  Py_CLEAR(p->__pyx_v_state);
+  Py_CLEAR(p->__pyx_v_timeout);
+  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute)))) {
+    __pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute[__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute++] = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute *)o);
+  } else {
+    (*Py_TYPE(o)->tp_free)(o);
+  }
+}
+
+static int __pyx_tp_traverse_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute *)o;
+  if (p->__pyx_v_return_extra) {
+    e = (*v)(p->__pyx_v_return_extra, a); if (e) return e;
+  }
+  if (p->__pyx_v_self) {
+    e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e;
+  }
+  if (p->__pyx_v_state) {
+    e = (*v)(((PyObject*)p->__pyx_v_state), a); if (e) return e;
+  }
+  if (p->__pyx_v_timeout) {
+    e = (*v)(p->__pyx_v_timeout, a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute(PyObject *o) {
+  PyObject* tmp;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute *)o;
+  tmp = ((PyObject*)p->__pyx_v_return_extra);
+  p->__pyx_v_return_extra = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_self);
+  p->__pyx_v_self = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_state);
+  p->__pyx_v_state = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_timeout);
+  p->__pyx_v_timeout = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+
+static PyTypeObject __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute = {
+  PyVarObject_HEAD_INIT(0, 0)
+  "asyncpg.protocol.protocol.__pyx_scope_struct_5_execute", /*tp_name*/
+  sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #endif
+  #if PY_MAJOR_VERSION >= 3
+  0, /*tp_as_async*/
+  #endif
+  0, /*tp_repr*/
+  0, /*tp_as_number*/
+  0, /*tp_as_sequence*/
+  0, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  0, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  0, /*tp_doc*/
+  __pyx_tp_traverse_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute, /*tp_traverse*/
+  __pyx_tp_clear_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  0, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  0, /*tp_version_tag*/
+  #if PY_VERSION_HEX >= 0x030400a1
+  0, /*tp_finalize*/
+  #endif
+};
+
+static struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query *__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query[8];
+static int __pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query = 0;
+
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+  PyObject *o;
+  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query)))) {
+    o = (PyObject*)__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query[--__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query];
+    memset(o, 0, sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query));
+    (void) PyObject_INIT(o, t);
+    PyObject_GC_Track(o);
+  } else {
+    o = (*t->tp_alloc)(t, 0);
+    if (unlikely(!o)) return 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query(PyObject *o) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query *)o;
+  PyObject_GC_UnTrack(o);
+  Py_CLEAR(p->__pyx_v_query);
+  Py_CLEAR(p->__pyx_v_self);
+  Py_CLEAR(p->__pyx_v_timeout);
+  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query)))) {
+    __pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query[__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query++] = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query *)o);
+  } else {
+    (*Py_TYPE(o)->tp_free)(o);
+  }
+}
+
+static int __pyx_tp_traverse_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query *)o;
+  if (p->__pyx_v_query) {
+    e = (*v)(p->__pyx_v_query, a); if (e) return e;
+  }
+  if (p->__pyx_v_self) {
+    e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e;
+  }
+  if (p->__pyx_v_timeout) {
+    e = (*v)(p->__pyx_v_timeout, a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query(PyObject *o) {
+  PyObject* tmp;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query *)o;
+  tmp = ((PyObject*)p->__pyx_v_query);
+  p->__pyx_v_query = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_self);
+  p->__pyx_v_self = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_timeout);
+  p->__pyx_v_timeout = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+
+static PyTypeObject __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query = {
+  PyVarObject_HEAD_INIT(0, 0)
+  "asyncpg.protocol.protocol.__pyx_scope_struct_6_query", /*tp_name*/
+  sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #endif
+  #if PY_MAJOR_VERSION >= 3
+  0, /*tp_as_async*/
+  #endif
+  0, /*tp_repr*/
+  0, /*tp_as_number*/
+  0, /*tp_as_sequence*/
+  0, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  0, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  0, /*tp_doc*/
+  __pyx_tp_traverse_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query, /*tp_traverse*/
+  __pyx_tp_clear_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  0, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  0, /*tp_version_tag*/
+  #if PY_VERSION_HEX >= 0x030400a1
+  0, /*tp_finalize*/
+  #endif
+};
+
+static struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement *__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement[8];
+static int __pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement = 0;
+
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+  PyObject *o;
+  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement)))) {
+    o = (PyObject*)__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement[--__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement];
+    memset(o, 0, sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement));
+    (void) PyObject_INIT(o, t);
+    PyObject_GC_Track(o);
+  } else {
+    o = (*t->tp_alloc)(t, 0);
+    if (unlikely(!o)) return 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement(PyObject *o) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement *)o;
+  PyObject_GC_UnTrack(o);
+  Py_CLEAR(p->__pyx_v_self);
+  Py_CLEAR(p->__pyx_v_state);
+  Py_CLEAR(p->__pyx_v_timeout);
+  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement)))) {
+    __pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement[__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement++] = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement *)o);
+  } else {
+    (*Py_TYPE(o)->tp_free)(o);
+  }
+}
+
+static int __pyx_tp_traverse_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement *)o;
+  if (p->__pyx_v_self) {
+    e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e;
+  }
+  if (p->__pyx_v_state) {
+    e = (*v)(((PyObject*)p->__pyx_v_state), a); if (e) return e;
+  }
+  if (p->__pyx_v_timeout) {
+    e = (*v)(p->__pyx_v_timeout, a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement(PyObject *o) {
+  PyObject* tmp;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement *)o;
+  tmp = ((PyObject*)p->__pyx_v_self);
+  p->__pyx_v_self = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_state);
+  p->__pyx_v_state = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_timeout);
+  p->__pyx_v_timeout = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+
+static PyTypeObject __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement = {
+  PyVarObject_HEAD_INIT(0, 0)
+  "asyncpg.protocol.protocol.__pyx_scope_struct_7_close_statement", /*tp_name*/
+  sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #endif
+  #if PY_MAJOR_VERSION >= 3
+  0, /*tp_as_async*/
+  #endif
+  0, /*tp_repr*/
+  0, /*tp_as_number*/
+  0, /*tp_as_sequence*/
+  0, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  0, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  0, /*tp_doc*/
+  __pyx_tp_traverse_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement, /*tp_traverse*/
+  __pyx_tp_clear_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  0, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  0, /*tp_version_tag*/
+  #if PY_VERSION_HEX >= 0x030400a1
+  0, /*tp_finalize*/
+  #endif
+};
+
+static struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close *__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close[8];
+static int __pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close = 0;
+
+static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+  PyObject *o;
+  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close)))) {
+    o = (PyObject*)__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close[--__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close];
+    memset(o, 0, sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close));
+    (void) PyObject_INIT(o, t);
+    PyObject_GC_Track(o);
+  } else {
+    o = (*t->tp_alloc)(t, 0);
+    if (unlikely(!o)) return 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close(PyObject *o) {
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close *)o;
+  PyObject_GC_UnTrack(o);
+  Py_CLEAR(p->__pyx_v_self);
+  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close)))) {
+    __pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close[__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close++] = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close *)o);
+  } else {
+    (*Py_TYPE(o)->tp_free)(o);
+  }
+}
+
+static int __pyx_tp_traverse_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close *)o;
+  if (p->__pyx_v_self) {
+    e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close(PyObject *o) {
+  PyObject* tmp;
+  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close *)o;
+  tmp = ((PyObject*)p->__pyx_v_self);
+  p->__pyx_v_self = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+
+static PyTypeObject __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close = {
+  PyVarObject_HEAD_INIT(0, 0)
+  "asyncpg.protocol.protocol.__pyx_scope_struct_8_close", /*tp_name*/
+  sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #endif
+  #if PY_MAJOR_VERSION >= 3
+  0, /*tp_as_async*/
+  #endif
+  0, /*tp_repr*/
+  0, /*tp_as_number*/
+  0, /*tp_as_sequence*/
+  0, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  0, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  0, /*tp_doc*/
+  __pyx_tp_traverse_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close, /*tp_traverse*/
+  __pyx_tp_clear_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  0, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  0, /*tp_version_tag*/
+  #if PY_VERSION_HEX >= 0x030400a1
+  0, /*tp_finalize*/
+  #endif
+};
+
+static PyMethodDef __pyx_methods[] = {
+  {0, 0, 0, 0}
+};
+
+#if PY_MAJOR_VERSION >= 3
+static struct PyModuleDef __pyx_moduledef = {
+  #if PY_VERSION_HEX < 0x03020000
+    { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
+  #else
+    PyModuleDef_HEAD_INIT,
+  #endif
+    "protocol",
+    0, /* m_doc */
+    -1, /* m_size */
+    __pyx_methods /* m_methods */,
+    NULL, /* m_reload */
+    NULL, /* m_traverse */
+    NULL, /* m_clear */
+    NULL /* m_free */
+};
+#endif
+
+static __Pyx_StringTabEntry __pyx_string_tab[] = {
+  {&__pyx_n_s_AF_UNIX, __pyx_k_AF_UNIX, sizeof(__pyx_k_AF_UNIX), 0, 0, 1, 1},
+  {&__pyx_n_u_AF_UNIX, __pyx_k_AF_UNIX, sizeof(__pyx_k_AF_UNIX), 0, 1, 0, 1},
+  {&__pyx_n_s_ARRAY_TYPES, __pyx_k_ARRAY_TYPES, sizeof(__pyx_k_ARRAY_TYPES), 0, 0, 1, 1},
+  {&__pyx_n_s_AUTH_METHOD_NAME, __pyx_k_AUTH_METHOD_NAME, sizeof(__pyx_k_AUTH_METHOD_NAME), 0, 0, 1, 1},
+  {&__pyx_n_s_Attribute, __pyx_k_Attribute, sizeof(__pyx_k_Attribute), 0, 0, 1, 1},
+  {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1},
+  {&__pyx_n_s_BaseProtocol_bind, __pyx_k_BaseProtocol_bind, sizeof(__pyx_k_BaseProtocol_bind), 0, 0, 1, 1},
+  {&__pyx_n_s_BaseProtocol_bind_execute, __pyx_k_BaseProtocol_bind_execute, sizeof(__pyx_k_BaseProtocol_bind_execute), 0, 0, 1, 1},
+  {&__pyx_n_s_BaseProtocol_bind_execute_many, __pyx_k_BaseProtocol_bind_execute_many, sizeof(__pyx_k_BaseProtocol_bind_execute_many), 0, 0, 1, 1},
+  {&__pyx_n_s_BaseProtocol_close, __pyx_k_BaseProtocol_close, sizeof(__pyx_k_BaseProtocol_close), 0, 0, 1, 1},
+  {&__pyx_n_s_BaseProtocol_close_statement, __pyx_k_BaseProtocol_close_statement, sizeof(__pyx_k_BaseProtocol_close_statement), 0, 0, 1, 1},
+  {&__pyx_n_s_BaseProtocol_execute, __pyx_k_BaseProtocol_execute, sizeof(__pyx_k_BaseProtocol_execute), 0, 0, 1, 1},
+  {&__pyx_n_s_BaseProtocol_prepare, __pyx_k_BaseProtocol_prepare, sizeof(__pyx_k_BaseProtocol_prepare), 0, 0, 1, 1},
+  {&__pyx_n_s_BaseProtocol_query, __pyx_k_BaseProtocol_query, sizeof(__pyx_k_BaseProtocol_query), 0, 0, 1, 1},
+  {&__pyx_n_s_BitString, __pyx_k_BitString, sizeof(__pyx_k_BitString), 0, 0, 1, 1},
+  {&__pyx_n_s_Box, __pyx_k_Box, sizeof(__pyx_k_Box), 0, 0, 1, 1},
+  {&__pyx_n_s_BufferError, __pyx_k_BufferError, sizeof(__pyx_k_BufferError), 0, 0, 1, 1},
+  {&__pyx_n_s_Circle, __pyx_k_Circle, sizeof(__pyx_k_Circle), 0, 0, 1, 1},
+  {&__pyx_kp_u_Codec_oid_elem_oid_core, __pyx_k_Codec_oid_elem_oid_core, sizeof(__pyx_k_Codec_oid_elem_oid_core), 0, 1, 0, 0},
+  {&__pyx_n_s_ConnectionDoesNotExistError, __pyx_k_ConnectionDoesNotExistError, sizeof(__pyx_k_ConnectionDoesNotExistError), 0, 0, 1, 1},
+  {&__pyx_n_s_Container, __pyx_k_Container, sizeof(__pyx_k_Container), 0, 0, 1, 1},
+  {&__pyx_n_s_ContainerABC, __pyx_k_ContainerABC, sizeof(__pyx_k_ContainerABC), 0, 0, 1, 1},
+  {&__pyx_kp_u_Deallocating_buffer_with_attache, __pyx_k_Deallocating_buffer_with_attache, sizeof(__pyx_k_Deallocating_buffer_with_attache), 0, 1, 0, 0},
+  {&__pyx_n_s_Dec, __pyx_k_Dec, sizeof(__pyx_k_Dec), 0, 0, 1, 1},
+  {&__pyx_n_s_Decimal, __pyx_k_Decimal, sizeof(__pyx_k_Decimal), 0, 0, 1, 1},
+  {&__pyx_n_s_Future, __pyx_k_Future, sizeof(__pyx_k_Future), 0, 0, 1, 1},
+  {&__pyx_n_s_IPPROTO_TCP, __pyx_k_IPPROTO_TCP, sizeof(__pyx_k_IPPROTO_TCP), 0, 0, 1, 1},
+  {&__pyx_n_s_InterfaceError, __pyx_k_InterfaceError, sizeof(__pyx_k_InterfaceError), 0, 0, 1, 1},
+  {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1},
+  {&__pyx_n_s_Line, __pyx_k_Line, sizeof(__pyx_k_Line), 0, 0, 1, 1},
+  {&__pyx_n_s_LineSegment, __pyx_k_LineSegment, sizeof(__pyx_k_LineSegment), 0, 0, 1, 1},
+  {&__pyx_n_s_MAXYEAR, __pyx_k_MAXYEAR, sizeof(__pyx_k_MAXYEAR), 0, 0, 1, 1},
+  {&__pyx_n_s_MINYEAR, __pyx_k_MINYEAR, sizeof(__pyx_k_MINYEAR), 0, 0, 1, 1},
+  {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
+  {&__pyx_n_u_NA, __pyx_k_NA, sizeof(__pyx_k_NA), 0, 1, 0, 1},
+  {&__pyx_n_s_NotImplementedError, __pyx_k_NotImplementedError, sizeof(__pyx_k_NotImplementedError), 0, 0, 1, 1},
+  {&__pyx_n_s_OrderedDict, __pyx_k_OrderedDict, sizeof(__pyx_k_OrderedDict), 0, 0, 1, 1},
+  {&__pyx_n_s_Path, __pyx_k_Path, sizeof(__pyx_k_Path), 0, 0, 1, 1},
+  {&__pyx_n_s_Point, __pyx_k_Point, sizeof(__pyx_k_Point), 0, 0, 1, 1},
+  {&__pyx_n_s_Polygon, __pyx_k_Polygon, sizeof(__pyx_k_Polygon), 0, 0, 1, 1},
+  {&__pyx_n_s_PostgresMessage, __pyx_k_PostgresMessage, sizeof(__pyx_k_PostgresMessage), 0, 0, 1, 1},
+  {&__pyx_n_s_Protocol, __pyx_k_Protocol, sizeof(__pyx_k_Protocol), 0, 0, 1, 1},
+  {&__pyx_n_s_Range, __pyx_k_Range, sizeof(__pyx_k_Range), 0, 0, 1, 1},
+  {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
+  {&__pyx_n_s_StopIteration, __pyx_k_StopIteration, sizeof(__pyx_k_StopIteration), 0, 0, 1, 1},
+  {&__pyx_n_s_TCP_NODELAY, __pyx_k_TCP_NODELAY, sizeof(__pyx_k_TCP_NODELAY), 0, 0, 1, 1},
+  {&__pyx_n_s_TYPEMAP, __pyx_k_TYPEMAP, sizeof(__pyx_k_TYPEMAP), 0, 0, 1, 1},
+  {&__pyx_n_s_TimeoutError, __pyx_k_TimeoutError, sizeof(__pyx_k_TimeoutError), 0, 0, 1, 1},
+  {&__pyx_n_s_Type, __pyx_k_Type, sizeof(__pyx_k_Type), 0, 0, 1, 1},
+  {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
+  {&__pyx_n_s_UUID, __pyx_k_UUID, sizeof(__pyx_k_UUID), 0, 0, 1, 1},
+  {&__pyx_n_s_UUID_2, __pyx_k_UUID_2, sizeof(__pyx_k_UUID_2), 0, 0, 1, 1},
+  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
+  {&__pyx_kp_b__18, __pyx_k__18, sizeof(__pyx_k__18), 0, 0, 0, 0},
+  {&__pyx_kp_u__18, __pyx_k__18, sizeof(__pyx_k__18), 0, 1, 0, 0},
+  {&__pyx_kp_b__19, __pyx_k__19, sizeof(__pyx_k__19), 0, 0, 0, 0},
+  {&__pyx_kp_u__28, __pyx_k__28, sizeof(__pyx_k__28), 0, 1, 0, 0},
+  {&__pyx_n_u__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 1, 0, 1},
+  {&__pyx_kp_u__66, __pyx_k__66, sizeof(__pyx_k__66), 0, 1, 0, 0},
+  {&__pyx_kp_u_a_boolean_is_required_got_type, __pyx_k_a_boolean_is_required_got_type, sizeof(__pyx_k_a_boolean_is_required_got_type), 0, 1, 0, 0},
+  {&__pyx_kp_u_a_non_trivial_iterable_expected, __pyx_k_a_non_trivial_iterable_expected, sizeof(__pyx_k_a_non_trivial_iterable_expected), 0, 1, 0, 0},
+  {&__pyx_n_u_abc, __pyx_k_abc, sizeof(__pyx_k_abc), 0, 1, 0, 1},
+  {&__pyx_n_s_abort, __pyx_k_abort, sizeof(__pyx_k_abort), 0, 0, 1, 1},
+  {&__pyx_n_u_abstime, __pyx_k_abstime, sizeof(__pyx_k_abstime), 0, 1, 0, 1},
+  {&__pyx_n_u_aclitem, __pyx_k_aclitem, sizeof(__pyx_k_aclitem), 0, 1, 0, 1},
+  {&__pyx_n_s_add, __pyx_k_add, sizeof(__pyx_k_add), 0, 0, 1, 1},
+  {&__pyx_n_s_add_done_callback, __pyx_k_add_done_callback, sizeof(__pyx_k_add_done_callback), 0, 0, 1, 1},
+  {&__pyx_n_s_add_python_codec, __pyx_k_add_python_codec, sizeof(__pyx_k_add_python_codec), 0, 0, 1, 1},
+  {&__pyx_n_s_add_types, __pyx_k_add_types, sizeof(__pyx_k_add_types), 0, 0, 1, 1},
+  {&__pyx_n_s_addr, __pyx_k_addr, sizeof(__pyx_k_addr), 0, 0, 1, 1},
+  {&__pyx_n_s_alias_to, __pyx_k_alias_to, sizeof(__pyx_k_alias_to), 0, 0, 1, 1},
+  {&__pyx_kp_u_already_connected, __pyx_k_already_connected, sizeof(__pyx_k_already_connected), 0, 1, 0, 0},
+  {&__pyx_n_u_alt, __pyx_k_alt, sizeof(__pyx_k_alt), 0, 1, 0, 1},
+  {&__pyx_n_u_any, __pyx_k_any, sizeof(__pyx_k_any), 0, 1, 0, 1},
+  {&__pyx_n_u_anyarray, __pyx_k_anyarray, sizeof(__pyx_k_anyarray), 0, 1, 0, 1},
+  {&__pyx_n_u_anyelement, __pyx_k_anyelement, sizeof(__pyx_k_anyelement), 0, 1, 0, 1},
+  {&__pyx_n_u_anyenum, __pyx_k_anyenum, sizeof(__pyx_k_anyenum), 0, 1, 0, 1},
+  {&__pyx_n_u_anynonarray, __pyx_k_anynonarray, sizeof(__pyx_k_anynonarray), 0, 1, 0, 1},
+  {&__pyx_n_u_anyrange, __pyx_k_anyrange, sizeof(__pyx_k_anyrange), 0, 1, 0, 1},
+  {&__pyx_n_s_apg_exc, __pyx_k_apg_exc, sizeof(__pyx_k_apg_exc), 0, 0, 1, 1},
+  {&__pyx_n_s_apg_exc_base, __pyx_k_apg_exc_base, sizeof(__pyx_k_apg_exc_base), 0, 0, 1, 1},
+  {&__pyx_n_s_apg_types, __pyx_k_apg_types, sizeof(__pyx_k_apg_types), 0, 0, 1, 1},
+  {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1},
+  {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
+  {&__pyx_n_u_array, __pyx_k_array, sizeof(__pyx_k_array), 0, 1, 0, 1},
+  {&__pyx_n_u_ascii, __pyx_k_ascii, sizeof(__pyx_k_ascii), 0, 1, 0, 1},
+  {&__pyx_n_s_astimezone, __pyx_k_astimezone, sizeof(__pyx_k_astimezone), 0, 0, 1, 1},
+  {&__pyx_n_s_asyncio, __pyx_k_asyncio, sizeof(__pyx_k_asyncio), 0, 0, 1, 1},
+  {&__pyx_n_s_asyncio_coroutines, __pyx_k_asyncio_coroutines, sizeof(__pyx_k_asyncio_coroutines), 0, 0, 1, 1},
+  {&__pyx_n_s_asyncio_tasks, __pyx_k_asyncio_tasks, sizeof(__pyx_k_asyncio_tasks), 0, 0, 1, 1},
+  {&__pyx_n_s_asyncpg, __pyx_k_asyncpg, sizeof(__pyx_k_asyncpg), 0, 0, 1, 1},
+  {&__pyx_n_s_asyncpg_exceptions, __pyx_k_asyncpg_exceptions, sizeof(__pyx_k_asyncpg_exceptions), 0, 0, 1, 1},
+  {&__pyx_n_s_asyncpg_protocol_protocol, __pyx_k_asyncpg_protocol_protocol, sizeof(__pyx_k_asyncpg_protocol_protocol), 0, 0, 1, 1},
+  {&__pyx_n_s_asyncpg_types, __pyx_k_asyncpg_types, sizeof(__pyx_k_asyncpg_types), 0, 0, 1, 1},
+  {&__pyx_n_u_attrnames, __pyx_k_attrnames, sizeof(__pyx_k_attrnames), 0, 1, 0, 1},
+  {&__pyx_n_u_attrtypoids, __pyx_k_attrtypoids, sizeof(__pyx_k_attrtypoids), 0, 1, 0, 1},
+  {&__pyx_n_s_auth_msg, __pyx_k_auth_msg, sizeof(__pyx_k_auth_msg), 0, 0, 1, 1},
+  {&__pyx_n_s_await, __pyx_k_await, sizeof(__pyx_k_await), 0, 0, 1, 1},
+  {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1},
+  {&__pyx_n_u_basetype, __pyx_k_basetype, sizeof(__pyx_k_basetype), 0, 1, 0, 1},
+  {&__pyx_n_s_binary, __pyx_k_binary, sizeof(__pyx_k_binary), 0, 0, 1, 1},
+  {&__pyx_n_s_bind, __pyx_k_bind, sizeof(__pyx_k_bind), 0, 0, 1, 1},
+  {&__pyx_n_s_bind_execute, __pyx_k_bind_execute, sizeof(__pyx_k_bind_execute), 0, 0, 1, 1},
+  {&__pyx_n_s_bind_execute_many, __pyx_k_bind_execute_many, sizeof(__pyx_k_bind_execute_many), 0, 0, 1, 1},
+  {&__pyx_n_s_bind_execute_many_locals_genexpr, __pyx_k_bind_execute_many_locals_genexpr, sizeof(__pyx_k_bind_execute_many_locals_genexpr), 0, 0, 1, 1},
+  {&__pyx_n_u_bit, __pyx_k_bit, sizeof(__pyx_k_bit), 0, 1, 0, 1},
+  {&__pyx_kp_u_bit_value_too_long, __pyx_k_bit_value_too_long, sizeof(__pyx_k_bit_value_too_long), 0, 1, 0, 0},
+  {&__pyx_n_u_bool, __pyx_k_bool, sizeof(__pyx_k_bool), 0, 1, 0, 1},
+  {&__pyx_n_u_box, __pyx_k_box, sizeof(__pyx_k_box), 0, 1, 0, 1},
+  {&__pyx_n_u_bpchar, __pyx_k_bpchar, sizeof(__pyx_k_bpchar), 0, 1, 0, 1},
+  {&__pyx_kp_u_buffer_overread, __pyx_k_buffer_overread, sizeof(__pyx_k_buffer_overread), 0, 1, 0, 0},
+  {&__pyx_n_u_bytea, __pyx_k_bytea, sizeof(__pyx_k_bytea), 0, 1, 0, 1},
+  {&__pyx_n_s_bytes, __pyx_k_bytes, sizeof(__pyx_k_bytes), 0, 0, 1, 1},
+  {&__pyx_n_b_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 0, 1},
+  {&__pyx_n_s_cache_key, __pyx_k_cache_key, sizeof(__pyx_k_cache_key), 0, 0, 1, 1},
+  {&__pyx_n_s_call_later, __pyx_k_call_later, sizeof(__pyx_k_call_later), 0, 0, 1, 1},
+  {&__pyx_n_s_cancel, __pyx_k_cancel, sizeof(__pyx_k_cancel), 0, 0, 1, 1},
+  {&__pyx_n_s_cancel_current_command, __pyx_k_cancel_current_command, sizeof(__pyx_k_cancel_current_command), 0, 0, 1, 1},
+  {&__pyx_n_s_cancelled, __pyx_k_cancelled, sizeof(__pyx_k_cancelled), 0, 0, 1, 1},
+  {&__pyx_kp_u_cannot_close_prepared_statement, __pyx_k_cannot_close_prepared_statement, sizeof(__pyx_k_cannot_close_prepared_statement), 0, 1, 0, 0},
+  {&__pyx_kp_u_cannot_override_codec_for_type, __pyx_k_cannot_override_codec_for_type, sizeof(__pyx_k_cannot_override_codec_for_type), 0, 1, 0, 0},
+  {&__pyx_kp_u_cannot_perform_operation_another, __pyx_k_cannot_perform_operation_another, sizeof(__pyx_k_cannot_perform_operation_another), 0, 1, 0, 0},
+  {&__pyx_kp_u_cannot_perform_operation_another_2, __pyx_k_cannot_perform_operation_another_2, sizeof(__pyx_k_cannot_perform_operation_another_2), 0, 1, 0, 0},
+  {&__pyx_kp_u_cannot_perform_operation_connect, __pyx_k_cannot_perform_operation_connect, sizeof(__pyx_k_cannot_perform_operation_connect), 0, 1, 0, 0},
+  {&__pyx_kp_u_cannot_register_core_codec_for_O, __pyx_k_cannot_register_core_codec_for_O, sizeof(__pyx_k_cannot_register_core_codec_for_O), 0, 1, 0, 0},
+  {&__pyx_kp_u_cannot_start_message_for_a_non_e, __pyx_k_cannot_start_message_for_a_non_e, sizeof(__pyx_k_cannot_start_message_for_a_non_e), 0, 1, 0, 0},
+  {&__pyx_kp_u_cannot_switch_to_idle_state_prot, __pyx_k_cannot_switch_to_idle_state_prot, sizeof(__pyx_k_cannot_switch_to_idle_state_prot), 0, 1, 0, 0},
+  {&__pyx_kp_u_cannot_switch_to_state_another_o, __pyx_k_cannot_switch_to_state_another_o, sizeof(__pyx_k_cannot_switch_to_state_another_o), 0, 1, 0, 0},
+  {&__pyx_kp_u_cannot_switch_to_state_protocol, __pyx_k_cannot_switch_to_state_protocol, sizeof(__pyx_k_cannot_switch_to_state_protocol), 0, 1, 0, 0},
+  {&__pyx_n_s_cause, __pyx_k_cause, sizeof(__pyx_k_cause), 0, 0, 1, 1},
+  {&__pyx_n_u_char, __pyx_k_char, sizeof(__pyx_k_char), 0, 1, 0, 1},
+  {&__pyx_n_s_chr, __pyx_k_chr, sizeof(__pyx_k_chr), 0, 0, 1, 1},
+  {&__pyx_n_u_cid, __pyx_k_cid, sizeof(__pyx_k_cid), 0, 1, 0, 1},
+  {&__pyx_n_u_cidr, __pyx_k_cidr, sizeof(__pyx_k_cidr), 0, 1, 0, 1},
+  {&__pyx_n_u_circle, __pyx_k_circle, sizeof(__pyx_k_circle), 0, 1, 0, 1},
+  {&__pyx_n_b_client_encoding, __pyx_k_client_encoding, sizeof(__pyx_k_client_encoding), 0, 0, 0, 1},
+  {&__pyx_n_u_client_encoding, __pyx_k_client_encoding, sizeof(__pyx_k_client_encoding), 0, 1, 0, 1},
+  {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
+  {&__pyx_n_s_close_statement, __pyx_k_close_statement, sizeof(__pyx_k_close_statement), 0, 0, 1, 1},
+  {&__pyx_n_s_codecs, __pyx_k_codecs, sizeof(__pyx_k_codecs), 0, 0, 1, 1},
+  {&__pyx_n_s_collections, __pyx_k_collections, sizeof(__pyx_k_collections), 0, 0, 1, 1},
+  {&__pyx_n_s_collections_abc, __pyx_k_collections_abc, sizeof(__pyx_k_collections_abc), 0, 0, 1, 1},
+  {&__pyx_n_s_command_timeout, __pyx_k_command_timeout, sizeof(__pyx_k_command_timeout), 0, 0, 1, 1},
+  {&__pyx_n_u_composite, __pyx_k_composite, sizeof(__pyx_k_composite), 0, 1, 0, 1},
+  {&__pyx_n_s_con_args, __pyx_k_con_args, sizeof(__pyx_k_con_args), 0, 0, 1, 1},
+  {&__pyx_n_s_conn_key, __pyx_k_conn_key, sizeof(__pyx_k_conn_key), 0, 0, 1, 1},
+  {&__pyx_n_s_connected_fut, __pyx_k_connected_fut, sizeof(__pyx_k_connected_fut), 0, 0, 1, 1},
+  {&__pyx_kp_u_connection_was_closed_in_the_mid, __pyx_k_connection_was_closed_in_the_mid, sizeof(__pyx_k_connection_was_closed_in_the_mid), 0, 1, 0, 0},
+  {&__pyx_n_u_cp1250, __pyx_k_cp1250, sizeof(__pyx_k_cp1250), 0, 1, 0, 1},
+  {&__pyx_n_u_cp1251, __pyx_k_cp1251, sizeof(__pyx_k_cp1251), 0, 1, 0, 1},
+  {&__pyx_n_u_cp1252, __pyx_k_cp1252, sizeof(__pyx_k_cp1252), 0, 1, 0, 1},
+  {&__pyx_n_u_cp1253, __pyx_k_cp1253, sizeof(__pyx_k_cp1253), 0, 1, 0, 1},
+  {&__pyx_n_u_cp1254, __pyx_k_cp1254, sizeof(__pyx_k_cp1254), 0, 1, 0, 1},
+  {&__pyx_n_u_cp1255, __pyx_k_cp1255, sizeof(__pyx_k_cp1255), 0, 1, 0, 1},
+  {&__pyx_n_u_cp1256, __pyx_k_cp1256, sizeof(__pyx_k_cp1256), 0, 1, 0, 1},
+  {&__pyx_n_u_cp1257, __pyx_k_cp1257, sizeof(__pyx_k_cp1257), 0, 1, 0, 1},
+  {&__pyx_n_u_cp1258, __pyx_k_cp1258, sizeof(__pyx_k_cp1258), 0, 1, 0, 1},
+  {&__pyx_n_u_cp1521, __pyx_k_cp1521, sizeof(__pyx_k_cp1521), 0, 1, 0, 1},
+  {&__pyx_n_u_cp866, __pyx_k_cp866, sizeof(__pyx_k_cp866), 0, 1, 0, 1},
+  {&__pyx_n_u_cp874, __pyx_k_cp874, sizeof(__pyx_k_cp874), 0, 1, 0, 1},
+  {&__pyx_n_u_cp932, __pyx_k_cp932, sizeof(__pyx_k_cp932), 0, 1, 0, 1},
+  {&__pyx_n_u_cp936, __pyx_k_cp936, sizeof(__pyx_k_cp936), 0, 1, 0, 1},
+  {&__pyx_n_u_cp949, __pyx_k_cp949, sizeof(__pyx_k_cp949), 0, 1, 0, 1},
+  {&__pyx_n_u_cp950, __pyx_k_cp950, sizeof(__pyx_k_cp950), 0, 1, 0, 1},
+  {&__pyx_n_s_create_future, __pyx_k_create_future, sizeof(__pyx_k_create_future), 0, 0, 1, 1},
+  {&__pyx_n_s_create_future_fallback, __pyx_k_create_future_fallback, sizeof(__pyx_k_create_future_fallback), 0, 0, 1, 1},
+  {&__pyx_n_s_create_record, __pyx_k_create_record, sizeof(__pyx_k_create_record), 0, 0, 1, 1},
+  {&__pyx_n_u_cstring, __pyx_k_cstring, sizeof(__pyx_k_cstring), 0, 1, 0, 1},
+  {&__pyx_n_b_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 0, 0, 1},
+  {&__pyx_n_u_database, __pyx_k_database, sizeof(__pyx_k_database), 0, 1, 0, 1},
+  {&__pyx_n_s_date, __pyx_k_date, sizeof(__pyx_k_date), 0, 0, 1, 1},
+  {&__pyx_n_u_date, __pyx_k_date, sizeof(__pyx_k_date), 0, 1, 0, 1},
+  {&__pyx_n_s_date_from_ordinal, __pyx_k_date_from_ordinal, sizeof(__pyx_k_date_from_ordinal), 0, 0, 1, 1},
+  {&__pyx_n_s_datetime, __pyx_k_datetime, sizeof(__pyx_k_datetime), 0, 0, 1, 1},
+  {&__pyx_n_s_days, __pyx_k_days, sizeof(__pyx_k_days), 0, 0, 1, 1},
+  {&__pyx_kp_u_debug_first_buffer_of_ReadBuffer, __pyx_k_debug_first_buffer_of_ReadBuffer, sizeof(__pyx_k_debug_first_buffer_of_ReadBuffer), 0, 1, 0, 0},
+  {&__pyx_kp_u_debug_second_buffer_of_ReadBuffe, __pyx_k_debug_second_buffer_of_ReadBuffe, sizeof(__pyx_k_debug_second_buffer_of_ReadBuffe), 0, 1, 0, 0},
+  {&__pyx_n_s_decimal, __pyx_k_decimal, sizeof(__pyx_k_decimal), 0, 0, 1, 1},
+  {&__pyx_n_s_decode, __pyx_k_decode, sizeof(__pyx_k_decode), 0, 0, 1, 1},
+  {&__pyx_kp_u_decode_row_statement_is_None, __pyx_k_decode_row_statement_is_None, sizeof(__pyx_k_decode_row_statement_is_None), 0, 1, 0, 0},
+  {&__pyx_n_s_decoder, __pyx_k_decoder, sizeof(__pyx_k_decoder), 0, 0, 1, 1},
+  {&__pyx_n_s_deque, __pyx_k_deque, sizeof(__pyx_k_deque), 0, 0, 1, 1},
+  {&__pyx_n_s_desc, __pyx_k_desc, sizeof(__pyx_k_desc), 0, 0, 1, 1},
+  {&__pyx_kp_u_discarding_message_r_unread_dat, __pyx_k_discarding_message_r_unread_dat, sizeof(__pyx_k_discarding_message_r_unread_dat), 0, 1, 0, 0},
+  {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
+  {&__pyx_n_s_done, __pyx_k_done, sizeof(__pyx_k_done), 0, 0, 1, 1},
+  {&__pyx_n_s_elem, __pyx_k_elem, sizeof(__pyx_k_elem), 0, 0, 1, 1},
+  {&__pyx_n_u_elem_has_bin_io, __pyx_k_elem_has_bin_io, sizeof(__pyx_k_elem_has_bin_io), 0, 1, 0, 1},
+  {&__pyx_n_u_elemdelim, __pyx_k_elemdelim, sizeof(__pyx_k_elemdelim), 0, 1, 0, 1},
+  {&__pyx_n_s_elems, __pyx_k_elems, sizeof(__pyx_k_elems), 0, 0, 1, 1},
+  {&__pyx_n_u_elemtype, __pyx_k_elemtype, sizeof(__pyx_k_elemtype), 0, 1, 0, 1},
+  {&__pyx_n_s_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 0, 0, 1, 1},
+  {&__pyx_kp_u_empty_first_buffer, __pyx_k_empty_first_buffer, sizeof(__pyx_k_empty_first_buffer), 0, 1, 0, 0},
+  {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
+  {&__pyx_n_s_encoder, __pyx_k_encoder, sizeof(__pyx_k_encoder), 0, 0, 1, 1},
+  {&__pyx_kp_u_end_message_buffer_is_too_small, __pyx_k_end_message_buffer_is_too_small, sizeof(__pyx_k_end_message_buffer_is_too_small), 0, 1, 0, 0},
+  {&__pyx_kp_u_end_message_can_only_be_called_w, __pyx_k_end_message_can_only_be_called_w, sizeof(__pyx_k_end_message_can_only_be_called_w), 0, 1, 0, 0},
+  {&__pyx_kp_u_end_message_message_is_too_large, __pyx_k_end_message_message_is_too_large, sizeof(__pyx_k_end_message_message_is_too_large), 0, 1, 0, 0},
+  {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
+  {&__pyx_n_u_euc_cn, __pyx_k_euc_cn, sizeof(__pyx_k_euc_cn), 0, 1, 0, 1},
+  {&__pyx_n_u_euc_jis_2004, __pyx_k_euc_jis_2004, sizeof(__pyx_k_euc_jis_2004), 0, 1, 0, 1},
+  {&__pyx_n_u_euc_jp, __pyx_k_euc_jp, sizeof(__pyx_k_euc_jp), 0, 1, 0, 1},
+  {&__pyx_n_u_euc_kr, __pyx_k_euc_kr, sizeof(__pyx_k_euc_kr), 0, 1, 0, 1},
+  {&__pyx_n_u_euccn, __pyx_k_euccn, sizeof(__pyx_k_euccn), 0, 1, 0, 1},
+  {&__pyx_n_u_eucjp, __pyx_k_eucjp, sizeof(__pyx_k_eucjp), 0, 1, 0, 1},
+  {&__pyx_n_u_euckr, __pyx_k_euckr, sizeof(__pyx_k_euckr), 0, 1, 0, 1},
+  {&__pyx_n_u_event_trigger, __pyx_k_event_trigger, sizeof(__pyx_k_event_trigger), 0, 1, 0, 1},
+  {&__pyx_n_s_exceptions, __pyx_k_exceptions, sizeof(__pyx_k_exceptions), 0, 0, 1, 1},
+  {&__pyx_n_s_execute, __pyx_k_execute, sizeof(__pyx_k_execute), 0, 0, 1, 1},
+  {&__pyx_kp_u_expected_0_1_or_2_elements_in_ra, __pyx_k_expected_0_1_or_2_elements_in_ra, sizeof(__pyx_k_expected_0_1_or_2_elements_in_ra), 0, 1, 0, 0},
+  {&__pyx_n_s_extend, __pyx_k_extend, sizeof(__pyx_k_extend), 0, 0, 1, 1},
+  {&__pyx_kp_u_failed_to_read_one_byte_on_a_non, __pyx_k_failed_to_read_one_byte_on_a_non, sizeof(__pyx_k_failed_to_read_one_byte_on_a_non), 0, 1, 0, 0},
+  {&__pyx_n_s_family, __pyx_k_family, sizeof(__pyx_k_family), 0, 0, 1, 1},
+  {&__pyx_n_u_fdw_handler, __pyx_k_fdw_handler, sizeof(__pyx_k_fdw_handler), 0, 1, 0, 1},
+  {&__pyx_kp_u_feed_data_bytes_object_expected, __pyx_k_feed_data_bytes_object_expected, sizeof(__pyx_k_feed_data_bytes_object_expected), 0, 1, 0, 0},
+  {&__pyx_n_s_find, __pyx_k_find, sizeof(__pyx_k_find), 0, 0, 1, 1},
+  {&__pyx_n_u_float4, __pyx_k_float4, sizeof(__pyx_k_float4), 0, 1, 0, 1},
+  {&__pyx_n_u_float8, __pyx_k_float8, sizeof(__pyx_k_float8), 0, 1, 0, 1},
+  {&__pyx_kp_u_float_value_too_large_to_be_enco, __pyx_k_float_value_too_large_to_be_enco, sizeof(__pyx_k_float_value_too_large_to_be_enco), 0, 1, 0, 0},
+  {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
+  {&__pyx_n_s_frombytes, __pyx_k_frombytes, sizeof(__pyx_k_frombytes), 0, 0, 1, 1},
+  {&__pyx_n_s_fromordinal, __pyx_k_fromordinal, sizeof(__pyx_k_fromordinal), 0, 0, 1, 1},
+  {&__pyx_n_s_genexpr, __pyx_k_genexpr, sizeof(__pyx_k_genexpr), 0, 0, 1, 1},
+  {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
+  {&__pyx_n_s_get_extra_info, __pyx_k_get_extra_info, sizeof(__pyx_k_get_extra_info), 0, 0, 1, 1},
+  {&__pyx_n_s_getattr, __pyx_k_getattr, sizeof(__pyx_k_getattr), 0, 0, 1, 1},
+  {&__pyx_kp_u_got_result_for_unknown_protocol, __pyx_k_got_result_for_unknown_protocol, sizeof(__pyx_k_got_result_for_unknown_protocol), 0, 1, 0, 0},
+  {&__pyx_n_u_gtsvector, __pyx_k_gtsvector, sizeof(__pyx_k_gtsvector), 0, 1, 0, 1},
+  {&__pyx_n_u_has_bin_io, __pyx_k_has_bin_io, sizeof(__pyx_k_has_bin_io), 0, 1, 0, 1},
+  {&__pyx_n_s_hashlib, __pyx_k_hashlib, sizeof(__pyx_k_hashlib), 0, 0, 1, 1},
+  {&__pyx_n_s_hashlib_md5, __pyx_k_hashlib_md5, sizeof(__pyx_k_hashlib_md5), 0, 0, 1, 1},
+  {&__pyx_n_s_hexdigest, __pyx_k_hexdigest, sizeof(__pyx_k_hexdigest), 0, 0, 1, 1},
+  {&__pyx_kp_s_home_travis_build_MagicStack_as, __pyx_k_home_travis_build_MagicStack_as, sizeof(__pyx_k_home_travis_build_MagicStack_as), 0, 0, 1, 0},
+  {&__pyx_n_s_hour, __pyx_k_hour, sizeof(__pyx_k_hour), 0, 0, 1, 1},
+  {&__pyx_kp_u_hstore_value_is_too_large, __pyx_k_hstore_value_is_too_large, sizeof(__pyx_k_hstore_value_is_too_large), 0, 1, 0, 0},
+  {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
+  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
+  {&__pyx_kp_u_inconsistent_sub_array_dimension, __pyx_k_inconsistent_sub_array_dimension, sizeof(__pyx_k_inconsistent_sub_array_dimension), 0, 1, 0, 0},
+  {&__pyx_n_u_inet, __pyx_k_inet, sizeof(__pyx_k_inet), 0, 1, 0, 1},
+  {&__pyx_n_s_infinity_date, __pyx_k_infinity_date, sizeof(__pyx_k_infinity_date), 0, 0, 1, 1},
+  {&__pyx_n_s_infinity_datetime, __pyx_k_infinity_datetime, sizeof(__pyx_k_infinity_datetime), 0, 0, 1, 1},
+  {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
+  {&__pyx_n_s_inspect, __pyx_k_inspect, sizeof(__pyx_k_inspect), 0, 0, 1, 1},
+  {&__pyx_kp_u_insufficient_data_in_buffer_requ, __pyx_k_insufficient_data_in_buffer_requ, sizeof(__pyx_k_insufficient_data_in_buffer_requ), 0, 1, 0, 0},
+  {&__pyx_n_u_int2, __pyx_k_int2, sizeof(__pyx_k_int2), 0, 1, 0, 1},
+  {&__pyx_n_u_int4, __pyx_k_int4, sizeof(__pyx_k_int4), 0, 1, 0, 1},
+  {&__pyx_n_u_int8, __pyx_k_int8, sizeof(__pyx_k_int8), 0, 1, 0, 1},
+  {&__pyx_kp_u_integer_too_large_to_be_encoded, __pyx_k_integer_too_large_to_be_encoded, sizeof(__pyx_k_integer_too_large_to_be_encoded), 0, 1, 0, 0},
+  {&__pyx_n_u_internal, __pyx_k_internal, sizeof(__pyx_k_internal), 0, 1, 0, 1},
+  {&__pyx_n_u_interval, __pyx_k_interval, sizeof(__pyx_k_interval), 0, 1, 0, 1},
+  {&__pyx_kp_u_invalid_address_family_in_value, __pyx_k_invalid_address_family_in_value, sizeof(__pyx_k_invalid_address_family_in_value), 0, 1, 0, 0},
+  {&__pyx_kp_u_invalid_array_element, __pyx_k_invalid_array_element, sizeof(__pyx_k_invalid_array_element), 0, 1, 0, 0},
+  {&__pyx_kp_u_invalid_array_element_at_index, __pyx_k_invalid_array_element_at_index, sizeof(__pyx_k_invalid_array_element_at_index), 0, 1, 0, 0},
+  {&__pyx_kp_u_invalid_bits_in_value, __pyx_k_invalid_bits_in_value, sizeof(__pyx_k_invalid_bits_in_value), 0, 1, 0, 0},
+  {&__pyx_kp_u_invalid_length_in_value, __pyx_k_invalid_length_in_value, sizeof(__pyx_k_invalid_length_in_value), 0, 1, 0, 0},
+  {&__pyx_kp_u_invalid_number_of_elements_in_tx, __pyx_k_invalid_number_of_elements_in_tx, sizeof(__pyx_k_invalid_number_of_elements_in_tx), 0, 1, 0, 0},
+  {&__pyx_kp_u_invalid_rows_codecs, __pyx_k_invalid_rows_codecs, sizeof(__pyx_k_invalid_rows_codecs), 0, 1, 0, 0},
+  {&__pyx_kp_u_invalid_state_after_cancellation, __pyx_k_invalid_state_after_cancellation, sizeof(__pyx_k_invalid_state_after_cancellation), 0, 1, 0, 0},
+  {&__pyx_n_s_ip_address, __pyx_k_ip_address, sizeof(__pyx_k_ip_address), 0, 0, 1, 1},
+  {&__pyx_n_s_ip_network, __pyx_k_ip_network, sizeof(__pyx_k_ip_network), 0, 0, 1, 1},
+  {&__pyx_n_s_ipaddr, __pyx_k_ipaddr, sizeof(__pyx_k_ipaddr), 0, 0, 1, 1},
+  {&__pyx_n_s_ipaddress, __pyx_k_ipaddress, sizeof(__pyx_k_ipaddress), 0, 0, 1, 1},
+  {&__pyx_n_s_ipnet, __pyx_k_ipnet, sizeof(__pyx_k_ipnet), 0, 0, 1, 1},
+  {&__pyx_n_s_is_closed, __pyx_k_is_closed, sizeof(__pyx_k_is_closed), 0, 0, 1, 1},
+  {&__pyx_n_s_isempty, __pyx_k_isempty, sizeof(__pyx_k_isempty), 0, 0, 1, 1},
+  {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
+  {&__pyx_n_u_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 1, 0, 1},
+  {&__pyx_n_u_json, __pyx_k_json, sizeof(__pyx_k_json), 0, 1, 0, 1},
+  {&__pyx_n_u_jsonb, __pyx_k_jsonb, sizeof(__pyx_k_jsonb), 0, 1, 0, 1},
+  {&__pyx_n_u_kind, __pyx_k_kind, sizeof(__pyx_k_kind), 0, 1, 0, 1},
+  {&__pyx_n_u_koi8_r, __pyx_k_koi8_r, sizeof(__pyx_k_koi8_r), 0, 1, 0, 1},
+  {&__pyx_n_u_koi8_u, __pyx_k_koi8_u, sizeof(__pyx_k_koi8_u), 0, 1, 0, 1},
+  {&__pyx_n_u_koi8r, __pyx_k_koi8r, sizeof(__pyx_k_koi8r), 0, 1, 0, 1},
+  {&__pyx_n_u_koi8u, __pyx_k_koi8u, sizeof(__pyx_k_koi8u), 0, 1, 0, 1},
+  {&__pyx_n_u_language_handler, __pyx_k_language_handler, sizeof(__pyx_k_language_handler), 0, 1, 0, 1},
+  {&__pyx_n_s_len, __pyx_k_len, sizeof(__pyx_k_len), 0, 0, 1, 1},
+  {&__pyx_n_s_limit, __pyx_k_limit, sizeof(__pyx_k_limit), 0, 0, 1, 1},
+  {&__pyx_n_u_line, __pyx_k_line, sizeof(__pyx_k_line), 0, 1, 0, 1},
+  {&__pyx_kp_u_list_or_tuple_expected_got_type, __pyx_k_list_or_tuple_expected_got_type, sizeof(__pyx_k_list_or_tuple_expected_got_type), 0, 1, 0, 0},
+  {&__pyx_kp_u_list_tuple_or_Range_object_expec, __pyx_k_list_tuple_or_Range_object_expec, sizeof(__pyx_k_list_tuple_or_Range_object_expec), 0, 1, 0, 0},
+  {&__pyx_n_s_lookup, __pyx_k_lookup, sizeof(__pyx_k_lookup), 0, 0, 1, 1},
+  {&__pyx_n_s_loop, __pyx_k_loop, sizeof(__pyx_k_loop), 0, 0, 1, 1},
+  {&__pyx_n_s_loop_2, __pyx_k_loop_2, sizeof(__pyx_k_loop_2), 0, 0, 1, 1},
+  {&__pyx_n_s_lower, __pyx_k_lower, sizeof(__pyx_k_lower), 0, 0, 1, 1},
+  {&__pyx_n_s_lower_inc, __pyx_k_lower_inc, sizeof(__pyx_k_lower_inc), 0, 0, 1, 1},
+  {&__pyx_n_u_lseg, __pyx_k_lseg, sizeof(__pyx_k_lseg), 0, 1, 0, 1},
+  {&__pyx_n_u_macaddr, __pyx_k_macaddr, sizeof(__pyx_k_macaddr), 0, 1, 0, 1},
+  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
+  {&__pyx_kp_u_malformed_array_literal_r, __pyx_k_malformed_array_literal_r, sizeof(__pyx_k_malformed_array_literal_r), 0, 1, 0, 0},
+  {&__pyx_n_s_mapping, __pyx_k_mapping, sizeof(__pyx_k_mapping), 0, 0, 1, 1},
+  {&__pyx_n_b_md5, __pyx_k_md5, sizeof(__pyx_k_md5), 0, 0, 0, 1},
+  {&__pyx_n_s_md5, __pyx_k_md5, sizeof(__pyx_k_md5), 0, 0, 1, 1},
+  {&__pyx_n_s_memoryview, __pyx_k_memoryview, sizeof(__pyx_k_memoryview), 0, 0, 1, 1},
+  {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
+  {&__pyx_n_s_microsecond, __pyx_k_microsecond, sizeof(__pyx_k_microsecond), 0, 0, 1, 1},
+  {&__pyx_n_s_microseconds, __pyx_k_microseconds, sizeof(__pyx_k_microseconds), 0, 0, 1, 1},
+  {&__pyx_n_s_minute, __pyx_k_minute, sizeof(__pyx_k_minute), 0, 0, 1, 1},
+  {&__pyx_n_s_minutes, __pyx_k_minutes, sizeof(__pyx_k_minutes), 0, 0, 1, 1},
+  {&__pyx_kp_u_missing_after_array_dimensions, __pyx_k_missing_after_array_dimensions, sizeof(__pyx_k_missing_after_array_dimensions), 0, 1, 0, 0},
+  {&__pyx_kp_u_missing_after_array_dimensions_2, __pyx_k_missing_after_array_dimensions_2, sizeof(__pyx_k_missing_after_array_dimensions_2), 0, 1, 0, 0},
+  {&__pyx_kp_u_missing_array_dimension_value, __pyx_k_missing_array_dimension_value, sizeof(__pyx_k_missing_array_dimension_value), 0, 1, 0, 0},
+  {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
+  {&__pyx_n_u_money, __pyx_k_money, sizeof(__pyx_k_money), 0, 1, 0, 1},
+  {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
+  {&__pyx_n_u_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 1, 0, 1},
+  {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
+  {&__pyx_n_s_negative_infinity_date, __pyx_k_negative_infinity_date, sizeof(__pyx_k_negative_infinity_date), 0, 0, 1, 1},
+  {&__pyx_n_s_negative_infinity_datetime, __pyx_k_negative_infinity_datetime, sizeof(__pyx_k_negative_infinity_datetime), 0, 0, 1, 1},
+  {&__pyx_n_s_network_address, __pyx_k_network_address, sizeof(__pyx_k_network_address), 0, 0, 1, 1},
+  {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
+  {&__pyx_n_s_new_prefix, __pyx_k_new_prefix, sizeof(__pyx_k_new_prefix), 0, 0, 1, 1},
+  {&__pyx_kp_u_no_codec_for_array_element_type, __pyx_k_no_codec_for_array_element_type, sizeof(__pyx_k_no_codec_for_array_element_type), 0, 1, 0, 0},
+  {&__pyx_kp_u_no_codec_for_composite_attribute, __pyx_k_no_codec_for_composite_attribute, sizeof(__pyx_k_no_codec_for_composite_attribute), 0, 1, 0, 0},
+  {&__pyx_kp_u_no_codec_for_domain_base_type, __pyx_k_no_codec_for_domain_base_type, sizeof(__pyx_k_no_codec_for_domain_base_type), 0, 1, 0, 0},
+  {&__pyx_kp_u_no_codec_for_range_element_type, __pyx_k_no_codec_for_range_element_type, sizeof(__pyx_k_no_codec_for_range_element_type), 0, 1, 0, 0},
+  {&__pyx_kp_u_no_decoder_for_OID, __pyx_k_no_decoder_for_OID, sizeof(__pyx_k_no_decoder_for_OID), 0, 1, 0, 0},
+  {&__pyx_kp_u_no_decoder_for_composite_type_el, __pyx_k_no_decoder_for_composite_type_el, sizeof(__pyx_k_no_decoder_for_composite_type_el), 0, 1, 0, 0},
+  {&__pyx_kp_u_no_decoder_for_type_OID, __pyx_k_no_decoder_for_type_OID, sizeof(__pyx_k_no_decoder_for_type_OID), 0, 1, 0, 0},
+  {&__pyx_kp_u_no_encoder_for_OID, __pyx_k_no_encoder_for_OID, sizeof(__pyx_k_no_encoder_for_OID), 0, 1, 0, 0},
+  {&__pyx_kp_u_no_message_to_consume, __pyx_k_no_message_to_consume, sizeof(__pyx_k_no_message_to_consume), 0, 1, 0, 0},
+  {&__pyx_kp_u_no_message_to_discard, __pyx_k_no_message_to_discard, sizeof(__pyx_k_no_message_to_discard), 0, 1, 0, 0},
+  {&__pyx_kp_u_non_homogeneous_array, __pyx_k_non_homogeneous_array, sizeof(__pyx_k_non_homogeneous_array), 0, 1, 0, 0},
+  {&__pyx_kp_u_not_connected, __pyx_k_not_connected, sizeof(__pyx_k_not_connected), 0, 1, 0, 0},
+  {&__pyx_kp_u_not_enough_data_to_read_bytes, __pyx_k_not_enough_data_to_read_bytes, sizeof(__pyx_k_not_enough_data_to_read_bytes), 0, 1, 0, 0},
+  {&__pyx_kp_u_not_enough_data_to_read_one_byte, __pyx_k_not_enough_data_to_read_one_byte, sizeof(__pyx_k_not_enough_data_to_read_one_byte), 0, 1, 0, 0},
+  {&__pyx_n_s_notify, __pyx_k_notify, sizeof(__pyx_k_notify), 0, 0, 1, 1},
+  {&__pyx_n_u_ns, __pyx_k_ns, sizeof(__pyx_k_ns), 0, 1, 0, 1},
+  {&__pyx_kp_u_null_value_not_allowed_in_hstore, __pyx_k_null_value_not_allowed_in_hstore, sizeof(__pyx_k_null_value_not_allowed_in_hstore), 0, 1, 0, 0},
+  {&__pyx_kp_u_number_of_arguments_does_not_mat, __pyx_k_number_of_arguments_does_not_mat, sizeof(__pyx_k_number_of_arguments_does_not_mat), 0, 1, 0, 0},
+  {&__pyx_kp_u_number_of_array_dimensions_excee, __pyx_k_number_of_array_dimensions_excee, sizeof(__pyx_k_number_of_array_dimensions_excee), 0, 1, 0, 0},
+  {&__pyx_kp_u_number_of_columns_in_result_is_d, __pyx_k_number_of_columns_in_result_is_d, sizeof(__pyx_k_number_of_columns_in_result_is_d), 0, 1, 0, 0},
+  {&__pyx_n_u_numeric, __pyx_k_numeric, sizeof(__pyx_k_numeric), 0, 1, 0, 1},
+  {&__pyx_n_s_object, __pyx_k_object, sizeof(__pyx_k_object), 0, 0, 1, 1},
+  {&__pyx_n_s_oid, __pyx_k_oid, sizeof(__pyx_k_oid), 0, 0, 1, 1},
+  {&__pyx_n_u_oid, __pyx_k_oid, sizeof(__pyx_k_oid), 0, 1, 0, 1},
+  {&__pyx_kp_u_oid_2, __pyx_k_oid_2, sizeof(__pyx_k_oid_2), 0, 1, 0, 0},
+  {&__pyx_n_s_on_error, __pyx_k_on_error, sizeof(__pyx_k_on_error), 0, 0, 1, 1},
+  {&__pyx_kp_u_on_result__prepare_statement_is, __pyx_k_on_result__prepare_statement_is, sizeof(__pyx_k_on_result__prepare_statement_is), 0, 1, 0, 0},
+  {&__pyx_kp_u_on_result_waiter_is_None, __pyx_k_on_result_waiter_is_None, sizeof(__pyx_k_on_result_waiter_is_None), 0, 1, 0, 0},
+  {&__pyx_kp_u_on_result_waiter_is_done, __pyx_k_on_result_waiter_is_done, sizeof(__pyx_k_on_result_waiter_is_done), 0, 1, 0, 0},
+  {&__pyx_n_s_on_timeout, __pyx_k_on_timeout, sizeof(__pyx_k_on_timeout), 0, 0, 1, 1},
+  {&__pyx_n_s_on_waiter_completed, __pyx_k_on_waiter_completed, sizeof(__pyx_k_on_waiter_completed), 0, 0, 1, 1},
+  {&__pyx_n_u_opaque, __pyx_k_opaque, sizeof(__pyx_k_opaque), 0, 1, 0, 1},
+  {&__pyx_n_s_packed, __pyx_k_packed, sizeof(__pyx_k_packed), 0, 0, 1, 1},
+  {&__pyx_kp_u_parse_data_msgs_first_message_i, __pyx_k_parse_data_msgs_first_message_i, sizeof(__pyx_k_parse_data_msgs_first_message_i), 0, 1, 0, 0},
+  {&__pyx_kp_u_parse_data_msgs_result_is_not_a, __pyx_k_parse_data_msgs_result_is_not_a, sizeof(__pyx_k_parse_data_msgs_result_is_not_a), 0, 1, 0, 0},
+  {&__pyx_n_s_password, __pyx_k_password, sizeof(__pyx_k_password), 0, 0, 1, 1},
+  {&__pyx_n_u_password, __pyx_k_password, sizeof(__pyx_k_password), 0, 1, 0, 1},
+  {&__pyx_n_u_path, __pyx_k_path, sizeof(__pyx_k_path), 0, 1, 0, 1},
+  {&__pyx_kp_u_path_value_too_long, __pyx_k_path_value_too_long, sizeof(__pyx_k_path_value_too_long), 0, 1, 0, 0},
+  {&__pyx_n_u_pg_catalog, __pyx_k_pg_catalog, sizeof(__pyx_k_pg_catalog), 0, 1, 0, 1},
+  {&__pyx_kp_u_pg_contrib_hstore, __pyx_k_pg_contrib_hstore, sizeof(__pyx_k_pg_contrib_hstore), 0, 1, 0, 0},
+  {&__pyx_n_u_pg_ddl_command, __pyx_k_pg_ddl_command, sizeof(__pyx_k_pg_ddl_command), 0, 1, 0, 1},
+  {&__pyx_n_s_pg_epoch_date, __pyx_k_pg_epoch_date, sizeof(__pyx_k_pg_epoch_date), 0, 0, 1, 1},
+  {&__pyx_n_s_pg_epoch_datetime, __pyx_k_pg_epoch_datetime, sizeof(__pyx_k_pg_epoch_datetime), 0, 0, 1, 1},
+  {&__pyx_n_s_pg_epoch_datetime_utc, __pyx_k_pg_epoch_datetime_utc, sizeof(__pyx_k_pg_epoch_datetime_utc), 0, 0, 1, 1},
+  {&__pyx_n_u_pg_lsn, __pyx_k_pg_lsn, sizeof(__pyx_k_pg_lsn), 0, 1, 0, 1},
+  {&__pyx_n_u_pg_node_tree, __pyx_k_pg_node_tree, sizeof(__pyx_k_pg_node_tree), 0, 1, 0, 1},
+  {&__pyx_n_u_point, __pyx_k_point, sizeof(__pyx_k_point), 0, 1, 0, 1},
+  {&__pyx_n_u_polygon, __pyx_k_polygon, sizeof(__pyx_k_polygon), 0, 1, 0, 1},
+  {&__pyx_kp_u_polygon_value_too_long, __pyx_k_polygon_value_too_long, sizeof(__pyx_k_polygon_value_too_long), 0, 1, 0, 0},
+  {&__pyx_n_s_popleft, __pyx_k_popleft, sizeof(__pyx_k_popleft), 0, 0, 1, 1},
+  {&__pyx_n_s_portal_name, __pyx_k_portal_name, sizeof(__pyx_k_portal_name), 0, 0, 1, 1},
+  {&__pyx_n_s_prefixlen, __pyx_k_prefixlen, sizeof(__pyx_k_prefixlen), 0, 0, 1, 1},
+  {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
+  {&__pyx_n_s_prepare_2, __pyx_k_prepare_2, sizeof(__pyx_k_prepare_2), 0, 0, 1, 1},
+  {&__pyx_n_s_print, __pyx_k_print, sizeof(__pyx_k_print), 0, 0, 1, 1},
+  {&__pyx_n_s_protocol, __pyx_k_protocol, sizeof(__pyx_k_protocol), 0, 0, 1, 1},
+  {&__pyx_kp_u_protocol_is_already_in_the_idle, __pyx_k_protocol_is_already_in_the_idle, sizeof(__pyx_k_protocol_is_already_in_the_idle), 0, 1, 0, 0},
+  {&__pyx_kp_u_protocol_is_in_an_unknown_state, __pyx_k_protocol_is_in_an_unknown_state, sizeof(__pyx_k_protocol_is_in_an_unknown_state), 0, 1, 0, 0},
+  {&__pyx_n_s_pyx_capi, __pyx_k_pyx_capi, sizeof(__pyx_k_pyx_capi), 0, 0, 1, 1},
+  {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
+  {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
+  {&__pyx_n_s_query, __pyx_k_query, sizeof(__pyx_k_query), 0, 0, 1, 1},
+  {&__pyx_n_b_r, __pyx_k_r, sizeof(__pyx_k_r), 0, 0, 0, 1},
+  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
+  {&__pyx_n_u_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 1, 0, 1},
+  {&__pyx_n_u_range_subtype, __pyx_k_range_subtype, sizeof(__pyx_k_range_subtype), 0, 1, 0, 1},
+  {&__pyx_kp_u_read_cstr_buffer_overread, __pyx_k_read_cstr_buffer_overread, sizeof(__pyx_k_read_cstr_buffer_overread), 0, 1, 0, 0},
+  {&__pyx_kp_u_read_cstr_only_works_when_the_me, __pyx_k_read_cstr_only_works_when_the_me, sizeof(__pyx_k_read_cstr_only_works_when_the_me), 0, 1, 0, 0},
+  {&__pyx_n_s_rec, __pyx_k_rec, sizeof(__pyx_k_rec), 0, 0, 1, 1},
+  {&__pyx_n_u_record, __pyx_k_record, sizeof(__pyx_k_record), 0, 1, 0, 1},
+  {&__pyx_n_u_refcursor, __pyx_k_refcursor, sizeof(__pyx_k_refcursor), 0, 1, 0, 1},
+  {&__pyx_n_u_regclass, __pyx_k_regclass, sizeof(__pyx_k_regclass), 0, 1, 0, 1},
+  {&__pyx_n_u_regconfig, __pyx_k_regconfig, sizeof(__pyx_k_regconfig), 0, 1, 0, 1},
+  {&__pyx_n_u_regdictionary, __pyx_k_regdictionary, sizeof(__pyx_k_regdictionary), 0, 1, 0, 1},
+  {&__pyx_n_u_regnamespace, __pyx_k_regnamespace, sizeof(__pyx_k_regnamespace), 0, 1, 0, 1},
+  {&__pyx_n_u_regoper, __pyx_k_regoper, sizeof(__pyx_k_regoper), 0, 1, 0, 1},
+  {&__pyx_n_u_regoperator, __pyx_k_regoperator, sizeof(__pyx_k_regoperator), 0, 1, 0, 1},
+  {&__pyx_n_u_regproc, __pyx_k_regproc, sizeof(__pyx_k_regproc), 0, 1, 0, 1},
+  {&__pyx_n_u_regprocedure, __pyx_k_regprocedure, sizeof(__pyx_k_regprocedure), 0, 1, 0, 1},
+  {&__pyx_n_u_regrole, __pyx_k_regrole, sizeof(__pyx_k_regrole), 0, 1, 0, 1},
+  {&__pyx_n_u_regtype, __pyx_k_regtype, sizeof(__pyx_k_regtype), 0, 1, 0, 1},
+  {&__pyx_n_u_reltime, __pyx_k_reltime, sizeof(__pyx_k_reltime), 0, 1, 0, 1},
+  {&__pyx_n_s_replace, __pyx_k_replace, sizeof(__pyx_k_replace), 0, 0, 1, 1},
+  {&__pyx_n_s_request_cancel, __pyx_k_request_cancel, sizeof(__pyx_k_request_cancel), 0, 0, 1, 1},
+  {&__pyx_n_s_return_extra, __pyx_k_return_extra, sizeof(__pyx_k_return_extra), 0, 0, 1, 1},
+  {&__pyx_n_u_scalar, __pyx_k_scalar, sizeof(__pyx_k_scalar), 0, 1, 0, 1},
+  {&__pyx_n_s_second, __pyx_k_second, sizeof(__pyx_k_second), 0, 0, 1, 1},
+  {&__pyx_n_s_seconds, __pyx_k_seconds, sizeof(__pyx_k_seconds), 0, 0, 1, 1},
+  {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1},
+  {&__pyx_n_s_set_builtin_type_codec, __pyx_k_set_builtin_type_codec, sizeof(__pyx_k_set_builtin_type_codec), 0, 0, 1, 1},
+  {&__pyx_n_s_set_exception, __pyx_k_set_exception, sizeof(__pyx_k_set_exception), 0, 0, 1, 1},
+  {&__pyx_n_s_set_result, __pyx_k_set_result, sizeof(__pyx_k_set_result), 0, 0, 1, 1},
+  {&__pyx_n_s_setsockopt, __pyx_k_setsockopt, sizeof(__pyx_k_setsockopt), 0, 0, 1, 1},
+  {&__pyx_n_u_shift_jis, __pyx_k_shift_jis, sizeof(__pyx_k_shift_jis), 0, 1, 0, 1},
+  {&__pyx_n_u_shift_jis_2004, __pyx_k_shift_jis_2004, sizeof(__pyx_k_shift_jis_2004), 0, 1, 0, 1},
+  {&__pyx_n_u_sjis, __pyx_k_sjis, sizeof(__pyx_k_sjis), 0, 1, 0, 1},
+  {&__pyx_n_u_smgr, __pyx_k_smgr, sizeof(__pyx_k_smgr), 0, 1, 0, 1},
+  {&__pyx_n_s_socket, __pyx_k_socket, sizeof(__pyx_k_socket), 0, 0, 1, 1},
+  {&__pyx_n_u_socket, __pyx_k_socket, sizeof(__pyx_k_socket), 0, 1, 0, 1},
+  {&__pyx_kp_u_specified_array_dimensions_do_no, __pyx_k_specified_array_dimensions_do_no, sizeof(__pyx_k_specified_array_dimensions_do_no), 0, 1, 0, 0},
+  {&__pyx_n_u_sql_ascii, __pyx_k_sql_ascii, sizeof(__pyx_k_sql_ascii), 0, 1, 0, 1},
+  {&__pyx_n_s_startswith, __pyx_k_startswith, sizeof(__pyx_k_startswith), 0, 0, 1, 1},
+  {&__pyx_n_s_state, __pyx_k_state, sizeof(__pyx_k_state), 0, 0, 1, 1},
+  {&__pyx_kp_u_stmt, __pyx_k_stmt, sizeof(__pyx_k_stmt), 0, 1, 0, 0},
+  {&__pyx_n_s_stmt_name, __pyx_k_stmt_name, sizeof(__pyx_k_stmt_name), 0, 0, 1, 1},
+  {&__pyx_kp_u_string_too_long, __pyx_k_string_too_long, sizeof(__pyx_k_string_too_long), 0, 1, 0, 0},
+  {&__pyx_n_s_supernet, __pyx_k_supernet, sizeof(__pyx_k_supernet), 0, 0, 1, 1},
+  {&__pyx_n_u_tcvn, __pyx_k_tcvn, sizeof(__pyx_k_tcvn), 0, 1, 0, 1},
+  {&__pyx_n_u_tcvn5712, __pyx_k_tcvn5712, sizeof(__pyx_k_tcvn5712), 0, 1, 0, 1},
+  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
+  {&__pyx_n_u_text, __pyx_k_text, sizeof(__pyx_k_text), 0, 1, 0, 1},
+  {&__pyx_kp_u_text_2, __pyx_k_text_2, sizeof(__pyx_k_text_2), 0, 1, 0, 0},
+  {&__pyx_kp_u_the_buffer_is_in_read_only_mode, __pyx_k_the_buffer_is_in_read_only_mode, sizeof(__pyx_k_the_buffer_is_in_read_only_mode), 0, 1, 0, 0},
+  {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
+  {&__pyx_n_u_tid, __pyx_k_tid, sizeof(__pyx_k_tid), 0, 1, 0, 1},
+  {&__pyx_n_s_time, __pyx_k_time, sizeof(__pyx_k_time), 0, 0, 1, 1},
+  {&__pyx_n_u_time, __pyx_k_time, sizeof(__pyx_k_time), 0, 1, 0, 1},
+  {&__pyx_n_s_timedelta, __pyx_k_timedelta, sizeof(__pyx_k_timedelta), 0, 0, 1, 1},
+  {&__pyx_n_s_timeout, __pyx_k_timeout, sizeof(__pyx_k_timeout), 0, 0, 1, 1},
+  {&__pyx_n_s_timestamp, __pyx_k_timestamp, sizeof(__pyx_k_timestamp), 0, 0, 1, 1},
+  {&__pyx_n_u_timestamp, __pyx_k_timestamp, sizeof(__pyx_k_timestamp), 0, 1, 0, 1},
+  {&__pyx_n_u_timestamptz, __pyx_k_timestamptz, sizeof(__pyx_k_timestamptz), 0, 1, 0, 1},
+  {&__pyx_n_u_timetz, __pyx_k_timetz, sizeof(__pyx_k_timetz), 0, 1, 0, 1},
+  {&__pyx_n_s_timezone, __pyx_k_timezone, sizeof(__pyx_k_timezone), 0, 0, 1, 1},
+  {&__pyx_n_u_tinterval, __pyx_k_tinterval, sizeof(__pyx_k_tinterval), 0, 1, 0, 1},
+  {&__pyx_kp_u_too_many_elements_in_array_value, __pyx_k_too_many_elements_in_array_value, sizeof(__pyx_k_too_many_elements_in_array_value), 0, 1, 0, 0},
+  {&__pyx_kp_u_too_many_elements_in_composite_t, __pyx_k_too_many_elements_in_composite_t, sizeof(__pyx_k_too_many_elements_in_composite_t), 0, 1, 0, 0},
+  {&__pyx_n_s_toordinal, __pyx_k_toordinal, sizeof(__pyx_k_toordinal), 0, 0, 1, 1},
+  {&__pyx_n_u_trigger, __pyx_k_trigger, sizeof(__pyx_k_trigger), 0, 1, 0, 1},
+  {&__pyx_n_u_tsm_handler, __pyx_k_tsm_handler, sizeof(__pyx_k_tsm_handler), 0, 1, 0, 1},
+  {&__pyx_n_u_tsquery, __pyx_k_tsquery, sizeof(__pyx_k_tsquery), 0, 1, 0, 1},
+  {&__pyx_n_u_tsvector, __pyx_k_tsvector, sizeof(__pyx_k_tsvector), 0, 1, 0, 1},
+  {&__pyx_n_u_txid_snapshot, __pyx_k_txid_snapshot, sizeof(__pyx_k_txid_snapshot), 0, 1, 0, 1},
+  {&__pyx_kp_u_txid_snapshot_value_is_too_long, __pyx_k_txid_snapshot_value_is_too_long, sizeof(__pyx_k_txid_snapshot_value_is_too_long), 0, 1, 0, 0},
+  {&__pyx_kp_u_type_record_missing_base_type_fo, __pyx_k_type_record_missing_base_type_fo, sizeof(__pyx_k_type_record_missing_base_type_fo), 0, 1, 0, 0},
+  {&__pyx_kp_u_type_record_missing_base_type_fo_2, __pyx_k_type_record_missing_base_type_fo_2, sizeof(__pyx_k_type_record_missing_base_type_fo_2), 0, 1, 0, 0},
+  {&__pyx_kp_u_type_record_missing_field_types, __pyx_k_type_record_missing_field_types, sizeof(__pyx_k_type_record_missing_field_types), 0, 1, 0, 0},
+  {&__pyx_n_s_typekind, __pyx_k_typekind, sizeof(__pyx_k_typekind), 0, 0, 1, 1},
+  {&__pyx_n_s_typename, __pyx_k_typename, sizeof(__pyx_k_typename), 0, 0, 1, 1},
+  {&__pyx_n_s_typeoid, __pyx_k_typeoid, sizeof(__pyx_k_typeoid), 0, 0, 1, 1},
+  {&__pyx_n_s_types, __pyx_k_types, sizeof(__pyx_k_types), 0, 0, 1, 1},
+  {&__pyx_n_s_typeschema, __pyx_k_typeschema, sizeof(__pyx_k_typeschema), 0, 0, 1, 1},
+  {&__pyx_n_s_tzinfo, __pyx_k_tzinfo, sizeof(__pyx_k_tzinfo), 0, 0, 1, 1},
+  {&__pyx_kp_u_unexpected_JSONB_format, __pyx_k_unexpected_JSONB_format, sizeof(__pyx_k_unexpected_JSONB_format), 0, 1, 0, 0},
+  {&__pyx_kp_u_unexpected_character_r_at_positi, __pyx_k_unexpected_character_r_at_positi, sizeof(__pyx_k_unexpected_character_r_at_positi), 0, 1, 0, 0},
+  {&__pyx_kp_u_unexpected_codec_type, __pyx_k_unexpected_codec_type, sizeof(__pyx_k_unexpected_codec_type), 0, 1, 0, 0},
+  {&__pyx_kp_u_unexpected_data_type_of_composit, __pyx_k_unexpected_data_type_of_composit, sizeof(__pyx_k_unexpected_data_type_of_composit), 0, 1, 0, 0},
+  {&__pyx_kp_u_unexpected_end_of_string, __pyx_k_unexpected_end_of_string, sizeof(__pyx_k_unexpected_end_of_string), 0, 1, 0, 0},
+  {&__pyx_kp_u_unexpected_trailing_bytes_in_buf, __pyx_k_unexpected_trailing_bytes_in_buf, sizeof(__pyx_k_unexpected_trailing_bytes_in_buf), 0, 1, 0, 0},
+  {&__pyx_kp_u_unhandled_standard_data_type_r_O, __pyx_k_unhandled_standard_data_type_r_O, sizeof(__pyx_k_unhandled_standard_data_type_r_O), 0, 1, 0, 0},
+  {&__pyx_n_u_unicode, __pyx_k_unicode, sizeof(__pyx_k_unicode), 0, 1, 0, 1},
+  {&__pyx_n_u_unknown, __pyx_k_unknown, sizeof(__pyx_k_unknown), 0, 1, 0, 1},
+  {&__pyx_kp_u_unknown_alias_target, __pyx_k_unknown_alias_target, sizeof(__pyx_k_unknown_alias_target), 0, 1, 0, 0},
+  {&__pyx_kp_u_unknown_error_in_protocol_implem, __pyx_k_unknown_error_in_protocol_implem, sizeof(__pyx_k_unknown_error_in_protocol_implem), 0, 1, 0, 0},
+  {&__pyx_kp_u_unsupported_authentication_metho, __pyx_k_unsupported_authentication_metho, sizeof(__pyx_k_unsupported_authentication_metho), 0, 1, 0, 0},
+  {&__pyx_kp_u_unsupported_authentication_metho_2, __pyx_k_unsupported_authentication_metho_2, sizeof(__pyx_k_unsupported_authentication_metho_2), 0, 1, 0, 0},
+  {&__pyx_n_s_upper, __pyx_k_upper, sizeof(__pyx_k_upper), 0, 0, 1, 1},
+  {&__pyx_n_s_upper_inc, __pyx_k_upper_inc, sizeof(__pyx_k_upper_inc), 0, 0, 1, 1},
+  {&__pyx_n_s_user, __pyx_k_user, sizeof(__pyx_k_user), 0, 0, 1, 1},
+  {&__pyx_n_u_user, __pyx_k_user, sizeof(__pyx_k_user), 0, 1, 0, 1},
+  {&__pyx_n_s_utc, __pyx_k_utc, sizeof(__pyx_k_utc), 0, 0, 1, 1},
+  {&__pyx_n_s_utcoffset, __pyx_k_utcoffset, sizeof(__pyx_k_utcoffset), 0, 0, 1, 1},
+  {&__pyx_kp_u_utf_8, __pyx_k_utf_8, sizeof(__pyx_k_utf_8), 0, 1, 0, 0},
+  {&__pyx_n_u_utf_8_2, __pyx_k_utf_8_2, sizeof(__pyx_k_utf_8_2), 0, 1, 0, 1},
+  {&__pyx_n_s_uuid, __pyx_k_uuid, sizeof(__pyx_k_uuid), 0, 0, 1, 1},
+  {&__pyx_n_u_uuid, __pyx_k_uuid, sizeof(__pyx_k_uuid), 0, 1, 0, 1},
+  {&__pyx_n_u_varbit, __pyx_k_varbit, sizeof(__pyx_k_varbit), 0, 1, 0, 1},
+  {&__pyx_n_u_varchar, __pyx_k_varchar, sizeof(__pyx_k_varchar), 0, 1, 0, 1},
+  {&__pyx_n_s_version, __pyx_k_version, sizeof(__pyx_k_version), 0, 0, 1, 1},
+  {&__pyx_n_u_void, __pyx_k_void, sizeof(__pyx_k_void), 0, 1, 0, 1},
+  {&__pyx_n_u_vscii, __pyx_k_vscii, sizeof(__pyx_k_vscii), 0, 1, 0, 1},
+  {&__pyx_n_u_win, __pyx_k_win, sizeof(__pyx_k_win), 0, 1, 0, 1},
+  {&__pyx_n_u_win1250, __pyx_k_win1250, sizeof(__pyx_k_win1250), 0, 1, 0, 1},
+  {&__pyx_n_u_win1251, __pyx_k_win1251, sizeof(__pyx_k_win1251), 0, 1, 0, 1},
+  {&__pyx_n_u_win1252, __pyx_k_win1252, sizeof(__pyx_k_win1252), 0, 1, 0, 1},
+  {&__pyx_n_u_win1253, __pyx_k_win1253, sizeof(__pyx_k_win1253), 0, 1, 0, 1},
+  {&__pyx_n_u_win1254, __pyx_k_win1254, sizeof(__pyx_k_win1254), 0, 1, 0, 1},
+  {&__pyx_n_u_win1255, __pyx_k_win1255, sizeof(__pyx_k_win1255), 0, 1, 0, 1},
+  {&__pyx_n_u_win1256, __pyx_k_win1256, sizeof(__pyx_k_win1256), 0, 1, 0, 1},
+  {&__pyx_n_u_win1257, __pyx_k_win1257, sizeof(__pyx_k_win1257), 0, 1, 0, 1},
+  {&__pyx_n_u_win1258, __pyx_k_win1258, sizeof(__pyx_k_win1258), 0, 1, 0, 1},
+  {&__pyx_n_u_win866, __pyx_k_win866, sizeof(__pyx_k_win866), 0, 1, 0, 1},
+  {&__pyx_n_u_win874, __pyx_k_win874, sizeof(__pyx_k_win874), 0, 1, 0, 1},
+  {&__pyx_n_u_win932, __pyx_k_win932, sizeof(__pyx_k_win932), 0, 1, 0, 1},
+  {&__pyx_n_u_win936, __pyx_k_win936, sizeof(__pyx_k_win936), 0, 1, 0, 1},
+  {&__pyx_n_u_win949, __pyx_k_win949, sizeof(__pyx_k_win949), 0, 1, 0, 1},
+  {&__pyx_n_u_win950, __pyx_k_win950, sizeof(__pyx_k_win950), 0, 1, 0, 1},
+  {&__pyx_n_u_windows1250, __pyx_k_windows1250, sizeof(__pyx_k_windows1250), 0, 1, 0, 1},
+  {&__pyx_n_u_windows1251, __pyx_k_windows1251, sizeof(__pyx_k_windows1251), 0, 1, 0, 1},
+  {&__pyx_n_u_windows1252, __pyx_k_windows1252, sizeof(__pyx_k_windows1252), 0, 1, 0, 1},
+  {&__pyx_n_u_windows1253, __pyx_k_windows1253, sizeof(__pyx_k_windows1253), 0, 1, 0, 1},
+  {&__pyx_n_u_windows1254, __pyx_k_windows1254, sizeof(__pyx_k_windows1254), 0, 1, 0, 1},
+  {&__pyx_n_u_windows1255, __pyx_k_windows1255, sizeof(__pyx_k_windows1255), 0, 1, 0, 1},
+  {&__pyx_n_u_windows1256, __pyx_k_windows1256, sizeof(__pyx_k_windows1256), 0, 1, 0, 1},
+  {&__pyx_n_u_windows1257, __pyx_k_windows1257, sizeof(__pyx_k_windows1257), 0, 1, 0, 1},
+  {&__pyx_n_u_windows1258, __pyx_k_windows1258, sizeof(__pyx_k_windows1258), 0, 1, 0, 1},
+  {&__pyx_n_u_windows866, __pyx_k_windows866, sizeof(__pyx_k_windows866), 0, 1, 0, 1},
+  {&__pyx_n_u_windows874, __pyx_k_windows874, sizeof(__pyx_k_windows874), 0, 1, 0, 1},
+  {&__pyx_n_u_windows932, __pyx_k_windows932, sizeof(__pyx_k_windows932), 0, 1, 0, 1},
+  {&__pyx_n_u_windows936, __pyx_k_windows936, sizeof(__pyx_k_windows936), 0, 1, 0, 1},
+  {&__pyx_n_u_windows949, __pyx_k_windows949, sizeof(__pyx_k_windows949), 0, 1, 0, 1},
+  {&__pyx_n_u_windows950, __pyx_k_windows950, sizeof(__pyx_k_windows950), 0, 1, 0, 1},
+  {&__pyx_n_s_write, __pyx_k_write, sizeof(__pyx_k_write), 0, 0, 1, 1},
+  {&__pyx_n_u_xid, __pyx_k_xid, sizeof(__pyx_k_xid), 0, 1, 0, 1},
+  {&__pyx_n_u_xml, __pyx_k_xml, sizeof(__pyx_k_xml), 0, 1, 0, 1},
+  {0, 0, 0, 0, 0, 0, 0}
+};
+static int __Pyx_InitCachedBuiltins(void) {
+  __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) __PYX_ERR(0, 59, __pyx_L1_error)
+  __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 60, __pyx_L1_error)
+  __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) __PYX_ERR(0, 62, __pyx_L1_error)
+  __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(1, 52, __pyx_L1_error)
+  __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(1, 94, __pyx_L1_error)
+  __pyx_builtin_chr = __Pyx_GetBuiltinName(__pyx_n_s_chr); if (!__pyx_builtin_chr) __PYX_ERR(1, 543, __pyx_L1_error)
+  __pyx_builtin_print = __Pyx_GetBuiltinName(__pyx_n_s_print); if (!__pyx_builtin_print) __PYX_ERR(1, 548, __pyx_L1_error)
+  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(2, 110, __pyx_L1_error)
+  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(2, 167, __pyx_L1_error)
+  __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(2, 405, __pyx_L1_error)
+  __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s_NotImplementedError); if (!__pyx_builtin_NotImplementedError) __PYX_ERR(2, 460, __pyx_L1_error)
+  __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(3, 10, __pyx_L1_error)
+  __pyx_builtin_memoryview = __Pyx_GetBuiltinName(__pyx_n_s_memoryview); if (!__pyx_builtin_memoryview) __PYX_ERR(4, 35, __pyx_L1_error)
+  __pyx_builtin_StopIteration = __Pyx_GetBuiltinName(__pyx_n_s_StopIteration); if (!__pyx_builtin_StopIteration) __PYX_ERR(4, 236, __pyx_L1_error)
+  return 0;
+  __pyx_L1_error:;
+  return -1;
+}
+
+static int __Pyx_InitCachedConstants(void) {
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
+
+  /* "asyncpg/protocol/settings.pyx":15
+ *         self._is_utf8 = True
+ *         self._settings = {}
+ *         self._codec = codecs.lookup('utf-8')             # <<<<<<<<<<<<<<
+ *         self._data_codecs = DataCodecConfig(conn_key)
+ * 
+ */
+  __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_utf_8); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 15, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple_);
+  __Pyx_GIVEREF(__pyx_tuple_);
+
+  /* "asyncpg/protocol/settings.pyx":56
+ * 
+ *     def __getattr__(self, name):
+ *         if not name.startswith('_'):             # <<<<<<<<<<<<<<
+ *             try:
+ *                 return self._settings[name]
+ */
+  __pyx_tuple__4 = PyTuple_Pack(1, __pyx_n_u__3); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 56, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__4);
+  __Pyx_GIVEREF(__pyx_tuple__4);
+
+  /* "asyncpg/protocol/buffer.pyx":52
+ * 
+ *         if self._view_count:
+ *             raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                 'Deallocating buffer with attached memoryviews')
+ * 
+ */
+  __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_Deallocating_buffer_with_attache); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 52, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__5);
+  __Pyx_GIVEREF(__pyx_tuple__5);
+
+  /* "asyncpg/protocol/buffer.pyx":68
+ *     cdef inline _check_readonly(self):
+ *         if self._view_count:
+ *             raise BufferError('the buffer is in read-only mode')             # <<<<<<<<<<<<<<
+ * 
+ *     cdef inline len(self):
+ */
+  __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_the_buffer_is_in_read_only_mode); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 68, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__6);
+  __Pyx_GIVEREF(__pyx_tuple__6);
+
+  /* "asyncpg/protocol/buffer.pyx":112
+ *     cdef inline start_message(self, char type):
+ *         if self._length != 0:
+ *             raise BufferError('cannot start_message for a non-empty buffer')             # <<<<<<<<<<<<<<
+ *         self._ensure_alloced(5)
+ *         self._message_mode = 1
+ */
+  __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_u_cannot_start_message_for_a_non_e); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 112, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__7);
+  __Pyx_GIVEREF(__pyx_tuple__7);
+
+  /* "asyncpg/protocol/buffer.pyx":124
+ *         self._check_readonly()
+ *         if not self._message_mode:
+ *             raise BufferError(             # <<<<<<<<<<<<<<
+ *                 'end_message can only be called with start_message')
+ *         if self._length < 5:
+ */
+  __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_u_end_message_can_only_be_called_w); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 124, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__8);
+  __Pyx_GIVEREF(__pyx_tuple__8);
+
+  /* "asyncpg/protocol/buffer.pyx":127
+ *                 'end_message can only be called with start_message')
+ *         if self._length < 5:
+ *             raise BufferError('end_message: buffer is too small')             # <<<<<<<<<<<<<<
+ *         if mlen > _MAXINT32:
+ *             raise BufferError('end_message: message is too large')
+ */
+  __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_u_end_message_buffer_is_too_small); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(1, 127, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__9);
+  __Pyx_GIVEREF(__pyx_tuple__9);
+
+  /* "asyncpg/protocol/buffer.pyx":129
+ *             raise BufferError('end_message: buffer is too small')
+ *         if mlen > _MAXINT32:
+ *             raise BufferError('end_message: message is too large')             # <<<<<<<<<<<<<<
+ * 
+ *         hton.pack_int32(&self._buf[1], <int32_t>mlen)
+ */
+  __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_u_end_message_message_is_too_large); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(1, 129, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__10);
+  __Pyx_GIVEREF(__pyx_tuple__10);
+
+  /* "asyncpg/protocol/buffer.pyx":255
+ * 
+ *         if not cpython.PyBytes_CheckExact(data):
+ *             raise BufferError('feed_data: bytes object expected')             # <<<<<<<<<<<<<<
+ *         data_bytes = <bytes>data
+ * 
+ */
+  __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_u_feed_data_bytes_object_expected); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(1, 255, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__11);
+  __Pyx_GIVEREF(__pyx_tuple__11);
+
+  /* "asyncpg/protocol/buffer.pyx":275
+ *     cdef inline _ensure_first_buf(self):
+ *         if self._len0 == 0:
+ *             raise BufferError('empty first buffer')             # <<<<<<<<<<<<<<
+ * 
+ *         if self._pos0 == self._len0:
+ */
+  __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_u_empty_first_buffer); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(1, 275, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__12);
+  __Pyx_GIVEREF(__pyx_tuple__12);
+
+  /* "asyncpg/protocol/buffer.pyx":295
+ *         if ASYNCPG_DEBUG:
+ *             if self._len0 < 1:
+ *                 raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                     'debug: second buffer of ReadBuffer is empty')
+ * 
+ */
+  __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_u_debug_second_buffer_of_ReadBuffe); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(1, 295, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__13);
+  __Pyx_GIVEREF(__pyx_tuple__13);
+
+  /* "asyncpg/protocol/buffer.pyx":342
+ *             self._current_message_len_unread -= nbytes
+ *             if self._current_message_len_unread < 0:
+ *                 raise BufferError('buffer overread')             # <<<<<<<<<<<<<<
+ * 
+ *         result = bytearray()
+ */
+  __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_u_buffer_overread); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(1, 342, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__14);
+  __Pyx_GIVEREF(__pyx_tuple__14);
+
+  /* "asyncpg/protocol/buffer.pyx":368
+ *         if ASYNCPG_DEBUG:
+ *             if not self._buf0:
+ *                 raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                     'debug: first buffer of ReadBuffer is empty')
+ * 
+ */
+  __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_u_debug_first_buffer_of_ReadBuffer); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(1, 368, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__15);
+  __Pyx_GIVEREF(__pyx_tuple__15);
+
+  /* "asyncpg/protocol/buffer.pyx":374
+ *         first_byte = self._try_read_bytes(1)
+ *         if first_byte is NULL:
+ *             raise BufferError('not enough data to read one byte')             # <<<<<<<<<<<<<<
+ * 
+ *         return first_byte[0]
+ */
+  __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_u_not_enough_data_to_read_one_byte); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(1, 374, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__16);
+  __Pyx_GIVEREF(__pyx_tuple__16);
+
+  /* "asyncpg/protocol/buffer.pyx":419
+ *     cdef inline read_cstr(self):
+ *         if not self._current_message_ready:
+ *             raise BufferError(             # <<<<<<<<<<<<<<
+ *                 'read_cstr only works when the message guaranteed '
+ *                 'to be in the buffer')
+ */
+  __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_u_read_cstr_only_works_when_the_me); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(1, 419, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__17);
+  __Pyx_GIVEREF(__pyx_tuple__17);
+
+  /* "asyncpg/protocol/buffer.pyx":457
+ *                 self._current_message_len_unread -= nread
+ *                 if self._current_message_len_unread < 0:
+ *                     raise BufferError('read_cstr: buffer overread')             # <<<<<<<<<<<<<<
+ * 
+ *                 return result
+ */
+  __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_u_read_cstr_buffer_overread); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(1, 457, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__20);
+  __Pyx_GIVEREF(__pyx_tuple__20);
+
+  /* "asyncpg/protocol/buffer.pyx":469
+ *                 self._current_message_len_unread -= nread
+ *                 if self._current_message_len_unread < 0:
+ *                     raise BufferError('read_cstr: buffer overread')             # <<<<<<<<<<<<<<
+ * 
+ *                 self._ensure_first_buf()
+ */
+  __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_u_read_cstr_buffer_overread); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(1, 469, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__21);
+  __Pyx_GIVEREF(__pyx_tuple__21);
+
+  /* "asyncpg/protocol/buffer.pyx":486
+ *             cbuf = self._try_read_bytes(1)
+ *             if cbuf == NULL:
+ *                 raise BufferError(             # <<<<<<<<<<<<<<
+ *                     'failed to read one byte on a non-empty buffer')
+ *             self._current_message_type = cbuf[0]
+ */
+  __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_u_failed_to_read_one_byte_on_a_non); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(1, 486, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__22);
+  __Pyx_GIVEREF(__pyx_tuple__22);
+
+  /* "asyncpg/protocol/buffer.pyx":525
+ *     cdef Memory consume_message(self):
+ *         if not self._current_message_ready:
+ *             raise BufferError('no message to consume')             # <<<<<<<<<<<<<<
+ *         if self._current_message_len_unread > 0:
+ *             mem = self.read(self._current_message_len_unread)
+ */
+  __pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_u_no_message_to_consume); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(1, 525, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__23);
+  __Pyx_GIVEREF(__pyx_tuple__23);
+
+  /* "asyncpg/protocol/buffer.pyx":539
+ * 
+ *         if not self._current_message_ready:
+ *             raise BufferError('no message to discard')             # <<<<<<<<<<<<<<
+ * 
+ *         if self._current_message_len_unread:
+ */
+  __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_u_no_message_to_discard); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(1, 539, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__24);
+  __Pyx_GIVEREF(__pyx_tuple__24);
+
+  /* "asyncpg/protocol/codecs/base.pyx":110
+ *         count = len(obj)
+ *         if count > _MAXINT32:
+ *             raise ValueError('too many elements in composite type record')             # <<<<<<<<<<<<<<
+ * 
+ *         elem_data = WriteBuffer.new()
+ */
+  __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_u_too_many_elements_in_composite_t); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(2, 110, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__25);
+  __Pyx_GIVEREF(__pyx_tuple__25);
+
+  /* "asyncpg/protocol/codecs/base.pyx":363
+ * 
+ *                 # Canonicalize type name to "elemtype[]"
+ *                 if name.startswith('_'):             # <<<<<<<<<<<<<<
+ *                     name = name[1:]
+ *                 name = '{}[]'.format(name)
+ */
+  __pyx_tuple__26 = PyTuple_Pack(1, __pyx_n_u__3); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(2, 363, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__26);
+  __Pyx_GIVEREF(__pyx_tuple__26);
+
+  /* "asyncpg/protocol/codecs/base.pyx":364
+ *                 # Canonicalize type name to "elemtype[]"
+ *                 if name.startswith('_'):
+ *                     name = name[1:]             # <<<<<<<<<<<<<<
+ *                 name = '{}[]'.format(name)
+ * 
+ */
+  __pyx_slice__27 = PySlice_New(__pyx_int_1, Py_None, Py_None); if (unlikely(!__pyx_slice__27)) __PYX_ERR(2, 364, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_slice__27);
+  __Pyx_GIVEREF(__pyx_slice__27);
+
+  /* "asyncpg/protocol/codecs/base.pyx":591
+ *     kind = 'scalar'
+ * 
+ *     codec = Codec(INVALIDOID)             # <<<<<<<<<<<<<<
+ *     codec.init(name, None, kind, CODEC_C, format, encode,
+ *                decode, None, None, None, None, None, None, 0)
+ */
+  __pyx_tuple__29 = PyTuple_Pack(1, __pyx_int_0); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(2, 591, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__29);
+  __Pyx_GIVEREF(__pyx_tuple__29);
+
+  /* "asyncpg/protocol/codecs/text.pyx":21
+ * 
+ *     if size[0] > 0x7fffffff:
+ *         raise ValueError('string too long')             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_u_string_too_long); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(7, 21, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__30);
+  __Pyx_GIVEREF(__pyx_tuple__30);
+
+  /* "asyncpg/protocol/codecs/bits.pyx":35
+ *     try:
+ *         if bitlen > _MAXINT32:
+ *             raise ValueError('bit value too long')             # <<<<<<<<<<<<<<
+ *         wbuf.write_int32(4 + <int32_t>len)
+ *         wbuf.write_int32(<int32_t>bitlen)
+ */
+  __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_u_bit_value_too_long); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(8, 35, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__31);
+  __Pyx_GIVEREF(__pyx_tuple__31);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":211
+ * 
+ * cdef timetz_encode(ConnectionSettings settings, WriteBuffer buf, obj):
+ *     offset = obj.tzinfo.utcoffset(None)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef:
+ */
+  __pyx_tuple__32 = PyTuple_Pack(1, Py_None); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(9, 211, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__32);
+  __Pyx_GIVEREF(__pyx_tuple__32);
+
+  /* "asyncpg/protocol/codecs/float.pyx":15
+ *     cdef float fval = <float>dval
+ *     if math.isinf(fval) and not math.isinf(dval):
+ *         raise ValueError('float value too large to be encoded as FLOAT4')             # <<<<<<<<<<<<<<
+ * 
+ *     buf.write_int32(4)
+ */
+  __pyx_tuple__33 = PyTuple_Pack(1, __pyx_kp_u_float_value_too_large_to_be_enco); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(10, 15, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__33);
+  __Pyx_GIVEREF(__pyx_tuple__33);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":115
+ *     encoded_len = 1 + 4 + 16 * npts
+ *     if encoded_len > _MAXINT32:
+ *         raise ValueError('path value too long')             # <<<<<<<<<<<<<<
+ * 
+ *     wbuf.write_int32(<int32_t>encoded_len)
+ */
+  __pyx_tuple__34 = PyTuple_Pack(1, __pyx_kp_u_path_value_too_long); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(11, 115, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__34);
+  __Pyx_GIVEREF(__pyx_tuple__34);
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":141
+ *     encoded_len = 4 + 16 * npts
+ *     if encoded_len > _MAXINT32:
+ *         raise ValueError('polygon value too long')             # <<<<<<<<<<<<<<
+ * 
+ *     wbuf.write_int32(<int32_t>encoded_len)
+ */
+  __pyx_tuple__35 = PyTuple_Pack(1, __pyx_kp_u_polygon_value_too_long); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(11, 141, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__35);
+  __Pyx_GIVEREF(__pyx_tuple__35);
+
+  /* "asyncpg/protocol/codecs/json.pyx":16
+ * 
+ *     if size > 0x7fffffff - 1:
+ *         raise ValueError('string too long')             # <<<<<<<<<<<<<<
+ * 
+ *     buf.write_int32(<int32_t>size + 1)
+ */
+  __pyx_tuple__36 = PyTuple_Pack(1, __pyx_kp_u_string_too_long); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(12, 16, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__36);
+  __Pyx_GIVEREF(__pyx_tuple__36);
+
+  /* "asyncpg/protocol/codecs/txid.pyx":21
+ * 
+ *     if len(obj) != 3:
+ *         raise ValueError(             # <<<<<<<<<<<<<<
+ *             'invalid number of elements in txid_snapshot tuple, expecting 4')
+ * 
+ */
+  __pyx_tuple__37 = PyTuple_Pack(1, __pyx_kp_u_invalid_number_of_elements_in_tx); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(17, 21, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__37);
+  __Pyx_GIVEREF(__pyx_tuple__37);
+
+  /* "asyncpg/protocol/codecs/txid.pyx":26
+ *     nxip = len(obj[2])
+ *     if nxip > _MAXINT32:
+ *         raise ValueError('txid_snapshot value is too long')             # <<<<<<<<<<<<<<
+ * 
+ *     xmin = obj[0]
+ */
+  __pyx_tuple__38 = PyTuple_Pack(1, __pyx_kp_u_txid_snapshot_value_is_too_long); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(17, 26, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__38);
+  __Pyx_GIVEREF(__pyx_tuple__38);
+
+  /* "asyncpg/protocol/codecs/array.pyx":49
+ * 
+ *     if mylen > _MAXINT32:
+ *         raise ValueError('too many elements in array value')             # <<<<<<<<<<<<<<
+ * 
+ *     if ndims[0] > ARRAY_MAXDIM:
+ */
+  __pyx_tuple__39 = PyTuple_Pack(1, __pyx_kp_u_too_many_elements_in_array_value); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(20, 49, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__39);
+  __Pyx_GIVEREF(__pyx_tuple__39);
+
+  /* "asyncpg/protocol/codecs/array.pyx":63
+ *                 elemlen = len(elem)
+ *                 if elemlen > _MAXINT32:
+ *                     raise ValueError('too many elements in array value')             # <<<<<<<<<<<<<<
+ *                 ndims[0] += 1
+ *                 _get_array_shape(elem, dims, ndims)
+ */
+  __pyx_tuple__40 = PyTuple_Pack(1, __pyx_kp_u_too_many_elements_in_array_value); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(20, 63, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__40);
+  __Pyx_GIVEREF(__pyx_tuple__40);
+
+  /* "asyncpg/protocol/codecs/array.pyx":68
+ *             else:
+ *                 if len(elem) != elemlen:
+ *                     raise ValueError('non-homogeneous array')             # <<<<<<<<<<<<<<
+ *         else:
+ *             if elemlen >= 0:
+ */
+  __pyx_tuple__41 = PyTuple_Pack(1, __pyx_kp_u_non_homogeneous_array); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(20, 68, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__41);
+  __Pyx_GIVEREF(__pyx_tuple__41);
+
+  /* "asyncpg/protocol/codecs/array.pyx":71
+ *         else:
+ *             if elemlen >= 0:
+ *                 raise ValueError('non-homogeneous array')             # <<<<<<<<<<<<<<
+ *             else:
+ *                 elemlen = -1
+ */
+  __pyx_tuple__42 = PyTuple_Pack(1, __pyx_kp_u_non_homogeneous_array); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(20, 71, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__42);
+  __Pyx_GIVEREF(__pyx_tuple__42);
+
+  /* "asyncpg/protocol/codecs/array.pyx":397
+ *         ptr = apg_parse_int32(ptr, &ubound)
+ *         if ptr == NULL:
+ *             raise ValueError('missing array dimension value')             # <<<<<<<<<<<<<<
+ * 
+ *         if ptr[0] == ':':
+ */
+  __pyx_tuple__43 = PyTuple_Pack(1, __pyx_kp_u_missing_array_dimension_value); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(20, 397, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__43);
+  __Pyx_GIVEREF(__pyx_tuple__43);
+
+  /* "asyncpg/protocol/codecs/array.pyx":406
+ *             ptr = apg_parse_int32(ptr, &ubound)
+ *             if ptr == NULL:
+ *                 raise ValueError('missing array dimension value')             # <<<<<<<<<<<<<<
+ *         else:
+ *             lbound = 1
+ */
+  __pyx_tuple__44 = PyTuple_Pack(1, __pyx_kp_u_missing_array_dimension_value); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(20, 406, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__44);
+  __Pyx_GIVEREF(__pyx_tuple__44);
+
+  /* "asyncpg/protocol/codecs/array.pyx":411
+ * 
+ *         if ptr[0] != ']':
+ *             raise ValueError('missing \']\' after array dimensions')             # <<<<<<<<<<<<<<
+ * 
+ *         ptr += 1  # ']'
+ */
+  __pyx_tuple__45 = PyTuple_Pack(1, __pyx_kp_u_missing_after_array_dimensions); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(20, 411, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__45);
+  __Pyx_GIVEREF(__pyx_tuple__45);
+
+  /* "asyncpg/protocol/codecs/array.pyx":421
+ *         # If dimensions were given, the '=' token is expected.
+ *         if ptr[0] != '=':
+ *             raise ValueError('missing \'=\' after array dimensions')             # <<<<<<<<<<<<<<
+ * 
+ *         ptr += 1  # '='
+ */
+  __pyx_tuple__46 = PyTuple_Pack(1, __pyx_kp_u_missing_after_array_dimensions_2); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(20, 421, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__46);
+  __Pyx_GIVEREF(__pyx_tuple__46);
+
+  /* "asyncpg/protocol/codecs/array.pyx":436
+ * 
+ *         if inferred_ndims != ndims:
+ *             raise ValueError(             # <<<<<<<<<<<<<<
+ *                 'specified array dimensions do not match array content')
+ * 
+ */
+  __pyx_tuple__47 = PyTuple_Pack(1, __pyx_kp_u_specified_array_dimensions_do_no); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(20, 436, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__47);
+  __Pyx_GIVEREF(__pyx_tuple__47);
+
+  /* "asyncpg/protocol/codecs/array.pyx":441
+ *         for i in range(ndims):
+ *             if inferred_dims[i] != dims[i]:
+ *                 raise ValueError(             # <<<<<<<<<<<<<<
+ *                     'specified array dimensions do not match array content')
+ *     else:
+ */
+  __pyx_tuple__48 = PyTuple_Pack(1, __pyx_kp_u_specified_array_dimensions_do_no); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(20, 441, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__48);
+  __Pyx_GIVEREF(__pyx_tuple__48);
+
+  /* "asyncpg/protocol/codecs/array.pyx":613
+ *         while not end_of_item:
+ *             if ptr[0] == '\0':
+ *                 raise ValueError('unexpected end of string')             # <<<<<<<<<<<<<<
+ * 
+ *             elif ptr[0] == '"':
+ */
+  __pyx_tuple__49 = PyTuple_Pack(1, __pyx_kp_u_unexpected_end_of_string); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(20, 613, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__49);
+  __Pyx_GIVEREF(__pyx_tuple__49);
+
+  /* "asyncpg/protocol/codecs/array.pyx":638
+ *                     ptr += 1
+ *                 else:
+ *                     raise ValueError('unexpected end of string')             # <<<<<<<<<<<<<<
+ * 
+ *             elif in_quotes:
+ */
+  __pyx_tuple__50 = PyTuple_Pack(1, __pyx_kp_u_unexpected_end_of_string); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(20, 638, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__50);
+  __Pyx_GIVEREF(__pyx_tuple__50);
+
+  /* "asyncpg/protocol/codecs/hstore.pyx":18
+ *     count = len(obj)
+ *     if count > _MAXINT32:
+ *         raise ValueError('hstore value is too large')             # <<<<<<<<<<<<<<
+ *     item_buf.write_int32(<int32_t>count)
+ * 
+ */
+  __pyx_tuple__51 = PyTuple_Pack(1, __pyx_kp_u_hstore_value_is_too_large); if (unlikely(!__pyx_tuple__51)) __PYX_ERR(23, 18, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__51);
+  __Pyx_GIVEREF(__pyx_tuple__51);
+
+  /* "asyncpg/protocol/codecs/hstore.pyx":28
+ *     for k, v in items:
+ *         if k is None:
+ *             raise ValueError('null value not allowed in hstore key')             # <<<<<<<<<<<<<<
+ *         as_pg_string_and_size(settings, k, &str, &size)
+ *         item_buf.write_int32(<int32_t>size)
+ */
+  __pyx_tuple__52 = PyTuple_Pack(1, __pyx_kp_u_null_value_not_allowed_in_hstore); if (unlikely(!__pyx_tuple__52)) __PYX_ERR(23, 28, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__52);
+  __Pyx_GIVEREF(__pyx_tuple__52);
+
+  /* "asyncpg/protocol/codecs/hstore.pyx":61
+ *         elem_len = hton.unpack_int32(buf.read(4))
+ *         if elem_len < 0:
+ *             raise ValueError('null value not allowed in hstore key')             # <<<<<<<<<<<<<<
+ * 
+ *         k = decode_pg_string(settings, buf.read(elem_len), elem_len)
+ */
+  __pyx_tuple__53 = PyTuple_Pack(1, __pyx_kp_u_null_value_not_allowed_in_hstore); if (unlikely(!__pyx_tuple__53)) __PYX_ERR(23, 61, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__53);
+  __Pyx_GIVEREF(__pyx_tuple__53);
+
+  /* "asyncpg/protocol/coreproto.pyx":15
+ *     def __init__(self, con_args):
+ *         self.buffer = ReadBuffer()
+ *         self.user = con_args.get('user')             # <<<<<<<<<<<<<<
+ *         self.password = con_args.get('password')
+ *         self.auth_msg = None
+ */
+  __pyx_tuple__54 = PyTuple_Pack(1, __pyx_n_u_user); if (unlikely(!__pyx_tuple__54)) __PYX_ERR(4, 15, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__54);
+  __Pyx_GIVEREF(__pyx_tuple__54);
+
+  /* "asyncpg/protocol/coreproto.pyx":16
+ *         self.buffer = ReadBuffer()
+ *         self.user = con_args.get('user')
+ *         self.password = con_args.get('password')             # <<<<<<<<<<<<<<
+ *         self.auth_msg = None
+ *         self.con_args = con_args
+ */
+  __pyx_tuple__55 = PyTuple_Pack(1, __pyx_n_u_password); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(4, 16, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__55);
+  __Pyx_GIVEREF(__pyx_tuple__55);
+
+  /* "asyncpg/protocol/coreproto.pyx":91
+ *                         if self.result_type != RESULT_FAILED:
+ *                             self.result_type = RESULT_FAILED
+ *                             self.result = RuntimeError(             # <<<<<<<<<<<<<<
+ *                                 'unknown error in protocol implementation')
+ * 
+ */
+  __pyx_tuple__56 = PyTuple_Pack(1, __pyx_kp_u_unknown_error_in_protocol_implem); if (unlikely(!__pyx_tuple__56)) __PYX_ERR(4, 91, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__56);
+  __Pyx_GIVEREF(__pyx_tuple__56);
+
+  /* "asyncpg/protocol/coreproto.pyx":326
+ *         if ASYNCPG_DEBUG:
+ *             if buf.get_message_type() != b'D':
+ *                 raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                     '_parse_data_msgs: first message is not "D"')
+ * 
+ */
+  __pyx_tuple__57 = PyTuple_Pack(1, __pyx_kp_u_parse_data_msgs_first_message_i); if (unlikely(!__pyx_tuple__57)) __PYX_ERR(4, 326, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__57);
+  __Pyx_GIVEREF(__pyx_tuple__57);
+
+  /* "asyncpg/protocol/coreproto.pyx":420
+ * 
+ *         msg = WriteBuffer.new_message(b'p')
+ *         msg.write_bytestring(self.password.encode('ascii'))             # <<<<<<<<<<<<<<
+ *         msg.end_message()
+ * 
+ */
+  __pyx_tuple__58 = PyTuple_Pack(1, __pyx_n_u_ascii); if (unlikely(!__pyx_tuple__58)) __PYX_ERR(4, 420, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__58);
+  __Pyx_GIVEREF(__pyx_tuple__58);
+
+  /* "asyncpg/protocol/coreproto.pyx":432
+ * 
+ *         # 'md5' + md5(md5(password + username) + salt))
+ *         userpass = ((self.password or '') + (self.user or '')).encode('ascii')             # <<<<<<<<<<<<<<
+ *         hash = hashlib_md5(hashlib_md5(userpass).hexdigest().\
+ *                 encode('ascii') + salt).hexdigest().encode('ascii')
+ */
+  __pyx_tuple__59 = PyTuple_Pack(1, __pyx_n_u_ascii); if (unlikely(!__pyx_tuple__59)) __PYX_ERR(4, 432, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__59);
+  __Pyx_GIVEREF(__pyx_tuple__59);
+
+  /* "asyncpg/protocol/coreproto.pyx":434
+ *         userpass = ((self.password or '') + (self.user or '')).encode('ascii')
+ *         hash = hashlib_md5(hashlib_md5(userpass).hexdigest().\
+ *                 encode('ascii') + salt).hexdigest().encode('ascii')             # <<<<<<<<<<<<<<
+ * 
+ *         msg.write_bytestring(b'md5' + hash)
+ */
+  __pyx_tuple__60 = PyTuple_Pack(1, __pyx_n_u_ascii); if (unlikely(!__pyx_tuple__60)) __PYX_ERR(4, 434, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__60);
+  __Pyx_GIVEREF(__pyx_tuple__60);
+  __pyx_tuple__61 = PyTuple_Pack(1, __pyx_n_u_ascii); if (unlikely(!__pyx_tuple__61)) __PYX_ERR(4, 434, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__61);
+  __Pyx_GIVEREF(__pyx_tuple__61);
+
+  /* "asyncpg/protocol/coreproto.pyx":491
+ *         if new_state == PROTOCOL_IDLE:
+ *             if self.state == PROTOCOL_FAILED:
+ *                 raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                     'cannot switch to "idle" state; '
+ *                     'protocol is in the "failed" state')
+ */
+  __pyx_tuple__62 = PyTuple_Pack(1, __pyx_kp_u_cannot_switch_to_idle_state_prot); if (unlikely(!__pyx_tuple__62)) __PYX_ERR(4, 491, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__62);
+  __Pyx_GIVEREF(__pyx_tuple__62);
+
+  /* "asyncpg/protocol/coreproto.pyx":495
+ *                     'protocol is in the "failed" state')
+ *             elif self.state == PROTOCOL_IDLE:
+ *                 raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                     'protocol is already in the "idle" state')
+ *             else:
+ */
+  __pyx_tuple__63 = PyTuple_Pack(1, __pyx_kp_u_protocol_is_already_in_the_idle); if (unlikely(!__pyx_tuple__63)) __PYX_ERR(4, 495, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__63);
+  __Pyx_GIVEREF(__pyx_tuple__63);
+
+  /* "asyncpg/protocol/coreproto.pyx":519
+ *     cdef _ensure_connected(self):
+ *         if self.con_status != CONNECTION_OK:
+ *             raise RuntimeError('not connected')             # <<<<<<<<<<<<<<
+ * 
+ *     cdef WriteBuffer _build_bind_message(self, str portal_name,
+ */
+  __pyx_tuple__64 = PyTuple_Pack(1, __pyx_kp_u_not_connected); if (unlikely(!__pyx_tuple__64)) __PYX_ERR(4, 519, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__64);
+  __Pyx_GIVEREF(__pyx_tuple__64);
+
+  /* "asyncpg/protocol/coreproto.pyx":544
+ * 
+ *         if self.con_status != CONNECTION_BAD:
+ *             raise RuntimeError('already connected')             # <<<<<<<<<<<<<<
+ * 
+ *         self._set_state(PROTOCOL_AUTH)
+ */
+  __pyx_tuple__65 = PyTuple_Pack(1, __pyx_kp_u_already_connected); if (unlikely(!__pyx_tuple__65)) __PYX_ERR(4, 544, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__65);
+  __Pyx_GIVEREF(__pyx_tuple__65);
+
+  /* "asyncpg/protocol/coreproto.pyx":557
+ * 
+ *         buf.write_bytestring(b'client_encoding')
+ *         buf.write_bytestring("'{}'".format(self.encoding).encode('ascii'))             # <<<<<<<<<<<<<<
+ * 
+ *         for param in self.con_args:
+ */
+  __pyx_tuple__67 = PyTuple_Pack(1, __pyx_n_u_ascii); if (unlikely(!__pyx_tuple__67)) __PYX_ERR(4, 557, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__67);
+  __Pyx_GIVEREF(__pyx_tuple__67);
+
+  /* "asyncpg/protocol/coreproto.pyx":735
+ *         self.transport = transport
+ * 
+ *         sock = transport.get_extra_info('socket')             # <<<<<<<<<<<<<<
+ *         if (sock is not None and
+ *               (not hasattr(socket, 'AF_UNIX')
+ */
+  __pyx_tuple__68 = PyTuple_Pack(1, __pyx_n_u_socket); if (unlikely(!__pyx_tuple__68)) __PYX_ERR(4, 735, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__68);
+  __Pyx_GIVEREF(__pyx_tuple__68);
+
+  /* "asyncpg/protocol/prepared_stmt.pyx":228
+ *             if fnum > 0:
+ *                 # It's OK to have no rows_codecs for empty records
+ *                 raise RuntimeError('invalid rows_codecs')             # <<<<<<<<<<<<<<
+ * 
+ *         dec_row = record.ApgRecord_New(self.cols_desc, fnum)
+ */
+  __pyx_tuple__69 = PyTuple_Pack(1, __pyx_kp_u_invalid_rows_codecs); if (unlikely(!__pyx_tuple__69)) __PYX_ERR(25, 228, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__69);
+  __Pyx_GIVEREF(__pyx_tuple__69);
+
+  /* "asyncpg/protocol/protocol.pyx":93
+ *         self.address = addr
+ *         self.settings = ConnectionSettings(
+ *             (self.address, con_args.get('database')))             # <<<<<<<<<<<<<<
+ * 
+ *         self.uid_counter = 0
+ */
+  __pyx_tuple__70 = PyTuple_Pack(1, __pyx_n_u_database); if (unlikely(!__pyx_tuple__70)) __PYX_ERR(27, 93, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__70);
+  __Pyx_GIVEREF(__pyx_tuple__70);
+
+  /* "asyncpg/protocol/protocol.pyx":335
+ *     cdef _handle_waiter_on_connection_lost(self, cause):
+ *         if self.waiter is not None and not self.waiter.done():
+ *             exc = apg_exc.ConnectionDoesNotExistError(             # <<<<<<<<<<<<<<
+ *                 'connection was closed in the middle of '
+ *                 'operation')
+ */
+  __pyx_tuple__71 = PyTuple_Pack(1, __pyx_kp_u_connection_was_closed_in_the_mid); if (unlikely(!__pyx_tuple__71)) __PYX_ERR(27, 335, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__71);
+  __Pyx_GIVEREF(__pyx_tuple__71);
+
+  /* "asyncpg/protocol/protocol.pyx":348
+ *     cdef _ensure_clear_state(self):
+ *         if self.cancel_waiter is not None:
+ *             raise apg_exc.InterfaceError(             # <<<<<<<<<<<<<<
+ *                 'cannot perform operation: another operation is cancelling')
+ *         if self.closing:
+ */
+  __pyx_tuple__72 = PyTuple_Pack(1, __pyx_kp_u_cannot_perform_operation_another); if (unlikely(!__pyx_tuple__72)) __PYX_ERR(27, 348, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__72);
+  __Pyx_GIVEREF(__pyx_tuple__72);
+
+  /* "asyncpg/protocol/protocol.pyx":351
+ *                 'cannot perform operation: another operation is cancelling')
+ *         if self.closing:
+ *             raise apg_exc.InterfaceError(             # <<<<<<<<<<<<<<
+ *                 'cannot perform operation: connection is closed')
+ *         if self.waiter is not None or self.timeout_handle is not None:
+ */
+  __pyx_tuple__73 = PyTuple_Pack(1, __pyx_kp_u_cannot_perform_operation_connect); if (unlikely(!__pyx_tuple__73)) __PYX_ERR(27, 351, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__73);
+  __Pyx_GIVEREF(__pyx_tuple__73);
+
+  /* "asyncpg/protocol/protocol.pyx":354
+ *                 'cannot perform operation: connection is closed')
+ *         if self.waiter is not None or self.timeout_handle is not None:
+ *             raise apg_exc.InterfaceError(             # <<<<<<<<<<<<<<
+ *                 'cannot perform operation: another operation is in progress')
+ * 
+ */
+  __pyx_tuple__74 = PyTuple_Pack(1, __pyx_kp_u_cannot_perform_operation_another_2); if (unlikely(!__pyx_tuple__74)) __PYX_ERR(27, 354, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__74);
+  __Pyx_GIVEREF(__pyx_tuple__74);
+
+  /* "asyncpg/protocol/protocol.pyx":368
+ * 
+ *     cdef _on_result__connect(self, object waiter):
+ *         waiter.set_result(True)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef _on_result__prepare(self, object waiter):
+ */
+  __pyx_tuple__75 = PyTuple_Pack(1, Py_True); if (unlikely(!__pyx_tuple__75)) __PYX_ERR(27, 368, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__75);
+  __Pyx_GIVEREF(__pyx_tuple__75);
+
+  /* "asyncpg/protocol/protocol.pyx":373
+ *         if ASYNCPG_DEBUG:
+ *             if self.statement is None:
+ *                 raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                     '_on_result__prepare: statement is None')
+ * 
+ */
+  __pyx_tuple__76 = PyTuple_Pack(1, __pyx_kp_u_on_result__prepare_statement_is); if (unlikely(!__pyx_tuple__76)) __PYX_ERR(27, 373, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__76);
+  __Pyx_GIVEREF(__pyx_tuple__76);
+
+  /* "asyncpg/protocol/protocol.pyx":403
+ *         if ASYNCPG_DEBUG:
+ *             if self.statement is None:
+ *                 raise RuntimeError(             # <<<<<<<<<<<<<<
+ *                     '_decode_row: statement is None')
+ * 
+ */
+  __pyx_tuple__77 = PyTuple_Pack(1, __pyx_kp_u_decode_row_statement_is_None); if (unlikely(!__pyx_tuple__77)) __PYX_ERR(27, 403, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__77);
+  __Pyx_GIVEREF(__pyx_tuple__77);
+
+  /* "asyncpg/protocol/protocol.pyx":414
+ *         if ASYNCPG_DEBUG:
+ *             if waiter is None:
+ *                 raise RuntimeError('_on_result: waiter is None')             # <<<<<<<<<<<<<<
+ * 
+ *         if waiter.cancelled():
+ */
+  __pyx_tuple__78 = PyTuple_Pack(1, __pyx_kp_u_on_result_waiter_is_None); if (unlikely(!__pyx_tuple__78)) __PYX_ERR(27, 414, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__78);
+  __Pyx_GIVEREF(__pyx_tuple__78);
+
+  /* "asyncpg/protocol/protocol.pyx":420
+ * 
+ *         if waiter.done():
+ *             raise RuntimeError('_on_result: waiter is done')             # <<<<<<<<<<<<<<
+ * 
+ *         if self.result_type == RESULT_FAILED:
+ */
+  __pyx_tuple__79 = PyTuple_Pack(1, __pyx_kp_u_on_result_waiter_is_done); if (unlikely(!__pyx_tuple__79)) __PYX_ERR(27, 420, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__79);
+  __Pyx_GIVEREF(__pyx_tuple__79);
+
+  /* "asyncpg/protocol/protocol.pyx":472
+ *             if self.waiter is None or not self.waiter.cancelled():
+ *                 self.cancel_waiter.set_result(
+ *                     RuntimeError('invalid state after cancellation'))             # <<<<<<<<<<<<<<
+ *             else:
+ *                 self.cancel_waiter.set_result(None)
+ */
+  __pyx_tuple__80 = PyTuple_Pack(1, __pyx_kp_u_invalid_state_after_cancellation); if (unlikely(!__pyx_tuple__80)) __PYX_ERR(27, 472, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__80);
+  __Pyx_GIVEREF(__pyx_tuple__80);
+
+  /* "asyncpg/protocol/protocol.pyx":474
+ *                     RuntimeError('invalid state after cancellation'))
+ *             else:
+ *                 self.cancel_waiter.set_result(None)             # <<<<<<<<<<<<<<
+ *             self.cancel_waiter = None
+ *             self.waiter = None
+ */
+  __pyx_tuple__81 = PyTuple_Pack(1, Py_None); if (unlikely(!__pyx_tuple__81)) __PYX_ERR(27, 474, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__81);
+  __Pyx_GIVEREF(__pyx_tuple__81);
+
+  /* "asyncpg/protocol/protocol.pyx":495
+ *             if self.waiter is not None and not self.waiter.done():
+ *                 if exc is None:
+ *                     self.waiter.set_result(None)             # <<<<<<<<<<<<<<
+ *                 else:
+ *                     self.waiter.set_exception(exc)
+ */
+  __pyx_tuple__82 = PyTuple_Pack(1, Py_None); if (unlikely(!__pyx_tuple__82)) __PYX_ERR(27, 495, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__82);
+  __Pyx_GIVEREF(__pyx_tuple__82);
+
+  /* "asyncpg/protocol/pgtypes.pxi":98
+ * DEF REGROLEOID = 4096
+ * 
+ * cdef ARRAY_TYPES = (_TEXTOID, _OIDOID,)             # <<<<<<<<<<<<<<
+ * 
+ * TYPEMAP = {
+ */
+  __pyx_tuple__83 = PyTuple_Pack(2, __pyx_int_1009, __pyx_int_1028); if (unlikely(!__pyx_tuple__83)) __PYX_ERR(32, 98, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__83);
+  __Pyx_GIVEREF(__pyx_tuple__83);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":14
+ * timedelta = datetime.timedelta
+ * 
+ * pg_epoch_datetime = datetime.datetime(2000, 1, 1)             # <<<<<<<<<<<<<<
+ * cdef int32_t pg_epoch_datetime_ts = \
+ *     <int32_t>cpython.PyLong_AsLong(int(pg_epoch_datetime.timestamp()))
+ */
+  __pyx_tuple__84 = PyTuple_Pack(3, __pyx_int_2000, __pyx_int_1, __pyx_int_1); if (unlikely(!__pyx_tuple__84)) __PYX_ERR(9, 14, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__84);
+  __Pyx_GIVEREF(__pyx_tuple__84);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":18
+ *     <int32_t>cpython.PyLong_AsLong(int(pg_epoch_datetime.timestamp()))
+ * 
+ * pg_epoch_datetime_utc = datetime.datetime(2000, 1, 1, tzinfo=utc)             # <<<<<<<<<<<<<<
+ * cdef int32_t pg_epoch_datetime_utc_ts = \
+ *     <int32_t>cpython.PyLong_AsLong(pg_epoch_datetime_utc.timestamp())
+ */
+  __pyx_tuple__85 = PyTuple_Pack(3, __pyx_int_2000, __pyx_int_1, __pyx_int_1); if (unlikely(!__pyx_tuple__85)) __PYX_ERR(9, 18, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__85);
+  __Pyx_GIVEREF(__pyx_tuple__85);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":22
+ *     <int32_t>cpython.PyLong_AsLong(pg_epoch_datetime_utc.timestamp())
+ * 
+ * pg_epoch_date = datetime.date(2000, 1, 1)             # <<<<<<<<<<<<<<
+ * cdef int32_t pg_date_offset_ord = \
+ *     <int32_t>cpython.PyLong_AsLong(pg_epoch_date.toordinal())
+ */
+  __pyx_tuple__86 = PyTuple_Pack(3, __pyx_int_2000, __pyx_int_1, __pyx_int_1); if (unlikely(!__pyx_tuple__86)) __PYX_ERR(9, 22, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__86);
+  __Pyx_GIVEREF(__pyx_tuple__86);
+
+  /* "asyncpg/protocol/protocol.pyx":511
+ * 
+ * 
+ * def _create_record(object mapping, tuple elems):             # <<<<<<<<<<<<<<
+ *     # Exposed only for testing purposes.
+ * 
+ */
+  __pyx_tuple__87 = PyTuple_Pack(6, __pyx_n_s_mapping, __pyx_n_s_elems, __pyx_n_s_rec, __pyx_n_s_i, __pyx_n_s_desc, __pyx_n_s_elem); if (unlikely(!__pyx_tuple__87)) __PYX_ERR(27, 511, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_tuple__87);
+  __Pyx_GIVEREF(__pyx_tuple__87);
+  __pyx_codeobj__88 = (PyObject*)__Pyx_PyCode_New(2, 0, 6, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__87, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_travis_build_MagicStack_as, __pyx_n_s_create_record, 511, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__88)) __PYX_ERR(27, 511, __pyx_L1_error)
+  __Pyx_RefNannyFinishContext();
+  return 0;
+  __pyx_L1_error:;
+  __Pyx_RefNannyFinishContext();
+  return -1;
+}
+
+static int __Pyx_InitGlobals(void) {
+  if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(27, 1, __pyx_L1_error);
+  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_6 = PyInt_FromLong(6); if (unlikely(!__pyx_int_6)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_12 = PyInt_FromLong(12); if (unlikely(!__pyx_int_12)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_16 = PyInt_FromLong(16); if (unlikely(!__pyx_int_16)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_17 = PyInt_FromLong(17); if (unlikely(!__pyx_int_17)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_18 = PyInt_FromLong(18); if (unlikely(!__pyx_int_18)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_19 = PyInt_FromLong(19); if (unlikely(!__pyx_int_19)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_20 = PyInt_FromLong(20); if (unlikely(!__pyx_int_20)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_21 = PyInt_FromLong(21); if (unlikely(!__pyx_int_21)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_23 = PyInt_FromLong(23); if (unlikely(!__pyx_int_23)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_24 = PyInt_FromLong(24); if (unlikely(!__pyx_int_24)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_25 = PyInt_FromLong(25); if (unlikely(!__pyx_int_25)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_26 = PyInt_FromLong(26); if (unlikely(!__pyx_int_26)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_27 = PyInt_FromLong(27); if (unlikely(!__pyx_int_27)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_28 = PyInt_FromLong(28); if (unlikely(!__pyx_int_28)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_29 = PyInt_FromLong(29); if (unlikely(!__pyx_int_29)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_31 = PyInt_FromLong(31); if (unlikely(!__pyx_int_31)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_32 = PyInt_FromLong(32); if (unlikely(!__pyx_int_32)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_59 = PyInt_FromLong(59); if (unlikely(!__pyx_int_59)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_114 = PyInt_FromLong(114); if (unlikely(!__pyx_int_114)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_142 = PyInt_FromLong(142); if (unlikely(!__pyx_int_142)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_194 = PyInt_FromLong(194); if (unlikely(!__pyx_int_194)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_210 = PyInt_FromLong(210); if (unlikely(!__pyx_int_210)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_600 = PyInt_FromLong(600); if (unlikely(!__pyx_int_600)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_601 = PyInt_FromLong(601); if (unlikely(!__pyx_int_601)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_602 = PyInt_FromLong(602); if (unlikely(!__pyx_int_602)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_603 = PyInt_FromLong(603); if (unlikely(!__pyx_int_603)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_604 = PyInt_FromLong(604); if (unlikely(!__pyx_int_604)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_628 = PyInt_FromLong(628); if (unlikely(!__pyx_int_628)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_650 = PyInt_FromLong(650); if (unlikely(!__pyx_int_650)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_700 = PyInt_FromLong(700); if (unlikely(!__pyx_int_700)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_701 = PyInt_FromLong(701); if (unlikely(!__pyx_int_701)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_702 = PyInt_FromLong(702); if (unlikely(!__pyx_int_702)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_703 = PyInt_FromLong(703); if (unlikely(!__pyx_int_703)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_704 = PyInt_FromLong(704); if (unlikely(!__pyx_int_704)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_705 = PyInt_FromLong(705); if (unlikely(!__pyx_int_705)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_718 = PyInt_FromLong(718); if (unlikely(!__pyx_int_718)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_790 = PyInt_FromLong(790); if (unlikely(!__pyx_int_790)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_829 = PyInt_FromLong(829); if (unlikely(!__pyx_int_829)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_869 = PyInt_FromLong(869); if (unlikely(!__pyx_int_869)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_1009 = PyInt_FromLong(1009); if (unlikely(!__pyx_int_1009)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_1028 = PyInt_FromLong(1028); if (unlikely(!__pyx_int_1028)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_1033 = PyInt_FromLong(1033); if (unlikely(!__pyx_int_1033)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_1042 = PyInt_FromLong(1042); if (unlikely(!__pyx_int_1042)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_1043 = PyInt_FromLong(1043); if (unlikely(!__pyx_int_1043)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_1082 = PyInt_FromLong(1082); if (unlikely(!__pyx_int_1082)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_1083 = PyInt_FromLong(1083); if (unlikely(!__pyx_int_1083)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_1114 = PyInt_FromLong(1114); if (unlikely(!__pyx_int_1114)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_1184 = PyInt_FromLong(1184); if (unlikely(!__pyx_int_1184)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_1186 = PyInt_FromLong(1186); if (unlikely(!__pyx_int_1186)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_1266 = PyInt_FromLong(1266); if (unlikely(!__pyx_int_1266)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_1560 = PyInt_FromLong(1560); if (unlikely(!__pyx_int_1560)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_1562 = PyInt_FromLong(1562); if (unlikely(!__pyx_int_1562)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_1700 = PyInt_FromLong(1700); if (unlikely(!__pyx_int_1700)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_1790 = PyInt_FromLong(1790); if (unlikely(!__pyx_int_1790)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_2000 = PyInt_FromLong(2000); if (unlikely(!__pyx_int_2000)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_2202 = PyInt_FromLong(2202); if (unlikely(!__pyx_int_2202)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_2203 = PyInt_FromLong(2203); if (unlikely(!__pyx_int_2203)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_2204 = PyInt_FromLong(2204); if (unlikely(!__pyx_int_2204)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_2205 = PyInt_FromLong(2205); if (unlikely(!__pyx_int_2205)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_2206 = PyInt_FromLong(2206); if (unlikely(!__pyx_int_2206)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_2249 = PyInt_FromLong(2249); if (unlikely(!__pyx_int_2249)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_2275 = PyInt_FromLong(2275); if (unlikely(!__pyx_int_2275)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_2276 = PyInt_FromLong(2276); if (unlikely(!__pyx_int_2276)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_2277 = PyInt_FromLong(2277); if (unlikely(!__pyx_int_2277)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_2278 = PyInt_FromLong(2278); if (unlikely(!__pyx_int_2278)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_2279 = PyInt_FromLong(2279); if (unlikely(!__pyx_int_2279)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_2280 = PyInt_FromLong(2280); if (unlikely(!__pyx_int_2280)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_2281 = PyInt_FromLong(2281); if (unlikely(!__pyx_int_2281)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_2282 = PyInt_FromLong(2282); if (unlikely(!__pyx_int_2282)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_2283 = PyInt_FromLong(2283); if (unlikely(!__pyx_int_2283)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_2776 = PyInt_FromLong(2776); if (unlikely(!__pyx_int_2776)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_2950 = PyInt_FromLong(2950); if (unlikely(!__pyx_int_2950)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_2970 = PyInt_FromLong(2970); if (unlikely(!__pyx_int_2970)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_3115 = PyInt_FromLong(3115); if (unlikely(!__pyx_int_3115)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_3220 = PyInt_FromLong(3220); if (unlikely(!__pyx_int_3220)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_3310 = PyInt_FromLong(3310); if (unlikely(!__pyx_int_3310)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_3500 = PyInt_FromLong(3500); if (unlikely(!__pyx_int_3500)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_3614 = PyInt_FromLong(3614); if (unlikely(!__pyx_int_3614)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_3615 = PyInt_FromLong(3615); if (unlikely(!__pyx_int_3615)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_3642 = PyInt_FromLong(3642); if (unlikely(!__pyx_int_3642)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_3734 = PyInt_FromLong(3734); if (unlikely(!__pyx_int_3734)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_3769 = PyInt_FromLong(3769); if (unlikely(!__pyx_int_3769)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_3802 = PyInt_FromLong(3802); if (unlikely(!__pyx_int_3802)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_3831 = PyInt_FromLong(3831); if (unlikely(!__pyx_int_3831)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_3838 = PyInt_FromLong(3838); if (unlikely(!__pyx_int_3838)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_4089 = PyInt_FromLong(4089); if (unlikely(!__pyx_int_4089)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_4096 = PyInt_FromLong(4096); if (unlikely(!__pyx_int_4096)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_9999 = PyInt_FromLong(9999); if (unlikely(!__pyx_int_9999)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_int_999999 = PyInt_FromLong(999999L); if (unlikely(!__pyx_int_999999)) __PYX_ERR(27, 1, __pyx_L1_error)
+  return 0;
+  __pyx_L1_error:;
+  return -1;
+}
+
+#if PY_MAJOR_VERSION < 3
+PyMODINIT_FUNC initprotocol(void); /*proto*/
+PyMODINIT_FUNC initprotocol(void)
+#else
+PyMODINIT_FUNC PyInit_protocol(void); /*proto*/
+PyMODINIT_FUNC PyInit_protocol(void)
+#endif
+{
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  long __pyx_t_5;
+  int __pyx_t_6;
+  PyObject *__pyx_t_7 = NULL;
+  static Py_UCS4 __pyx_t_8[5];
+  __Pyx_RefNannyDeclarations
+  #if CYTHON_REFNANNY
+  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
+  if (!__Pyx_RefNanny) {
+      PyErr_Clear();
+      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
+      if (!__Pyx_RefNanny)
+          Py_FatalError("failed to import 'refnanny' module");
+  }
+  #endif
+  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_protocol(void)", 0);
+  if (__Pyx_check_binary_version() < 0) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(27, 1, __pyx_L1_error)
+  #ifdef __Pyx_CyFunction_USED
+  if (__pyx_CyFunction_init() < 0) __PYX_ERR(27, 1, __pyx_L1_error)
+  #endif
+  #ifdef __Pyx_FusedFunction_USED
+  if (__pyx_FusedFunction_init() < 0) __PYX_ERR(27, 1, __pyx_L1_error)
+  #endif
+  #ifdef __Pyx_Coroutine_USED
+  if (__pyx_Coroutine_init() < 0) __PYX_ERR(27, 1, __pyx_L1_error)
+  #endif
+  #ifdef __Pyx_Generator_USED
+  if (__pyx_Generator_init() < 0) __PYX_ERR(27, 1, __pyx_L1_error)
+  #endif
+  #ifdef __Pyx_StopAsyncIteration_USED
+  if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(27, 1, __pyx_L1_error)
+  #endif
+  /*--- Library function declarations ---*/
+  /*--- Threads initialization code ---*/
+  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
+  #ifdef WITH_THREAD /* Python build with threading support? */
+  PyEval_InitThreads();
+  #endif
+  #endif
+  /*--- Module creation code ---*/
+  #if PY_MAJOR_VERSION < 3
+  __pyx_m = Py_InitModule4("protocol", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
+  #else
+  __pyx_m = PyModule_Create(&__pyx_moduledef);
+  #endif
+  if (unlikely(!__pyx_m)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(27, 1, __pyx_L1_error)
+  Py_INCREF(__pyx_d);
+  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(27, 1, __pyx_L1_error)
+  #if CYTHON_COMPILING_IN_PYPY
+  Py_INCREF(__pyx_b);
+  #endif
+  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(27, 1, __pyx_L1_error);
+  /*--- Initialize various global constants etc. ---*/
+  if (__Pyx_InitGlobals() < 0) __PYX_ERR(27, 1, __pyx_L1_error)
+  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
+  if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(27, 1, __pyx_L1_error)
+  #endif
+  if (__pyx_module_is_main_asyncpg__protocol__protocol) {
+    if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(27, 1, __pyx_L1_error)
+  }
+  #if PY_MAJOR_VERSION >= 3
+  {
+    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(27, 1, __pyx_L1_error)
+    if (!PyDict_GetItemString(modules, "asyncpg.protocol.protocol")) {
+      if (unlikely(PyDict_SetItemString(modules, "asyncpg.protocol.protocol", __pyx_m) < 0)) __PYX_ERR(27, 1, __pyx_L1_error)
+    }
+  }
+  #endif
+  /*--- Builtin init code ---*/
+  if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(27, 1, __pyx_L1_error)
+  /*--- Constants init code ---*/
+  if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(27, 1, __pyx_L1_error)
+  /*--- Global init code ---*/
+  __pyx_v_7asyncpg_8protocol_8protocol_ARRAY_TYPES = Py_None; Py_INCREF(Py_None);
+  __pyx_v_7asyncpg_8protocol_8protocol_ENCODINGS_MAP = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  __pyx_v_7asyncpg_8protocol_8protocol_TYPE_CODECS_CACHE = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  __pyx_v_7asyncpg_8protocol_8protocol_EXTRA_CODECS = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  __pyx_v_7asyncpg_8protocol_8protocol_SYNC_MESSAGE = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  /*--- Variable export code ---*/
+  if (__Pyx_ExportVoidPtr(__pyx_n_s_ARRAY_TYPES, (void *)&__pyx_v_7asyncpg_8protocol_8protocol_ARRAY_TYPES, "PyObject *") < 0) __PYX_ERR(27, 1, __pyx_L1_error)
+  /*--- Function export code ---*/
+  /*--- Type init code ---*/
+  __pyx_vtabptr_7asyncpg_8protocol_8protocol_Memory = &__pyx_vtable_7asyncpg_8protocol_8protocol_Memory;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_Memory.as_bytes = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *))__pyx_f_7asyncpg_8protocol_8protocol_6Memory_as_bytes;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_Memory.new = (struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *(*)(char *, PyObject *, Py_ssize_t))__pyx_f_7asyncpg_8protocol_8protocol_6Memory_new;
+  if (PyType_Ready(&__pyx_type_7asyncpg_8protocol_8protocol_Memory) < 0) __PYX_ERR(1, 18, __pyx_L1_error)
+  __pyx_type_7asyncpg_8protocol_8protocol_Memory.tp_print = 0;
+  if (__Pyx_SetVtable(__pyx_type_7asyncpg_8protocol_8protocol_Memory.tp_dict, __pyx_vtabptr_7asyncpg_8protocol_8protocol_Memory) < 0) __PYX_ERR(1, 18, __pyx_L1_error)
+  if (PyObject_SetAttrString(__pyx_m, "Memory", (PyObject *)&__pyx_type_7asyncpg_8protocol_8protocol_Memory) < 0) __PYX_ERR(1, 18, __pyx_L1_error)
+  __pyx_ptype_7asyncpg_8protocol_8protocol_Memory = &__pyx_type_7asyncpg_8protocol_8protocol_Memory;
+  __pyx_vtabptr_7asyncpg_8protocol_8protocol_WriteBuffer = &__pyx_vtable_7asyncpg_8protocol_8protocol_WriteBuffer;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_WriteBuffer._check_readonly = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *))__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__check_readonly;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_WriteBuffer.len = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *))__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_len;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_WriteBuffer._ensure_alloced = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, Py_ssize_t))__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__ensure_alloced;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_WriteBuffer._reallocate = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, Py_ssize_t))__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer__reallocate;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_WriteBuffer.start_message = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, char))__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_start_message;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_WriteBuffer.end_message = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *))__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_end_message;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_WriteBuffer.write_buffer = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *))__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_buffer;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_WriteBuffer.write_byte = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, char))__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_WriteBuffer.write_bytes = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_bytes;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_WriteBuffer.write_bytestring = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_bytestring;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_WriteBuffer.write_str = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_str;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_WriteBuffer.write_cstr = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, char *, Py_ssize_t))__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_cstr;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_WriteBuffer.write_int16 = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, int16_t))__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int16;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_WriteBuffer.write_int32 = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, int32_t))__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_WriteBuffer.write_int64 = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, int64_t))__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int64;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_WriteBuffer.write_float = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, float))__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_float;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_WriteBuffer.write_double = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, double))__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_double;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_WriteBuffer.new_message = (struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *(*)(char))__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new_message;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_WriteBuffer.new = (struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *(*)(void))__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new;
+  if (PyType_Ready(&__pyx_type_7asyncpg_8protocol_8protocol_WriteBuffer) < 0) __PYX_ERR(1, 36, __pyx_L1_error)
+  __pyx_type_7asyncpg_8protocol_8protocol_WriteBuffer.tp_print = 0;
+  if (__Pyx_SetVtable(__pyx_type_7asyncpg_8protocol_8protocol_WriteBuffer.tp_dict, __pyx_vtabptr_7asyncpg_8protocol_8protocol_WriteBuffer) < 0) __PYX_ERR(1, 36, __pyx_L1_error)
+  if (PyObject_SetAttrString(__pyx_m, "WriteBuffer", (PyObject *)&__pyx_type_7asyncpg_8protocol_8protocol_WriteBuffer) < 0) __PYX_ERR(1, 36, __pyx_L1_error)
+  __pyx_ptype_7asyncpg_8protocol_8protocol_WriteBuffer = &__pyx_type_7asyncpg_8protocol_8protocol_WriteBuffer;
+  __pyx_vtabptr_7asyncpg_8protocol_8protocol_ReadBuffer = &__pyx_vtable_7asyncpg_8protocol_8protocol_ReadBuffer;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_ReadBuffer.feed_data = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_feed_data;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_ReadBuffer._ensure_first_buf = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *))__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__ensure_first_buf;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_ReadBuffer._switch_to_next_buf = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *))__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__switch_to_next_buf;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_ReadBuffer.read_byte = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *))__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_byte;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_ReadBuffer._try_read_bytes = (char *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *, Py_ssize_t))__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__try_read_bytes;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_ReadBuffer.read = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *, Py_ssize_t))__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_ReadBuffer.read_bytes = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *, Py_ssize_t))__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_bytes;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_ReadBuffer.read_int32 = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *))__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_int32;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_ReadBuffer.read_int16 = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *))__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_int16;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_ReadBuffer.read_cstr = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *))__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_cstr;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_ReadBuffer.has_message = (int32_t (*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *))__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_has_message;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_ReadBuffer.try_consume_message = (char *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *, Py_ssize_t *))__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_try_consume_message;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_ReadBuffer.consume_message = (struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *))__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_ReadBuffer.discard_message = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *))__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_discard_message;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_ReadBuffer._discard_message = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *))__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__discard_message;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_ReadBuffer.get_message_type = (char (*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *))__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_get_message_type;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_ReadBuffer.get_message_length = (int32_t (*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *))__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_get_message_length;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_ReadBuffer.new_message_parser = (struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *(*)(PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_new_message_parser;
+  if (PyType_Ready(&__pyx_type_7asyncpg_8protocol_8protocol_ReadBuffer) < 0) __PYX_ERR(1, 231, __pyx_L1_error)
+  __pyx_type_7asyncpg_8protocol_8protocol_ReadBuffer.tp_print = 0;
+  if (__Pyx_SetVtable(__pyx_type_7asyncpg_8protocol_8protocol_ReadBuffer.tp_dict, __pyx_vtabptr_7asyncpg_8protocol_8protocol_ReadBuffer) < 0) __PYX_ERR(1, 231, __pyx_L1_error)
+  if (PyObject_SetAttrString(__pyx_m, "ReadBuffer", (PyObject *)&__pyx_type_7asyncpg_8protocol_8protocol_ReadBuffer) < 0) __PYX_ERR(1, 231, __pyx_L1_error)
+  __pyx_ptype_7asyncpg_8protocol_8protocol_ReadBuffer = &__pyx_type_7asyncpg_8protocol_8protocol_ReadBuffer;
+  __pyx_vtabptr_7asyncpg_8protocol_8protocol_FastReadBuffer = &__pyx_vtable_7asyncpg_8protocol_8protocol_FastReadBuffer;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_FastReadBuffer.read = (char const *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *, Py_ssize_t))__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_FastReadBuffer.read_all = (char const *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *))__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read_all;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_FastReadBuffer.slice_from = (struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *, Py_ssize_t))__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_slice_from;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_FastReadBuffer._raise_ins_err = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *, Py_ssize_t, Py_ssize_t))__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer__raise_ins_err;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_FastReadBuffer.new = (struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *(*)(void))__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_new;
+  if (PyType_Ready(&__pyx_type_7asyncpg_8protocol_8protocol_FastReadBuffer) < 0) __PYX_ERR(1, 582, __pyx_L1_error)
+  __pyx_type_7asyncpg_8protocol_8protocol_FastReadBuffer.tp_print = 0;
+  if (__Pyx_SetVtable(__pyx_type_7asyncpg_8protocol_8protocol_FastReadBuffer.tp_dict, __pyx_vtabptr_7asyncpg_8protocol_8protocol_FastReadBuffer) < 0) __PYX_ERR(1, 582, __pyx_L1_error)
+  if (PyObject_SetAttrString(__pyx_m, "FastReadBuffer", (PyObject *)&__pyx_type_7asyncpg_8protocol_8protocol_FastReadBuffer) < 0) __PYX_ERR(1, 582, __pyx_L1_error)
+  __pyx_ptype_7asyncpg_8protocol_8protocol_FastReadBuffer = &__pyx_type_7asyncpg_8protocol_8protocol_FastReadBuffer;
+  __pyx_vtabptr_7asyncpg_8protocol_8protocol_Codec = &__pyx_vtable_7asyncpg_8protocol_8protocol_Codec;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_Codec.init = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, PyObject *, PyObject *, PyObject *, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecType, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat, __pyx_t_7asyncpg_8protocol_8protocol_encode_func, __pyx_t_7asyncpg_8protocol_8protocol_decode_func, PyObject *, PyObject *, struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, PyObject *, PyObject *, PyObject *, Py_UCS4))__pyx_f_7asyncpg_8protocol_8protocol_5Codec_init;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_Codec.encode_scalar = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_scalar;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_Codec.encode_array = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_array;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_Codec.encode_range = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_range;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_Codec.encode_composite = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_composite;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_Codec.encode_in_python = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_in_python;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_Codec.decode_scalar = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *))__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_scalar;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_Codec.decode_array = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *))__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_array;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_Codec.decode_array_text = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *))__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_array_text;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_Codec.decode_range = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *))__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_range;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_Codec.decode_composite = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *))__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_composite;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_Codec.decode_in_python = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *))__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode_in_python;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_Codec.encode = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_Codec.decode = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *))__pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_Codec.has_encoder = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *))__pyx_f_7asyncpg_8protocol_8protocol_5Codec_has_encoder;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_Codec.has_decoder = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *))__pyx_f_7asyncpg_8protocol_8protocol_5Codec_has_decoder;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_Codec.is_binary = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *))__pyx_f_7asyncpg_8protocol_8protocol_5Codec_is_binary;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_Codec.copy = (struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *))__pyx_f_7asyncpg_8protocol_8protocol_5Codec_copy;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_Codec.new_array_codec = (struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *(*)(uint32_t, PyObject *, PyObject *, struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *, Py_UCS4))__pyx_f_7asyncpg_8protocol_8protocol_5Codec_new_array_codec;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_Codec.new_range_codec = (struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *(*)(uint32_t, PyObject *, PyObject *, struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *))__pyx_f_7asyncpg_8protocol_8protocol_5Codec_new_range_codec;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_Codec.new_composite_codec = (struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *(*)(uint32_t, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_5Codec_new_composite_codec;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_Codec.new_python_codec = (struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *(*)(uint32_t, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat))__pyx_f_7asyncpg_8protocol_8protocol_5Codec_new_python_codec;
+  if (PyType_Ready(&__pyx_type_7asyncpg_8protocol_8protocol_Codec) < 0) __PYX_ERR(2, 15, __pyx_L1_error)
+  __pyx_type_7asyncpg_8protocol_8protocol_Codec.tp_print = 0;
+  if (__Pyx_SetVtable(__pyx_type_7asyncpg_8protocol_8protocol_Codec.tp_dict, __pyx_vtabptr_7asyncpg_8protocol_8protocol_Codec) < 0) __PYX_ERR(2, 15, __pyx_L1_error)
+  if (PyObject_SetAttrString(__pyx_m, "Codec", (PyObject *)&__pyx_type_7asyncpg_8protocol_8protocol_Codec) < 0) __PYX_ERR(2, 15, __pyx_L1_error)
+  __pyx_ptype_7asyncpg_8protocol_8protocol_Codec = &__pyx_type_7asyncpg_8protocol_8protocol_Codec;
+  __pyx_vtabptr_7asyncpg_8protocol_8protocol_DataCodecConfig = &__pyx_vtable_7asyncpg_8protocol_8protocol_DataCodecConfig;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_DataCodecConfig.get_codec = (struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *, uint32_t, enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat))__pyx_f_7asyncpg_8protocol_8protocol_15DataCodecConfig_get_codec;
+  if (PyType_Ready(&__pyx_type_7asyncpg_8protocol_8protocol_DataCodecConfig) < 0) __PYX_ERR(2, 318, __pyx_L1_error)
+  __pyx_type_7asyncpg_8protocol_8protocol_DataCodecConfig.tp_print = 0;
+  if (__Pyx_SetVtable(__pyx_type_7asyncpg_8protocol_8protocol_DataCodecConfig.tp_dict, __pyx_vtabptr_7asyncpg_8protocol_8protocol_DataCodecConfig) < 0) __PYX_ERR(2, 318, __pyx_L1_error)
+  if (PyObject_SetAttrString(__pyx_m, "DataCodecConfig", (PyObject *)&__pyx_type_7asyncpg_8protocol_8protocol_DataCodecConfig) < 0) __PYX_ERR(2, 318, __pyx_L1_error)
+  __pyx_ptype_7asyncpg_8protocol_8protocol_DataCodecConfig = &__pyx_type_7asyncpg_8protocol_8protocol_DataCodecConfig;
+  __pyx_vtabptr_7asyncpg_8protocol_8protocol_ConnectionSettings = &__pyx_vtable_7asyncpg_8protocol_8protocol_ConnectionSettings;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_ConnectionSettings.add_setting = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, PyObject *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_add_setting;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_ConnectionSettings.is_encoding_utf8 = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *))__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_is_encoding_utf8;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_ConnectionSettings.get_text_codec = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, int __pyx_skip_dispatch))__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_text_codec;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_ConnectionSettings.register_data_types = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, PyObject *, int __pyx_skip_dispatch))__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_register_data_types;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_ConnectionSettings.add_python_codec = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_add_python_codec;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_ConnectionSettings.set_builtin_type_codec = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_set_builtin_type_codec;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_ConnectionSettings.get_data_codec = (struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, uint32_t, int __pyx_skip_dispatch, struct __pyx_opt_args_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_data_codec *__pyx_optional_args))__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_data_codec;
+  if (PyType_Ready(&__pyx_type_7asyncpg_8protocol_8protocol_ConnectionSettings) < 0) __PYX_ERR(0, 9, __pyx_L1_error)
+  __pyx_type_7asyncpg_8protocol_8protocol_ConnectionSettings.tp_print = 0;
+  if (__Pyx_SetVtable(__pyx_type_7asyncpg_8protocol_8protocol_ConnectionSettings.tp_dict, __pyx_vtabptr_7asyncpg_8protocol_8protocol_ConnectionSettings) < 0) __PYX_ERR(0, 9, __pyx_L1_error)
+  if (PyObject_SetAttrString(__pyx_m, "ConnectionSettings", (PyObject *)&__pyx_type_7asyncpg_8protocol_8protocol_ConnectionSettings) < 0) __PYX_ERR(0, 9, __pyx_L1_error)
+  __pyx_ptype_7asyncpg_8protocol_8protocol_ConnectionSettings = &__pyx_type_7asyncpg_8protocol_8protocol_ConnectionSettings;
+  __pyx_vtabptr_7asyncpg_8protocol_8protocol_CoreProtocol = &__pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._process__auth = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, char))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__auth;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._process__prepare = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, char))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__prepare;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._process__bind_execute = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, char))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__bind_execute;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._process__bind_execute_many = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, char))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__bind_execute_many;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._process__close_stmt_portal = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, char))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__close_stmt_portal;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._process__simple_query = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, char))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__simple_query;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._process__bind = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, char))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__bind;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._parse_msg_authentication = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__parse_msg_authentication;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._parse_msg_parameter_status = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__parse_msg_parameter_status;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._parse_msg_notification = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__parse_msg_notification;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._parse_msg_backend_key_data = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__parse_msg_backend_key_data;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._parse_msg_ready_for_query = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__parse_msg_ready_for_query;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._parse_data_msgs = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__parse_data_msgs;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._parse_msg_error_response = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__parse_msg_error_response;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._parse_msg_command_complete = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__parse_msg_command_complete;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._auth_password_message_cleartext = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__auth_password_message_cleartext;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._auth_password_message_md5 = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__auth_password_message_md5;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._write = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__write;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._write_sync_message = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__write_sync_message;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._read_server_messages = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__read_server_messages;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._push_result = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__push_result;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._reset_result = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__reset_result;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._set_state = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__set_state;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._ensure_connected = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__ensure_connected;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._build_bind_message = (struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *, PyObject *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__build_bind_message;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._connect = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__connect;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._prepare = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__prepare;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._send_bind_message = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *, PyObject *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, int32_t))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__send_bind_message;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._bind_execute = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *, PyObject *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, int32_t))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__bind_execute;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._bind_execute_many = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *, PyObject *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__bind_execute_many;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._bind = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *, PyObject *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__bind;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._execute = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *, int32_t))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__execute;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._close = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *, int))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__close;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._simple_query = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__simple_query;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._terminate = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__terminate;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._decode_row = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, char const *, Py_ssize_t))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__decode_row;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._on_result = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__on_result;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._on_notification = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *, PyObject *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__on_notification;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._set_server_parameter = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__set_server_parameter;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._on_connection_lost = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__on_connection_lost;
+  if (PyType_Ready(&__pyx_type_7asyncpg_8protocol_8protocol_CoreProtocol) < 0) __PYX_ERR(4, 11, __pyx_L1_error)
+  __pyx_type_7asyncpg_8protocol_8protocol_CoreProtocol.tp_print = 0;
+  if (__Pyx_SetVtable(__pyx_type_7asyncpg_8protocol_8protocol_CoreProtocol.tp_dict, __pyx_vtabptr_7asyncpg_8protocol_8protocol_CoreProtocol) < 0) __PYX_ERR(4, 11, __pyx_L1_error)
+  if (PyObject_SetAttrString(__pyx_m, "CoreProtocol", (PyObject *)&__pyx_type_7asyncpg_8protocol_8protocol_CoreProtocol) < 0) __PYX_ERR(4, 11, __pyx_L1_error)
+  __pyx_ptype_7asyncpg_8protocol_8protocol_CoreProtocol = &__pyx_type_7asyncpg_8protocol_8protocol_CoreProtocol;
+  __pyx_vtabptr_7asyncpg_8protocol_8protocol_PreparedStatementState = &__pyx_vtable_7asyncpg_8protocol_8protocol_PreparedStatementState;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_PreparedStatementState._encode_bind_msg = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__encode_bind_msg;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_PreparedStatementState._ensure_rows_decoder = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *))__pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__ensure_rows_decoder;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_PreparedStatementState._ensure_args_encoder = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *))__pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__ensure_args_encoder;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_PreparedStatementState._set_row_desc = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__set_row_desc;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_PreparedStatementState._set_args_desc = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__set_args_desc;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_PreparedStatementState._decode_row = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *, char const *, Py_ssize_t))__pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__decode_row;
+  if (PyType_Ready(&__pyx_type_7asyncpg_8protocol_8protocol_PreparedStatementState) < 0) __PYX_ERR(25, 9, __pyx_L1_error)
+  __pyx_type_7asyncpg_8protocol_8protocol_PreparedStatementState.tp_print = 0;
+  if (__Pyx_SetVtable(__pyx_type_7asyncpg_8protocol_8protocol_PreparedStatementState.tp_dict, __pyx_vtabptr_7asyncpg_8protocol_8protocol_PreparedStatementState) < 0) __PYX_ERR(25, 9, __pyx_L1_error)
+  if (PyObject_SetAttrString(__pyx_m, "PreparedStatementState", (PyObject *)&__pyx_type_7asyncpg_8protocol_8protocol_PreparedStatementState) < 0) __PYX_ERR(25, 9, __pyx_L1_error)
+  __pyx_ptype_7asyncpg_8protocol_8protocol_PreparedStatementState = &__pyx_type_7asyncpg_8protocol_8protocol_PreparedStatementState;
+  __pyx_vtabptr_7asyncpg_8protocol_8protocol_BaseProtocol = &__pyx_vtable_7asyncpg_8protocol_8protocol_BaseProtocol;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_BaseProtocol.__pyx_base = *__pyx_vtabptr_7asyncpg_8protocol_8protocol_CoreProtocol;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_BaseProtocol.__pyx_base._decode_row = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, char const *, Py_ssize_t))__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__decode_row;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_BaseProtocol.__pyx_base._on_result = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *))__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_result;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_BaseProtocol.__pyx_base._on_notification = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *, PyObject *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_notification;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_BaseProtocol.__pyx_base._set_server_parameter = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__set_server_parameter;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_BaseProtocol.__pyx_base._on_connection_lost = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_connection_lost;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_BaseProtocol._ensure_clear_state = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *))__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__ensure_clear_state;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_BaseProtocol._new_waiter = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__new_waiter;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_BaseProtocol._on_result__connect = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_result__connect;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_BaseProtocol._on_result__prepare = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_result__prepare;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_BaseProtocol._on_result__bind_and_exec = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_result__bind_and_exec;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_BaseProtocol._on_result__close_stmt_or_portal = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_result__close_stmt_or_portal;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_BaseProtocol._on_result__simple_query = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_result__simple_query;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_BaseProtocol._on_result__bind = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_result__bind;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_BaseProtocol._handle_waiter_on_connection_lost = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__handle_waiter_on_connection_lost;
+  __pyx_vtable_7asyncpg_8protocol_8protocol_BaseProtocol._dispatch_result = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *))__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__dispatch_result;
+  __pyx_type_7asyncpg_8protocol_8protocol_BaseProtocol.tp_base = __pyx_ptype_7asyncpg_8protocol_8protocol_CoreProtocol;
+  if (PyType_Ready(&__pyx_type_7asyncpg_8protocol_8protocol_BaseProtocol) < 0) __PYX_ERR(27, 82, __pyx_L1_error)
+  __pyx_type_7asyncpg_8protocol_8protocol_BaseProtocol.tp_print = 0;
+  if (__Pyx_SetVtable(__pyx_type_7asyncpg_8protocol_8protocol_BaseProtocol.tp_dict, __pyx_vtabptr_7asyncpg_8protocol_8protocol_BaseProtocol) < 0) __PYX_ERR(27, 82, __pyx_L1_error)
+  if (PyObject_SetAttrString(__pyx_m, "BaseProtocol", (PyObject *)&__pyx_type_7asyncpg_8protocol_8protocol_BaseProtocol) < 0) __PYX_ERR(27, 82, __pyx_L1_error)
+  __pyx_ptype_7asyncpg_8protocol_8protocol_BaseProtocol = &__pyx_type_7asyncpg_8protocol_8protocol_BaseProtocol;
+  if (PyType_Ready(&__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare) < 0) __PYX_ERR(27, 123, __pyx_L1_error)
+  __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare.tp_print = 0;
+  __pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare = &__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct__prepare;
+  if (PyType_Ready(&__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute) < 0) __PYX_ERR(27, 142, __pyx_L1_error)
+  __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute.tp_print = 0;
+  __pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute = &__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_1_bind_execute;
+  if (PyType_Ready(&__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many) < 0) __PYX_ERR(27, 167, __pyx_L1_error)
+  __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many.tp_print = 0;
+  __pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many = &__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_2_bind_execute_many;
+  if (PyType_Ready(&__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr) < 0) __PYX_ERR(27, 181, __pyx_L1_error)
+  __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr.tp_print = 0;
+  __pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr = &__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_3_genexpr;
+  if (PyType_Ready(&__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind) < 0) __PYX_ERR(27, 198, __pyx_L1_error)
+  __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind.tp_print = 0;
+  __pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind = &__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_4_bind;
+  if (PyType_Ready(&__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute) < 0) __PYX_ERR(27, 219, __pyx_L1_error)
+  __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute.tp_print = 0;
+  __pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute = &__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_5_execute;
+  if (PyType_Ready(&__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query) < 0) __PYX_ERR(27, 242, __pyx_L1_error)
+  __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query.tp_print = 0;
+  __pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query = &__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_6_query;
+  if (PyType_Ready(&__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement) < 0) __PYX_ERR(27, 257, __pyx_L1_error)
+  __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement.tp_print = 0;
+  __pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement = &__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_close_statement;
+  if (PyType_Ready(&__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close) < 0) __PYX_ERR(27, 289, __pyx_L1_error)
+  __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close.tp_print = 0;
+  __pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close = &__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_close;
+  /*--- Type import code ---*/
+  __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", 
+  #if CYTHON_COMPILING_IN_PYPY
+  sizeof(PyTypeObject),
+  #else
+  sizeof(PyHeapTypeObject),
+  #endif
+  0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(29, 9, __pyx_L1_error)
+  __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) __PYX_ERR(30, 8, __pyx_L1_error)
+  __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), 0); if (unlikely(!__pyx_ptype_7cpython_7complex_complex)) __PYX_ERR(31, 15, __pyx_L1_error)
+  /*--- Variable import code ---*/
+  /*--- Function import code ---*/
+  /*--- Execution code ---*/
+  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
+  if (__Pyx_patch_abc() < 0) __PYX_ERR(27, 1, __pyx_L1_error)
+  #endif
+
+  /* "asyncpg/protocol/protocol.pyx":13
+ * cimport cpython
+ * 
+ * import asyncio             # <<<<<<<<<<<<<<
+ * import codecs
+ * import collections
+ */
+  __pyx_t_1 = __Pyx_patch_asyncio(__Pyx_Import(__pyx_n_s_asyncio, 0, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 13, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_asyncio, __pyx_t_1) < 0) __PYX_ERR(27, 13, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":14
+ * 
+ * import asyncio
+ * import codecs             # <<<<<<<<<<<<<<
+ * import collections
+ * import socket
+ */
+  __pyx_t_1 = __Pyx_Import(__pyx_n_s_codecs, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 14, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_codecs, __pyx_t_1) < 0) __PYX_ERR(27, 14, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":15
+ * import asyncio
+ * import codecs
+ * import collections             # <<<<<<<<<<<<<<
+ * import socket
+ * 
+ */
+  __pyx_t_1 = __Pyx_Import(__pyx_n_s_collections, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 15, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_collections, __pyx_t_1) < 0) __PYX_ERR(27, 15, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":16
+ * import codecs
+ * import collections
+ * import socket             # <<<<<<<<<<<<<<
+ * 
+ * from libc.stdint cimport int8_t, uint8_t, int16_t, uint16_t, \
+ */
+  __pyx_t_1 = __Pyx_Import(__pyx_n_s_socket, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 16, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_socket, __pyx_t_1) < 0) __PYX_ERR(27, 16, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":32
+ * from cpython cimport PyBuffer_FillInfo, PyBytes_AsString
+ * 
+ * from asyncpg.exceptions import _base as apg_exc_base             # <<<<<<<<<<<<<<
+ * from asyncpg import types as apg_types
+ * from asyncpg import exceptions as apg_exc
+ */
+  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 32, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(__pyx_n_s_base);
+  __Pyx_GIVEREF(__pyx_n_s_base);
+  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_base);
+  __pyx_t_2 = __Pyx_Import(__pyx_n_s_asyncpg_exceptions, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 32, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 32, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_apg_exc_base, __pyx_t_1) < 0) __PYX_ERR(27, 32, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":33
+ * 
+ * from asyncpg.exceptions import _base as apg_exc_base
+ * from asyncpg import types as apg_types             # <<<<<<<<<<<<<<
+ * from asyncpg import exceptions as apg_exc
+ * 
+ */
+  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 33, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_n_s_types);
+  __Pyx_GIVEREF(__pyx_n_s_types);
+  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_types);
+  __pyx_t_1 = __Pyx_Import(__pyx_n_s_asyncpg, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 33, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 33, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_apg_types, __pyx_t_2) < 0) __PYX_ERR(27, 33, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":34
+ * from asyncpg.exceptions import _base as apg_exc_base
+ * from asyncpg import types as apg_types
+ * from asyncpg import exceptions as apg_exc             # <<<<<<<<<<<<<<
+ * 
+ * from asyncpg.protocol cimport hton
+ */
+  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 34, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(__pyx_n_s_exceptions);
+  __Pyx_GIVEREF(__pyx_n_s_exceptions);
+  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_exceptions);
+  __pyx_t_2 = __Pyx_Import(__pyx_n_s_asyncpg, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 34, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 34, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_apg_exc, __pyx_t_1) < 0) __PYX_ERR(27, 34, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/pgtypes.pxi":98
+ * DEF REGROLEOID = 4096
+ * 
+ * cdef ARRAY_TYPES = (_TEXTOID, _OIDOID,)             # <<<<<<<<<<<<<<
+ * 
+ * TYPEMAP = {
+ */
+  __Pyx_INCREF(__pyx_tuple__83);
+  __Pyx_XGOTREF(__pyx_v_7asyncpg_8protocol_8protocol_ARRAY_TYPES);
+  __Pyx_DECREF_SET(__pyx_v_7asyncpg_8protocol_8protocol_ARRAY_TYPES, __pyx_tuple__83);
+  __Pyx_GIVEREF(__pyx_tuple__83);
+
+  /* "asyncpg/protocol/pgtypes.pxi":101
+ * 
+ * TYPEMAP = {
+ *     ABSTIMEOID: 'abstime',             # <<<<<<<<<<<<<<
+ *     ACLITEMOID: 'aclitem',
+ *     ANYARRAYOID: 'anyarray',
+ */
+  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(32, 101, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_702, __pyx_n_u_abstime) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_1033, __pyx_n_u_aclitem) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2277, __pyx_n_u_anyarray) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2283, __pyx_n_u_anyelement) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_3500, __pyx_n_u_anyenum) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2776, __pyx_n_u_anynonarray) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2276, __pyx_n_u_any) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_3831, __pyx_n_u_anyrange) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_1560, __pyx_n_u_bit) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_16, __pyx_n_u_bool) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_603, __pyx_n_u_box) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_1042, __pyx_n_u_bpchar) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_17, __pyx_n_u_bytea) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_18, __pyx_n_u_char) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_29, __pyx_n_u_cid) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_650, __pyx_n_u_cidr) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_718, __pyx_n_u_circle) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2275, __pyx_n_u_cstring) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_1082, __pyx_n_u_date) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_3838, __pyx_n_u_event_trigger) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_3115, __pyx_n_u_fdw_handler) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_700, __pyx_n_u_float4) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_701, __pyx_n_u_float8) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_3642, __pyx_n_u_gtsvector) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_869, __pyx_n_u_inet) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_21, __pyx_n_u_int2) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_23, __pyx_n_u_int4) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_20, __pyx_n_u_int8) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2281, __pyx_n_u_internal) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_1186, __pyx_n_u_interval) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_3802, __pyx_n_u_jsonb) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_114, __pyx_n_u_json) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2280, __pyx_n_u_language_handler) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_628, __pyx_n_u_line) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_601, __pyx_n_u_lseg) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_829, __pyx_n_u_macaddr) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_790, __pyx_n_u_money) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_19, __pyx_n_u_name) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_1700, __pyx_n_u_numeric) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_26, __pyx_n_u_oid) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2282, __pyx_n_u_opaque) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_602, __pyx_n_u_path) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_32, __pyx_n_u_pg_ddl_command) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_3220, __pyx_n_u_pg_lsn) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_194, __pyx_n_u_pg_node_tree) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_600, __pyx_n_u_point) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_604, __pyx_n_u_polygon) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2249, __pyx_n_u_record) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_1790, __pyx_n_u_refcursor) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2205, __pyx_n_u_regclass) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_3734, __pyx_n_u_regconfig) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_3769, __pyx_n_u_regdictionary) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_4089, __pyx_n_u_regnamespace) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2204, __pyx_n_u_regoperator) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2203, __pyx_n_u_regoper) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2202, __pyx_n_u_regprocedure) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_24, __pyx_n_u_regproc) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_4096, __pyx_n_u_regrole) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2206, __pyx_n_u_regtype) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_703, __pyx_n_u_reltime) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_210, __pyx_n_u_smgr) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_25, __pyx_n_u_text) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_27, __pyx_n_u_tid) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_1083, __pyx_n_u_time) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_1114, __pyx_n_u_timestamp) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_1184, __pyx_n_u_timestamptz) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_1266, __pyx_n_u_timetz) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_704, __pyx_n_u_tinterval) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2279, __pyx_n_u_trigger) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_3310, __pyx_n_u_tsm_handler) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_3615, __pyx_n_u_tsquery) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_3614, __pyx_n_u_tsvector) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2970, __pyx_n_u_txid_snapshot) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_705, __pyx_n_u_unknown) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2950, __pyx_n_u_uuid) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_1562, __pyx_n_u_varbit) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_1043, __pyx_n_u_varchar) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2278, __pyx_n_u_void) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_28, __pyx_n_u_xid) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_142, __pyx_n_u_xml) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_1028, __pyx_kp_u_oid_2) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_int_1009, __pyx_kp_u_text_2) < 0) __PYX_ERR(32, 101, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_TYPEMAP, __pyx_t_2) < 0) __PYX_ERR(32, 100, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/encodings.pyx":14
+ * 
+ * cdef dict ENCODINGS_MAP = {
+ *     'abc': 'cp1258',             # <<<<<<<<<<<<<<
+ *     'alt': 'cp866',
+ *     'euc_cn': 'euccn',
+ */
+  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 14, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_abc, __pyx_n_u_cp1258) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_alt, __pyx_n_u_cp866) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_euc_cn, __pyx_n_u_euccn) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_euc_jp, __pyx_n_u_eucjp) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_euc_kr, __pyx_n_u_euckr) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_koi8r, __pyx_n_u_koi8_r) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_koi8u, __pyx_n_u_koi8_u) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_shift_jis_2004, __pyx_n_u_euc_jis_2004) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_sjis, __pyx_n_u_shift_jis) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_sql_ascii, __pyx_n_u_ascii) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_vscii, __pyx_n_u_cp1258) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_tcvn, __pyx_n_u_cp1258) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_tcvn5712, __pyx_n_u_cp1258) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_unicode, __pyx_n_u_utf_8_2) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_win, __pyx_n_u_cp1521) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_win1250, __pyx_n_u_cp1250) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_win1251, __pyx_n_u_cp1251) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_win1252, __pyx_n_u_cp1252) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_win1253, __pyx_n_u_cp1253) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_win1254, __pyx_n_u_cp1254) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_win1255, __pyx_n_u_cp1255) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_win1256, __pyx_n_u_cp1256) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_win1257, __pyx_n_u_cp1257) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_win1258, __pyx_n_u_cp1258) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_win866, __pyx_n_u_cp866) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_win874, __pyx_n_u_cp874) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_win932, __pyx_n_u_cp932) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_win936, __pyx_n_u_cp936) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_win949, __pyx_n_u_cp949) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_win950, __pyx_n_u_cp950) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_windows1250, __pyx_n_u_cp1250) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_windows1251, __pyx_n_u_cp1251) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_windows1252, __pyx_n_u_cp1252) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_windows1253, __pyx_n_u_cp1253) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_windows1254, __pyx_n_u_cp1254) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_windows1255, __pyx_n_u_cp1255) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_windows1256, __pyx_n_u_cp1256) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_windows1257, __pyx_n_u_cp1257) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_windows1258, __pyx_n_u_cp1258) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_windows866, __pyx_n_u_cp866) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_windows874, __pyx_n_u_cp874) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_windows932, __pyx_n_u_cp932) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_windows936, __pyx_n_u_cp936) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_windows949, __pyx_n_u_cp949) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_windows950, __pyx_n_u_cp950) < 0) __PYX_ERR(5, 14, __pyx_L1_error)
+  __Pyx_XGOTREF(__pyx_v_7asyncpg_8protocol_8protocol_ENCODINGS_MAP);
+  __Pyx_DECREF_SET(__pyx_v_7asyncpg_8protocol_8protocol_ENCODINGS_MAP, ((PyObject*)__pyx_t_2));
+  __Pyx_GIVEREF(__pyx_t_2);
+  __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/settings.pyx":46
+ * 
+ *     cpdef inline Codec get_data_codec(self, uint32_t oid,
+ *                                       CodecFormat format=PG_FORMAT_ANY):             # <<<<<<<<<<<<<<
+ *         if format == PG_FORMAT_ANY:
+ *             codec = self._data_codecs.get_codec(oid, PG_FORMAT_BINARY)
+ */
+  __pyx_k__2 = __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_ANY;
+
+  /* "asyncpg/protocol/settings.pyx":45
+ *                                           typekind, alias_to)
+ * 
+ *     cpdef inline Codec get_data_codec(self, uint32_t oid,             # <<<<<<<<<<<<<<
+ *                                       CodecFormat format=PG_FORMAT_ANY):
+ *         if format == PG_FORMAT_ANY:
+ */
+  __pyx_k__2 = __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_ANY;
+
+  /* "asyncpg/protocol/buffer.pyx":12
+ * 
+ * 
+ * class BufferError(Exception):             # <<<<<<<<<<<<<<
+ *     pass
+ * 
+ */
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 12, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
+  __Pyx_GIVEREF(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
+  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
+  __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_2, __pyx_n_s_BufferError, __pyx_n_s_BufferError, (PyObject *) NULL, __pyx_n_s_asyncpg_protocol_protocol, (PyObject *) NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 12, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_BufferError, __pyx_t_2, __pyx_t_3, NULL, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 12, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_BufferError, __pyx_t_4) < 0) __PYX_ERR(1, 12, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":10
+ * cdef void* binary_codec_map[MAXSUPPORTEDOID + 1]
+ * cdef void* text_codec_map[MAXSUPPORTEDOID + 1]
+ * cdef dict TYPE_CODECS_CACHE = {}             # <<<<<<<<<<<<<<
+ * cdef dict EXTRA_CODECS = {}
+ * 
+ */
+  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 10, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_XGOTREF(__pyx_v_7asyncpg_8protocol_8protocol_TYPE_CODECS_CACHE);
+  __Pyx_DECREF_SET(__pyx_v_7asyncpg_8protocol_8protocol_TYPE_CODECS_CACHE, ((PyObject*)__pyx_t_2));
+  __Pyx_GIVEREF(__pyx_t_2);
+  __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/base.pyx":11
+ * cdef void* text_codec_map[MAXSUPPORTEDOID + 1]
+ * cdef dict TYPE_CODECS_CACHE = {}
+ * cdef dict EXTRA_CODECS = {}             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 11, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_XGOTREF(__pyx_v_7asyncpg_8protocol_8protocol_EXTRA_CODECS);
+  __Pyx_DECREF_SET(__pyx_v_7asyncpg_8protocol_8protocol_EXTRA_CODECS, ((PyObject*)__pyx_t_2));
+  __Pyx_GIVEREF(__pyx_t_2);
+  __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/bytea.pyx":48
+ *                         PG_FORMAT_BINARY)
+ * 
+ * init_bytea_codecs()             # <<<<<<<<<<<<<<
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_init_bytea_codecs(); if (unlikely(!__pyx_t_2)) __PYX_ERR(6, 48, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/text.pyx":67
+ * 
+ * 
+ * init_text_codecs()             # <<<<<<<<<<<<<<
+ */
+  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_init_text_codecs(); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 67, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/bits.pyx":8
+ * 
+ * 
+ * from asyncpg.types import BitString             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(8, 8, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_n_s_BitString);
+  __Pyx_GIVEREF(__pyx_n_s_BitString);
+  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_BitString);
+  __pyx_t_1 = __Pyx_Import(__pyx_n_s_asyncpg_types, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 8, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_BitString); if (unlikely(!__pyx_t_2)) __PYX_ERR(8, 8, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_BitString, __pyx_t_2) < 0) __PYX_ERR(8, 8, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/bits.pyx":64
+ *                         PG_FORMAT_BINARY)
+ * 
+ * init_bits_codecs()             # <<<<<<<<<<<<<<
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_init_bits_codecs(); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 64, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":8
+ * 
+ * 
+ * import datetime             # <<<<<<<<<<<<<<
+ * 
+ * utc = datetime.timezone.utc
+ */
+  __pyx_t_1 = __Pyx_Import(__pyx_n_s_datetime, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 8, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_datetime, __pyx_t_1) < 0) __PYX_ERR(9, 8, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":10
+ * import datetime
+ * 
+ * utc = datetime.timezone.utc             # <<<<<<<<<<<<<<
+ * date_from_ordinal = datetime.date.fromordinal
+ * timedelta = datetime.timedelta
+ */
+  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_datetime); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 10, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_timezone); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 10, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_utc); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 10, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_utc, __pyx_t_1) < 0) __PYX_ERR(9, 10, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":11
+ * 
+ * utc = datetime.timezone.utc
+ * date_from_ordinal = datetime.date.fromordinal             # <<<<<<<<<<<<<<
+ * timedelta = datetime.timedelta
+ * 
+ */
+  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_datetime); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 11, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_date); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 11, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_fromordinal); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 11, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_date_from_ordinal, __pyx_t_1) < 0) __PYX_ERR(9, 11, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":12
+ * utc = datetime.timezone.utc
+ * date_from_ordinal = datetime.date.fromordinal
+ * timedelta = datetime.timedelta             # <<<<<<<<<<<<<<
+ * 
+ * pg_epoch_datetime = datetime.datetime(2000, 1, 1)
+ */
+  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_datetime); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 12, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_timedelta); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 12, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_timedelta, __pyx_t_2) < 0) __PYX_ERR(9, 12, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":14
+ * timedelta = datetime.timedelta
+ * 
+ * pg_epoch_datetime = datetime.datetime(2000, 1, 1)             # <<<<<<<<<<<<<<
+ * cdef int32_t pg_epoch_datetime_ts = \
+ *     <int32_t>cpython.PyLong_AsLong(int(pg_epoch_datetime.timestamp()))
+ */
+  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_datetime); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 14, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_datetime); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 14, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__84, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 14, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pg_epoch_datetime, __pyx_t_2) < 0) __PYX_ERR(9, 14, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":16
+ * pg_epoch_datetime = datetime.datetime(2000, 1, 1)
+ * cdef int32_t pg_epoch_datetime_ts = \
+ *     <int32_t>cpython.PyLong_AsLong(int(pg_epoch_datetime.timestamp()))             # <<<<<<<<<<<<<<
+ * 
+ * pg_epoch_datetime_utc = datetime.datetime(2000, 1, 1, tzinfo=utc)
+ */
+  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_pg_epoch_datetime); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 16, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_timestamp); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 16, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = NULL;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
+    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
+    if (likely(__pyx_t_1)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+      __Pyx_INCREF(__pyx_t_1);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_3, function);
+    }
+  }
+  if (__pyx_t_1) {
+    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 16, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  } else {
+    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 16, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 16, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_5 = PyLong_AsLong(__pyx_t_3); if (unlikely(__pyx_t_5 == -1L && PyErr_Occurred())) __PYX_ERR(9, 16, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_v_7asyncpg_8protocol_8protocol_pg_epoch_datetime_ts = ((int32_t)__pyx_t_5);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":18
+ *     <int32_t>cpython.PyLong_AsLong(int(pg_epoch_datetime.timestamp()))
+ * 
+ * pg_epoch_datetime_utc = datetime.datetime(2000, 1, 1, tzinfo=utc)             # <<<<<<<<<<<<<<
+ * cdef int32_t pg_epoch_datetime_utc_ts = \
+ *     <int32_t>cpython.PyLong_AsLong(pg_epoch_datetime_utc.timestamp())
+ */
+  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 18, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_datetime); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 18, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 18, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_utc); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 18, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_tzinfo, __pyx_t_1) < 0) __PYX_ERR(9, 18, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__85, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 18, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pg_epoch_datetime_utc, __pyx_t_1) < 0) __PYX_ERR(9, 18, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":20
+ * pg_epoch_datetime_utc = datetime.datetime(2000, 1, 1, tzinfo=utc)
+ * cdef int32_t pg_epoch_datetime_utc_ts = \
+ *     <int32_t>cpython.PyLong_AsLong(pg_epoch_datetime_utc.timestamp())             # <<<<<<<<<<<<<<
+ * 
+ * pg_epoch_date = datetime.date(2000, 1, 1)
+ */
+  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_pg_epoch_datetime_utc); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 20, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_timestamp); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 20, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = NULL;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (__pyx_t_3) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 20, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  } else {
+    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 20, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_5 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_5 == -1L && PyErr_Occurred())) __PYX_ERR(9, 20, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_7asyncpg_8protocol_8protocol_pg_epoch_datetime_utc_ts = ((int32_t)__pyx_t_5);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":22
+ *     <int32_t>cpython.PyLong_AsLong(pg_epoch_datetime_utc.timestamp())
+ * 
+ * pg_epoch_date = datetime.date(2000, 1, 1)             # <<<<<<<<<<<<<<
+ * cdef int32_t pg_date_offset_ord = \
+ *     <int32_t>cpython.PyLong_AsLong(pg_epoch_date.toordinal())
+ */
+  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_datetime); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 22, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_date); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 22, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__86, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 22, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pg_epoch_date, __pyx_t_1) < 0) __PYX_ERR(9, 22, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":24
+ * pg_epoch_date = datetime.date(2000, 1, 1)
+ * cdef int32_t pg_date_offset_ord = \
+ *     <int32_t>cpython.PyLong_AsLong(pg_epoch_date.toordinal())             # <<<<<<<<<<<<<<
+ * 
+ * # Binary representations of infinity for datetimes.
+ */
+  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_pg_epoch_date); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 24, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_toordinal); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 24, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = NULL;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
+    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
+    if (likely(__pyx_t_2)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+      __Pyx_INCREF(__pyx_t_2);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_3, function);
+    }
+  }
+  if (__pyx_t_2) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 24, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  } else {
+    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 24, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_5 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_5 == -1L && PyErr_Occurred())) __PYX_ERR(9, 24, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_7asyncpg_8protocol_8protocol_pg_date_offset_ord = ((int32_t)__pyx_t_5);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":27
+ * 
+ * # Binary representations of infinity for datetimes.
+ * cdef int64_t pg_time64_infinity = 0x7fffffffffffffff             # <<<<<<<<<<<<<<
+ * cdef int64_t pg_time64_negative_infinity = <int64_t>0x8000000000000000
+ * cdef int32_t pg_date_infinity = 0x7fffffff
+ */
+  __pyx_v_7asyncpg_8protocol_8protocol_pg_time64_infinity = 0x7fffffffffffffff;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":28
+ * # Binary representations of infinity for datetimes.
+ * cdef int64_t pg_time64_infinity = 0x7fffffffffffffff
+ * cdef int64_t pg_time64_negative_infinity = <int64_t>0x8000000000000000             # <<<<<<<<<<<<<<
+ * cdef int32_t pg_date_infinity = 0x7fffffff
+ * cdef int32_t pg_date_negative_infinity = <int32_t>0x80000000
+ */
+  __pyx_v_7asyncpg_8protocol_8protocol_pg_time64_negative_infinity = ((int64_t)0x8000000000000000);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":29
+ * cdef int64_t pg_time64_infinity = 0x7fffffffffffffff
+ * cdef int64_t pg_time64_negative_infinity = <int64_t>0x8000000000000000
+ * cdef int32_t pg_date_infinity = 0x7fffffff             # <<<<<<<<<<<<<<
+ * cdef int32_t pg_date_negative_infinity = <int32_t>0x80000000
+ * 
+ */
+  __pyx_v_7asyncpg_8protocol_8protocol_pg_date_infinity = 0x7fffffff;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":30
+ * cdef int64_t pg_time64_negative_infinity = <int64_t>0x8000000000000000
+ * cdef int32_t pg_date_infinity = 0x7fffffff
+ * cdef int32_t pg_date_negative_infinity = <int32_t>0x80000000             # <<<<<<<<<<<<<<
+ * 
+ * infinity_datetime = datetime.datetime(
+ */
+  __pyx_v_7asyncpg_8protocol_8protocol_pg_date_negative_infinity = ((int32_t)0x80000000);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":32
+ * cdef int32_t pg_date_negative_infinity = <int32_t>0x80000000
+ * 
+ * infinity_datetime = datetime.datetime(             # <<<<<<<<<<<<<<
+ *     datetime.MAXYEAR, 12, 31, 23, 59, 59, 999999)
+ * 
+ */
+  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 32, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_datetime); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 32, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":33
+ * 
+ * infinity_datetime = datetime.datetime(
+ *     datetime.MAXYEAR, 12, 31, 23, 59, 59, 999999)             # <<<<<<<<<<<<<<
+ * 
+ * cdef int32_t infinity_datetime_ord = <int32_t>cpython.PyLong_AsLong(
+ */
+  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 33, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_MAXYEAR); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 33, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = NULL;
+  __pyx_t_6 = 0;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+      __pyx_t_6 = 1;
+    }
+  }
+  #if CYTHON_FAST_PYCALL
+  if (PyFunction_Check(__pyx_t_2)) {
+    PyObject *__pyx_temp[8] = {__pyx_t_3, __pyx_t_4, __pyx_int_12, __pyx_int_31, __pyx_int_23, __pyx_int_59, __pyx_int_59, __pyx_int_999999};
+    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 7+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 32, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  } else
+  #endif
+  #if CYTHON_FAST_PYCCALL
+  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+    PyObject *__pyx_temp[8] = {__pyx_t_3, __pyx_t_4, __pyx_int_12, __pyx_int_31, __pyx_int_23, __pyx_int_59, __pyx_int_59, __pyx_int_999999};
+    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 7+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 32, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  } else
+  #endif
+  {
+    __pyx_t_7 = PyTuple_New(7+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(9, 32, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_7);
+    if (__pyx_t_3) {
+      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL;
+    }
+    __Pyx_GIVEREF(__pyx_t_4);
+    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_4);
+    __Pyx_INCREF(__pyx_int_12);
+    __Pyx_GIVEREF(__pyx_int_12);
+    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_int_12);
+    __Pyx_INCREF(__pyx_int_31);
+    __Pyx_GIVEREF(__pyx_int_31);
+    PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_int_31);
+    __Pyx_INCREF(__pyx_int_23);
+    __Pyx_GIVEREF(__pyx_int_23);
+    PyTuple_SET_ITEM(__pyx_t_7, 3+__pyx_t_6, __pyx_int_23);
+    __Pyx_INCREF(__pyx_int_59);
+    __Pyx_GIVEREF(__pyx_int_59);
+    PyTuple_SET_ITEM(__pyx_t_7, 4+__pyx_t_6, __pyx_int_59);
+    __Pyx_INCREF(__pyx_int_59);
+    __Pyx_GIVEREF(__pyx_int_59);
+    PyTuple_SET_ITEM(__pyx_t_7, 5+__pyx_t_6, __pyx_int_59);
+    __Pyx_INCREF(__pyx_int_999999);
+    __Pyx_GIVEREF(__pyx_int_999999);
+    PyTuple_SET_ITEM(__pyx_t_7, 6+__pyx_t_6, __pyx_int_999999);
+    __pyx_t_4 = 0;
+    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 32, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_infinity_datetime, __pyx_t_1) < 0) __PYX_ERR(9, 32, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":36
+ * 
+ * cdef int32_t infinity_datetime_ord = <int32_t>cpython.PyLong_AsLong(
+ *     infinity_datetime.toordinal())             # <<<<<<<<<<<<<<
+ * 
+ * cdef int64_t infinity_datetime_ts = 252455615999999999
+ */
+  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_infinity_datetime); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 36, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_toordinal); if (unlikely(!__pyx_t_7)) __PYX_ERR(9, 36, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_7);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = NULL;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
+    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7);
+    if (likely(__pyx_t_2)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
+      __Pyx_INCREF(__pyx_t_2);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_7, function);
+    }
+  }
+  if (__pyx_t_2) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 36, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  } else {
+    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 36, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":35
+ *     datetime.MAXYEAR, 12, 31, 23, 59, 59, 999999)
+ * 
+ * cdef int32_t infinity_datetime_ord = <int32_t>cpython.PyLong_AsLong(             # <<<<<<<<<<<<<<
+ *     infinity_datetime.toordinal())
+ * 
+ */
+  __pyx_t_5 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_5 == -1L && PyErr_Occurred())) __PYX_ERR(9, 35, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_7asyncpg_8protocol_8protocol_infinity_datetime_ord = ((int32_t)__pyx_t_5);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":38
+ *     infinity_datetime.toordinal())
+ * 
+ * cdef int64_t infinity_datetime_ts = 252455615999999999             # <<<<<<<<<<<<<<
+ * 
+ * negative_infinity_datetime = datetime.datetime(
+ */
+  __pyx_v_7asyncpg_8protocol_8protocol_infinity_datetime_ts = 0x380E70B913B7FFF;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":40
+ * cdef int64_t infinity_datetime_ts = 252455615999999999
+ * 
+ * negative_infinity_datetime = datetime.datetime(             # <<<<<<<<<<<<<<
+ *     datetime.MINYEAR, 1, 1, 0, 0, 0, 0)
+ * 
+ */
+  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_datetime); if (unlikely(!__pyx_t_7)) __PYX_ERR(9, 40, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_7);
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_datetime); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 40, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":41
+ * 
+ * negative_infinity_datetime = datetime.datetime(
+ *     datetime.MINYEAR, 1, 1, 0, 0, 0, 0)             # <<<<<<<<<<<<<<
+ * 
+ * cdef int32_t negative_infinity_datetime_ord = <int32_t>cpython.PyLong_AsLong(
+ */
+  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_datetime); if (unlikely(!__pyx_t_7)) __PYX_ERR(9, 41, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_7);
+  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_MINYEAR); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 41, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+  __pyx_t_7 = NULL;
+  __pyx_t_6 = 0;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_7)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_7);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+      __pyx_t_6 = 1;
+    }
+  }
+  #if CYTHON_FAST_PYCALL
+  if (PyFunction_Check(__pyx_t_2)) {
+    PyObject *__pyx_temp[8] = {__pyx_t_7, __pyx_t_4, __pyx_int_1, __pyx_int_1, __pyx_int_0, __pyx_int_0, __pyx_int_0, __pyx_int_0};
+    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 7+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 40, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  } else
+  #endif
+  #if CYTHON_FAST_PYCCALL
+  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+    PyObject *__pyx_temp[8] = {__pyx_t_7, __pyx_t_4, __pyx_int_1, __pyx_int_1, __pyx_int_0, __pyx_int_0, __pyx_int_0, __pyx_int_0};
+    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 7+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 40, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  } else
+  #endif
+  {
+    __pyx_t_3 = PyTuple_New(7+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 40, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    if (__pyx_t_7) {
+      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7); __pyx_t_7 = NULL;
+    }
+    __Pyx_GIVEREF(__pyx_t_4);
+    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_6, __pyx_t_4);
+    __Pyx_INCREF(__pyx_int_1);
+    __Pyx_GIVEREF(__pyx_int_1);
+    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_6, __pyx_int_1);
+    __Pyx_INCREF(__pyx_int_1);
+    __Pyx_GIVEREF(__pyx_int_1);
+    PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_6, __pyx_int_1);
+    __Pyx_INCREF(__pyx_int_0);
+    __Pyx_GIVEREF(__pyx_int_0);
+    PyTuple_SET_ITEM(__pyx_t_3, 3+__pyx_t_6, __pyx_int_0);
+    __Pyx_INCREF(__pyx_int_0);
+    __Pyx_GIVEREF(__pyx_int_0);
+    PyTuple_SET_ITEM(__pyx_t_3, 4+__pyx_t_6, __pyx_int_0);
+    __Pyx_INCREF(__pyx_int_0);
+    __Pyx_GIVEREF(__pyx_int_0);
+    PyTuple_SET_ITEM(__pyx_t_3, 5+__pyx_t_6, __pyx_int_0);
+    __Pyx_INCREF(__pyx_int_0);
+    __Pyx_GIVEREF(__pyx_int_0);
+    PyTuple_SET_ITEM(__pyx_t_3, 6+__pyx_t_6, __pyx_int_0);
+    __pyx_t_4 = 0;
+    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 40, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_negative_infinity_datetime, __pyx_t_1) < 0) __PYX_ERR(9, 40, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":44
+ * 
+ * cdef int32_t negative_infinity_datetime_ord = <int32_t>cpython.PyLong_AsLong(
+ *     negative_infinity_datetime.toordinal())             # <<<<<<<<<<<<<<
+ * 
+ * cdef int64_t negative_infinity_datetime_ts = -63082281600000000
+ */
+  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_negative_infinity_datetime); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 44, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_toordinal); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 44, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = NULL;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
+    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
+    if (likely(__pyx_t_2)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+      __Pyx_INCREF(__pyx_t_2);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_3, function);
+    }
+  }
+  if (__pyx_t_2) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 44, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  } else {
+    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 44, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":43
+ *     datetime.MINYEAR, 1, 1, 0, 0, 0, 0)
+ * 
+ * cdef int32_t negative_infinity_datetime_ord = <int32_t>cpython.PyLong_AsLong(             # <<<<<<<<<<<<<<
+ *     negative_infinity_datetime.toordinal())
+ * 
+ */
+  __pyx_t_5 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_5 == -1L && PyErr_Occurred())) __PYX_ERR(9, 43, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_7asyncpg_8protocol_8protocol_negative_infinity_datetime_ord = ((int32_t)__pyx_t_5);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":46
+ *     negative_infinity_datetime.toordinal())
+ * 
+ * cdef int64_t negative_infinity_datetime_ts = -63082281600000000             # <<<<<<<<<<<<<<
+ * 
+ * infinity_date = datetime.date(datetime.MAXYEAR, 12, 31)
+ */
+  __pyx_v_7asyncpg_8protocol_8protocol_negative_infinity_datetime_ts = -63082281600000000L;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":48
+ * cdef int64_t negative_infinity_datetime_ts = -63082281600000000
+ * 
+ * infinity_date = datetime.date(datetime.MAXYEAR, 12, 31)             # <<<<<<<<<<<<<<
+ * 
+ * cdef int32_t infinity_date_ord = <int32_t>cpython.PyLong_AsLong(
+ */
+  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 48, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_date); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 48, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 48, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_MAXYEAR); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 48, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = NULL;
+  __pyx_t_6 = 0;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+      __pyx_t_6 = 1;
+    }
+  }
+  #if CYTHON_FAST_PYCALL
+  if (PyFunction_Check(__pyx_t_2)) {
+    PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_t_4, __pyx_int_12, __pyx_int_31};
+    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 48, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  } else
+  #endif
+  #if CYTHON_FAST_PYCCALL
+  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+    PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_t_4, __pyx_int_12, __pyx_int_31};
+    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 48, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  } else
+  #endif
+  {
+    __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(9, 48, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_7);
+    if (__pyx_t_3) {
+      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL;
+    }
+    __Pyx_GIVEREF(__pyx_t_4);
+    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_4);
+    __Pyx_INCREF(__pyx_int_12);
+    __Pyx_GIVEREF(__pyx_int_12);
+    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_int_12);
+    __Pyx_INCREF(__pyx_int_31);
+    __Pyx_GIVEREF(__pyx_int_31);
+    PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_int_31);
+    __pyx_t_4 = 0;
+    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 48, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_infinity_date, __pyx_t_1) < 0) __PYX_ERR(9, 48, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":51
+ * 
+ * cdef int32_t infinity_date_ord = <int32_t>cpython.PyLong_AsLong(
+ *     infinity_date.toordinal())             # <<<<<<<<<<<<<<
+ * 
+ * negative_infinity_date = datetime.date(datetime.MINYEAR, 1, 1)
+ */
+  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_infinity_date); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 51, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_toordinal); if (unlikely(!__pyx_t_7)) __PYX_ERR(9, 51, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_7);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = NULL;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
+    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7);
+    if (likely(__pyx_t_2)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
+      __Pyx_INCREF(__pyx_t_2);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_7, function);
+    }
+  }
+  if (__pyx_t_2) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 51, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  } else {
+    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 51, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":50
+ * infinity_date = datetime.date(datetime.MAXYEAR, 12, 31)
+ * 
+ * cdef int32_t infinity_date_ord = <int32_t>cpython.PyLong_AsLong(             # <<<<<<<<<<<<<<
+ *     infinity_date.toordinal())
+ * 
+ */
+  __pyx_t_5 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_5 == -1L && PyErr_Occurred())) __PYX_ERR(9, 50, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_7asyncpg_8protocol_8protocol_infinity_date_ord = ((int32_t)__pyx_t_5);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":53
+ *     infinity_date.toordinal())
+ * 
+ * negative_infinity_date = datetime.date(datetime.MINYEAR, 1, 1)             # <<<<<<<<<<<<<<
+ * 
+ * cdef int32_t negative_infinity_date_ord = <int32_t>cpython.PyLong_AsLong(
+ */
+  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_datetime); if (unlikely(!__pyx_t_7)) __PYX_ERR(9, 53, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_7);
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_date); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 53, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_datetime); if (unlikely(!__pyx_t_7)) __PYX_ERR(9, 53, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_7);
+  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_MINYEAR); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 53, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+  __pyx_t_7 = NULL;
+  __pyx_t_6 = 0;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_7)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_7);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+      __pyx_t_6 = 1;
+    }
+  }
+  #if CYTHON_FAST_PYCALL
+  if (PyFunction_Check(__pyx_t_2)) {
+    PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_4, __pyx_int_1, __pyx_int_1};
+    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 53, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  } else
+  #endif
+  #if CYTHON_FAST_PYCCALL
+  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
+    PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_4, __pyx_int_1, __pyx_int_1};
+    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 53, __pyx_L1_error)
+    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  } else
+  #endif
+  {
+    __pyx_t_3 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 53, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_3);
+    if (__pyx_t_7) {
+      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7); __pyx_t_7 = NULL;
+    }
+    __Pyx_GIVEREF(__pyx_t_4);
+    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_6, __pyx_t_4);
+    __Pyx_INCREF(__pyx_int_1);
+    __Pyx_GIVEREF(__pyx_int_1);
+    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_6, __pyx_int_1);
+    __Pyx_INCREF(__pyx_int_1);
+    __Pyx_GIVEREF(__pyx_int_1);
+    PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_6, __pyx_int_1);
+    __pyx_t_4 = 0;
+    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 53, __pyx_L1_error)
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_negative_infinity_date, __pyx_t_1) < 0) __PYX_ERR(9, 53, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":56
+ * 
+ * cdef int32_t negative_infinity_date_ord = <int32_t>cpython.PyLong_AsLong(
+ *     negative_infinity_date.toordinal())             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_negative_infinity_date); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 56, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_toordinal); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 56, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = NULL;
+  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
+    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
+    if (likely(__pyx_t_2)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+      __Pyx_INCREF(__pyx_t_2);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_3, function);
+    }
+  }
+  if (__pyx_t_2) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 56, __pyx_L1_error)
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  } else {
+    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 56, __pyx_L1_error)
+  }
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":55
+ * negative_infinity_date = datetime.date(datetime.MINYEAR, 1, 1)
+ * 
+ * cdef int32_t negative_infinity_date_ord = <int32_t>cpython.PyLong_AsLong(             # <<<<<<<<<<<<<<
+ *     negative_infinity_date.toordinal())
+ * 
+ */
+  __pyx_t_5 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_5 == -1L && PyErr_Occurred())) __PYX_ERR(9, 55, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_7asyncpg_8protocol_8protocol_negative_infinity_date_ord = ((int32_t)__pyx_t_5);
+
+  /* "asyncpg/protocol/codecs/datetime.pyx":311
+ *                         PG_FORMAT_TEXT)
+ * 
+ * init_datetime_codecs()             # <<<<<<<<<<<<<<
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_init_datetime_codecs(); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 311, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/float.pyx":49
+ * 
+ * 
+ * init_float_codecs()             # <<<<<<<<<<<<<<
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_init_float_codecs(); if (unlikely(!__pyx_t_1)) __PYX_ERR(10, 49, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":8
+ * 
+ * 
+ * from asyncpg.types import Box, Line, LineSegment, Path, Point, Polygon, Circle             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_1 = PyList_New(7); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 8, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(__pyx_n_s_Box);
+  __Pyx_GIVEREF(__pyx_n_s_Box);
+  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Box);
+  __Pyx_INCREF(__pyx_n_s_Line);
+  __Pyx_GIVEREF(__pyx_n_s_Line);
+  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_Line);
+  __Pyx_INCREF(__pyx_n_s_LineSegment);
+  __Pyx_GIVEREF(__pyx_n_s_LineSegment);
+  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_LineSegment);
+  __Pyx_INCREF(__pyx_n_s_Path);
+  __Pyx_GIVEREF(__pyx_n_s_Path);
+  PyList_SET_ITEM(__pyx_t_1, 3, __pyx_n_s_Path);
+  __Pyx_INCREF(__pyx_n_s_Point);
+  __Pyx_GIVEREF(__pyx_n_s_Point);
+  PyList_SET_ITEM(__pyx_t_1, 4, __pyx_n_s_Point);
+  __Pyx_INCREF(__pyx_n_s_Polygon);
+  __Pyx_GIVEREF(__pyx_n_s_Polygon);
+  PyList_SET_ITEM(__pyx_t_1, 5, __pyx_n_s_Polygon);
+  __Pyx_INCREF(__pyx_n_s_Circle);
+  __Pyx_GIVEREF(__pyx_n_s_Circle);
+  PyList_SET_ITEM(__pyx_t_1, 6, __pyx_n_s_Circle);
+  __pyx_t_3 = __Pyx_Import(__pyx_n_s_asyncpg_types, __pyx_t_1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(11, 8, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_Box); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 8, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Box, __pyx_t_1) < 0) __PYX_ERR(11, 8, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_Line); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 8, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Line, __pyx_t_1) < 0) __PYX_ERR(11, 8, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_LineSegment); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 8, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_LineSegment, __pyx_t_1) < 0) __PYX_ERR(11, 8, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_Path); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 8, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Path, __pyx_t_1) < 0) __PYX_ERR(11, 8, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_Point); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 8, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Point, __pyx_t_1) < 0) __PYX_ERR(11, 8, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_Polygon); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 8, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Polygon, __pyx_t_1) < 0) __PYX_ERR(11, 8, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_Circle); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 8, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Circle, __pyx_t_1) < 0) __PYX_ERR(11, 8, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/geometry.pyx":205
+ * 
+ * 
+ * init_geometry_codecs()             # <<<<<<<<<<<<<<
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_init_geometry_codecs(); if (unlikely(!__pyx_t_3)) __PYX_ERR(11, 205, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/int.pyx":79
+ * 
+ * 
+ * init_int_codecs()             # <<<<<<<<<<<<<<
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_init_int_codecs(); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 79, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/json.pyx":42
+ *                         PG_FORMAT_BINARY)
+ * 
+ * init_json_codecs()             # <<<<<<<<<<<<<<
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_init_json_codecs(); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 42, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/money.pyx":20
+ * 
+ * 
+ * init_monetary_codecs()             # <<<<<<<<<<<<<<
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_init_monetary_codecs(); if (unlikely(!__pyx_t_3)) __PYX_ERR(13, 20, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/network.pyx":8
+ * 
+ * 
+ * import ipaddress             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_3 = __Pyx_Import(__pyx_n_s_ipaddress, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 8, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ipaddress, __pyx_t_3) < 0) __PYX_ERR(14, 8, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/network.pyx":17
+ * 
+ * 
+ * _ipaddr = ipaddress.ip_address             # <<<<<<<<<<<<<<
+ * _ipnet = ipaddress.ip_network
+ * 
+ */
+  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_ipaddress); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 17, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ip_address); if (unlikely(!__pyx_t_1)) __PYX_ERR(14, 17, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ipaddr, __pyx_t_1) < 0) __PYX_ERR(14, 17, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/network.pyx":18
+ * 
+ * _ipaddr = ipaddress.ip_address
+ * _ipnet = ipaddress.ip_network             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_ipaddress); if (unlikely(!__pyx_t_1)) __PYX_ERR(14, 18, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ip_network); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 18, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ipnet, __pyx_t_3) < 0) __PYX_ERR(14, 18, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/network.pyx":111
+ * 
+ * 
+ * init_network_codecs()             # <<<<<<<<<<<<<<
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_init_network_codecs(); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 111, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/numeric.pyx":8
+ * 
+ * 
+ * import decimal             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_3 = __Pyx_Import(__pyx_n_s_decimal, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(15, 8, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_decimal, __pyx_t_3) < 0) __PYX_ERR(15, 8, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/numeric.pyx":11
+ * 
+ * 
+ * _Dec = decimal.Decimal             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_decimal); if (unlikely(!__pyx_t_3)) __PYX_ERR(15, 11, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_Decimal); if (unlikely(!__pyx_t_1)) __PYX_ERR(15, 11, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Dec, __pyx_t_1) < 0) __PYX_ERR(15, 11, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/numeric.pyx":28
+ *                         PG_FORMAT_TEXT)
+ * 
+ * init_numeric_codecs()             # <<<<<<<<<<<<<<
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_init_numeric_codecs(); if (unlikely(!__pyx_t_1)) __PYX_ERR(15, 28, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/tsearch.pyx":26
+ * 
+ * 
+ * init_tsearch_codecs()             # <<<<<<<<<<<<<<
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_init_tsearch_codecs(); if (unlikely(!__pyx_t_1)) __PYX_ERR(16, 26, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/txid.pyx":71
+ * 
+ * 
+ * init_txid_codecs()             # <<<<<<<<<<<<<<
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_init_txid_codecs(); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 71, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/uuid.pyx":8
+ * 
+ * 
+ * import uuid             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_1 = __Pyx_Import(__pyx_n_s_uuid, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 8, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_uuid, __pyx_t_1) < 0) __PYX_ERR(18, 8, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/uuid.pyx":11
+ * 
+ * 
+ * _UUID = uuid.UUID             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_uuid); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 11, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_UUID_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(18, 11, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_UUID, __pyx_t_3) < 0) __PYX_ERR(18, 11, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/uuid.pyx":31
+ *                         PG_FORMAT_BINARY)
+ * 
+ * init_uuid_codecs()             # <<<<<<<<<<<<<<
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_init_uuid_codecs(); if (unlikely(!__pyx_t_3)) __PYX_ERR(18, 31, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/misc.pyx":108
+ * 
+ * 
+ * init_pseudo_codecs()             # <<<<<<<<<<<<<<
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_init_pseudo_codecs(); if (unlikely(!__pyx_t_3)) __PYX_ERR(19, 108, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":8
+ * 
+ * 
+ * from collections.abc import Container as ContainerABC             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 8, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_INCREF(__pyx_n_s_Container);
+  __Pyx_GIVEREF(__pyx_n_s_Container);
+  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_Container);
+  __pyx_t_1 = __Pyx_Import(__pyx_n_s_collections_abc, __pyx_t_3, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 8, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_Container); if (unlikely(!__pyx_t_3)) __PYX_ERR(20, 8, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ContainerABC, __pyx_t_3) < 0) __PYX_ERR(20, 8, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/array.pyx":14
+ * 
+ * # "NULL"
+ * cdef Py_UCS4 *APG_NULL = [0x004E, 0x0055, 0x004C, 0x004C, 0x0000]             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_8[0] = 0x004E;
+  __pyx_t_8[1] = 0x0055;
+  __pyx_t_8[2] = 0x004C;
+  __pyx_t_8[3] = 0x004C;
+  __pyx_t_8[4] = 0x0000;
+  __pyx_v_7asyncpg_8protocol_8protocol_APG_NULL = __pyx_t_8;
+
+  /* "asyncpg/protocol/codecs/array.pyx":789
+ *                         PG_FORMAT_BINARY)
+ * 
+ * init_array_codecs()             # <<<<<<<<<<<<<<
+ */
+  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_init_array_codecs(); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 789, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/codecs/range.pyx":8
+ * 
+ * 
+ * from asyncpg import types as apg_types             # <<<<<<<<<<<<<<
+ * 
+ * # defined in postgresql/src/include/utils/rangetypes.h
+ */
+  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(21, 8, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(__pyx_n_s_types);
+  __Pyx_GIVEREF(__pyx_n_s_types);
+  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_types);
+  __pyx_t_3 = __Pyx_Import(__pyx_n_s_asyncpg, __pyx_t_1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(21, 8, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_types); if (unlikely(!__pyx_t_1)) __PYX_ERR(21, 8, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_apg_types, __pyx_t_1) < 0) __PYX_ERR(21, 8, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/range.pyx":149
+ * 
+ * 
+ * init_range_codecs()             # <<<<<<<<<<<<<<
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_init_range_codecs(); if (unlikely(!__pyx_t_3)) __PYX_ERR(21, 149, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/record.pyx":57
+ *                         PG_FORMAT_BINARY)
+ * 
+ * init_record_codecs()             # <<<<<<<<<<<<<<
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_init_record_codecs(); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 57, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/codecs/hstore.pyx":82
+ *                          PG_FORMAT_BINARY)
+ * 
+ * init_hstore_codecs()             # <<<<<<<<<<<<<<
+ */
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_init_hstore_codecs(); if (unlikely(!__pyx_t_3)) __PYX_ERR(23, 82, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":8
+ * 
+ * 
+ * from hashlib import md5 as hashlib_md5  # for MD5 authentication             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 8, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_INCREF(__pyx_n_s_md5);
+  __Pyx_GIVEREF(__pyx_n_s_md5);
+  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_md5);
+  __pyx_t_1 = __Pyx_Import(__pyx_n_s_hashlib, __pyx_t_3, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 8, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_md5); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 8, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_hashlib_md5, __pyx_t_3) < 0) __PYX_ERR(4, 8, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "asyncpg/protocol/coreproto.pyx":756
+ * 
+ * 
+ * cdef bytes SYNC_MESSAGE = bytes(WriteBuffer.new_message(b'S').end_message())             # <<<<<<<<<<<<<<
+ */
+  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new_message('S')); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 756, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_end_message(((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 756, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 756, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_3);
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
+  __pyx_t_3 = 0;
+  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&PyBytes_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 756, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_XGOTREF(__pyx_v_7asyncpg_8protocol_8protocol_SYNC_MESSAGE);
+  __Pyx_DECREF_SET(__pyx_v_7asyncpg_8protocol_8protocol_SYNC_MESSAGE, ((PyObject*)__pyx_t_3));
+  __Pyx_GIVEREF(__pyx_t_3);
+  __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":507
+ * 
+ * 
+ * class Protocol(BaseProtocol, asyncio.Protocol):             # <<<<<<<<<<<<<<
+ *     pass
+ * 
+ */
+  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_asyncio); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 507, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_Protocol); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 507, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 507, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_INCREF(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_BaseProtocol));
+  __Pyx_GIVEREF(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_BaseProtocol));
+  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_BaseProtocol));
+  __Pyx_GIVEREF(__pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
+  __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 507, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_3, __pyx_n_s_Protocol, __pyx_n_s_Protocol, (PyObject *) NULL, __pyx_n_s_asyncpg_protocol_protocol, (PyObject *) NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(27, 507, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_Protocol, __pyx_t_3, __pyx_t_2, NULL, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(27, 507, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_4);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Protocol, __pyx_t_4) < 0) __PYX_ERR(27, 507, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":511
+ * 
+ * 
+ * def _create_record(object mapping, tuple elems):             # <<<<<<<<<<<<<<
+ *     # Exposed only for testing purposes.
+ * 
+ */
+  __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_7asyncpg_8protocol_8protocol_1_create_record, NULL, __pyx_n_s_asyncpg_protocol_protocol); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 511, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_create_record, __pyx_t_3) < 0) __PYX_ERR(27, 511, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "asyncpg/protocol/protocol.pyx":532
+ * 
+ * 
+ * record.ApgRecord_InitTypes()             # <<<<<<<<<<<<<<
+ */
+  __pyx_t_6 = ApgRecord_InitTypes(); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(27, 532, __pyx_L1_error)
+
+  /* "asyncpg/protocol/protocol.pyx":1
+ * # Copyright (C) 2016-present the ayncpg authors and contributors             # <<<<<<<<<<<<<<
+ * # <see AUTHORS file>
+ * #
+ */
+  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 1, __pyx_L1_error)
+  __Pyx_GOTREF(__pyx_t_3);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_3) < 0) __PYX_ERR(27, 1, __pyx_L1_error)
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "hton.pxd":81
+ * 
+ * 
+ * cdef inline double unpack_double(const char* buf):             # <<<<<<<<<<<<<<
+ *     cdef _doubleconv v
+ *     v.i = <uint64_t>unpack_int64(buf)
+ */
+
+  /*--- Wrapped vars code ---*/
+
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_7);
+  if (__pyx_m) {
+    if (__pyx_d) {
+      __Pyx_AddTraceback("init asyncpg.protocol.protocol", __pyx_clineno, __pyx_lineno, __pyx_filename);
+    }
+    Py_DECREF(__pyx_m); __pyx_m = 0;
+  } else if (!PyErr_Occurred()) {
+    PyErr_SetString(PyExc_ImportError, "init asyncpg.protocol.protocol");
+  }
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  #if PY_MAJOR_VERSION < 3
+  return;
+  #else
+  return __pyx_m;
+  #endif
+}
+
+/* --- Runtime support code --- */
+/* Refnanny */
+#if CYTHON_REFNANNY
+static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
+    PyObject *m = NULL, *p = NULL;
+    void *r = NULL;
+    m = PyImport_ImportModule((char *)modname);
+    if (!m) goto end;
+    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
+    if (!p) goto end;
+    r = PyLong_AsVoidPtr(p);
+end:
+    Py_XDECREF(p);
+    Py_XDECREF(m);
+    return (__Pyx_RefNannyAPIStruct *)r;
+}
+#endif
+
+/* GetBuiltinName */
+static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
+    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
+    if (unlikely(!result)) {
+        PyErr_Format(PyExc_NameError,
+#if PY_MAJOR_VERSION >= 3
+            "name '%U' is not defined", name);
+#else
+            "name '%.200s' is not defined", PyString_AS_STRING(name));
+#endif
+    }
+    return result;
+}
+
+/* dict_getitem_default */
+static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) {
+    PyObject* value;
+#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
+    value = PyDict_GetItemWithError(d, key);
+    if (unlikely(!value)) {
+        if (unlikely(PyErr_Occurred()))
+            return NULL;
+        value = default_value;
+    }
+    Py_INCREF(value);
+#else
+    if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) {
+        value = PyDict_GetItem(d, key);
+        if (unlikely(!value)) {
+            value = default_value;
+        }
+        Py_INCREF(value);
+    } else {
+        if (default_value == Py_None)
+            default_value = NULL;
+        value = PyObject_CallMethodObjArgs(
+            d, __pyx_n_s_get, key, default_value, NULL);
+    }
+#endif
+    return value;
+}
+
+/* PyCFunctionFastCall */
+#if CYTHON_FAST_PYCCALL
+static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
+    PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
+    PyCFunction meth = PyCFunction_GET_FUNCTION(func);
+    PyObject *self = PyCFunction_GET_SELF(func);
+    assert(PyCFunction_Check(func));
+    assert(METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)));
+    assert(nargs >= 0);
+    assert(nargs == 0 || args != NULL);
+    /* _PyCFunction_FastCallDict() must not be called with an exception set,
+       because it may clear it (directly or indirectly) and so the
+       caller loses its exception */
+    assert(!PyErr_Occurred());
+    return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs, NULL);
+}
+#endif  // CYTHON_FAST_PYCCALL
+
+/* PyFunctionFastCall */
+#if CYTHON_FAST_PYCALL
+#include "frameobject.h"
+static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
+                                               PyObject *globals) {
+    PyFrameObject *f;
+    PyThreadState *tstate = PyThreadState_GET();
+    PyObject **fastlocals;
+    Py_ssize_t i;
+    PyObject *result;
+    assert(globals != NULL);
+    /* XXX Perhaps we should create a specialized
+       PyFrame_New() that doesn't take locals, but does
+       take builtins without sanity checking them.
+       */
+    assert(tstate != NULL);
+    f = PyFrame_New(tstate, co, globals, NULL);
+    if (f == NULL) {
+        return NULL;
+    }
+    fastlocals = f->f_localsplus;
+    for (i = 0; i < na; i++) {
+        Py_INCREF(*args);
+        fastlocals[i] = *args++;
+    }
+    result = PyEval_EvalFrameEx(f,0);
+    ++tstate->recursion_depth;
+    Py_DECREF(f);
+    --tstate->recursion_depth;
+    return result;
+}
+#if 1 || PY_VERSION_HEX < 0x030600B1
+static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
+    PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
+    PyObject *globals = PyFunction_GET_GLOBALS(func);
+    PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
+    PyObject *closure;
+#if PY_MAJOR_VERSION >= 3
+    PyObject *kwdefs;
+#endif
+    PyObject *kwtuple, **k;
+    PyObject **d;
+    Py_ssize_t nd;
+    Py_ssize_t nk;
+    PyObject *result;
+    assert(kwargs == NULL || PyDict_Check(kwargs));
+    nk = kwargs ? PyDict_Size(kwargs) : 0;
+    if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
+        return NULL;
+    }
+    if (
+#if PY_MAJOR_VERSION >= 3
+            co->co_kwonlyargcount == 0 &&
+#endif
+            likely(kwargs == NULL || nk == 0) &&
+            co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
+        if (argdefs == NULL && co->co_argcount == nargs) {
+            result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
+            goto done;
+        }
+        else if (nargs == 0 && argdefs != NULL
+                 && co->co_argcount == Py_SIZE(argdefs)) {
+            /* function called with no arguments, but all parameters have
+               a default value: use default values as arguments .*/
+            args = &PyTuple_GET_ITEM(argdefs, 0);
+            result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
+            goto done;
+        }
+    }
+    if (kwargs != NULL) {
+        Py_ssize_t pos, i;
+        kwtuple = PyTuple_New(2 * nk);
+        if (kwtuple == NULL) {
+            result = NULL;
+            goto done;
+        }
+        k = &PyTuple_GET_ITEM(kwtuple, 0);
+        pos = i = 0;
+        while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
+            Py_INCREF(k[i]);
+            Py_INCREF(k[i+1]);
+            i += 2;
+        }
+        nk = i / 2;
+    }
+    else {
+        kwtuple = NULL;
+        k = NULL;
+    }
+    closure = PyFunction_GET_CLOSURE(func);
+#if PY_MAJOR_VERSION >= 3
+    kwdefs = PyFunction_GET_KW_DEFAULTS(func);
+#endif
+    if (argdefs != NULL) {
+        d = &PyTuple_GET_ITEM(argdefs, 0);
+        nd = Py_SIZE(argdefs);
+    }
+    else {
+        d = NULL;
+        nd = 0;
+    }
+#if PY_MAJOR_VERSION >= 3
+    result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
+                               args, nargs,
+                               k, (int)nk,
+                               d, (int)nd, kwdefs, closure);
+#else
+    result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
+                               args, nargs,
+                               k, (int)nk,
+                               d, (int)nd, closure);
+#endif
+    Py_XDECREF(kwtuple);
+done:
+    Py_LeaveRecursiveCall();
+    return result;
+}
+#endif  // CPython < 3.6
+#endif  // CYTHON_FAST_PYCALL
+
+/* PyObjectCall */
+#if CYTHON_COMPILING_IN_CPYTHON
+static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
+    PyObject *result;
+    ternaryfunc call = func->ob_type->tp_call;
+    if (unlikely(!call))
+        return PyObject_Call(func, arg, kw);
+    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
+        return NULL;
+    result = (*call)(func, arg, kw);
+    Py_LeaveRecursiveCall();
+    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
+        PyErr_SetString(
+            PyExc_SystemError,
+            "NULL result without error in PyObject_Call");
+    }
+    return result;
+}
+#endif
+
+/* PyObjectCallMethO */
+#if CYTHON_COMPILING_IN_CPYTHON
+static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
+    PyObject *self, *result;
+    PyCFunction cfunc;
+    cfunc = PyCFunction_GET_FUNCTION(func);
+    self = PyCFunction_GET_SELF(func);
+    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
+        return NULL;
+    result = cfunc(self, arg);
+    Py_LeaveRecursiveCall();
+    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
+        PyErr_SetString(
+            PyExc_SystemError,
+            "NULL result without error in PyObject_Call");
+    }
+    return result;
+}
+#endif
+
+/* PyObjectCallOneArg */
+#if CYTHON_COMPILING_IN_CPYTHON
+static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
+    PyObject *result;
+    PyObject *args = PyTuple_New(1);
+    if (unlikely(!args)) return NULL;
+    Py_INCREF(arg);
+    PyTuple_SET_ITEM(args, 0, arg);
+    result = __Pyx_PyObject_Call(func, args, NULL);
+    Py_DECREF(args);
+    return result;
+}
+static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
+#if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(func)) {
+        return __Pyx_PyFunction_FastCall(func, &arg, 1);
+    }
+#endif
+#ifdef __Pyx_CyFunction_USED
+    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
+#else
+    if (likely(PyCFunction_Check(func))) {
+#endif
+        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
+            return __Pyx_PyObject_CallMethO(func, arg);
+#if CYTHON_FAST_PYCCALL
+        } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
+            return __Pyx_PyCFunction_FastCall(func, &arg, 1);
+#endif
+        }
+    }
+    return __Pyx__PyObject_CallOneArg(func, arg);
+}
+#else
+static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
+    PyObject *result;
+    PyObject *args = PyTuple_Pack(1, arg);
+    if (unlikely(!args)) return NULL;
+    result = __Pyx_PyObject_Call(func, args, NULL);
+    Py_DECREF(args);
+    return result;
+}
+#endif
+
+/* PyObjectCallNoArg */
+  #if CYTHON_COMPILING_IN_CPYTHON
+static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
+#if CYTHON_FAST_PYCALL
+    if (PyFunction_Check(func)) {
+        return __Pyx_PyFunction_FastCall(func, NULL, 0);
+    }
+#endif
+#ifdef __Pyx_CyFunction_USED
+    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
+#else
+    if (likely(PyCFunction_Check(func))) {
+#endif
+        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
+            return __Pyx_PyObject_CallMethO(func, NULL);
+        }
+    }
+    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
+}
+#endif
+
+/* RaiseDoubleKeywords */
+    static void __Pyx_RaiseDoubleKeywordsError(
+    const char* func_name,
+    PyObject* kw_name)
+{
+    PyErr_Format(PyExc_TypeError,
+        #if PY_MAJOR_VERSION >= 3
+        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
+        #else
+        "%s() got multiple values for keyword argument '%s'", func_name,
+        PyString_AsString(kw_name));
+        #endif
+}
+
+/* ParseKeywords */
+    static int __Pyx_ParseOptionalKeywords(
+    PyObject *kwds,
+    PyObject **argnames[],
+    PyObject *kwds2,
+    PyObject *values[],
+    Py_ssize_t num_pos_args,
+    const char* function_name)
+{
+    PyObject *key = 0, *value = 0;
+    Py_ssize_t pos = 0;
+    PyObject*** name;
+    PyObject*** first_kw_arg = argnames + num_pos_args;
+    while (PyDict_Next(kwds, &pos, &key, &value)) {
+        name = first_kw_arg;
+        while (*name && (**name != key)) name++;
+        if (*name) {
+            values[name-argnames] = value;
+            continue;
+        }
+        name = first_kw_arg;
+        #if PY_MAJOR_VERSION < 3
+        if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
+            while (*name) {
+                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
+                        && _PyString_Eq(**name, key)) {
+                    values[name-argnames] = value;
+                    break;
+                }
+                name++;
+            }
+            if (*name) continue;
+            else {
+                PyObject*** argname = argnames;
+                while (argname != first_kw_arg) {
+                    if ((**argname == key) || (
+                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
+                             && _PyString_Eq(**argname, key))) {
+                        goto arg_passed_twice;
+                    }
+                    argname++;
+                }
+            }
+        } else
+        #endif
+        if (likely(PyUnicode_Check(key))) {
+            while (*name) {
+                int cmp = (**name == key) ? 0 :
+                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
+                    (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
+                #endif
+                    PyUnicode_Compare(**name, key);
+                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
+                if (cmp == 0) {
+                    values[name-argnames] = value;
+                    break;
+                }
+                name++;
+            }
+            if (*name) continue;
+            else {
+                PyObject*** argname = argnames;
+                while (argname != first_kw_arg) {
+                    int cmp = (**argname == key) ? 0 :
+                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
+                        (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
+                    #endif
+                        PyUnicode_Compare(**argname, key);
+                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
+                    if (cmp == 0) goto arg_passed_twice;
+                    argname++;
+                }
+            }
+        } else
+            goto invalid_keyword_type;
+        if (kwds2) {
+            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
+        } else {
+            goto invalid_keyword;
+        }
+    }
+    return 0;
+arg_passed_twice:
+    __Pyx_RaiseDoubleKeywordsError(function_name, key);
+    goto bad;
+invalid_keyword_type:
+    PyErr_Format(PyExc_TypeError,
+        "%.200s() keywords must be strings", function_name);
+    goto bad;
+invalid_keyword:
+    PyErr_Format(PyExc_TypeError,
+    #if PY_MAJOR_VERSION < 3
+        "%.200s() got an unexpected keyword argument '%.200s'",
+        function_name, PyString_AsString(key));
+    #else
+        "%s() got an unexpected keyword argument '%U'",
+        function_name, key);
+    #endif
+bad:
+    return -1;
+}
+
+/* RaiseArgTupleInvalid */
+    static void __Pyx_RaiseArgtupleInvalid(
+    const char* func_name,
+    int exact,
+    Py_ssize_t num_min,
+    Py_ssize_t num_max,
+    Py_ssize_t num_found)
+{
+    Py_ssize_t num_expected;
+    const char *more_or_less;
+    if (num_found < num_min) {
+        num_expected = num_min;
+        more_or_less = "at least";
+    } else {
+        num_expected = num_max;
+        more_or_less = "at most";
+    }
+    if (exact) {
+        more_or_less = "exactly";
+    }
+    PyErr_Format(PyExc_TypeError,
+                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
+                 func_name, more_or_less, num_expected,
+                 (num_expected == 1) ? "" : "s", num_found);
+}
+
+/* GetModuleGlobalName */
+    static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
+    PyObject *result;
+#if !CYTHON_AVOID_BORROWED_REFS
+    result = PyDict_GetItem(__pyx_d, name);
+    if (likely(result)) {
+        Py_INCREF(result);
+    } else {
+#else
+    result = PyObject_GetItem(__pyx_d, name);
+    if (!result) {
+        PyErr_Clear();
+#endif
+        result = __Pyx_GetBuiltinName(name);
+    }
+    return result;
+}
+
+/* BytesEquals */
+      static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
+#if CYTHON_COMPILING_IN_PYPY
+    return PyObject_RichCompareBool(s1, s2, equals);
+#else
+    if (s1 == s2) {
+        return (equals == Py_EQ);
+    } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
+        const char *ps1, *ps2;
+        Py_ssize_t length = PyBytes_GET_SIZE(s1);
+        if (length != PyBytes_GET_SIZE(s2))
+            return (equals == Py_NE);
+        ps1 = PyBytes_AS_STRING(s1);
+        ps2 = PyBytes_AS_STRING(s2);
+        if (ps1[0] != ps2[0]) {
+            return (equals == Py_NE);
+        } else if (length == 1) {
+            return (equals == Py_EQ);
+        } else {
+            int result = memcmp(ps1, ps2, (size_t)length);
+            return (equals == Py_EQ) ? (result == 0) : (result != 0);
+        }
+    } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
+        return (equals == Py_NE);
+    } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
+        return (equals == Py_NE);
+    } else {
+        int result;
+        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
+        if (!py_result)
+            return -1;
+        result = __Pyx_PyObject_IsTrue(py_result);
+        Py_DECREF(py_result);
+        return result;
+    }
+#endif
+}
+
+/* UnicodeEquals */
+      static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
+#if CYTHON_COMPILING_IN_PYPY
+    return PyObject_RichCompareBool(s1, s2, equals);
+#else
+#if PY_MAJOR_VERSION < 3
+    PyObject* owned_ref = NULL;
+#endif
+    int s1_is_unicode, s2_is_unicode;
+    if (s1 == s2) {
+        goto return_eq;
+    }
+    s1_is_unicode = PyUnicode_CheckExact(s1);
+    s2_is_unicode = PyUnicode_CheckExact(s2);
+#if PY_MAJOR_VERSION < 3
+    if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
+        owned_ref = PyUnicode_FromObject(s2);
+        if (unlikely(!owned_ref))
+            return -1;
+        s2 = owned_ref;
+        s2_is_unicode = 1;
+    } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
+        owned_ref = PyUnicode_FromObject(s1);
+        if (unlikely(!owned_ref))
+            return -1;
+        s1 = owned_ref;
+        s1_is_unicode = 1;
+    } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
+        return __Pyx_PyBytes_Equals(s1, s2, equals);
+    }
+#endif
+    if (s1_is_unicode & s2_is_unicode) {
+        Py_ssize_t length;
+        int kind;
+        void *data1, *data2;
+        if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
+            return -1;
+        length = __Pyx_PyUnicode_GET_LENGTH(s1);
+        if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
+            goto return_ne;
+        }
+        kind = __Pyx_PyUnicode_KIND(s1);
+        if (kind != __Pyx_PyUnicode_KIND(s2)) {
+            goto return_ne;
+        }
+        data1 = __Pyx_PyUnicode_DATA(s1);
+        data2 = __Pyx_PyUnicode_DATA(s2);
+        if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
+            goto return_ne;
+        } else if (length == 1) {
+            goto return_eq;
+        } else {
+            int result = memcmp(data1, data2, (size_t)(length * kind));
+            #if PY_MAJOR_VERSION < 3
+            Py_XDECREF(owned_ref);
+            #endif
+            return (equals == Py_EQ) ? (result == 0) : (result != 0);
+        }
+    } else if ((s1 == Py_None) & s2_is_unicode) {
+        goto return_ne;
+    } else if ((s2 == Py_None) & s1_is_unicode) {
+        goto return_ne;
+    } else {
+        int result;
+        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
+        if (!py_result)
+            return -1;
+        result = __Pyx_PyObject_IsTrue(py_result);
+        Py_DECREF(py_result);
+        return result;
+    }
+return_eq:
+    #if PY_MAJOR_VERSION < 3
+    Py_XDECREF(owned_ref);
+    #endif
+    return (equals == Py_EQ);
+return_ne:
+    #if PY_MAJOR_VERSION < 3
+    Py_XDECREF(owned_ref);
+    #endif
+    return (equals == Py_NE);
+#endif
+}
+
+/* SaveResetException */
+      #if CYTHON_FAST_THREAD_STATE
+static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
+    *type = tstate->exc_type;
+    *value = tstate->exc_value;
+    *tb = tstate->exc_traceback;
+    Py_XINCREF(*type);
+    Py_XINCREF(*value);
+    Py_XINCREF(*tb);
+}
+static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
+    PyObject *tmp_type, *tmp_value, *tmp_tb;
+    tmp_type = tstate->exc_type;
+    tmp_value = tstate->exc_value;
+    tmp_tb = tstate->exc_traceback;
+    tstate->exc_type = type;
+    tstate->exc_value = value;
+    tstate->exc_traceback = tb;
+    Py_XDECREF(tmp_type);
+    Py_XDECREF(tmp_value);
+    Py_XDECREF(tmp_tb);
+}
+#endif
+
+/* PyErrExceptionMatches */
+      #if CYTHON_FAST_THREAD_STATE
+static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
+    PyObject *exc_type = tstate->curexc_type;
+    if (exc_type == err) return 1;
+    if (unlikely(!exc_type)) return 0;
+    return PyErr_GivenExceptionMatches(exc_type, err);
+}
+#endif
+
+/* GetException */
+      #if CYTHON_FAST_THREAD_STATE
+static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
+#else
+static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
+#endif
+    PyObject *local_type, *local_value, *local_tb;
+#if CYTHON_FAST_THREAD_STATE
+    PyObject *tmp_type, *tmp_value, *tmp_tb;
+    local_type = tstate->curexc_type;
+    local_value = tstate->curexc_value;
+    local_tb = tstate->curexc_traceback;
+    tstate->curexc_type = 0;
+    tstate->curexc_value = 0;
+    tstate->curexc_traceback = 0;
+#else
+    PyErr_Fetch(&local_type, &local_value, &local_tb);
+#endif
+    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
+#if CYTHON_FAST_THREAD_STATE
+    if (unlikely(tstate->curexc_type))
+#else
+    if (unlikely(PyErr_Occurred()))
+#endif
+        goto bad;
+    #if PY_MAJOR_VERSION >= 3
+    if (local_tb) {
+        if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
+            goto bad;
+    }
+    #endif
+    Py_XINCREF(local_tb);
+    Py_XINCREF(local_type);
+    Py_XINCREF(local_value);
+    *type = local_type;
+    *value = local_value;
+    *tb = local_tb;
+#if CYTHON_FAST_THREAD_STATE
+    tmp_type = tstate->exc_type;
+    tmp_value = tstate->exc_value;
+    tmp_tb = tstate->exc_traceback;
+    tstate->exc_type = local_type;
+    tstate->exc_value = local_value;
+    tstate->exc_traceback = local_tb;
+    Py_XDECREF(tmp_type);
+    Py_XDECREF(tmp_value);
+    Py_XDECREF(tmp_tb);
+#else
+    PyErr_SetExcInfo(local_type, local_value, local_tb);
+#endif
+    return 0;
+bad:
+    *type = 0;
+    *value = 0;
+    *tb = 0;
+    Py_XDECREF(local_type);
+    Py_XDECREF(local_value);
+    Py_XDECREF(local_tb);
+    return -1;
+}
+
+/* PyErrFetchRestore */
+        #if CYTHON_FAST_THREAD_STATE
+static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
+    PyObject *tmp_type, *tmp_value, *tmp_tb;
+    tmp_type = tstate->curexc_type;
+    tmp_value = tstate->curexc_value;
+    tmp_tb = tstate->curexc_traceback;
+    tstate->curexc_type = type;
+    tstate->curexc_value = value;
+    tstate->curexc_traceback = tb;
+    Py_XDECREF(tmp_type);
+    Py_XDECREF(tmp_value);
+    Py_XDECREF(tmp_tb);
+}
+static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
+    *type = tstate->curexc_type;
+    *value = tstate->curexc_value;
+    *tb = tstate->curexc_traceback;
+    tstate->curexc_type = 0;
+    tstate->curexc_value = 0;
+    tstate->curexc_traceback = 0;
+}
+#endif
+
+/* RaiseException */
+        #if PY_MAJOR_VERSION < 3
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
+                        CYTHON_UNUSED PyObject *cause) {
+    __Pyx_PyThreadState_declare
+    Py_XINCREF(type);
+    if (!value || value == Py_None)
+        value = NULL;
+    else
+        Py_INCREF(value);
+    if (!tb || tb == Py_None)
+        tb = NULL;
+    else {
+        Py_INCREF(tb);
+        if (!PyTraceBack_Check(tb)) {
+            PyErr_SetString(PyExc_TypeError,
+                "raise: arg 3 must be a traceback or None");
+            goto raise_error;
+        }
+    }
+    if (PyType_Check(type)) {
+#if CYTHON_COMPILING_IN_PYPY
+        if (!value) {
+            Py_INCREF(Py_None);
+            value = Py_None;
+        }
+#endif
+        PyErr_NormalizeException(&type, &value, &tb);
+    } else {
+        if (value) {
+            PyErr_SetString(PyExc_TypeError,
+                "instance exception may not have a separate value");
+            goto raise_error;
+        }
+        value = type;
+        type = (PyObject*) Py_TYPE(type);
+        Py_INCREF(type);
+        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
+            PyErr_SetString(PyExc_TypeError,
+                "raise: exception class must be a subclass of BaseException");
+            goto raise_error;
+        }
+    }
+    __Pyx_PyThreadState_assign
+    __Pyx_ErrRestore(type, value, tb);
+    return;
+raise_error:
+    Py_XDECREF(value);
+    Py_XDECREF(type);
+    Py_XDECREF(tb);
+    return;
+}
+#else
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
+    PyObject* owned_instance = NULL;
+    if (tb == Py_None) {
+        tb = 0;
+    } else if (tb && !PyTraceBack_Check(tb)) {
+        PyErr_SetString(PyExc_TypeError,
+            "raise: arg 3 must be a traceback or None");
+        goto bad;
+    }
+    if (value == Py_None)
+        value = 0;
+    if (PyExceptionInstance_Check(type)) {
+        if (value) {
+            PyErr_SetString(PyExc_TypeError,
+                "instance exception may not have a separate value");
+            goto bad;
+        }
+        value = type;
+        type = (PyObject*) Py_TYPE(value);
+    } else if (PyExceptionClass_Check(type)) {
+        PyObject *instance_class = NULL;
+        if (value && PyExceptionInstance_Check(value)) {
+            instance_class = (PyObject*) Py_TYPE(value);
+            if (instance_class != type) {
+                int is_subclass = PyObject_IsSubclass(instance_class, type);
+                if (!is_subclass) {
+                    instance_class = NULL;
+                } else if (unlikely(is_subclass == -1)) {
+                    goto bad;
+                } else {
+                    type = instance_class;
+                }
+            }
+        }
+        if (!instance_class) {
+            PyObject *args;
+            if (!value)
+                args = PyTuple_New(0);
+            else if (PyTuple_Check(value)) {
+                Py_INCREF(value);
+                args = value;
+            } else
+                args = PyTuple_Pack(1, value);
+            if (!args)
+                goto bad;
+            owned_instance = PyObject_Call(type, args, NULL);
+            Py_DECREF(args);
+            if (!owned_instance)
+                goto bad;
+            value = owned_instance;
+            if (!PyExceptionInstance_Check(value)) {
+                PyErr_Format(PyExc_TypeError,
+                             "calling %R should have returned an instance of "
+                             "BaseException, not %R",
+                             type, Py_TYPE(value));
+                goto bad;
+            }
+        }
+    } else {
+        PyErr_SetString(PyExc_TypeError,
+            "raise: exception class must be a subclass of BaseException");
+        goto bad;
+    }
+#if PY_VERSION_HEX >= 0x03030000
+    if (cause) {
+#else
+    if (cause && cause != Py_None) {
+#endif
+        PyObject *fixed_cause;
+        if (cause == Py_None) {
+            fixed_cause = NULL;
+        } else if (PyExceptionClass_Check(cause)) {
+            fixed_cause = PyObject_CallObject(cause, NULL);
+            if (fixed_cause == NULL)
+                goto bad;
+        } else if (PyExceptionInstance_Check(cause)) {
+            fixed_cause = cause;
+            Py_INCREF(fixed_cause);
+        } else {
+            PyErr_SetString(PyExc_TypeError,
+                            "exception causes must derive from "
+                            "BaseException");
+            goto bad;
+        }
+        PyException_SetCause(value, fixed_cause);
+    }
+    PyErr_SetObject(type, value);
+    if (tb) {
+#if CYTHON_COMPILING_IN_PYPY
+        PyObject *tmp_type, *tmp_value, *tmp_tb;
+        PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
+        Py_INCREF(tb);
+        PyErr_Restore(tmp_type, tmp_value, tb);
+        Py_XDECREF(tmp_tb);
+#else
+        PyThreadState *tstate = PyThreadState_GET();
+        PyObject* tmp_tb = tstate->curexc_traceback;
+        if (tb != tmp_tb) {
+            Py_INCREF(tb);
+            tstate->curexc_traceback = tb;
+            Py_XDECREF(tmp_tb);
+        }
+#endif
+    }
+bad:
+    Py_XDECREF(owned_instance);
+    return;
+}
+#endif
+
+/* ExtTypeTest */
+          static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
+    if (unlikely(!type)) {
+        PyErr_SetString(PyExc_SystemError, "Missing type object");
+        return 0;
+    }
+    if (likely(PyObject_TypeCheck(obj, type)))
+        return 1;
+    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
+                 Py_TYPE(obj)->tp_name, type->tp_name);
+    return 0;
+}
+
+/* KeywordStringCheck */
+          static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
+    PyObject *kwdict,
+    const char* function_name,
+    int kw_allowed)
+{
+    PyObject* key = 0;
+    Py_ssize_t pos = 0;
+#if CYTHON_COMPILING_IN_PYPY
+    if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
+        goto invalid_keyword;
+    return 1;
+#else
+    while (PyDict_Next(kwdict, &pos, &key, 0)) {
+        #if PY_MAJOR_VERSION < 3
+        if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key)))
+        #endif
+            if (unlikely(!PyUnicode_Check(key)))
+                goto invalid_keyword_type;
+    }
+    if ((!kw_allowed) && unlikely(key))
+        goto invalid_keyword;
+    return 1;
+invalid_keyword_type:
+    PyErr_Format(PyExc_TypeError,
+        "%.200s() keywords must be strings", function_name);
+    return 0;
+#endif
+invalid_keyword:
+    PyErr_Format(PyExc_TypeError,
+    #if PY_MAJOR_VERSION < 3
+        "%.200s() got an unexpected keyword argument '%.200s'",
+        function_name, PyString_AsString(key));
+    #else
+        "%s() got an unexpected keyword argument '%U'",
+        function_name, key);
+    #endif
+    return 0;
+}
+
+/* WriteUnraisableException */
+          static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
+                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
+                                  int full_traceback, CYTHON_UNUSED int nogil) {
+    PyObject *old_exc, *old_val, *old_tb;
+    PyObject *ctx;
+    __Pyx_PyThreadState_declare
+#ifdef WITH_THREAD
+    PyGILState_STATE state;
+    if (nogil)
+        state = PyGILState_Ensure();
+#ifdef _MSC_VER
+    else state = (PyGILState_STATE)-1;
+#endif
+#endif
+    __Pyx_PyThreadState_assign
+    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
+    if (full_traceback) {
+        Py_XINCREF(old_exc);
+        Py_XINCREF(old_val);
+        Py_XINCREF(old_tb);
+        __Pyx_ErrRestore(old_exc, old_val, old_tb);
+        PyErr_PrintEx(1);
+    }
+    #if PY_MAJOR_VERSION < 3
+    ctx = PyString_FromString(name);
+    #else
+    ctx = PyUnicode_FromString(name);
+    #endif
+    __Pyx_ErrRestore(old_exc, old_val, old_tb);
+    if (!ctx) {
+        PyErr_WriteUnraisable(Py_None);
+    } else {
+        PyErr_WriteUnraisable(ctx);
+        Py_DECREF(ctx);
+    }
+#ifdef WITH_THREAD
+    if (nogil)
+        PyGILState_Release(state);
+#endif
+}
+
+/* GetItemInt */
+          static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
+    PyObject *r;
+    if (!j) return NULL;
+    r = PyObject_GetItem(o, j);
+    Py_DECREF(j);
+    return r;
+}
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
+                                                              CYTHON_NCP_UNUSED int wraparound,
+                                                              CYTHON_NCP_UNUSED int boundscheck) {
+#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+    if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o);
+    if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
+        PyObject *r = PyList_GET_ITEM(o, i);
+        Py_INCREF(r);
+        return r;
+    }
+    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
+#else
+    return PySequence_GetItem(o, i);
+#endif
+}
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
+                                                              CYTHON_NCP_UNUSED int wraparound,
+                                                              CYTHON_NCP_UNUSED int boundscheck) {
+#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+    if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o);
+    if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
+        PyObject *r = PyTuple_GET_ITEM(o, i);
+        Py_INCREF(r);
+        return r;
+    }
+    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
+#else
+    return PySequence_GetItem(o, i);
+#endif
+}
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
+                                                     CYTHON_NCP_UNUSED int wraparound,
+                                                     CYTHON_NCP_UNUSED int boundscheck) {
+#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
+    if (is_list || PyList_CheckExact(o)) {
+        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
+        if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
+            PyObject *r = PyList_GET_ITEM(o, n);
+            Py_INCREF(r);
+            return r;
+        }
+    }
+    else if (PyTuple_CheckExact(o)) {
+        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
+        if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
+            PyObject *r = PyTuple_GET_ITEM(o, n);
+            Py_INCREF(r);
+            return r;
+        }
+    } else {
+        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
+        if (likely(m && m->sq_item)) {
+            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
+                Py_ssize_t l = m->sq_length(o);
+                if (likely(l >= 0)) {
+                    i += l;
+                } else {
+                    if (!PyErr_ExceptionMatches(PyExc_OverflowError))
+                        return NULL;
+                    PyErr_Clear();
+                }
+            }
+            return m->sq_item(o, i);
+        }
+    }
+#else
+    if (is_list || PySequence_Check(o)) {
+        return PySequence_GetItem(o, i);
+    }
+#endif
+    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
+}
+
+/* None */
+          static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
+    PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
+}
+
+/* SliceObject */
+          static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
+        Py_ssize_t cstart, Py_ssize_t cstop,
+        PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
+        int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
+#if CYTHON_USE_TYPE_SLOTS
+    PyMappingMethods* mp;
+#if PY_MAJOR_VERSION < 3
+    PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
+    if (likely(ms && ms->sq_slice)) {
+        if (!has_cstart) {
+            if (_py_start && (*_py_start != Py_None)) {
+                cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
+                if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
+            } else
+                cstart = 0;
+        }
+        if (!has_cstop) {
+            if (_py_stop && (*_py_stop != Py_None)) {
+                cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
+                if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
+            } else
+                cstop = PY_SSIZE_T_MAX;
+        }
+        if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
+            Py_ssize_t l = ms->sq_length(obj);
+            if (likely(l >= 0)) {
+                if (cstop < 0) {
+                    cstop += l;
+                    if (cstop < 0) cstop = 0;
+                }
+                if (cstart < 0) {
+                    cstart += l;
+                    if (cstart < 0) cstart = 0;
+                }
+            } else {
+                if (!PyErr_ExceptionMatches(PyExc_OverflowError))
+                    goto bad;
+                PyErr_Clear();
+            }
+        }
+        return ms->sq_slice(obj, cstart, cstop);
+    }
+#endif
+    mp = Py_TYPE(obj)->tp_as_mapping;
+    if (likely(mp && mp->mp_subscript))
+#endif
+    {
+        PyObject* result;
+        PyObject *py_slice, *py_start, *py_stop;
+        if (_py_slice) {
+            py_slice = *_py_slice;
+        } else {
+            PyObject* owned_start = NULL;
+            PyObject* owned_stop = NULL;
+            if (_py_start) {
+                py_start = *_py_start;
+            } else {
+                if (has_cstart) {
+                    owned_start = py_start = PyInt_FromSsize_t(cstart);
+                    if (unlikely(!py_start)) goto bad;
+                } else
+                    py_start = Py_None;
+            }
+            if (_py_stop) {
+                py_stop = *_py_stop;
+            } else {
+                if (has_cstop) {
+                    owned_stop = py_stop = PyInt_FromSsize_t(cstop);
+                    if (unlikely(!py_stop)) {
+                        Py_XDECREF(owned_start);
+                        goto bad;
+                    }
+                } else
+                    py_stop = Py_None;
+            }
+            py_slice = PySlice_New(py_start, py_stop, Py_None);
+            Py_XDECREF(owned_start);
+            Py_XDECREF(owned_stop);
+            if (unlikely(!py_slice)) goto bad;
+        }
+#if CYTHON_USE_TYPE_SLOTS
+        result = mp->mp_subscript(obj, py_slice);
+#else
+        result = PyObject_GetItem(obj, py_slice);
+#endif
+        if (!_py_slice) {
+            Py_DECREF(py_slice);
+        }
+        return result;
+    }
+    PyErr_Format(PyExc_TypeError,
+        "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
+bad:
+    return NULL;
+}
+
+/* PyIntBinop */
+          #if !CYTHON_COMPILING_IN_PYPY
+static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
+    #if PY_MAJOR_VERSION < 3
+    if (likely(PyInt_CheckExact(op1))) {
+        const long b = intval;
+        long x;
+        long a = PyInt_AS_LONG(op1);
+            x = (long)((unsigned long)a + b);
+            if (likely((x^a) >= 0 || (x^b) >= 0))
+                return PyInt_FromLong(x);
+            return PyLong_Type.tp_as_number->nb_add(op1, op2);
+    }
+    #endif
+    #if CYTHON_USE_PYLONG_INTERNALS
+    if (likely(PyLong_CheckExact(op1))) {
+        const long b = intval;
+        long a, x;
+#ifdef HAVE_LONG_LONG
+        const PY_LONG_LONG llb = intval;
+        PY_LONG_LONG lla, llx;
+#endif
+        const digit* digits = ((PyLongObject*)op1)->ob_digit;
+        const Py_ssize_t size = Py_SIZE(op1);
+        if (likely(__Pyx_sst_abs(size) <= 1)) {
+            a = likely(size) ? digits[0] : 0;
+            if (size == -1) a = -a;
+        } else {
+            switch (size) {
+                case -2:
+                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
+                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
+                        break;
+#ifdef HAVE_LONG_LONG
+                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
+                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
+                        goto long_long;
+#endif
+                    }
+                case 2:
+                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
+                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
+                        break;
+#ifdef HAVE_LONG_LONG
+                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
+                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
+                        goto long_long;
+#endif
+                    }
+                case -3:
+                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
+                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
+                        break;
+#ifdef HAVE_LONG_LONG
+                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
+                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
+                        goto long_long;
+#endif
+                    }
+                case 3:
+                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
+                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
+                        break;
+#ifdef HAVE_LONG_LONG
+                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
+                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
+                        goto long_long;
+#endif
+                    }
+                case -4:
+                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
+                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
+                        break;
+#ifdef HAVE_LONG_LONG
+                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
+                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
+                        goto long_long;
+#endif
+                    }
+                case 4:
+                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
+                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
+                        break;
+#ifdef HAVE_LONG_LONG
+                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
+                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
+                        goto long_long;
+#endif
+                    }
+                default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
+            }
+        }
+                x = a + b;
+            return PyLong_FromLong(x);
+#ifdef HAVE_LONG_LONG
+        long_long:
+                llx = lla + llb;
+            return PyLong_FromLongLong(llx);
+#endif
+        
+        
+    }
+    #endif
+    if (PyFloat_CheckExact(op1)) {
+        const long b = intval;
+        double a = PyFloat_AS_DOUBLE(op1);
+            double result;
+            PyFPE_START_PROTECT("add", return NULL)
+            result = ((double)a) + (double)b;
+            PyFPE_END_PROTECT(result)
+            return PyFloat_FromDouble(result);
+    }
+    return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
+}
+#endif
+
+/* SwapException */
+          #if CYTHON_FAST_THREAD_STATE
+static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
+    PyObject *tmp_type, *tmp_value, *tmp_tb;
+    tmp_type = tstate->exc_type;
+    tmp_value = tstate->exc_value;
+    tmp_tb = tstate->exc_traceback;
+    tstate->exc_type = *type;
+    tstate->exc_value = *value;
+    tstate->exc_traceback = *tb;
+    *type = tmp_type;
+    *value = tmp_value;
+    *tb = tmp_tb;
+}
+#else
+static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
+    PyObject *tmp_type, *tmp_value, *tmp_tb;
+    PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
+    PyErr_SetExcInfo(*type, *value, *tb);
+    *type = tmp_type;
+    *value = tmp_value;
+    *tb = tmp_tb;
+}
+#endif
+
+/* None */
+          static CYTHON_INLINE int64_t __Pyx_mod_int64_t(int64_t a, int64_t b) {
+    int64_t r = a % b;
+    r += ((r != 0) & ((r ^ b) < 0)) * b;
+    return r;
+}
+
+/* PyIntBinop */
+          #if !CYTHON_COMPILING_IN_PYPY
+static PyObject* __Pyx_PyInt_AddCObj(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
+    #if PY_MAJOR_VERSION < 3
+    if (likely(PyInt_CheckExact(op2))) {
+        const long a = intval;
+        long x;
+        long b = PyInt_AS_LONG(op2);
+            x = (long)((unsigned long)a + b);
+            if (likely((x^a) >= 0 || (x^b) >= 0))
+                return PyInt_FromLong(x);
+            return PyLong_Type.tp_as_number->nb_add(op1, op2);
+    }
+    #endif
+    #if CYTHON_USE_PYLONG_INTERNALS
+    if (likely(PyLong_CheckExact(op2))) {
+        const long a = intval;
+        long b, x;
+#ifdef HAVE_LONG_LONG
+        const PY_LONG_LONG lla = intval;
+        PY_LONG_LONG llb, llx;
+#endif
+        const digit* digits = ((PyLongObject*)op2)->ob_digit;
+        const Py_ssize_t size = Py_SIZE(op2);
+        if (likely(__Pyx_sst_abs(size) <= 1)) {
+            b = likely(size) ? digits[0] : 0;
+            if (size == -1) b = -b;
+        } else {
+            switch (size) {
+                case -2:
+                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
+                        b = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
+                        break;
+#ifdef HAVE_LONG_LONG
+                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
+                        llb = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
+                        goto long_long;
+#endif
+                    }
+                case 2:
+                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
+                        b = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
+                        break;
+#ifdef HAVE_LONG_LONG
+                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
+                        llb = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
+                        goto long_long;
+#endif
+                    }
+                case -3:
+                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
+                        b = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
+                        break;
+#ifdef HAVE_LONG_LONG
+                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
+                        llb = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
+                        goto long_long;
+#endif
+                    }
+                case 3:
+                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
+                        b = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
+                        break;
+#ifdef HAVE_LONG_LONG
+                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
+                        llb = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
+                        goto long_long;
+#endif
+                    }
+                case -4:
+                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
+                        b = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
+                        break;
+#ifdef HAVE_LONG_LONG
+                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
+                        llb = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
+                        goto long_long;
+#endif
+                    }
+                case 4:
+                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
+                        b = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
+                        break;
+#ifdef HAVE_LONG_LONG
+                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
+                        llb = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
+                        goto long_long;
+#endif
+                    }
+                default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
+            }
+        }
+                x = a + b;
+            return PyLong_FromLong(x);
+#ifdef HAVE_LONG_LONG
+        long_long:
+                llx = lla + llb;
+            return PyLong_FromLongLong(llx);
+#endif
+        
+        
+    }
+    #endif
+    if (PyFloat_CheckExact(op2)) {
+        const long a = intval;
+        double b = PyFloat_AS_DOUBLE(op2);
+            double result;
+            PyFPE_START_PROTECT("add", return NULL)
+            result = ((double)a) + (double)b;
+            PyFPE_END_PROTECT(result)
+            return PyFloat_FromDouble(result);
+    }
+    return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
+}
+#endif
+
+/* RaiseTooManyValuesToUnpack */
+          static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
+    PyErr_Format(PyExc_ValueError,
+                 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
+}
+
+/* RaiseNeedMoreValuesToUnpack */
+          static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
+    PyErr_Format(PyExc_ValueError,
+                 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
+                 index, (index == 1) ? "" : "s");
+}
+
+/* IterFinish */
+          static CYTHON_INLINE int __Pyx_IterFinish(void) {
+#if CYTHON_FAST_THREAD_STATE
+    PyThreadState *tstate = PyThreadState_GET();
+    PyObject* exc_type = tstate->curexc_type;
+    if (unlikely(exc_type)) {
+        if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) {
+            PyObject *exc_value, *exc_tb;
+            exc_value = tstate->curexc_value;
+            exc_tb = tstate->curexc_traceback;
+            tstate->curexc_type = 0;
+            tstate->curexc_value = 0;
+            tstate->curexc_traceback = 0;
+            Py_DECREF(exc_type);
+            Py_XDECREF(exc_value);
+            Py_XDECREF(exc_tb);
+            return 0;
+        } else {
+            return -1;
+        }
+    }
+    return 0;
+#else
+    if (unlikely(PyErr_Occurred())) {
+        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
+            PyErr_Clear();
+            return 0;
+        } else {
+            return -1;
+        }
+    }
+    return 0;
+#endif
+}
+
+/* UnpackItemEndCheck */
+          static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
+    if (unlikely(retval)) {
+        Py_DECREF(retval);
+        __Pyx_RaiseTooManyValuesError(expected);
+        return -1;
+    } else {
+        return __Pyx_IterFinish();
+    }
+    return 0;
+}
+
+/* IterNext */
+          static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) {
+    PyObject* next;
+    iternextfunc iternext = Py_TYPE(iterator)->tp_iternext;
+#if CYTHON_USE_TYPE_SLOTS
+    if (unlikely(!iternext)) {
+#else
+    if (unlikely(!iternext) || unlikely(!PyIter_Check(iterator))) {
+#endif
+        PyErr_Format(PyExc_TypeError,
+            "%.200s object is not an iterator", Py_TYPE(iterator)->tp_name);
+        return NULL;
+    }
+    next = iternext(iterator);
+    if (likely(next))
+        return next;
+#if CYTHON_USE_TYPE_SLOTS
+#if PY_VERSION_HEX >= 0x02070000
+    if (unlikely(iternext == &_PyObject_NextNotImplemented))
+        return NULL;
+#endif
+#endif
+    if (defval) {
+        PyObject* exc_type = PyErr_Occurred();
+        if (exc_type) {
+            if (unlikely(exc_type != PyExc_StopIteration) &&
+                    !PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))
+                return NULL;
+            PyErr_Clear();
+        }
+        Py_INCREF(defval);
+        return defval;
+    }
+    if (!PyErr_Occurred())
+        PyErr_SetNone(PyExc_StopIteration);
+    return NULL;
+}
+
+/* decode_c_bytes */
+            static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes(
+         const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop,
+         const char* encoding, const char* errors,
+         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
+    if (unlikely((start < 0) | (stop < 0))) {
+        if (start < 0) {
+            start += length;
+            if (start < 0)
+                start = 0;
+        }
+        if (stop < 0)
+            stop += length;
+    }
+    if (stop > length)
+        stop = length;
+    length = stop - start;
+    if (unlikely(length <= 0))
+        return PyUnicode_FromUnicode(NULL, 0);
+    cstring += start;
+    if (decode_func) {
+        return decode_func(cstring, length, errors);
+    } else {
+        return PyUnicode_Decode(cstring, length, encoding, errors);
+    }
+}
+
+/* PyObjectCallMethod0 */
+            static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
+    PyObject *method, *result = NULL;
+    method = __Pyx_PyObject_GetAttrStr(obj, method_name);
+    if (unlikely(!method)) goto bad;
+#if CYTHON_UNPACK_METHODS
+    if (likely(PyMethod_Check(method))) {
+        PyObject *self = PyMethod_GET_SELF(method);
+        if (likely(self)) {
+            PyObject *function = PyMethod_GET_FUNCTION(method);
+            result = __Pyx_PyObject_CallOneArg(function, self);
+            Py_DECREF(method);
+            return result;
+        }
+    }
+#endif
+    result = __Pyx_PyObject_CallNoArg(method);
+    Py_DECREF(method);
+bad:
+    return result;
+}
+
+/* RaiseNoneIterError */
+            static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
+}
+
+/* UnpackTupleError */
+            static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) {
+    if (t == Py_None) {
+      __Pyx_RaiseNoneNotIterableError();
+    } else if (PyTuple_GET_SIZE(t) < index) {
+      __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t));
+    } else {
+      __Pyx_RaiseTooManyValuesError(index);
+    }
+}
+
+/* UnpackTuple2 */
+            static CYTHON_INLINE int __Pyx_unpack_tuple2(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2,
+                                             int is_tuple, int has_known_size, int decref_tuple) {
+    Py_ssize_t index;
+    PyObject *value1 = NULL, *value2 = NULL, *iter = NULL;
+    if (!is_tuple && unlikely(!PyTuple_Check(tuple))) {
+        iternextfunc iternext;
+        iter = PyObject_GetIter(tuple);
+        if (unlikely(!iter)) goto bad;
+        if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; }
+        iternext = Py_TYPE(iter)->tp_iternext;
+        value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; }
+        value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; }
+        if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad;
+        Py_DECREF(iter);
+    } else {
+        if (!has_known_size && unlikely(PyTuple_GET_SIZE(tuple) != 2)) {
+            __Pyx_UnpackTupleError(tuple, 2);
+            goto bad;
+        }
+#if CYTHON_COMPILING_IN_PYPY
+        value1 = PySequence_ITEM(tuple, 0);
+        if (unlikely(!value1)) goto bad;
+        value2 = PySequence_ITEM(tuple, 1);
+        if (unlikely(!value2)) goto bad;
+#else
+        value1 = PyTuple_GET_ITEM(tuple, 0);
+        value2 = PyTuple_GET_ITEM(tuple, 1);
+        Py_INCREF(value1);
+        Py_INCREF(value2);
+#endif
+        if (decref_tuple) { Py_DECREF(tuple); }
+    }
+    *pvalue1 = value1;
+    *pvalue2 = value2;
+    return 0;
+unpacking_failed:
+    if (!has_known_size && __Pyx_IterFinish() == 0)
+        __Pyx_RaiseNeedMoreValuesError(index);
+bad:
+    Py_XDECREF(iter);
+    Py_XDECREF(value1);
+    Py_XDECREF(value2);
+    if (decref_tuple) { Py_XDECREF(tuple); }
+    return -1;
+}
+
+/* dict_iter */
+            static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_dict, PyObject* method_name,
+                                                   Py_ssize_t* p_orig_length, int* p_source_is_dict) {
+    is_dict = is_dict || likely(PyDict_CheckExact(iterable));
+    *p_source_is_dict = is_dict;
+#if !CYTHON_COMPILING_IN_PYPY
+    if (is_dict) {
+        *p_orig_length = PyDict_Size(iterable);
+        Py_INCREF(iterable);
+        return iterable;
+    }
+#endif
+    *p_orig_length = 0;
+    if (method_name) {
+        PyObject* iter;
+        iterable = __Pyx_PyObject_CallMethod0(iterable, method_name);
+        if (!iterable)
+            return NULL;
+#if !CYTHON_COMPILING_IN_PYPY
+        if (PyTuple_CheckExact(iterable) || PyList_CheckExact(iterable))
+            return iterable;
+#endif
+        iter = PyObject_GetIter(iterable);
+        Py_DECREF(iterable);
+        return iter;
+    }
+    return PyObject_GetIter(iterable);
+}
+static CYTHON_INLINE int __Pyx_dict_iter_next(
+        PyObject* iter_obj, CYTHON_NCP_UNUSED Py_ssize_t orig_length, CYTHON_NCP_UNUSED Py_ssize_t* ppos,
+        PyObject** pkey, PyObject** pvalue, PyObject** pitem, int source_is_dict) {
+    PyObject* next_item;
+#if !CYTHON_COMPILING_IN_PYPY
+    if (source_is_dict) {
+        PyObject *key, *value;
+        if (unlikely(orig_length != PyDict_Size(iter_obj))) {
+            PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration");
+            return -1;
+        }
+        if (unlikely(!PyDict_Next(iter_obj, ppos, &key, &value))) {
+            return 0;
+        }
+        if (pitem) {
+            PyObject* tuple = PyTuple_New(2);
+            if (unlikely(!tuple)) {
+                return -1;
+            }
+            Py_INCREF(key);
+            Py_INCREF(value);
+            PyTuple_SET_ITEM(tuple, 0, key);
+            PyTuple_SET_ITEM(tuple, 1, value);
+            *pitem = tuple;
+        } else {
+            if (pkey) {
+                Py_INCREF(key);
+                *pkey = key;
+            }
+            if (pvalue) {
+                Py_INCREF(value);
+                *pvalue = value;
+            }
+        }
+        return 1;
+    } else if (PyTuple_CheckExact(iter_obj)) {
+        Py_ssize_t pos = *ppos;
+        if (unlikely(pos >= PyTuple_GET_SIZE(iter_obj))) return 0;
+        *ppos = pos + 1;
+        next_item = PyTuple_GET_ITEM(iter_obj, pos);
+        Py_INCREF(next_item);
+    } else if (PyList_CheckExact(iter_obj)) {
+        Py_ssize_t pos = *ppos;
+        if (unlikely(pos >= PyList_GET_SIZE(iter_obj))) return 0;
+        *ppos = pos + 1;
+        next_item = PyList_GET_ITEM(iter_obj, pos);
+        Py_INCREF(next_item);
+    } else
+#endif
+    {
+        next_item = PyIter_Next(iter_obj);
+        if (unlikely(!next_item)) {
+            return __Pyx_IterFinish();
+        }
+    }
+    if (pitem) {
+        *pitem = next_item;
+    } else if (pkey && pvalue) {
+        if (__Pyx_unpack_tuple2(next_item, pkey, pvalue, source_is_dict, source_is_dict, 1))
+            return -1;
+    } else if (pkey) {
+        *pkey = next_item;
+    } else {
+        *pvalue = next_item;
+    }
+    return 1;
+}
+
+/* ArgTypeTest */
+            static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) {
+    PyErr_Format(PyExc_TypeError,
+        "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
+        name, type->tp_name, Py_TYPE(obj)->tp_name);
+}
+static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
+    const char *name, int exact)
+{
+    if (unlikely(!type)) {
+        PyErr_SetString(PyExc_SystemError, "Missing type object");
+        return 0;
+    }
+    if (none_allowed && obj == Py_None) return 1;
+    else if (exact) {
+        if (likely(Py_TYPE(obj) == type)) return 1;
+        #if PY_MAJOR_VERSION == 2
+        else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
+        #endif
+    }
+    else {
+        if (likely(PyObject_TypeCheck(obj, type))) return 1;
+    }
+    __Pyx_RaiseArgumentTypeInvalid(name, obj, type);
+    return 0;
+}
+
+/* FetchCommonType */
+            static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
+    PyObject* fake_module;
+    PyTypeObject* cached_type = NULL;
+    fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
+    if (!fake_module) return NULL;
+    Py_INCREF(fake_module);
+    cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
+    if (cached_type) {
+        if (!PyType_Check((PyObject*)cached_type)) {
+            PyErr_Format(PyExc_TypeError,
+                "Shared Cython type %.200s is not a type object",
+                type->tp_name);
+            goto bad;
+        }
+        if (cached_type->tp_basicsize != type->tp_basicsize) {
+            PyErr_Format(PyExc_TypeError,
+                "Shared Cython type %.200s has the wrong size, try recompiling",
+                type->tp_name);
+            goto bad;
+        }
+    } else {
+        if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
+        PyErr_Clear();
+        if (PyType_Ready(type) < 0) goto bad;
+        if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
+            goto bad;
+        Py_INCREF(type);
+        cached_type = type;
+    }
+done:
+    Py_DECREF(fake_module);
+    return cached_type;
+bad:
+    Py_XDECREF(cached_type);
+    cached_type = NULL;
+    goto done;
+}
+
+/* PyObjectCallMethod1 */
+            static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
+    PyObject *method, *result = NULL;
+    method = __Pyx_PyObject_GetAttrStr(obj, method_name);
+    if (unlikely(!method)) goto done;
+#if CYTHON_UNPACK_METHODS
+    if (likely(PyMethod_Check(method))) {
+        PyObject *self = PyMethod_GET_SELF(method);
+        if (likely(self)) {
+            PyObject *args;
+            PyObject *function = PyMethod_GET_FUNCTION(method);
+            #if CYTHON_FAST_PYCALL
+            if (PyFunction_Check(function)) {
+                PyObject *args[2] = {self, arg};
+                result = __Pyx_PyFunction_FastCall(function, args, 2);
+                goto done;
+            }
+            #endif
+            #if CYTHON_FAST_PYCCALL
+            if (__Pyx_PyFastCFunction_Check(function)) {
+                PyObject *args[2] = {self, arg};
+                result = __Pyx_PyCFunction_FastCall(function, args, 2);
+                goto done;
+            }
+            #endif
+            args = PyTuple_New(2);
+            if (unlikely(!args)) goto done;
+            Py_INCREF(self);
+            PyTuple_SET_ITEM(args, 0, self);
+            Py_INCREF(arg);
+            PyTuple_SET_ITEM(args, 1, arg);
+            Py_INCREF(function);
+            Py_DECREF(method); method = NULL;
+            result = __Pyx_PyObject_Call(function, args, NULL);
+            Py_DECREF(args);
+            Py_DECREF(function);
+            return result;
+        }
+    }
+#endif
+    result = __Pyx_PyObject_CallOneArg(method, arg);
+done:
+    Py_XDECREF(method);
+    return result;
+}
+
+/* CoroutineBase */
+            #include <structmember.h>
+#include <frameobject.h>
+static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value);
+static PyObject *__Pyx_Coroutine_Close(PyObject *self);
+static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args);
+#define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom)
+#if 1 || PY_VERSION_HEX < 0x030300B0
+static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue) {
+    PyObject *et, *ev, *tb;
+    PyObject *value = NULL;
+    __Pyx_PyThreadState_declare
+    __Pyx_PyThreadState_assign
+    __Pyx_ErrFetch(&et, &ev, &tb);
+    if (!et) {
+        Py_XDECREF(tb);
+        Py_XDECREF(ev);
+        Py_INCREF(Py_None);
+        *pvalue = Py_None;
+        return 0;
+    }
+    if (likely(et == PyExc_StopIteration)) {
+        if (!ev) {
+            Py_INCREF(Py_None);
+            value = Py_None;
+        }
+#if PY_VERSION_HEX >= 0x030300A0
+        else if (Py_TYPE(ev) == (PyTypeObject*)PyExc_StopIteration) {
+            value = ((PyStopIterationObject *)ev)->value;
+            Py_INCREF(value);
+            Py_DECREF(ev);
+        }
+#endif
+        else if (unlikely(PyTuple_Check(ev))) {
+            if (PyTuple_GET_SIZE(ev) >= 1) {
+#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+                value = PyTuple_GET_ITEM(ev, 0);
+                Py_INCREF(value);
+#else
+                value = PySequence_ITEM(ev, 0);
+#endif
+            } else {
+                Py_INCREF(Py_None);
+                value = Py_None;
+            }
+            Py_DECREF(ev);
+        }
+        else if (!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
+            value = ev;
+        }
+        if (likely(value)) {
+            Py_XDECREF(tb);
+            Py_DECREF(et);
+            *pvalue = value;
+            return 0;
+        }
+    } else if (!PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) {
+        __Pyx_ErrRestore(et, ev, tb);
+        return -1;
+    }
+    PyErr_NormalizeException(&et, &ev, &tb);
+    if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) {
+        __Pyx_ErrRestore(et, ev, tb);
+        return -1;
+    }
+    Py_XDECREF(tb);
+    Py_DECREF(et);
+#if PY_VERSION_HEX >= 0x030300A0
+    value = ((PyStopIterationObject *)ev)->value;
+    Py_INCREF(value);
+    Py_DECREF(ev);
+#else
+    {
+        PyObject* args = __Pyx_PyObject_GetAttrStr(ev, __pyx_n_s_args);
+        Py_DECREF(ev);
+        if (likely(args)) {
+            value = PySequence_GetItem(args, 0);
+            Py_DECREF(args);
+        }
+        if (unlikely(!value)) {
+            __Pyx_ErrRestore(NULL, NULL, NULL);
+            Py_INCREF(Py_None);
+            value = Py_None;
+        }
+    }
+#endif
+    *pvalue = value;
+    return 0;
+}
+#endif
+static CYTHON_INLINE
+void __Pyx_Coroutine_ExceptionClear(__pyx_CoroutineObject *self) {
+    PyObject *exc_type = self->exc_type;
+    PyObject *exc_value = self->exc_value;
+    PyObject *exc_traceback = self->exc_traceback;
+    self->exc_type = NULL;
+    self->exc_value = NULL;
+    self->exc_traceback = NULL;
+    Py_XDECREF(exc_type);
+    Py_XDECREF(exc_value);
+    Py_XDECREF(exc_traceback);
+}
+static CYTHON_INLINE
+int __Pyx_Coroutine_CheckRunning(__pyx_CoroutineObject *gen) {
+    if (unlikely(gen->is_running)) {
+        PyErr_SetString(PyExc_ValueError,
+                        "generator already executing");
+        return 1;
+    }
+    return 0;
+}
+static CYTHON_INLINE
+PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value) {
+    PyObject *retval;
+    __Pyx_PyThreadState_declare
+    assert(!self->is_running);
+    if (unlikely(self->resume_label == 0)) {
+        if (unlikely(value && value != Py_None)) {
+            PyErr_SetString(PyExc_TypeError,
+                            "can't send non-None value to a "
+                            "just-started generator");
+            return NULL;
+        }
+    }
+    if (unlikely(self->resume_label == -1)) {
+        PyErr_SetNone(PyExc_StopIteration);
+        return NULL;
+    }
+    __Pyx_PyThreadState_assign
+    if (value) {
+#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
+#else
+        if (self->exc_traceback) {
+            PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
+            PyFrameObject *f = tb->tb_frame;
+            Py_XINCREF(__pyx_tstate->frame);
+            assert(f->f_back == NULL);
+            f->f_back = __pyx_tstate->frame;
+        }
+#endif
+        __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
+                            &self->exc_traceback);
+    } else {
+        __Pyx_Coroutine_ExceptionClear(self);
+    }
+    self->is_running = 1;
+    retval = self->body((PyObject *) self, value);
+    self->is_running = 0;
+    if (retval) {
+        __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
+                            &self->exc_traceback);
+#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
+#else
+        if (self->exc_traceback) {
+            PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
+            PyFrameObject *f = tb->tb_frame;
+            Py_CLEAR(f->f_back);
+        }
+#endif
+    } else {
+        __Pyx_Coroutine_ExceptionClear(self);
+    }
+    return retval;
+}
+static CYTHON_INLINE
+PyObject *__Pyx_Coroutine_MethodReturn(PyObject *retval) {
+    if (unlikely(!retval && !PyErr_Occurred())) {
+        PyErr_SetNone(PyExc_StopIteration);
+    }
+    return retval;
+}
+static CYTHON_INLINE
+PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) {
+    PyObject *ret;
+    PyObject *val = NULL;
+    __Pyx_Coroutine_Undelegate(gen);
+    __Pyx_PyGen_FetchStopIterationValue(&val);
+    ret = __Pyx_Coroutine_SendEx(gen, val);
+    Py_XDECREF(val);
+    return ret;
+}
+static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
+    PyObject *retval;
+    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
+    PyObject *yf = gen->yieldfrom;
+    if (unlikely(__Pyx_Coroutine_CheckRunning(gen)))
+        return NULL;
+    if (yf) {
+        PyObject *ret;
+        gen->is_running = 1;
+        #ifdef __Pyx_Generator_USED
+        if (__Pyx_Generator_CheckExact(yf)) {
+            ret = __Pyx_Coroutine_Send(yf, value);
+        } else
+        #endif
+        #ifdef __Pyx_Coroutine_USED
+        if (__Pyx_Coroutine_CheckExact(yf)) {
+            ret = __Pyx_Coroutine_Send(yf, value);
+        } else
+        #endif
+        {
+            if (value == Py_None)
+                ret = Py_TYPE(yf)->tp_iternext(yf);
+            else
+                ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value);
+        }
+        gen->is_running = 0;
+        if (likely(ret)) {
+            return ret;
+        }
+        retval = __Pyx_Coroutine_FinishDelegation(gen);
+    } else {
+        retval = __Pyx_Coroutine_SendEx(gen, value);
+    }
+    return __Pyx_Coroutine_MethodReturn(retval);
+}
+static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
+    PyObject *retval = NULL;
+    int err = 0;
+    #ifdef __Pyx_Generator_USED
+    if (__Pyx_Generator_CheckExact(yf)) {
+        retval = __Pyx_Coroutine_Close(yf);
+        if (!retval)
+            return -1;
+    } else
+    #endif
+    #ifdef __Pyx_Coroutine_USED
+    if (__Pyx_Coroutine_CheckExact(yf)) {
+        retval = __Pyx_Coroutine_Close(yf);
+        if (!retval)
+            return -1;
+    } else
+    #endif
+    {
+        PyObject *meth;
+        gen->is_running = 1;
+        meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_close);
+        if (unlikely(!meth)) {
+            if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
+                PyErr_WriteUnraisable(yf);
+            }
+            PyErr_Clear();
+        } else {
+            retval = PyObject_CallFunction(meth, NULL);
+            Py_DECREF(meth);
+            if (!retval)
+                err = -1;
+        }
+        gen->is_running = 0;
+    }
+    Py_XDECREF(retval);
+    return err;
+}
+static PyObject *__Pyx_Generator_Next(PyObject *self) {
+    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
+    PyObject *yf = gen->yieldfrom;
+    if (unlikely(__Pyx_Coroutine_CheckRunning(gen)))
+        return NULL;
+    if (yf) {
+        PyObject *ret;
+        gen->is_running = 1;
+        #ifdef __Pyx_Generator_USED
+        if (__Pyx_Generator_CheckExact(yf)) {
+            ret = __Pyx_Generator_Next(yf);
+        } else
+        #endif
+            ret = Py_TYPE(yf)->tp_iternext(yf);
+        gen->is_running = 0;
+        if (likely(ret)) {
+            return ret;
+        }
+        return __Pyx_Coroutine_FinishDelegation(gen);
+    }
+    return __Pyx_Coroutine_SendEx(gen, Py_None);
+}
+static PyObject *__Pyx_Coroutine_Close(PyObject *self) {
+    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
+    PyObject *retval, *raised_exception;
+    PyObject *yf = gen->yieldfrom;
+    int err = 0;
+    if (unlikely(__Pyx_Coroutine_CheckRunning(gen)))
+        return NULL;
+    if (yf) {
+        Py_INCREF(yf);
+        err = __Pyx_Coroutine_CloseIter(gen, yf);
+        __Pyx_Coroutine_Undelegate(gen);
+        Py_DECREF(yf);
+    }
+    if (err == 0)
+        PyErr_SetNone(PyExc_GeneratorExit);
+    retval = __Pyx_Coroutine_SendEx(gen, NULL);
+    if (retval) {
+        Py_DECREF(retval);
+        PyErr_SetString(PyExc_RuntimeError,
+                        "generator ignored GeneratorExit");
+        return NULL;
+    }
+    raised_exception = PyErr_Occurred();
+    if (!raised_exception
+        || raised_exception == PyExc_StopIteration
+        || raised_exception == PyExc_GeneratorExit
+        || PyErr_GivenExceptionMatches(raised_exception, PyExc_GeneratorExit)
+        || PyErr_GivenExceptionMatches(raised_exception, PyExc_StopIteration))
+    {
+        if (raised_exception) PyErr_Clear();
+        Py_INCREF(Py_None);
+        return Py_None;
+    }
+    return NULL;
+}
+static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
+    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
+    PyObject *typ;
+    PyObject *tb = NULL;
+    PyObject *val = NULL;
+    PyObject *yf = gen->yieldfrom;
+    if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))
+        return NULL;
+    if (unlikely(__Pyx_Coroutine_CheckRunning(gen)))
+        return NULL;
+    if (yf) {
+        PyObject *ret;
+        Py_INCREF(yf);
+        if (PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit)) {
+            int err = __Pyx_Coroutine_CloseIter(gen, yf);
+            Py_DECREF(yf);
+            __Pyx_Coroutine_Undelegate(gen);
+            if (err < 0)
+                return __Pyx_Coroutine_MethodReturn(__Pyx_Coroutine_SendEx(gen, NULL));
+            goto throw_here;
+        }
+        gen->is_running = 1;
+        #ifdef __Pyx_Generator_USED
+        if (__Pyx_Generator_CheckExact(yf)) {
+            ret = __Pyx_Coroutine_Throw(yf, args);
+        } else
+        #endif
+        #ifdef __Pyx_Coroutine_USED
+        if (__Pyx_Coroutine_CheckExact(yf)) {
+            ret = __Pyx_Coroutine_Throw(yf, args);
+        } else
+        #endif
+        {
+            PyObject *meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_throw);
+            if (unlikely(!meth)) {
+                Py_DECREF(yf);
+                if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
+                    gen->is_running = 0;
+                    return NULL;
+                }
+                PyErr_Clear();
+                __Pyx_Coroutine_Undelegate(gen);
+                gen->is_running = 0;
+                goto throw_here;
+            }
+            ret = PyObject_CallObject(meth, args);
+            Py_DECREF(meth);
+        }
+        gen->is_running = 0;
+        Py_DECREF(yf);
+        if (!ret) {
+            ret = __Pyx_Coroutine_FinishDelegation(gen);
+        }
+        return __Pyx_Coroutine_MethodReturn(ret);
+    }
+throw_here:
+    __Pyx_Raise(typ, val, tb, NULL);
+    return __Pyx_Coroutine_MethodReturn(__Pyx_Coroutine_SendEx(gen, NULL));
+}
+static int __Pyx_Coroutine_traverse(PyObject *self, visitproc visit, void *arg) {
+    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
+    Py_VISIT(gen->closure);
+    Py_VISIT(gen->classobj);
+    Py_VISIT(gen->yieldfrom);
+    Py_VISIT(gen->exc_type);
+    Py_VISIT(gen->exc_value);
+    Py_VISIT(gen->exc_traceback);
+    return 0;
+}
+static int __Pyx_Coroutine_clear(PyObject *self) {
+    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
+    Py_CLEAR(gen->closure);
+    Py_CLEAR(gen->classobj);
+    Py_CLEAR(gen->yieldfrom);
+    Py_CLEAR(gen->exc_type);
+    Py_CLEAR(gen->exc_value);
+    Py_CLEAR(gen->exc_traceback);
+    Py_CLEAR(gen->gi_name);
+    Py_CLEAR(gen->gi_qualname);
+    return 0;
+}
+static void __Pyx_Coroutine_dealloc(PyObject *self) {
+    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
+    PyObject_GC_UnTrack(gen);
+    if (gen->gi_weakreflist != NULL)
+        PyObject_ClearWeakRefs(self);
+    if (gen->resume_label > 0) {
+        PyObject_GC_Track(self);
+#if PY_VERSION_HEX >= 0x030400a1
+        if (PyObject_CallFinalizerFromDealloc(self))
+#else
+        Py_TYPE(gen)->tp_del(self);
+        if (self->ob_refcnt > 0)
+#endif
+        {
+            return;
+        }
+        PyObject_GC_UnTrack(self);
+    }
+    __Pyx_Coroutine_clear(self);
+    PyObject_GC_Del(gen);
+}
+static void __Pyx_Coroutine_del(PyObject *self) {
+    PyObject *res;
+    PyObject *error_type, *error_value, *error_traceback;
+    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
+    __Pyx_PyThreadState_declare
+    if (gen->resume_label <= 0)
+        return ;
+#if PY_VERSION_HEX < 0x030400a1
+    assert(self->ob_refcnt == 0);
+    self->ob_refcnt = 1;
+#endif
+    __Pyx_PyThreadState_assign
+    __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
+    res = __Pyx_Coroutine_Close(self);
+    if (res == NULL)
+        PyErr_WriteUnraisable(self);
+    else
+        Py_DECREF(res);
+    __Pyx_ErrRestore(error_type, error_value, error_traceback);
+#if PY_VERSION_HEX < 0x030400a1
+    assert(self->ob_refcnt > 0);
+    if (--self->ob_refcnt == 0) {
+        return;
+    }
+    {
+        Py_ssize_t refcnt = self->ob_refcnt;
+        _Py_NewReference(self);
+        self->ob_refcnt = refcnt;
+    }
+#if CYTHON_COMPILING_IN_CPYTHON
+    assert(PyType_IS_GC(self->ob_type) &&
+           _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
+    _Py_DEC_REFTOTAL;
+#endif
+#ifdef COUNT_ALLOCS
+    --Py_TYPE(self)->tp_frees;
+    --Py_TYPE(self)->tp_allocs;
+#endif
+#endif
+}
+static PyObject *
+__Pyx_Coroutine_get_name(__pyx_CoroutineObject *self)
+{
+    PyObject *name = self->gi_name;
+    if (unlikely(!name)) name = Py_None;
+    Py_INCREF(name);
+    return name;
+}
+static int
+__Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value)
+{
+    PyObject *tmp;
+#if PY_MAJOR_VERSION >= 3
+    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
+#else
+    if (unlikely(value == NULL || !PyString_Check(value))) {
+#endif
+        PyErr_SetString(PyExc_TypeError,
+                        "__name__ must be set to a string object");
+        return -1;
+    }
+    tmp = self->gi_name;
+    Py_INCREF(value);
+    self->gi_name = value;
+    Py_XDECREF(tmp);
+    return 0;
+}
+static PyObject *
+__Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self)
+{
+    PyObject *name = self->gi_qualname;
+    if (unlikely(!name)) name = Py_None;
+    Py_INCREF(name);
+    return name;
+}
+static int
+__Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value)
+{
+    PyObject *tmp;
+#if PY_MAJOR_VERSION >= 3
+    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
+#else
+    if (unlikely(value == NULL || !PyString_Check(value))) {
+#endif
+        PyErr_SetString(PyExc_TypeError,
+                        "__qualname__ must be set to a string object");
+        return -1;
+    }
+    tmp = self->gi_qualname;
+    Py_INCREF(value);
+    self->gi_qualname = value;
+    Py_XDECREF(tmp);
+    return 0;
+}
+static __pyx_CoroutineObject *__Pyx__Coroutine_New(
+            PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *closure,
+            PyObject *name, PyObject *qualname, PyObject *module_name) {
+    __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type);
+    if (gen == NULL)
+        return NULL;
+    gen->body = body;
+    gen->closure = closure;
+    Py_XINCREF(closure);
+    gen->is_running = 0;
+    gen->resume_label = 0;
+    gen->classobj = NULL;
+    gen->yieldfrom = NULL;
+    gen->exc_type = NULL;
+    gen->exc_value = NULL;
+    gen->exc_traceback = NULL;
+    gen->gi_weakreflist = NULL;
+    Py_XINCREF(qualname);
+    gen->gi_qualname = qualname;
+    Py_XINCREF(name);
+    gen->gi_name = name;
+    Py_XINCREF(module_name);
+    gen->gi_modulename = module_name;
+    PyObject_GC_Track(gen);
+    return gen;
+}
+
+/* PatchModuleWithCoroutine */
+                static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) {
+#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
+    int result;
+    PyObject *globals, *result_obj;
+    globals = PyDict_New();  if (unlikely(!globals)) goto ignore;
+    result = PyDict_SetItemString(globals, "_cython_coroutine_type",
+    #ifdef __Pyx_Coroutine_USED
+        (PyObject*)__pyx_CoroutineType);
+    #else
+        Py_None);
+    #endif
+    if (unlikely(result < 0)) goto ignore;
+    result = PyDict_SetItemString(globals, "_cython_generator_type",
+    #ifdef __Pyx_Generator_USED
+        (PyObject*)__pyx_GeneratorType);
+    #else
+        Py_None);
+    #endif
+    if (unlikely(result < 0)) goto ignore;
+    if (unlikely(PyDict_SetItemString(globals, "_module", module) < 0)) goto ignore;
+    if (unlikely(PyDict_SetItemString(globals, "__builtins__", __pyx_b) < 0)) goto ignore;
+    result_obj = PyRun_String(py_code, Py_file_input, globals, globals);
+    if (unlikely(!result_obj)) goto ignore;
+    Py_DECREF(result_obj);
+    Py_DECREF(globals);
+    return module;
+ignore:
+    Py_XDECREF(globals);
+    PyErr_WriteUnraisable(module);
+    if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch module with custom type", 1) < 0)) {
+        Py_DECREF(module);
+        module = NULL;
+    }
+#else
+    py_code++;
+#endif
+    return module;
+}
+
+/* PatchGeneratorABC */
+                #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
+static PyObject* __Pyx_patch_abc_module(PyObject *module);
+static PyObject* __Pyx_patch_abc_module(PyObject *module) {
+    module = __Pyx_Coroutine_patch_module(
+        module, ""
+"if _cython_generator_type is not None:\n"
+"    try: Generator = _module.Generator\n"
+"    except AttributeError: pass\n"
+"    else: Generator.register(_cython_generator_type)\n"
+"if _cython_coroutine_type is not None:\n"
+"    try: Coroutine = _module.Coroutine\n"
+"    except AttributeError: pass\n"
+"    else: Coroutine.register(_cython_coroutine_type)\n"
+    );
+    return module;
+}
+#endif
+static int __Pyx_patch_abc(void) {
+#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
+    static int abc_patched = 0;
+    if (!abc_patched) {
+        PyObject *module;
+        module = PyImport_ImportModule((PY_VERSION_HEX >= 0x03030000) ? "collections.abc" : "collections");
+        if (!module) {
+            PyErr_WriteUnraisable(NULL);
+            if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning,
+                    ((PY_VERSION_HEX >= 0x03030000) ?
+                        "Cython module failed to register with collections.abc module" :
+                        "Cython module failed to register with collections module"), 1) < 0)) {
+                return -1;
+            }
+        } else {
+            module = __Pyx_patch_abc_module(module);
+            abc_patched = 1;
+            if (unlikely(!module))
+                return -1;
+            Py_DECREF(module);
+        }
+        module = PyImport_ImportModule("backports_abc");
+        if (module) {
+            module = __Pyx_patch_abc_module(module);
+            Py_XDECREF(module);
+        }
+        if (!module) {
+            PyErr_Clear();
+        }
+    }
+#else
+    if (0) __Pyx_Coroutine_patch_module(NULL, NULL);
+#endif
+    return 0;
+}
+
+/* Coroutine */
+                typedef struct {
+    PyObject_HEAD
+    PyObject *coroutine;
+} __pyx_CoroutineAwaitObject;
+static void __Pyx_CoroutineAwait_dealloc(PyObject *self) {
+    PyObject_GC_UnTrack(self);
+    Py_CLEAR(((__pyx_CoroutineAwaitObject*)self)->coroutine);
+    PyObject_GC_Del(self);
+}
+static int __Pyx_CoroutineAwait_traverse(__pyx_CoroutineAwaitObject *self, visitproc visit, void *arg) {
+    Py_VISIT(self->coroutine);
+    return 0;
+}
+static int __Pyx_CoroutineAwait_clear(__pyx_CoroutineAwaitObject *self) {
+    Py_CLEAR(self->coroutine);
+    return 0;
+}
+static PyObject *__Pyx_CoroutineAwait_Next(__pyx_CoroutineAwaitObject *self) {
+    return __Pyx_Generator_Next(self->coroutine);
+}
+static PyObject *__Pyx_CoroutineAwait_Send(__pyx_CoroutineAwaitObject *self, PyObject *value) {
+    return __Pyx_Coroutine_Send(self->coroutine, value);
+}
+static PyObject *__Pyx_CoroutineAwait_Throw(__pyx_CoroutineAwaitObject *self, PyObject *args) {
+    return __Pyx_Coroutine_Throw(self->coroutine, args);
+}
+static PyObject *__Pyx_CoroutineAwait_Close(__pyx_CoroutineAwaitObject *self) {
+    return __Pyx_Coroutine_Close(self->coroutine);
+}
+static PyObject *__Pyx_CoroutineAwait_self(PyObject *self) {
+    Py_INCREF(self);
+    return self;
+}
+#if !CYTHON_COMPILING_IN_PYPY
+static PyObject *__Pyx_CoroutineAwait_no_new(CYTHON_UNUSED PyTypeObject *type, CYTHON_UNUSED PyObject *args, CYTHON_UNUSED PyObject *kwargs) {
+    PyErr_SetString(PyExc_TypeError, "cannot instantiate type, use 'await coroutine' instead");
+    return NULL;
+}
+#endif
+static PyMethodDef __pyx_CoroutineAwait_methods[] = {
+    {"send", (PyCFunction) __Pyx_CoroutineAwait_Send, METH_O,
+     (char*) PyDoc_STR("send(arg) -> send 'arg' into coroutine,\nreturn next yielded value or raise StopIteration.")},
+    {"throw", (PyCFunction) __Pyx_CoroutineAwait_Throw, METH_VARARGS,
+     (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in coroutine,\nreturn next yielded value or raise StopIteration.")},
+    {"close", (PyCFunction) __Pyx_CoroutineAwait_Close, METH_NOARGS,
+     (char*) PyDoc_STR("close() -> raise GeneratorExit inside coroutine.")},
+    {0, 0, 0, 0}
+};
+static PyTypeObject __pyx_CoroutineAwaitType_type = {
+    PyVarObject_HEAD_INIT(0, 0)
+    "coroutine_wrapper",
+    sizeof(__pyx_CoroutineAwaitObject),
+    0,
+    (destructor) __Pyx_CoroutineAwait_dealloc,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
+    PyDoc_STR("A wrapper object implementing __await__ for coroutines."),
+    (traverseproc) __Pyx_CoroutineAwait_traverse,
+    (inquiry) __Pyx_CoroutineAwait_clear,
+    0,
+    0,
+    __Pyx_CoroutineAwait_self,
+    (iternextfunc) __Pyx_CoroutineAwait_Next,
+    __pyx_CoroutineAwait_methods,
+    0                         ,
+    0                      ,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+#if !CYTHON_COMPILING_IN_PYPY
+    __Pyx_CoroutineAwait_no_new,
+#else
+    0,
+#endif
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+#if PY_VERSION_HEX >= 0x030400a1
+    0,
+#endif
+};
+static CYTHON_INLINE PyObject *__Pyx__Coroutine_await(PyObject *coroutine) {
+#if CYTHON_COMPILING_IN_CPYTHON
+    __pyx_CoroutineAwaitObject *await = PyObject_GC_New(__pyx_CoroutineAwaitObject, __pyx_CoroutineAwaitType);
+#else
+    __pyx_CoroutineAwaitObject *await = (__pyx_CoroutineAwaitObject*)
+        __pyx_CoroutineAwaitType->tp_new(__pyx_CoroutineAwaitType, __pyx_empty_tuple, NULL);
+#endif
+    if (unlikely(!await)) return NULL;
+    Py_INCREF(coroutine);
+    await->coroutine = coroutine;
+#if CYTHON_COMPILING_IN_CPYTHON
+    PyObject_GC_Track(await);
+#endif
+    return (PyObject*)await;
+}
+static PyObject *__Pyx_Coroutine_await(PyObject *coroutine) {
+    if (unlikely(!coroutine || !__Pyx_Coroutine_CheckExact(coroutine))) {
+        PyErr_SetString(PyExc_TypeError, "invalid input, expected coroutine");
+        return NULL;
+    }
+    return __Pyx__Coroutine_await(coroutine);
+}
+static void __Pyx_Coroutine_check_and_dealloc(PyObject *self) {
+    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
+    if (gen->resume_label == 0 && !PyErr_Occurred()) {
+        PyObject_GC_UnTrack(self);
+#if PY_VERSION_HEX >= 0x03030000 || defined(PyErr_WarnFormat)
+        PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname);
+        PyErr_Clear();
+#else
+        {PyObject *msg;
+        char *cmsg;
+        #if CYTHON_COMPILING_IN_PYPY
+        msg = NULL;
+        cmsg = (char*) "coroutine was never awaited";
+        #else
+        char *cname;
+        PyObject *qualname;
+        #if PY_MAJOR_VERSION >= 3
+        qualname = PyUnicode_AsUTF8String(gen->gi_qualname);
+        if (likely(qualname)) {
+            cname = PyBytes_AS_STRING(qualname);
+        } else {
+            PyErr_Clear();
+            cname = (char*) "?";
+        }
+        msg = PyBytes_FromFormat(
+        #else
+        qualname = gen->gi_qualname;
+        cname = PyString_AS_STRING(qualname);
+        msg = PyString_FromFormat(
+        #endif
+            "coroutine '%.50s' was never awaited", cname);
+        #if PY_MAJOR_VERSION >= 3
+        Py_XDECREF(qualname);
+        #endif
+        if (unlikely(!msg)) {
+            PyErr_Clear();
+            cmsg = (char*) "coroutine was never awaited";
+        } else {
+            #if PY_MAJOR_VERSION >= 3
+            cmsg = PyBytes_AS_STRING(msg);
+            #else
+            cmsg = PyString_AS_STRING(msg);
+            #endif
+        }
+        #endif
+        if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0))
+            PyErr_WriteUnraisable(self);
+        Py_XDECREF(msg);}
+#endif
+        PyObject_GC_Track(self);
+    }
+    __Pyx_Coroutine_dealloc(self);
+}
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 && PY_VERSION_HEX < 0x030500B1
+static PyObject *__Pyx_Coroutine_compare(PyObject *obj, PyObject *other, int op) {
+    PyObject* result;
+    switch (op) {
+        case Py_EQ: result = (other == obj) ? Py_True : Py_False; break;
+        case Py_NE: result = (other != obj) ? Py_True : Py_False; break;
+        default:
+            result = Py_NotImplemented;
+    }
+    Py_INCREF(result);
+    return result;
+}
+#endif
+static PyMethodDef __pyx_Coroutine_methods[] = {
+    {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
+     (char*) PyDoc_STR("send(arg) -> send 'arg' into coroutine,\nreturn next iterated value or raise StopIteration.")},
+    {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS,
+     (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in coroutine,\nreturn next iterated value or raise StopIteration.")},
+    {"close", (PyCFunction) __Pyx_Coroutine_Close, METH_NOARGS,
+     (char*) PyDoc_STR("close() -> raise GeneratorExit inside coroutine.")},
+#if PY_VERSION_HEX < 0x030500B1
+    {"__await__", (PyCFunction) __Pyx_Coroutine_await, METH_NOARGS,
+     (char*) PyDoc_STR("__await__() -> return an iterator to be used in await expression.")},
+#endif
+    {0, 0, 0, 0}
+};
+static PyMemberDef __pyx_Coroutine_memberlist[] = {
+    {(char *) "cr_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL},
+    {(char*) "cr_await", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
+     (char*) PyDoc_STR("object being awaited, or None")},
+    {(char *) "__module__", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_modulename), PY_WRITE_RESTRICTED, 0},
+    {0, 0, 0, 0, 0}
+};
+static PyGetSetDef __pyx_Coroutine_getsets[] = {
+    {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
+     (char*) PyDoc_STR("name of the coroutine"), 0},
+    {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
+     (char*) PyDoc_STR("qualified name of the coroutine"), 0},
+    {0, 0, 0, 0, 0}
+};
+#if CYTHON_USE_ASYNC_SLOTS
+static __Pyx_PyAsyncMethodsStruct __pyx_Coroutine_as_async = {
+    __Pyx_Coroutine_await,
+    0,
+    0,
+};
+#endif
+static PyTypeObject __pyx_CoroutineType_type = {
+    PyVarObject_HEAD_INIT(0, 0)
+    "coroutine",
+    sizeof(__pyx_CoroutineObject),
+    0,
+    (destructor) __Pyx_Coroutine_check_and_dealloc,
+    0,
+    0,
+    0,
+#if CYTHON_USE_ASYNC_SLOTS
+    &__pyx_Coroutine_as_async,
+#else
+    0,
+#endif
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE,
+    0,
+    (traverseproc) __Pyx_Coroutine_traverse,
+    0,
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 && PY_VERSION_HEX < 0x030500B1
+    __Pyx_Coroutine_compare,
+#else
+    0,
+#endif
+            offsetof(__pyx_CoroutineObject, gi_weakreflist),
+            __Pyx_Coroutine_await, /* tp_iter */
+            (iternextfunc) __Pyx_Generator_Next, /* tp_iternext */
+            __pyx_Coroutine_methods,
+            __pyx_Coroutine_memberlist,
+            __pyx_Coroutine_getsets,
+            
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+#if PY_VERSION_HEX >= 0x030400a1
+    0,
+#else
+    __Pyx_Coroutine_del,
+#endif
+    0,
+#if PY_VERSION_HEX >= 0x030400a1
+    __Pyx_Coroutine_del,
+#endif
+};
+static int __pyx_Coroutine_init(void) {
+    __pyx_CoroutineType_type.tp_getattro = PyObject_GenericGetAttr;
+    __pyx_CoroutineType = __Pyx_FetchCommonType(&__pyx_CoroutineType_type);
+    if (unlikely(!__pyx_CoroutineType))
+        return -1;
+    __pyx_CoroutineAwaitType = __Pyx_FetchCommonType(&__pyx_CoroutineAwaitType_type);
+    if (unlikely(!__pyx_CoroutineAwaitType))
+        return -1;
+    return 0;
+}
+
+/* GetAwaitIter */
+                static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAwaitableIter(PyObject *o) {
+#ifdef __Pyx_Coroutine_USED
+    if (__Pyx_Coroutine_CheckExact(o)) {
+        Py_INCREF(o);
+        return o;
+    }
+#endif
+    return __Pyx__Coroutine_GetAwaitableIter(o);
+}
+static PyObject *__Pyx__Coroutine_GetAwaitableIter(PyObject *obj) {
+    PyObject *res;
+#if CYTHON_USE_ASYNC_SLOTS
+    __Pyx_PyAsyncMethodsStruct* am = __Pyx_PyType_AsAsync(obj);
+    if (likely(am && am->am_await)) {
+        res = (*am->am_await)(obj);
+    } else
+#endif
+#if PY_VERSION_HEX >= 0x030500B2 || defined(PyCoro_CheckExact)
+    if (PyCoro_CheckExact(obj)) {
+        Py_INCREF(obj);
+        return obj;
+    } else
+#endif
+#if CYTHON_COMPILING_IN_CPYTHON && defined(CO_ITERABLE_COROUTINE)
+    if (PyGen_CheckExact(obj) && ((PyGenObject*)obj)->gi_code && ((PyCodeObject *)((PyGenObject*)obj)->gi_code)->co_flags & CO_ITERABLE_COROUTINE) {
+        Py_INCREF(obj);
+        return obj;
+    } else
+#endif
+    {
+        PyObject *method = __Pyx_PyObject_GetAttrStr(obj, __pyx_n_s_await);
+        if (unlikely(!method)) goto slot_error;
+        #if CYTHON_UNPACK_METHODS
+        if (likely(PyMethod_Check(method))) {
+            PyObject *self = PyMethod_GET_SELF(method);
+            if (likely(self)) {
+                PyObject *function = PyMethod_GET_FUNCTION(method);
+                res = __Pyx_PyObject_CallOneArg(function, self);
+            } else
+                res = __Pyx_PyObject_CallNoArg(method);
+        } else
+        #endif
+            res = __Pyx_PyObject_CallNoArg(method);
+        Py_DECREF(method);
+    }
+    if (unlikely(!res)) goto bad;
+    if (!PyIter_Check(res)) {
+        PyErr_Format(PyExc_TypeError,
+                     "__await__() returned non-iterator of type '%.100s'",
+                     Py_TYPE(res)->tp_name);
+        Py_CLEAR(res);
+    } else {
+        int is_coroutine = 0;
+        #ifdef __Pyx_Coroutine_USED
+        is_coroutine |= __Pyx_Coroutine_CheckExact(res);
+        #endif
+        #if PY_VERSION_HEX >= 0x030500B2 || defined(PyCoro_CheckExact)
+        is_coroutine |= PyCoro_CheckExact(res);
+        #endif
+        if (unlikely(is_coroutine)) {
+            /* __await__ must return an *iterator*, not
+               a coroutine or another awaitable (see PEP 492) */
+            PyErr_SetString(PyExc_TypeError,
+                            "__await__() returned a coroutine");
+            Py_CLEAR(res);
+        }
+    }
+    return res;
+slot_error:
+    PyErr_Format(PyExc_TypeError,
+                 "object %.100s can't be used in 'await' expression",
+                 Py_TYPE(obj)->tp_name);
+bad:
+    return NULL;
+}
+
+/* CoroutineYieldFrom */
+                static int __Pyx_WarnAIterDeprecation(PyObject *aiter) {
+    int result;
+#if PY_MAJOR_VERSION >= 3
+    result = PyErr_WarnFormat(
+        PyExc_PendingDeprecationWarning, 1,
+        "'%.100s' implements legacy __aiter__ protocol; "
+        "__aiter__ should return an asynchronous "
+        "iterator, not awaitable",
+        Py_TYPE(aiter)->tp_name);
+#else
+    result = PyErr_WarnEx(
+        PyExc_PendingDeprecationWarning,
+        "object implements legacy __aiter__ protocol; "
+        "__aiter__ should return an asynchronous "
+        "iterator, not awaitable",
+        1);
+#endif
+    return result != 0;
+}
+static CYTHON_INLINE PyObject* __Pyx__Coroutine_Yield_From(__pyx_CoroutineObject *gen, PyObject *source, int warn) {
+    PyObject *retval;
+    if (__Pyx_Coroutine_CheckExact(source)) {
+        if (warn && unlikely(__Pyx_WarnAIterDeprecation(source))) {
+            return NULL;
+        }
+        retval = __Pyx_Generator_Next(source);
+        if (retval) {
+            Py_INCREF(source);
+            gen->yieldfrom = source;
+            return retval;
+        }
+    } else {
+        PyObject *source_gen = __Pyx__Coroutine_GetAwaitableIter(source);
+        if (unlikely(!source_gen))
+            return NULL;
+        if (warn && unlikely(__Pyx_WarnAIterDeprecation(source))) {
+            Py_DECREF(source_gen);
+            return NULL;
+        }
+        if (__Pyx_Coroutine_CheckExact(source_gen)) {
+            retval = __Pyx_Generator_Next(source_gen);
+        } else {
+            retval = Py_TYPE(source_gen)->tp_iternext(source_gen);
+        }
+        if (retval) {
+            gen->yieldfrom = source_gen;
+            return retval;
+        }
+        Py_DECREF(source_gen);
+    }
+    return NULL;
+}
+
+/* ReturnWithStopIteration */
+                static void __Pyx__ReturnWithStopIteration(PyObject* value) {
+    PyObject *exc, *args;
+#if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_PYSTON
+    __Pyx_PyThreadState_declare
+    if ((PY_VERSION_HEX >= 0x03030000 && PY_VERSION_HEX < 0x030500B1) || unlikely(PyTuple_Check(value))) {
+        args = PyTuple_New(1);
+        if (unlikely(!args)) return;
+        Py_INCREF(value);
+        PyTuple_SET_ITEM(args, 0, value);
+        exc = PyType_Type.tp_call(PyExc_StopIteration, args, NULL);
+        Py_DECREF(args);
+        if (!exc) return;
+    } else {
+        Py_INCREF(value);
+        exc = value;
+    }
+    __Pyx_PyThreadState_assign
+    if (!__pyx_tstate->exc_type) {
+        Py_INCREF(PyExc_StopIteration);
+        __Pyx_ErrRestore(PyExc_StopIteration, exc, NULL);
+        return;
+    }
+#else
+    args = PyTuple_Pack(1, value);
+    if (unlikely(!args)) return;
+    exc = PyObject_Call(PyExc_StopIteration, args, NULL);
+    Py_DECREF(args);
+    if (unlikely(!exc)) return;
+#endif
+    PyErr_SetObject(PyExc_StopIteration, exc);
+    Py_DECREF(exc);
+}
+
+/* None */
+                static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) {
+    PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
+}
+
+/* SetVTable */
+                static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
+#if PY_VERSION_HEX >= 0x02070000
+    PyObject *ob = PyCapsule_New(vtable, 0, 0);
+#else
+    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
+#endif
+    if (!ob)
+        goto bad;
+    if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
+        goto bad;
+    Py_DECREF(ob);
+    return 0;
+bad:
+    Py_XDECREF(ob);
+    return -1;
+}
+
+/* Import */
+                static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
+    PyObject *empty_list = 0;
+    PyObject *module = 0;
+    PyObject *global_dict = 0;
+    PyObject *empty_dict = 0;
+    PyObject *list;
+    #if PY_VERSION_HEX < 0x03030000
+    PyObject *py_import;
+    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
+    if (!py_import)
+        goto bad;
+    #endif
+    if (from_list)
+        list = from_list;
+    else {
+        empty_list = PyList_New(0);
+        if (!empty_list)
+            goto bad;
+        list = empty_list;
+    }
+    global_dict = PyModule_GetDict(__pyx_m);
+    if (!global_dict)
+        goto bad;
+    empty_dict = PyDict_New();
+    if (!empty_dict)
+        goto bad;
+    {
+        #if PY_MAJOR_VERSION >= 3
+        if (level == -1) {
+            if (strchr(__Pyx_MODULE_NAME, '.')) {
+                #if PY_VERSION_HEX < 0x03030000
+                PyObject *py_level = PyInt_FromLong(1);
+                if (!py_level)
+                    goto bad;
+                module = PyObject_CallFunctionObjArgs(py_import,
+                    name, global_dict, empty_dict, list, py_level, NULL);
+                Py_DECREF(py_level);
+                #else
+                module = PyImport_ImportModuleLevelObject(
+                    name, global_dict, empty_dict, list, 1);
+                #endif
+                if (!module) {
+                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
+                        goto bad;
+                    PyErr_Clear();
+                }
+            }
+            level = 0;
+        }
+        #endif
+        if (!module) {
+            #if PY_VERSION_HEX < 0x03030000
+            PyObject *py_level = PyInt_FromLong(level);
+            if (!py_level)
+                goto bad;
+            module = PyObject_CallFunctionObjArgs(py_import,
+                name, global_dict, empty_dict, list, py_level, NULL);
+            Py_DECREF(py_level);
+            #else
+            module = PyImport_ImportModuleLevelObject(
+                name, global_dict, empty_dict, list, level);
+            #endif
+        }
+    }
+bad:
+    #if PY_VERSION_HEX < 0x03030000
+    Py_XDECREF(py_import);
+    #endif
+    Py_XDECREF(empty_list);
+    Py_XDECREF(empty_dict);
+    return module;
+}
+
+/* PatchInspect */
+                static PyObject* __Pyx_patch_inspect(PyObject* module) {
+#if defined(__Pyx_Generator_USED) && (!defined(CYTHON_PATCH_INSPECT) || CYTHON_PATCH_INSPECT)
+    static int inspect_patched = 0;
+    if (unlikely((!inspect_patched) && module)) {
+        module = __Pyx_Coroutine_patch_module(
+            module, ""
+"old_types = getattr(_module.isgenerator, '_cython_generator_types', None)\n"
+"if old_types is None or not isinstance(old_types, set):\n"
+"    old_types = set()\n"
+"    def cy_wrap(orig_func, type=type, cython_generator_types=old_types):\n"
+"        def cy_isgenerator(obj): return type(obj) in cython_generator_types or orig_func(obj)\n"
+"        cy_isgenerator._cython_generator_types = cython_generator_types\n"
+"        return cy_isgenerator\n"
+"    _module.isgenerator = cy_wrap(_module.isgenerator)\n"
+"old_types.add(_cython_generator_type)\n"
+        );
+        inspect_patched = 1;
+    }
+#else
+    if (0) return __Pyx_Coroutine_patch_module(module, NULL);
+#endif
+    return module;
+}
+
+/* PatchAsyncIO */
+                static PyObject* __Pyx_patch_asyncio(PyObject* module) {
+#if PY_VERSION_HEX < 0x030500B2 &&\
+        (defined(__Pyx_Coroutine_USED) || defined(__Pyx_Generator_USED)) &&\
+        (!defined(CYTHON_PATCH_ASYNCIO) || CYTHON_PATCH_ASYNCIO)
+    PyObject *patch_module = NULL;
+    static int asyncio_patched = 0;
+    if (unlikely((!asyncio_patched) && module)) {
+        PyObject *package;
+        package = __Pyx_Import(__pyx_n_s_asyncio_coroutines, NULL, 0);
+        if (package) {
+            patch_module = __Pyx_Coroutine_patch_module(
+                PyObject_GetAttrString(package, "coroutines"), ""
+"try:\n"
+"    coro_types = _module._COROUTINE_TYPES\n"
+"except AttributeError: pass\n"
+"else:\n"
+"    if _cython_coroutine_type is not None and _cython_coroutine_type not in coro_types:\n"
+"        coro_types = tuple(coro_types) + (_cython_coroutine_type,)\n"
+"    if _cython_generator_type is not None and _cython_generator_type not in coro_types:\n"
+"        coro_types = tuple(coro_types) + (_cython_generator_type,)\n"
+"_module._COROUTINE_TYPES = coro_types\n"
+            );
+        } else {
+            PyErr_Clear();
+#if PY_VERSION_HEX < 0x03040200
+            package = __Pyx_Import(__pyx_n_s_asyncio_tasks, NULL, 0);
+            if (unlikely(!package)) goto asyncio_done;
+            patch_module = __Pyx_Coroutine_patch_module(
+                PyObject_GetAttrString(package, "tasks"), ""
+"if hasattr(_module, 'iscoroutine'):\n"
+"    old_types = getattr(_module.iscoroutine, '_cython_coroutine_types', None)\n"
+"    if old_types is None or not isinstance(old_types, set):\n"
+"        old_types = set()\n"
+"        def cy_wrap(orig_func, type=type, cython_coroutine_types=old_types):\n"
+"            def cy_iscoroutine(obj): return type(obj) in cython_coroutine_types or orig_func(obj)\n"
+"            cy_iscoroutine._cython_coroutine_types = cython_coroutine_types\n"
+"            return cy_iscoroutine\n"
+"        _module.iscoroutine = cy_wrap(_module.iscoroutine)\n"
+"    if _cython_coroutine_type is not None:\n"
+"        old_types.add(_cython_coroutine_type)\n"
+"    if _cython_generator_type is not None:\n"
+"        old_types.add(_cython_generator_type)\n"
+            );
+#endif
+        }
+        Py_DECREF(package);
+        if (unlikely(!patch_module)) goto ignore;
+#if PY_VERSION_HEX < 0x03040200
+asyncio_done:
+        PyErr_Clear();
+#endif
+        asyncio_patched = 1;
+#ifdef __Pyx_Generator_USED
+        {
+            PyObject *inspect_module;
+            if (patch_module) {
+                inspect_module = PyObject_GetAttr(patch_module, __pyx_n_s_inspect);
+                Py_DECREF(patch_module);
+            } else {
+                inspect_module = __Pyx_Import(__pyx_n_s_inspect, NULL, 0);
+            }
+            if (unlikely(!inspect_module)) goto ignore;
+            inspect_module = __Pyx_patch_inspect(inspect_module);
+            if (unlikely(!inspect_module)) {
+                Py_DECREF(module);
+                module = NULL;
+            }
+            Py_XDECREF(inspect_module);
+        }
+#else
+        if (0) return __Pyx_patch_inspect(module);
+#endif
+    }
+    return module;
+ignore:
+    PyErr_WriteUnraisable(module);
+    if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch asyncio package with custom generator type", 1) < 0)) {
+        Py_DECREF(module);
+        module = NULL;
+    }
+#else
+    if (0) return __Pyx_patch_inspect(__Pyx_Coroutine_patch_module(module, NULL));
+#endif
+    return module;
+}
+
+/* ImportFrom */
+                static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
+    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
+    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
+        PyErr_Format(PyExc_ImportError,
+        #if PY_MAJOR_VERSION < 3
+            "cannot import name %.230s", PyString_AS_STRING(name));
+        #else
+            "cannot import name %S", name);
+        #endif
+    }
+    return value;
+}
+
+/* CalculateMetaclass */
+                static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
+    Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
+    for (i=0; i < nbases; i++) {
+        PyTypeObject *tmptype;
+        PyObject *tmp = PyTuple_GET_ITEM(bases, i);
+        tmptype = Py_TYPE(tmp);
+#if PY_MAJOR_VERSION < 3
+        if (tmptype == &PyClass_Type)
+            continue;
+#endif
+        if (!metaclass) {
+            metaclass = tmptype;
+            continue;
+        }
+        if (PyType_IsSubtype(metaclass, tmptype))
+            continue;
+        if (PyType_IsSubtype(tmptype, metaclass)) {
+            metaclass = tmptype;
+            continue;
+        }
+        PyErr_SetString(PyExc_TypeError,
+                        "metaclass conflict: "
+                        "the metaclass of a derived class "
+                        "must be a (non-strict) subclass "
+                        "of the metaclasses of all its bases");
+        return NULL;
+    }
+    if (!metaclass) {
+#if PY_MAJOR_VERSION < 3
+        metaclass = &PyClass_Type;
+#else
+        metaclass = &PyType_Type;
+#endif
+    }
+    Py_INCREF((PyObject*) metaclass);
+    return (PyObject*) metaclass;
+}
+
+/* Py3ClassCreate */
+                static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
+                                           PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
+    PyObject *ns;
+    if (metaclass) {
+        PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare_2);
+        if (prep) {
+            PyObject *pargs = PyTuple_Pack(2, name, bases);
+            if (unlikely(!pargs)) {
+                Py_DECREF(prep);
+                return NULL;
+            }
+            ns = PyObject_Call(prep, pargs, mkw);
+            Py_DECREF(prep);
+            Py_DECREF(pargs);
+        } else {
+            if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
+                return NULL;
+            PyErr_Clear();
+            ns = PyDict_New();
+        }
+    } else {
+        ns = PyDict_New();
+    }
+    if (unlikely(!ns))
+        return NULL;
+    if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
+    if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
+    if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad;
+    return ns;
+bad:
+    Py_DECREF(ns);
+    return NULL;
+}
+static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
+                                      PyObject *dict, PyObject *mkw,
+                                      int calculate_metaclass, int allow_py2_metaclass) {
+    PyObject *result, *margs;
+    PyObject *owned_metaclass = NULL;
+    if (allow_py2_metaclass) {
+        owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
+        if (owned_metaclass) {
+            metaclass = owned_metaclass;
+        } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
+            PyErr_Clear();
+        } else {
+            return NULL;
+        }
+    }
+    if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
+        metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
+        Py_XDECREF(owned_metaclass);
+        if (unlikely(!metaclass))
+            return NULL;
+        owned_metaclass = metaclass;
+    }
+    margs = PyTuple_Pack(3, name, bases, dict);
+    if (unlikely(!margs)) {
+        result = NULL;
+    } else {
+        result = PyObject_Call(metaclass, margs, mkw);
+        Py_DECREF(margs);
+    }
+    Py_XDECREF(owned_metaclass);
+    return result;
+}
+
+/* CodeObjectCache */
+                static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
+    int start = 0, mid = 0, end = count - 1;
+    if (end >= 0 && code_line > entries[end].code_line) {
+        return count;
+    }
+    while (start < end) {
+        mid = start + (end - start) / 2;
+        if (code_line < entries[mid].code_line) {
+            end = mid;
+        } else if (code_line > entries[mid].code_line) {
+             start = mid + 1;
+        } else {
+            return mid;
+        }
+    }
+    if (code_line <= entries[mid].code_line) {
+        return mid;
+    } else {
+        return mid + 1;
+    }
+}
+static PyCodeObject *__pyx_find_code_object(int code_line) {
+    PyCodeObject* code_object;
+    int pos;
+    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
+        return NULL;
+    }
+    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
+    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
+        return NULL;
+    }
+    code_object = __pyx_code_cache.entries[pos].code_object;
+    Py_INCREF(code_object);
+    return code_object;
+}
+static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
+    int pos, i;
+    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
+    if (unlikely(!code_line)) {
+        return;
+    }
+    if (unlikely(!entries)) {
+        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
+        if (likely(entries)) {
+            __pyx_code_cache.entries = entries;
+            __pyx_code_cache.max_count = 64;
+            __pyx_code_cache.count = 1;
+            entries[0].code_line = code_line;
+            entries[0].code_object = code_object;
+            Py_INCREF(code_object);
+        }
+        return;
+    }
+    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
+    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
+        PyCodeObject* tmp = entries[pos].code_object;
+        entries[pos].code_object = code_object;
+        Py_DECREF(tmp);
+        return;
+    }
+    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
+        int new_max = __pyx_code_cache.max_count + 64;
+        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
+            __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
+        if (unlikely(!entries)) {
+            return;
+        }
+        __pyx_code_cache.entries = entries;
+        __pyx_code_cache.max_count = new_max;
+    }
+    for (i=__pyx_code_cache.count; i>pos; i--) {
+        entries[i] = entries[i-1];
+    }
+    entries[pos].code_line = code_line;
+    entries[pos].code_object = code_object;
+    __pyx_code_cache.count++;
+    Py_INCREF(code_object);
+}
+
+/* AddTraceback */
+                #include "compile.h"
+#include "frameobject.h"
+#include "traceback.h"
+static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
+            const char *funcname, int c_line,
+            int py_line, const char *filename) {
+    PyCodeObject *py_code = 0;
+    PyObject *py_srcfile = 0;
+    PyObject *py_funcname = 0;
+    #if PY_MAJOR_VERSION < 3
+    py_srcfile = PyString_FromString(filename);
+    #else
+    py_srcfile = PyUnicode_FromString(filename);
+    #endif
+    if (!py_srcfile) goto bad;
+    if (c_line) {
+        #if PY_MAJOR_VERSION < 3
+        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
+        #else
+        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
+        #endif
+    }
+    else {
+        #if PY_MAJOR_VERSION < 3
+        py_funcname = PyString_FromString(funcname);
+        #else
+        py_funcname = PyUnicode_FromString(funcname);
+        #endif
+    }
+    if (!py_funcname) goto bad;
+    py_code = __Pyx_PyCode_New(
+        0,
+        0,
+        0,
+        0,
+        0,
+        __pyx_empty_bytes, /*PyObject *code,*/
+        __pyx_empty_tuple, /*PyObject *consts,*/
+        __pyx_empty_tuple, /*PyObject *names,*/
+        __pyx_empty_tuple, /*PyObject *varnames,*/
+        __pyx_empty_tuple, /*PyObject *freevars,*/
+        __pyx_empty_tuple, /*PyObject *cellvars,*/
+        py_srcfile,   /*PyObject *filename,*/
+        py_funcname,  /*PyObject *name,*/
+        py_line,
+        __pyx_empty_bytes  /*PyObject *lnotab*/
+    );
+    Py_DECREF(py_srcfile);
+    Py_DECREF(py_funcname);
+    return py_code;
+bad:
+    Py_XDECREF(py_srcfile);
+    Py_XDECREF(py_funcname);
+    return NULL;
+}
+static void __Pyx_AddTraceback(const char *funcname, int c_line,
+                               int py_line, const char *filename) {
+    PyCodeObject *py_code = 0;
+    PyFrameObject *py_frame = 0;
+    py_code = __pyx_find_code_object(c_line ? c_line : py_line);
+    if (!py_code) {
+        py_code = __Pyx_CreateCodeObjectForTraceback(
+            funcname, c_line, py_line, filename);
+        if (!py_code) goto bad;
+        __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
+    }
+    py_frame = PyFrame_New(
+        PyThreadState_GET(), /*PyThreadState *tstate,*/
+        py_code,             /*PyCodeObject *code,*/
+        __pyx_d,      /*PyObject *globals,*/
+        0                    /*PyObject *locals*/
+    );
+    if (!py_frame) goto bad;
+    __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
+    PyTraceBack_Here(py_frame);
+bad:
+    Py_XDECREF(py_code);
+    Py_XDECREF(py_frame);
+}
+
+/* CIntToPy */
+                static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_AuthenticationMessage(enum __pyx_t_7asyncpg_8protocol_8protocol_AuthenticationMessage value) {
+    const enum __pyx_t_7asyncpg_8protocol_8protocol_AuthenticationMessage neg_one = (enum __pyx_t_7asyncpg_8protocol_8protocol_AuthenticationMessage) -1, const_zero = (enum __pyx_t_7asyncpg_8protocol_8protocol_AuthenticationMessage) 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (is_unsigned) {
+        if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_AuthenticationMessage) < sizeof(long)) {
+            return PyInt_FromLong((long) value);
+        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_AuthenticationMessage) <= sizeof(unsigned long)) {
+            return PyLong_FromUnsignedLong((unsigned long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_AuthenticationMessage) <= sizeof(unsigned PY_LONG_LONG)) {
+            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
+#endif
+        }
+    } else {
+        if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_AuthenticationMessage) <= sizeof(long)) {
+            return PyInt_FromLong((long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_AuthenticationMessage) <= sizeof(PY_LONG_LONG)) {
+            return PyLong_FromLongLong((PY_LONG_LONG) value);
+#endif
+        }
+    }
+    {
+        int one = 1; int little = (int)*(unsigned char *)&one;
+        unsigned char *bytes = (unsigned char *)&value;
+        return _PyLong_FromByteArray(bytes, sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_AuthenticationMessage),
+                                     little, !is_unsigned);
+    }
+}
+
+/* CIntFromPyVerify */
+                #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
+    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
+#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
+    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
+#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
+    {\
+        func_type value = func_value;\
+        if (sizeof(target_type) < sizeof(func_type)) {\
+            if (unlikely(value != (func_type) (target_type) value)) {\
+                func_type zero = 0;\
+                if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
+                    return (target_type) -1;\
+                if (is_unsigned && unlikely(value < zero))\
+                    goto raise_neg_overflow;\
+                else\
+                    goto raise_overflow;\
+            }\
+        }\
+        return (target_type) value;\
+    }
+
+/* CIntToPy */
+                static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
+    const long neg_one = (long) -1, const_zero = (long) 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (is_unsigned) {
+        if (sizeof(long) < sizeof(long)) {
+            return PyInt_FromLong((long) value);
+        } else if (sizeof(long) <= sizeof(unsigned long)) {
+            return PyLong_FromUnsignedLong((unsigned long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
+            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
+#endif
+        }
+    } else {
+        if (sizeof(long) <= sizeof(long)) {
+            return PyInt_FromLong((long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
+            return PyLong_FromLongLong((PY_LONG_LONG) value);
+#endif
+        }
+    }
+    {
+        int one = 1; int little = (int)*(unsigned char *)&one;
+        unsigned char *bytes = (unsigned char *)&value;
+        return _PyLong_FromByteArray(bytes, sizeof(long),
+                                     little, !is_unsigned);
+    }
+}
+
+/* CIntToPy */
+                static CYTHON_INLINE PyObject* __Pyx_PyInt_From_char(char value) {
+    const char neg_one = (char) -1, const_zero = (char) 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (is_unsigned) {
+        if (sizeof(char) < sizeof(long)) {
+            return PyInt_FromLong((long) value);
+        } else if (sizeof(char) <= sizeof(unsigned long)) {
+            return PyLong_FromUnsignedLong((unsigned long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(char) <= sizeof(unsigned PY_LONG_LONG)) {
+            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
+#endif
+        }
+    } else {
+        if (sizeof(char) <= sizeof(long)) {
+            return PyInt_FromLong((long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(char) <= sizeof(PY_LONG_LONG)) {
+            return PyLong_FromLongLong((PY_LONG_LONG) value);
+#endif
+        }
+    }
+    {
+        int one = 1; int little = (int)*(unsigned char *)&one;
+        unsigned char *bytes = (unsigned char *)&value;
+        return _PyLong_FromByteArray(bytes, sizeof(char),
+                                     little, !is_unsigned);
+    }
+}
+
+/* CIntToPy */
+                static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int32_t(int32_t value) {
+    const int32_t neg_one = (int32_t) -1, const_zero = (int32_t) 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (is_unsigned) {
+        if (sizeof(int32_t) < sizeof(long)) {
+            return PyInt_FromLong((long) value);
+        } else if (sizeof(int32_t) <= sizeof(unsigned long)) {
+            return PyLong_FromUnsignedLong((unsigned long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(int32_t) <= sizeof(unsigned PY_LONG_LONG)) {
+            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
+#endif
+        }
+    } else {
+        if (sizeof(int32_t) <= sizeof(long)) {
+            return PyInt_FromLong((long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(int32_t) <= sizeof(PY_LONG_LONG)) {
+            return PyLong_FromLongLong((PY_LONG_LONG) value);
+#endif
+        }
+    }
+    {
+        int one = 1; int little = (int)*(unsigned char *)&one;
+        unsigned char *bytes = (unsigned char *)&value;
+        return _PyLong_FromByteArray(bytes, sizeof(int32_t),
+                                     little, !is_unsigned);
+    }
+}
+
+/* CIntToPy */
+                static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int16_t(int16_t value) {
+    const int16_t neg_one = (int16_t) -1, const_zero = (int16_t) 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (is_unsigned) {
+        if (sizeof(int16_t) < sizeof(long)) {
+            return PyInt_FromLong((long) value);
+        } else if (sizeof(int16_t) <= sizeof(unsigned long)) {
+            return PyLong_FromUnsignedLong((unsigned long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(int16_t) <= sizeof(unsigned PY_LONG_LONG)) {
+            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
+#endif
+        }
+    } else {
+        if (sizeof(int16_t) <= sizeof(long)) {
+            return PyInt_FromLong((long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(int16_t) <= sizeof(PY_LONG_LONG)) {
+            return PyLong_FromLongLong((PY_LONG_LONG) value);
+#endif
+        }
+    }
+    {
+        int one = 1; int little = (int)*(unsigned char *)&one;
+        unsigned char *bytes = (unsigned char *)&value;
+        return _PyLong_FromByteArray(bytes, sizeof(int16_t),
+                                     little, !is_unsigned);
+    }
+}
+
+/* CIntToPy */
+                static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_CodecType(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecType value) {
+    const enum __pyx_t_7asyncpg_8protocol_8protocol_CodecType neg_one = (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecType) -1, const_zero = (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecType) 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (is_unsigned) {
+        if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecType) < sizeof(long)) {
+            return PyInt_FromLong((long) value);
+        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecType) <= sizeof(unsigned long)) {
+            return PyLong_FromUnsignedLong((unsigned long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecType) <= sizeof(unsigned PY_LONG_LONG)) {
+            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
+#endif
+        }
+    } else {
+        if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecType) <= sizeof(long)) {
+            return PyInt_FromLong((long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecType) <= sizeof(PY_LONG_LONG)) {
+            return PyLong_FromLongLong((PY_LONG_LONG) value);
+#endif
+        }
+    }
+    {
+        int one = 1; int little = (int)*(unsigned char *)&one;
+        unsigned char *bytes = (unsigned char *)&value;
+        return _PyLong_FromByteArray(bytes, sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecType),
+                                     little, !is_unsigned);
+    }
+}
+
+/* CIntToPy */
+                static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint32_t(uint32_t value) {
+    const uint32_t neg_one = (uint32_t) -1, const_zero = (uint32_t) 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (is_unsigned) {
+        if (sizeof(uint32_t) < sizeof(long)) {
+            return PyInt_FromLong((long) value);
+        } else if (sizeof(uint32_t) <= sizeof(unsigned long)) {
+            return PyLong_FromUnsignedLong((unsigned long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(uint32_t) <= sizeof(unsigned PY_LONG_LONG)) {
+            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
+#endif
+        }
+    } else {
+        if (sizeof(uint32_t) <= sizeof(long)) {
+            return PyInt_FromLong((long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(uint32_t) <= sizeof(PY_LONG_LONG)) {
+            return PyLong_FromLongLong((PY_LONG_LONG) value);
+#endif
+        }
+    }
+    {
+        int one = 1; int little = (int)*(unsigned char *)&one;
+        unsigned char *bytes = (unsigned char *)&value;
+        return _PyLong_FromByteArray(bytes, sizeof(uint32_t),
+                                     little, !is_unsigned);
+    }
+}
+
+/* CIntToPy */
+                static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
+    const int neg_one = (int) -1, const_zero = (int) 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (is_unsigned) {
+        if (sizeof(int) < sizeof(long)) {
+            return PyInt_FromLong((long) value);
+        } else if (sizeof(int) <= sizeof(unsigned long)) {
+            return PyLong_FromUnsignedLong((unsigned long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
+            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
+#endif
+        }
+    } else {
+        if (sizeof(int) <= sizeof(long)) {
+            return PyInt_FromLong((long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
+            return PyLong_FromLongLong((PY_LONG_LONG) value);
+#endif
+        }
+    }
+    {
+        int one = 1; int little = (int)*(unsigned char *)&one;
+        unsigned char *bytes = (unsigned char *)&value;
+        return _PyLong_FromByteArray(bytes, sizeof(int),
+                                     little, !is_unsigned);
+    }
+}
+
+/* UnicodeAsUCS4 */
+                static CYTHON_INLINE Py_UCS4 __Pyx_PyUnicode_AsPy_UCS4(PyObject* x) {
+   Py_ssize_t length;
+   #if CYTHON_PEP393_ENABLED
+   length = PyUnicode_GET_LENGTH(x);
+   if (likely(length == 1)) {
+       return PyUnicode_READ_CHAR(x, 0);
+   }
+   #else
+   length = PyUnicode_GET_SIZE(x);
+   if (likely(length == 1)) {
+       return PyUnicode_AS_UNICODE(x)[0];
+   }
+   #if Py_UNICODE_SIZE == 2
+   else if (PyUnicode_GET_SIZE(x) == 2) {
+       Py_UCS4 high_val = PyUnicode_AS_UNICODE(x)[0];
+       if (high_val >= 0xD800 && high_val <= 0xDBFF) {
+           Py_UCS4 low_val = PyUnicode_AS_UNICODE(x)[1];
+           if (low_val >= 0xDC00 && low_val <= 0xDFFF) {
+               return 0x10000 + (((high_val & ((1<<10)-1)) << 10) | (low_val & ((1<<10)-1)));
+           }
+       }
+   }
+   #endif
+   #endif
+   PyErr_Format(PyExc_ValueError,
+                "only single character unicode strings can be converted to Py_UCS4, "
+                "got length %" CYTHON_FORMAT_SSIZE_T "d", length);
+   return (Py_UCS4)-1;
+}
+
+/* CIntToPy */
+                static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_CodecFormat(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat value) {
+    const enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat neg_one = (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) -1, const_zero = (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (is_unsigned) {
+        if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) < sizeof(long)) {
+            return PyInt_FromLong((long) value);
+        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) <= sizeof(unsigned long)) {
+            return PyLong_FromUnsignedLong((unsigned long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) <= sizeof(unsigned PY_LONG_LONG)) {
+            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
+#endif
+        }
+    } else {
+        if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) <= sizeof(long)) {
+            return PyInt_FromLong((long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) <= sizeof(PY_LONG_LONG)) {
+            return PyLong_FromLongLong((PY_LONG_LONG) value);
+#endif
+        }
+    }
+    {
+        int one = 1; int little = (int)*(unsigned char *)&one;
+        unsigned char *bytes = (unsigned char *)&value;
+        return _PyLong_FromByteArray(bytes, sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat),
+                                     little, !is_unsigned);
+    }
+}
+
+/* CIntToPy */
+                static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int64_t(int64_t value) {
+    const int64_t neg_one = (int64_t) -1, const_zero = (int64_t) 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (is_unsigned) {
+        if (sizeof(int64_t) < sizeof(long)) {
+            return PyInt_FromLong((long) value);
+        } else if (sizeof(int64_t) <= sizeof(unsigned long)) {
+            return PyLong_FromUnsignedLong((unsigned long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(int64_t) <= sizeof(unsigned PY_LONG_LONG)) {
+            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
+#endif
+        }
+    } else {
+        if (sizeof(int64_t) <= sizeof(long)) {
+            return PyInt_FromLong((long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(int64_t) <= sizeof(PY_LONG_LONG)) {
+            return PyLong_FromLongLong((PY_LONG_LONG) value);
+#endif
+        }
+    }
+    {
+        int one = 1; int little = (int)*(unsigned char *)&one;
+        unsigned char *bytes = (unsigned char *)&value;
+        return _PyLong_FromByteArray(bytes, sizeof(int64_t),
+                                     little, !is_unsigned);
+    }
+}
+
+/* CIntToPy */
+                static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint8_t(uint8_t value) {
+    const uint8_t neg_one = (uint8_t) -1, const_zero = (uint8_t) 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (is_unsigned) {
+        if (sizeof(uint8_t) < sizeof(long)) {
+            return PyInt_FromLong((long) value);
+        } else if (sizeof(uint8_t) <= sizeof(unsigned long)) {
+            return PyLong_FromUnsignedLong((unsigned long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(uint8_t) <= sizeof(unsigned PY_LONG_LONG)) {
+            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
+#endif
+        }
+    } else {
+        if (sizeof(uint8_t) <= sizeof(long)) {
+            return PyInt_FromLong((long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(uint8_t) <= sizeof(PY_LONG_LONG)) {
+            return PyLong_FromLongLong((PY_LONG_LONG) value);
+#endif
+        }
+    }
+    {
+        int one = 1; int little = (int)*(unsigned char *)&one;
+        unsigned char *bytes = (unsigned char *)&value;
+        return _PyLong_FromByteArray(bytes, sizeof(uint8_t),
+                                     little, !is_unsigned);
+    }
+}
+
+/* CIntToPy */
+                static CYTHON_INLINE PyObject* __Pyx_PyInt_From_ptrdiff_t(ptrdiff_t value) {
+    const ptrdiff_t neg_one = (ptrdiff_t) -1, const_zero = (ptrdiff_t) 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (is_unsigned) {
+        if (sizeof(ptrdiff_t) < sizeof(long)) {
+            return PyInt_FromLong((long) value);
+        } else if (sizeof(ptrdiff_t) <= sizeof(unsigned long)) {
+            return PyLong_FromUnsignedLong((unsigned long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(ptrdiff_t) <= sizeof(unsigned PY_LONG_LONG)) {
+            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
+#endif
+        }
+    } else {
+        if (sizeof(ptrdiff_t) <= sizeof(long)) {
+            return PyInt_FromLong((long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(ptrdiff_t) <= sizeof(PY_LONG_LONG)) {
+            return PyLong_FromLongLong((PY_LONG_LONG) value);
+#endif
+        }
+    }
+    {
+        int one = 1; int little = (int)*(unsigned char *)&one;
+        unsigned char *bytes = (unsigned char *)&value;
+        return _PyLong_FromByteArray(bytes, sizeof(ptrdiff_t),
+                                     little, !is_unsigned);
+    }
+}
+
+/* CIntToPy */
+                static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ProtocolState(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState value) {
+    const enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState neg_one = (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) -1, const_zero = (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (is_unsigned) {
+        if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) < sizeof(long)) {
+            return PyInt_FromLong((long) value);
+        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) <= sizeof(unsigned long)) {
+            return PyLong_FromUnsignedLong((unsigned long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) <= sizeof(unsigned PY_LONG_LONG)) {
+            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
+#endif
+        }
+    } else {
+        if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) <= sizeof(long)) {
+            return PyInt_FromLong((long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) <= sizeof(PY_LONG_LONG)) {
+            return PyLong_FromLongLong((PY_LONG_LONG) value);
+#endif
+        }
+    }
+    {
+        int one = 1; int little = (int)*(unsigned char *)&one;
+        unsigned char *bytes = (unsigned char *)&value;
+        return _PyLong_FromByteArray(bytes, sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState),
+                                     little, !is_unsigned);
+    }
+}
+
+/* CIntToPy */
+                static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint64_t(uint64_t value) {
+    const uint64_t neg_one = (uint64_t) -1, const_zero = (uint64_t) 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (is_unsigned) {
+        if (sizeof(uint64_t) < sizeof(long)) {
+            return PyInt_FromLong((long) value);
+        } else if (sizeof(uint64_t) <= sizeof(unsigned long)) {
+            return PyLong_FromUnsignedLong((unsigned long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(uint64_t) <= sizeof(unsigned PY_LONG_LONG)) {
+            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
+#endif
+        }
+    } else {
+        if (sizeof(uint64_t) <= sizeof(long)) {
+            return PyInt_FromLong((long) value);
+#ifdef HAVE_LONG_LONG
+        } else if (sizeof(uint64_t) <= sizeof(PY_LONG_LONG)) {
+            return PyLong_FromLongLong((PY_LONG_LONG) value);
+#endif
+        }
+    }
+    {
+        int one = 1; int little = (int)*(unsigned char *)&one;
+        unsigned char *bytes = (unsigned char *)&value;
+        return _PyLong_FromByteArray(bytes, sizeof(uint64_t),
+                                     little, !is_unsigned);
+    }
+}
+
+/* CIntFromPy */
+                static CYTHON_INLINE uint32_t __Pyx_PyInt_As_uint32_t(PyObject *x) {
+    const uint32_t neg_one = (uint32_t) -1, const_zero = (uint32_t) 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_MAJOR_VERSION < 3
+    if (likely(PyInt_Check(x))) {
+        if (sizeof(uint32_t) < sizeof(long)) {
+            __PYX_VERIFY_RETURN_INT(uint32_t, long, PyInt_AS_LONG(x))
+        } else {
+            long val = PyInt_AS_LONG(x);
+            if (is_unsigned && unlikely(val < 0)) {
+                goto raise_neg_overflow;
+            }
+            return (uint32_t) val;
+        }
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+#if CYTHON_USE_PYLONG_INTERNALS
+            const digit* digits = ((PyLongObject*)x)->ob_digit;
+            switch (Py_SIZE(x)) {
+                case  0: return (uint32_t) 0;
+                case  1: __PYX_VERIFY_RETURN_INT(uint32_t, digit, digits[0])
+                case 2:
+                    if (8 * sizeof(uint32_t) > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(uint32_t) >= 2 * PyLong_SHIFT) {
+                            return (uint32_t) (((((uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0]));
+                        }
+                    }
+                    break;
+                case 3:
+                    if (8 * sizeof(uint32_t) > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(uint32_t) >= 3 * PyLong_SHIFT) {
+                            return (uint32_t) (((((((uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0]));
+                        }
+                    }
+                    break;
+                case 4:
+                    if (8 * sizeof(uint32_t) > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(uint32_t) >= 4 * PyLong_SHIFT) {
+                            return (uint32_t) (((((((((uint32_t)digits[3]) << PyLong_SHIFT) | (uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0]));
+                        }
+                    }
+                    break;
+            }
+#endif
+#if CYTHON_COMPILING_IN_CPYTHON
+            if (unlikely(Py_SIZE(x) < 0)) {
+                goto raise_neg_overflow;
+            }
+#else
+            {
+                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
+                if (unlikely(result < 0))
+                    return (uint32_t) -1;
+                if (unlikely(result == 1))
+                    goto raise_neg_overflow;
+            }
+#endif
+            if (sizeof(uint32_t) <= sizeof(unsigned long)) {
+                __PYX_VERIFY_RETURN_INT_EXC(uint32_t, unsigned long, PyLong_AsUnsignedLong(x))
+#ifdef HAVE_LONG_LONG
+            } else if (sizeof(uint32_t) <= sizeof(unsigned PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT_EXC(uint32_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
+#endif
+            }
+        } else {
+#if CYTHON_USE_PYLONG_INTERNALS
+            const digit* digits = ((PyLongObject*)x)->ob_digit;
+            switch (Py_SIZE(x)) {
+                case  0: return (uint32_t) 0;
+                case -1: __PYX_VERIFY_RETURN_INT(uint32_t, sdigit, (sdigit) (-(sdigit)digits[0]))
+                case  1: __PYX_VERIFY_RETURN_INT(uint32_t,  digit, +digits[0])
+                case -2:
+                    if (8 * sizeof(uint32_t) - 1 > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(uint32_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(uint32_t) - 1 > 2 * PyLong_SHIFT) {
+                            return (uint32_t) (((uint32_t)-1)*(((((uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
+                        }
+                    }
+                    break;
+                case 2:
+                    if (8 * sizeof(uint32_t) > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(uint32_t) - 1 > 2 * PyLong_SHIFT) {
+                            return (uint32_t) ((((((uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
+                        }
+                    }
+                    break;
+                case -3:
+                    if (8 * sizeof(uint32_t) - 1 > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(uint32_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(uint32_t) - 1 > 3 * PyLong_SHIFT) {
+                            return (uint32_t) (((uint32_t)-1)*(((((((uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
+                        }
+                    }
+                    break;
+                case 3:
+                    if (8 * sizeof(uint32_t) > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(uint32_t) - 1 > 3 * PyLong_SHIFT) {
+                            return (uint32_t) ((((((((uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
+                        }
+                    }
+                    break;
+                case -4:
+                    if (8 * sizeof(uint32_t) - 1 > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(uint32_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(uint32_t) - 1 > 4 * PyLong_SHIFT) {
+                            return (uint32_t) (((uint32_t)-1)*(((((((((uint32_t)digits[3]) << PyLong_SHIFT) | (uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
+                        }
+                    }
+                    break;
+                case 4:
+                    if (8 * sizeof(uint32_t) > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(uint32_t) - 1 > 4 * PyLong_SHIFT) {
+                            return (uint32_t) ((((((((((uint32_t)digits[3]) << PyLong_SHIFT) | (uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
+                        }
+                    }
+                    break;
+            }
+#endif
+            if (sizeof(uint32_t) <= sizeof(long)) {
+                __PYX_VERIFY_RETURN_INT_EXC(uint32_t, long, PyLong_AsLong(x))
+#ifdef HAVE_LONG_LONG
+            } else if (sizeof(uint32_t) <= sizeof(PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT_EXC(uint32_t, PY_LONG_LONG, PyLong_AsLongLong(x))
+#endif
+            }
+        }
+        {
+#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
+            PyErr_SetString(PyExc_RuntimeError,
+                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
+#else
+            uint32_t val;
+            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
+ #if PY_MAJOR_VERSION < 3
+            if (likely(v) && !PyLong_Check(v)) {
+                PyObject *tmp = v;
+                v = PyNumber_Long(tmp);
+                Py_DECREF(tmp);
+            }
+ #endif
+            if (likely(v)) {
+                int one = 1; int is_little = (int)*(unsigned char *)&one;
+                unsigned char *bytes = (unsigned char *)&val;
+                int ret = _PyLong_AsByteArray((PyLongObject *)v,
+                                              bytes, sizeof(val),
+                                              is_little, !is_unsigned);
+                Py_DECREF(v);
+                if (likely(!ret))
+                    return val;
+            }
+#endif
+            return (uint32_t) -1;
+        }
+    } else {
+        uint32_t val;
+        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
+        if (!tmp) return (uint32_t) -1;
+        val = __Pyx_PyInt_As_uint32_t(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+raise_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "value too large to convert to uint32_t");
+    return (uint32_t) -1;
+raise_neg_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "can't convert negative value to uint32_t");
+    return (uint32_t) -1;
+}
+
+/* CIntFromPy */
+                static CYTHON_INLINE enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat __Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_CodecFormat(PyObject *x) {
+    const enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat neg_one = (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) -1, const_zero = (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_MAJOR_VERSION < 3
+    if (likely(PyInt_Check(x))) {
+        if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) < sizeof(long)) {
+            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat, long, PyInt_AS_LONG(x))
+        } else {
+            long val = PyInt_AS_LONG(x);
+            if (is_unsigned && unlikely(val < 0)) {
+                goto raise_neg_overflow;
+            }
+            return (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) val;
+        }
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+#if CYTHON_USE_PYLONG_INTERNALS
+            const digit* digits = ((PyLongObject*)x)->ob_digit;
+            switch (Py_SIZE(x)) {
+                case  0: return (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) 0;
+                case  1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat, digit, digits[0])
+                case 2:
+                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) >= 2 * PyLong_SHIFT) {
+                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) (((((enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[0]));
+                        }
+                    }
+                    break;
+                case 3:
+                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) >= 3 * PyLong_SHIFT) {
+                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) (((((((enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[0]));
+                        }
+                    }
+                    break;
+                case 4:
+                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) >= 4 * PyLong_SHIFT) {
+                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) (((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[0]));
+                        }
+                    }
+                    break;
+            }
+#endif
+#if CYTHON_COMPILING_IN_CPYTHON
+            if (unlikely(Py_SIZE(x) < 0)) {
+                goto raise_neg_overflow;
+            }
+#else
+            {
+                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
+                if (unlikely(result < 0))
+                    return (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) -1;
+                if (unlikely(result == 1))
+                    goto raise_neg_overflow;
+            }
+#endif
+            if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) <= sizeof(unsigned long)) {
+                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat, unsigned long, PyLong_AsUnsignedLong(x))
+#ifdef HAVE_LONG_LONG
+            } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) <= sizeof(unsigned PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
+#endif
+            }
+        } else {
+#if CYTHON_USE_PYLONG_INTERNALS
+            const digit* digits = ((PyLongObject*)x)->ob_digit;
+            switch (Py_SIZE(x)) {
+                case  0: return (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) 0;
+                case -1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat, sdigit, (sdigit) (-(sdigit)digits[0]))
+                case  1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat,  digit, +digits[0])
+                case -2:
+                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) - 1 > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) - 1 > 2 * PyLong_SHIFT) {
+                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) (((enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)-1)*(((((enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[0])));
+                        }
+                    }
+                    break;
+                case 2:
+                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) - 1 > 2 * PyLong_SHIFT) {
+                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) ((((((enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[0])));
+                        }
+                    }
+                    break;
+                case -3:
+                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) - 1 > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) - 1 > 3 * PyLong_SHIFT) {
+                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) (((enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)-1)*(((((((enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[0])));
+                        }
+                    }
+                    break;
+                case 3:
+                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) - 1 > 3 * PyLong_SHIFT) {
+                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) ((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[0])));
+                        }
+                    }
+                    break;
+                case -4:
+                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) - 1 > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) - 1 > 4 * PyLong_SHIFT) {
+                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) (((enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)-1)*(((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[0])));
+                        }
+                    }
+                    break;
+                case 4:
+                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) - 1 > 4 * PyLong_SHIFT) {
+                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) ((((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat)digits[0])));
+                        }
+                    }
+                    break;
+            }
+#endif
+            if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) <= sizeof(long)) {
+                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat, long, PyLong_AsLong(x))
+#ifdef HAVE_LONG_LONG
+            } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) <= sizeof(PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat, PY_LONG_LONG, PyLong_AsLongLong(x))
+#endif
+            }
+        }
+        {
+#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
+            PyErr_SetString(PyExc_RuntimeError,
+                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
+#else
+            enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat val;
+            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
+ #if PY_MAJOR_VERSION < 3
+            if (likely(v) && !PyLong_Check(v)) {
+                PyObject *tmp = v;
+                v = PyNumber_Long(tmp);
+                Py_DECREF(tmp);
+            }
+ #endif
+            if (likely(v)) {
+                int one = 1; int is_little = (int)*(unsigned char *)&one;
+                unsigned char *bytes = (unsigned char *)&val;
+                int ret = _PyLong_AsByteArray((PyLongObject *)v,
+                                              bytes, sizeof(val),
+                                              is_little, !is_unsigned);
+                Py_DECREF(v);
+                if (likely(!ret))
+                    return val;
+            }
+#endif
+            return (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) -1;
+        }
+    } else {
+        enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat val;
+        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
+        if (!tmp) return (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) -1;
+        val = __Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_CodecFormat(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+raise_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "value too large to convert to enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat");
+    return (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) -1;
+raise_neg_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "can't convert negative value to enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat");
+    return (enum __pyx_t_7asyncpg_8protocol_8protocol_CodecFormat) -1;
+}
+
+/* CIntFromPy */
+                static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
+    const int neg_one = (int) -1, const_zero = (int) 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_MAJOR_VERSION < 3
+    if (likely(PyInt_Check(x))) {
+        if (sizeof(int) < sizeof(long)) {
+            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
+        } else {
+            long val = PyInt_AS_LONG(x);
+            if (is_unsigned && unlikely(val < 0)) {
+                goto raise_neg_overflow;
+            }
+            return (int) val;
+        }
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+#if CYTHON_USE_PYLONG_INTERNALS
+            const digit* digits = ((PyLongObject*)x)->ob_digit;
+            switch (Py_SIZE(x)) {
+                case  0: return (int) 0;
+                case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
+                case 2:
+                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
+                            return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
+                        }
+                    }
+                    break;
+                case 3:
+                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
+                            return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
+                        }
+                    }
+                    break;
+                case 4:
+                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
+                            return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
+                        }
+                    }
+                    break;
+            }
+#endif
+#if CYTHON_COMPILING_IN_CPYTHON
+            if (unlikely(Py_SIZE(x) < 0)) {
+                goto raise_neg_overflow;
+            }
+#else
+            {
+                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
+                if (unlikely(result < 0))
+                    return (int) -1;
+                if (unlikely(result == 1))
+                    goto raise_neg_overflow;
+            }
+#endif
+            if (sizeof(int) <= sizeof(unsigned long)) {
+                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
+#ifdef HAVE_LONG_LONG
+            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
+#endif
+            }
+        } else {
+#if CYTHON_USE_PYLONG_INTERNALS
+            const digit* digits = ((PyLongObject*)x)->ob_digit;
+            switch (Py_SIZE(x)) {
+                case  0: return (int) 0;
+                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
+                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
+                case -2:
+                    if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
+                            return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
+                        }
+                    }
+                    break;
+                case 2:
+                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
+                            return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
+                        }
+                    }
+                    break;
+                case -3:
+                    if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
+                            return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
+                        }
+                    }
+                    break;
+                case 3:
+                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
+                            return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
+                        }
+                    }
+                    break;
+                case -4:
+                    if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
+                            return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
+                        }
+                    }
+                    break;
+                case 4:
+                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
+                            return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
+                        }
+                    }
+                    break;
+            }
+#endif
+            if (sizeof(int) <= sizeof(long)) {
+                __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
+#ifdef HAVE_LONG_LONG
+            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
+#endif
+            }
+        }
+        {
+#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
+            PyErr_SetString(PyExc_RuntimeError,
+                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
+#else
+            int val;
+            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
+ #if PY_MAJOR_VERSION < 3
+            if (likely(v) && !PyLong_Check(v)) {
+                PyObject *tmp = v;
+                v = PyNumber_Long(tmp);
+                Py_DECREF(tmp);
+            }
+ #endif
+            if (likely(v)) {
+                int one = 1; int is_little = (int)*(unsigned char *)&one;
+                unsigned char *bytes = (unsigned char *)&val;
+                int ret = _PyLong_AsByteArray((PyLongObject *)v,
+                                              bytes, sizeof(val),
+                                              is_little, !is_unsigned);
+                Py_DECREF(v);
+                if (likely(!ret))
+                    return val;
+            }
+#endif
+            return (int) -1;
+        }
+    } else {
+        int val;
+        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
+        if (!tmp) return (int) -1;
+        val = __Pyx_PyInt_As_int(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+raise_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "value too large to convert to int");
+    return (int) -1;
+raise_neg_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "can't convert negative value to int");
+    return (int) -1;
+}
+
+/* CIntFromPy */
+                static CYTHON_INLINE int64_t __Pyx_PyInt_As_int64_t(PyObject *x) {
+    const int64_t neg_one = (int64_t) -1, const_zero = (int64_t) 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_MAJOR_VERSION < 3
+    if (likely(PyInt_Check(x))) {
+        if (sizeof(int64_t) < sizeof(long)) {
+            __PYX_VERIFY_RETURN_INT(int64_t, long, PyInt_AS_LONG(x))
+        } else {
+            long val = PyInt_AS_LONG(x);
+            if (is_unsigned && unlikely(val < 0)) {
+                goto raise_neg_overflow;
+            }
+            return (int64_t) val;
+        }
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+#if CYTHON_USE_PYLONG_INTERNALS
+            const digit* digits = ((PyLongObject*)x)->ob_digit;
+            switch (Py_SIZE(x)) {
+                case  0: return (int64_t) 0;
+                case  1: __PYX_VERIFY_RETURN_INT(int64_t, digit, digits[0])
+                case 2:
+                    if (8 * sizeof(int64_t) > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int64_t) >= 2 * PyLong_SHIFT) {
+                            return (int64_t) (((((int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0]));
+                        }
+                    }
+                    break;
+                case 3:
+                    if (8 * sizeof(int64_t) > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int64_t) >= 3 * PyLong_SHIFT) {
+                            return (int64_t) (((((((int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0]));
+                        }
+                    }
+                    break;
+                case 4:
+                    if (8 * sizeof(int64_t) > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int64_t) >= 4 * PyLong_SHIFT) {
+                            return (int64_t) (((((((((int64_t)digits[3]) << PyLong_SHIFT) | (int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0]));
+                        }
+                    }
+                    break;
+            }
+#endif
+#if CYTHON_COMPILING_IN_CPYTHON
+            if (unlikely(Py_SIZE(x) < 0)) {
+                goto raise_neg_overflow;
+            }
+#else
+            {
+                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
+                if (unlikely(result < 0))
+                    return (int64_t) -1;
+                if (unlikely(result == 1))
+                    goto raise_neg_overflow;
+            }
+#endif
+            if (sizeof(int64_t) <= sizeof(unsigned long)) {
+                __PYX_VERIFY_RETURN_INT_EXC(int64_t, unsigned long, PyLong_AsUnsignedLong(x))
+#ifdef HAVE_LONG_LONG
+            } else if (sizeof(int64_t) <= sizeof(unsigned PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT_EXC(int64_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
+#endif
+            }
+        } else {
+#if CYTHON_USE_PYLONG_INTERNALS
+            const digit* digits = ((PyLongObject*)x)->ob_digit;
+            switch (Py_SIZE(x)) {
+                case  0: return (int64_t) 0;
+                case -1: __PYX_VERIFY_RETURN_INT(int64_t, sdigit, (sdigit) (-(sdigit)digits[0]))
+                case  1: __PYX_VERIFY_RETURN_INT(int64_t,  digit, +digits[0])
+                case -2:
+                    if (8 * sizeof(int64_t) - 1 > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int64_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int64_t) - 1 > 2 * PyLong_SHIFT) {
+                            return (int64_t) (((int64_t)-1)*(((((int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
+                        }
+                    }
+                    break;
+                case 2:
+                    if (8 * sizeof(int64_t) > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int64_t) - 1 > 2 * PyLong_SHIFT) {
+                            return (int64_t) ((((((int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
+                        }
+                    }
+                    break;
+                case -3:
+                    if (8 * sizeof(int64_t) - 1 > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int64_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int64_t) - 1 > 3 * PyLong_SHIFT) {
+                            return (int64_t) (((int64_t)-1)*(((((((int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
+                        }
+                    }
+                    break;
+                case 3:
+                    if (8 * sizeof(int64_t) > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int64_t) - 1 > 3 * PyLong_SHIFT) {
+                            return (int64_t) ((((((((int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
+                        }
+                    }
+                    break;
+                case -4:
+                    if (8 * sizeof(int64_t) - 1 > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int64_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int64_t) - 1 > 4 * PyLong_SHIFT) {
+                            return (int64_t) (((int64_t)-1)*(((((((((int64_t)digits[3]) << PyLong_SHIFT) | (int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
+                        }
+                    }
+                    break;
+                case 4:
+                    if (8 * sizeof(int64_t) > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int64_t) - 1 > 4 * PyLong_SHIFT) {
+                            return (int64_t) ((((((((((int64_t)digits[3]) << PyLong_SHIFT) | (int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
+                        }
+                    }
+                    break;
+            }
+#endif
+            if (sizeof(int64_t) <= sizeof(long)) {
+                __PYX_VERIFY_RETURN_INT_EXC(int64_t, long, PyLong_AsLong(x))
+#ifdef HAVE_LONG_LONG
+            } else if (sizeof(int64_t) <= sizeof(PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT_EXC(int64_t, PY_LONG_LONG, PyLong_AsLongLong(x))
+#endif
+            }
+        }
+        {
+#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
+            PyErr_SetString(PyExc_RuntimeError,
+                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
+#else
+            int64_t val;
+            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
+ #if PY_MAJOR_VERSION < 3
+            if (likely(v) && !PyLong_Check(v)) {
+                PyObject *tmp = v;
+                v = PyNumber_Long(tmp);
+                Py_DECREF(tmp);
+            }
+ #endif
+            if (likely(v)) {
+                int one = 1; int is_little = (int)*(unsigned char *)&one;
+                unsigned char *bytes = (unsigned char *)&val;
+                int ret = _PyLong_AsByteArray((PyLongObject *)v,
+                                              bytes, sizeof(val),
+                                              is_little, !is_unsigned);
+                Py_DECREF(v);
+                if (likely(!ret))
+                    return val;
+            }
+#endif
+            return (int64_t) -1;
+        }
+    } else {
+        int64_t val;
+        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
+        if (!tmp) return (int64_t) -1;
+        val = __Pyx_PyInt_As_int64_t(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+raise_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "value too large to convert to int64_t");
+    return (int64_t) -1;
+raise_neg_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "can't convert negative value to int64_t");
+    return (int64_t) -1;
+}
+
+/* CIntFromPy */
+                static CYTHON_INLINE int32_t __Pyx_PyInt_As_int32_t(PyObject *x) {
+    const int32_t neg_one = (int32_t) -1, const_zero = (int32_t) 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_MAJOR_VERSION < 3
+    if (likely(PyInt_Check(x))) {
+        if (sizeof(int32_t) < sizeof(long)) {
+            __PYX_VERIFY_RETURN_INT(int32_t, long, PyInt_AS_LONG(x))
+        } else {
+            long val = PyInt_AS_LONG(x);
+            if (is_unsigned && unlikely(val < 0)) {
+                goto raise_neg_overflow;
+            }
+            return (int32_t) val;
+        }
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+#if CYTHON_USE_PYLONG_INTERNALS
+            const digit* digits = ((PyLongObject*)x)->ob_digit;
+            switch (Py_SIZE(x)) {
+                case  0: return (int32_t) 0;
+                case  1: __PYX_VERIFY_RETURN_INT(int32_t, digit, digits[0])
+                case 2:
+                    if (8 * sizeof(int32_t) > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int32_t) >= 2 * PyLong_SHIFT) {
+                            return (int32_t) (((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]));
+                        }
+                    }
+                    break;
+                case 3:
+                    if (8 * sizeof(int32_t) > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int32_t) >= 3 * PyLong_SHIFT) {
+                            return (int32_t) (((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]));
+                        }
+                    }
+                    break;
+                case 4:
+                    if (8 * sizeof(int32_t) > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int32_t) >= 4 * PyLong_SHIFT) {
+                            return (int32_t) (((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]));
+                        }
+                    }
+                    break;
+            }
+#endif
+#if CYTHON_COMPILING_IN_CPYTHON
+            if (unlikely(Py_SIZE(x) < 0)) {
+                goto raise_neg_overflow;
+            }
+#else
+            {
+                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
+                if (unlikely(result < 0))
+                    return (int32_t) -1;
+                if (unlikely(result == 1))
+                    goto raise_neg_overflow;
+            }
+#endif
+            if (sizeof(int32_t) <= sizeof(unsigned long)) {
+                __PYX_VERIFY_RETURN_INT_EXC(int32_t, unsigned long, PyLong_AsUnsignedLong(x))
+#ifdef HAVE_LONG_LONG
+            } else if (sizeof(int32_t) <= sizeof(unsigned PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT_EXC(int32_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
+#endif
+            }
+        } else {
+#if CYTHON_USE_PYLONG_INTERNALS
+            const digit* digits = ((PyLongObject*)x)->ob_digit;
+            switch (Py_SIZE(x)) {
+                case  0: return (int32_t) 0;
+                case -1: __PYX_VERIFY_RETURN_INT(int32_t, sdigit, (sdigit) (-(sdigit)digits[0]))
+                case  1: __PYX_VERIFY_RETURN_INT(int32_t,  digit, +digits[0])
+                case -2:
+                    if (8 * sizeof(int32_t) - 1 > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int32_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT) {
+                            return (int32_t) (((int32_t)-1)*(((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
+                        }
+                    }
+                    break;
+                case 2:
+                    if (8 * sizeof(int32_t) > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT) {
+                            return (int32_t) ((((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
+                        }
+                    }
+                    break;
+                case -3:
+                    if (8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int32_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT) {
+                            return (int32_t) (((int32_t)-1)*(((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
+                        }
+                    }
+                    break;
+                case 3:
+                    if (8 * sizeof(int32_t) > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT) {
+                            return (int32_t) ((((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
+                        }
+                    }
+                    break;
+                case -4:
+                    if (8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int32_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int32_t) - 1 > 4 * PyLong_SHIFT) {
+                            return (int32_t) (((int32_t)-1)*(((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
+                        }
+                    }
+                    break;
+                case 4:
+                    if (8 * sizeof(int32_t) > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int32_t) - 1 > 4 * PyLong_SHIFT) {
+                            return (int32_t) ((((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
+                        }
+                    }
+                    break;
+            }
+#endif
+            if (sizeof(int32_t) <= sizeof(long)) {
+                __PYX_VERIFY_RETURN_INT_EXC(int32_t, long, PyLong_AsLong(x))
+#ifdef HAVE_LONG_LONG
+            } else if (sizeof(int32_t) <= sizeof(PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT_EXC(int32_t, PY_LONG_LONG, PyLong_AsLongLong(x))
+#endif
+            }
+        }
+        {
+#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
+            PyErr_SetString(PyExc_RuntimeError,
+                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
+#else
+            int32_t val;
+            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
+ #if PY_MAJOR_VERSION < 3
+            if (likely(v) && !PyLong_Check(v)) {
+                PyObject *tmp = v;
+                v = PyNumber_Long(tmp);
+                Py_DECREF(tmp);
+            }
+ #endif
+            if (likely(v)) {
+                int one = 1; int is_little = (int)*(unsigned char *)&one;
+                unsigned char *bytes = (unsigned char *)&val;
+                int ret = _PyLong_AsByteArray((PyLongObject *)v,
+                                              bytes, sizeof(val),
+                                              is_little, !is_unsigned);
+                Py_DECREF(v);
+                if (likely(!ret))
+                    return val;
+            }
+#endif
+            return (int32_t) -1;
+        }
+    } else {
+        int32_t val;
+        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
+        if (!tmp) return (int32_t) -1;
+        val = __Pyx_PyInt_As_int32_t(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+raise_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "value too large to convert to int32_t");
+    return (int32_t) -1;
+raise_neg_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "can't convert negative value to int32_t");
+    return (int32_t) -1;
+}
+
+/* CIntFromPy */
+                static CYTHON_INLINE int8_t __Pyx_PyInt_As_int8_t(PyObject *x) {
+    const int8_t neg_one = (int8_t) -1, const_zero = (int8_t) 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_MAJOR_VERSION < 3
+    if (likely(PyInt_Check(x))) {
+        if (sizeof(int8_t) < sizeof(long)) {
+            __PYX_VERIFY_RETURN_INT(int8_t, long, PyInt_AS_LONG(x))
+        } else {
+            long val = PyInt_AS_LONG(x);
+            if (is_unsigned && unlikely(val < 0)) {
+                goto raise_neg_overflow;
+            }
+            return (int8_t) val;
+        }
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+#if CYTHON_USE_PYLONG_INTERNALS
+            const digit* digits = ((PyLongObject*)x)->ob_digit;
+            switch (Py_SIZE(x)) {
+                case  0: return (int8_t) 0;
+                case  1: __PYX_VERIFY_RETURN_INT(int8_t, digit, digits[0])
+                case 2:
+                    if (8 * sizeof(int8_t) > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int8_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int8_t) >= 2 * PyLong_SHIFT) {
+                            return (int8_t) (((((int8_t)digits[1]) << PyLong_SHIFT) | (int8_t)digits[0]));
+                        }
+                    }
+                    break;
+                case 3:
+                    if (8 * sizeof(int8_t) > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int8_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int8_t) >= 3 * PyLong_SHIFT) {
+                            return (int8_t) (((((((int8_t)digits[2]) << PyLong_SHIFT) | (int8_t)digits[1]) << PyLong_SHIFT) | (int8_t)digits[0]));
+                        }
+                    }
+                    break;
+                case 4:
+                    if (8 * sizeof(int8_t) > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int8_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int8_t) >= 4 * PyLong_SHIFT) {
+                            return (int8_t) (((((((((int8_t)digits[3]) << PyLong_SHIFT) | (int8_t)digits[2]) << PyLong_SHIFT) | (int8_t)digits[1]) << PyLong_SHIFT) | (int8_t)digits[0]));
+                        }
+                    }
+                    break;
+            }
+#endif
+#if CYTHON_COMPILING_IN_CPYTHON
+            if (unlikely(Py_SIZE(x) < 0)) {
+                goto raise_neg_overflow;
+            }
+#else
+            {
+                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
+                if (unlikely(result < 0))
+                    return (int8_t) -1;
+                if (unlikely(result == 1))
+                    goto raise_neg_overflow;
+            }
+#endif
+            if (sizeof(int8_t) <= sizeof(unsigned long)) {
+                __PYX_VERIFY_RETURN_INT_EXC(int8_t, unsigned long, PyLong_AsUnsignedLong(x))
+#ifdef HAVE_LONG_LONG
+            } else if (sizeof(int8_t) <= sizeof(unsigned PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT_EXC(int8_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
+#endif
+            }
+        } else {
+#if CYTHON_USE_PYLONG_INTERNALS
+            const digit* digits = ((PyLongObject*)x)->ob_digit;
+            switch (Py_SIZE(x)) {
+                case  0: return (int8_t) 0;
+                case -1: __PYX_VERIFY_RETURN_INT(int8_t, sdigit, (sdigit) (-(sdigit)digits[0]))
+                case  1: __PYX_VERIFY_RETURN_INT(int8_t,  digit, +digits[0])
+                case -2:
+                    if (8 * sizeof(int8_t) - 1 > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int8_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int8_t) - 1 > 2 * PyLong_SHIFT) {
+                            return (int8_t) (((int8_t)-1)*(((((int8_t)digits[1]) << PyLong_SHIFT) | (int8_t)digits[0])));
+                        }
+                    }
+                    break;
+                case 2:
+                    if (8 * sizeof(int8_t) > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int8_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int8_t) - 1 > 2 * PyLong_SHIFT) {
+                            return (int8_t) ((((((int8_t)digits[1]) << PyLong_SHIFT) | (int8_t)digits[0])));
+                        }
+                    }
+                    break;
+                case -3:
+                    if (8 * sizeof(int8_t) - 1 > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int8_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int8_t) - 1 > 3 * PyLong_SHIFT) {
+                            return (int8_t) (((int8_t)-1)*(((((((int8_t)digits[2]) << PyLong_SHIFT) | (int8_t)digits[1]) << PyLong_SHIFT) | (int8_t)digits[0])));
+                        }
+                    }
+                    break;
+                case 3:
+                    if (8 * sizeof(int8_t) > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int8_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int8_t) - 1 > 3 * PyLong_SHIFT) {
+                            return (int8_t) ((((((((int8_t)digits[2]) << PyLong_SHIFT) | (int8_t)digits[1]) << PyLong_SHIFT) | (int8_t)digits[0])));
+                        }
+                    }
+                    break;
+                case -4:
+                    if (8 * sizeof(int8_t) - 1 > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int8_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int8_t) - 1 > 4 * PyLong_SHIFT) {
+                            return (int8_t) (((int8_t)-1)*(((((((((int8_t)digits[3]) << PyLong_SHIFT) | (int8_t)digits[2]) << PyLong_SHIFT) | (int8_t)digits[1]) << PyLong_SHIFT) | (int8_t)digits[0])));
+                        }
+                    }
+                    break;
+                case 4:
+                    if (8 * sizeof(int8_t) > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int8_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int8_t) - 1 > 4 * PyLong_SHIFT) {
+                            return (int8_t) ((((((((((int8_t)digits[3]) << PyLong_SHIFT) | (int8_t)digits[2]) << PyLong_SHIFT) | (int8_t)digits[1]) << PyLong_SHIFT) | (int8_t)digits[0])));
+                        }
+                    }
+                    break;
+            }
+#endif
+            if (sizeof(int8_t) <= sizeof(long)) {
+                __PYX_VERIFY_RETURN_INT_EXC(int8_t, long, PyLong_AsLong(x))
+#ifdef HAVE_LONG_LONG
+            } else if (sizeof(int8_t) <= sizeof(PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT_EXC(int8_t, PY_LONG_LONG, PyLong_AsLongLong(x))
+#endif
+            }
+        }
+        {
+#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
+            PyErr_SetString(PyExc_RuntimeError,
+                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
+#else
+            int8_t val;
+            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
+ #if PY_MAJOR_VERSION < 3
+            if (likely(v) && !PyLong_Check(v)) {
+                PyObject *tmp = v;
+                v = PyNumber_Long(tmp);
+                Py_DECREF(tmp);
+            }
+ #endif
+            if (likely(v)) {
+                int one = 1; int is_little = (int)*(unsigned char *)&one;
+                unsigned char *bytes = (unsigned char *)&val;
+                int ret = _PyLong_AsByteArray((PyLongObject *)v,
+                                              bytes, sizeof(val),
+                                              is_little, !is_unsigned);
+                Py_DECREF(v);
+                if (likely(!ret))
+                    return val;
+            }
+#endif
+            return (int8_t) -1;
+        }
+    } else {
+        int8_t val;
+        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
+        if (!tmp) return (int8_t) -1;
+        val = __Pyx_PyInt_As_int8_t(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+raise_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "value too large to convert to int8_t");
+    return (int8_t) -1;
+raise_neg_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "can't convert negative value to int8_t");
+    return (int8_t) -1;
+}
+
+/* CIntFromPy */
+                static CYTHON_INLINE uint8_t __Pyx_PyInt_As_uint8_t(PyObject *x) {
+    const uint8_t neg_one = (uint8_t) -1, const_zero = (uint8_t) 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_MAJOR_VERSION < 3
+    if (likely(PyInt_Check(x))) {
+        if (sizeof(uint8_t) < sizeof(long)) {
+            __PYX_VERIFY_RETURN_INT(uint8_t, long, PyInt_AS_LONG(x))
+        } else {
+            long val = PyInt_AS_LONG(x);
+            if (is_unsigned && unlikely(val < 0)) {
+                goto raise_neg_overflow;
+            }
+            return (uint8_t) val;
+        }
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+#if CYTHON_USE_PYLONG_INTERNALS
+            const digit* digits = ((PyLongObject*)x)->ob_digit;
+            switch (Py_SIZE(x)) {
+                case  0: return (uint8_t) 0;
+                case  1: __PYX_VERIFY_RETURN_INT(uint8_t, digit, digits[0])
+                case 2:
+                    if (8 * sizeof(uint8_t) > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(uint8_t) >= 2 * PyLong_SHIFT) {
+                            return (uint8_t) (((((uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0]));
+                        }
+                    }
+                    break;
+                case 3:
+                    if (8 * sizeof(uint8_t) > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(uint8_t) >= 3 * PyLong_SHIFT) {
+                            return (uint8_t) (((((((uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0]));
+                        }
+                    }
+                    break;
+                case 4:
+                    if (8 * sizeof(uint8_t) > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(uint8_t) >= 4 * PyLong_SHIFT) {
+                            return (uint8_t) (((((((((uint8_t)digits[3]) << PyLong_SHIFT) | (uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0]));
+                        }
+                    }
+                    break;
+            }
+#endif
+#if CYTHON_COMPILING_IN_CPYTHON
+            if (unlikely(Py_SIZE(x) < 0)) {
+                goto raise_neg_overflow;
+            }
+#else
+            {
+                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
+                if (unlikely(result < 0))
+                    return (uint8_t) -1;
+                if (unlikely(result == 1))
+                    goto raise_neg_overflow;
+            }
+#endif
+            if (sizeof(uint8_t) <= sizeof(unsigned long)) {
+                __PYX_VERIFY_RETURN_INT_EXC(uint8_t, unsigned long, PyLong_AsUnsignedLong(x))
+#ifdef HAVE_LONG_LONG
+            } else if (sizeof(uint8_t) <= sizeof(unsigned PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT_EXC(uint8_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
+#endif
+            }
+        } else {
+#if CYTHON_USE_PYLONG_INTERNALS
+            const digit* digits = ((PyLongObject*)x)->ob_digit;
+            switch (Py_SIZE(x)) {
+                case  0: return (uint8_t) 0;
+                case -1: __PYX_VERIFY_RETURN_INT(uint8_t, sdigit, (sdigit) (-(sdigit)digits[0]))
+                case  1: __PYX_VERIFY_RETURN_INT(uint8_t,  digit, +digits[0])
+                case -2:
+                    if (8 * sizeof(uint8_t) - 1 > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(uint8_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(uint8_t) - 1 > 2 * PyLong_SHIFT) {
+                            return (uint8_t) (((uint8_t)-1)*(((((uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
+                        }
+                    }
+                    break;
+                case 2:
+                    if (8 * sizeof(uint8_t) > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(uint8_t) - 1 > 2 * PyLong_SHIFT) {
+                            return (uint8_t) ((((((uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
+                        }
+                    }
+                    break;
+                case -3:
+                    if (8 * sizeof(uint8_t) - 1 > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(uint8_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(uint8_t) - 1 > 3 * PyLong_SHIFT) {
+                            return (uint8_t) (((uint8_t)-1)*(((((((uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
+                        }
+                    }
+                    break;
+                case 3:
+                    if (8 * sizeof(uint8_t) > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(uint8_t) - 1 > 3 * PyLong_SHIFT) {
+                            return (uint8_t) ((((((((uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
+                        }
+                    }
+                    break;
+                case -4:
+                    if (8 * sizeof(uint8_t) - 1 > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(uint8_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(uint8_t) - 1 > 4 * PyLong_SHIFT) {
+                            return (uint8_t) (((uint8_t)-1)*(((((((((uint8_t)digits[3]) << PyLong_SHIFT) | (uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
+                        }
+                    }
+                    break;
+                case 4:
+                    if (8 * sizeof(uint8_t) > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(uint8_t) - 1 > 4 * PyLong_SHIFT) {
+                            return (uint8_t) ((((((((((uint8_t)digits[3]) << PyLong_SHIFT) | (uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
+                        }
+                    }
+                    break;
+            }
+#endif
+            if (sizeof(uint8_t) <= sizeof(long)) {
+                __PYX_VERIFY_RETURN_INT_EXC(uint8_t, long, PyLong_AsLong(x))
+#ifdef HAVE_LONG_LONG
+            } else if (sizeof(uint8_t) <= sizeof(PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT_EXC(uint8_t, PY_LONG_LONG, PyLong_AsLongLong(x))
+#endif
+            }
+        }
+        {
+#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
+            PyErr_SetString(PyExc_RuntimeError,
+                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
+#else
+            uint8_t val;
+            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
+ #if PY_MAJOR_VERSION < 3
+            if (likely(v) && !PyLong_Check(v)) {
+                PyObject *tmp = v;
+                v = PyNumber_Long(tmp);
+                Py_DECREF(tmp);
+            }
+ #endif
+            if (likely(v)) {
+                int one = 1; int is_little = (int)*(unsigned char *)&one;
+                unsigned char *bytes = (unsigned char *)&val;
+                int ret = _PyLong_AsByteArray((PyLongObject *)v,
+                                              bytes, sizeof(val),
+                                              is_little, !is_unsigned);
+                Py_DECREF(v);
+                if (likely(!ret))
+                    return val;
+            }
+#endif
+            return (uint8_t) -1;
+        }
+    } else {
+        uint8_t val;
+        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
+        if (!tmp) return (uint8_t) -1;
+        val = __Pyx_PyInt_As_uint8_t(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+raise_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "value too large to convert to uint8_t");
+    return (uint8_t) -1;
+raise_neg_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "can't convert negative value to uint8_t");
+    return (uint8_t) -1;
+}
+
+/* CIntFromPy */
+                static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) {
+    const char neg_one = (char) -1, const_zero = (char) 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_MAJOR_VERSION < 3
+    if (likely(PyInt_Check(x))) {
+        if (sizeof(char) < sizeof(long)) {
+            __PYX_VERIFY_RETURN_INT(char, long, PyInt_AS_LONG(x))
+        } else {
+            long val = PyInt_AS_LONG(x);
+            if (is_unsigned && unlikely(val < 0)) {
+                goto raise_neg_overflow;
+            }
+            return (char) val;
+        }
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+#if CYTHON_USE_PYLONG_INTERNALS
+            const digit* digits = ((PyLongObject*)x)->ob_digit;
+            switch (Py_SIZE(x)) {
+                case  0: return (char) 0;
+                case  1: __PYX_VERIFY_RETURN_INT(char, digit, digits[0])
+                case 2:
+                    if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(char) >= 2 * PyLong_SHIFT) {
+                            return (char) (((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
+                        }
+                    }
+                    break;
+                case 3:
+                    if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(char) >= 3 * PyLong_SHIFT) {
+                            return (char) (((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
+                        }
+                    }
+                    break;
+                case 4:
+                    if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(char) >= 4 * PyLong_SHIFT) {
+                            return (char) (((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
+                        }
+                    }
+                    break;
+            }
+#endif
+#if CYTHON_COMPILING_IN_CPYTHON
+            if (unlikely(Py_SIZE(x) < 0)) {
+                goto raise_neg_overflow;
+            }
+#else
+            {
+                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
+                if (unlikely(result < 0))
+                    return (char) -1;
+                if (unlikely(result == 1))
+                    goto raise_neg_overflow;
+            }
+#endif
+            if (sizeof(char) <= sizeof(unsigned long)) {
+                __PYX_VERIFY_RETURN_INT_EXC(char, unsigned long, PyLong_AsUnsignedLong(x))
+#ifdef HAVE_LONG_LONG
+            } else if (sizeof(char) <= sizeof(unsigned PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT_EXC(char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
+#endif
+            }
+        } else {
+#if CYTHON_USE_PYLONG_INTERNALS
+            const digit* digits = ((PyLongObject*)x)->ob_digit;
+            switch (Py_SIZE(x)) {
+                case  0: return (char) 0;
+                case -1: __PYX_VERIFY_RETURN_INT(char, sdigit, (sdigit) (-(sdigit)digits[0]))
+                case  1: __PYX_VERIFY_RETURN_INT(char,  digit, +digits[0])
+                case -2:
+                    if (8 * sizeof(char) - 1 > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
+                            return (char) (((char)-1)*(((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
+                        }
+                    }
+                    break;
+                case 2:
+                    if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
+                            return (char) ((((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
+                        }
+                    }
+                    break;
+                case -3:
+                    if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
+                            return (char) (((char)-1)*(((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
+                        }
+                    }
+                    break;
+                case 3:
+                    if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
+                            return (char) ((((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
+                        }
+                    }
+                    break;
+                case -4:
+                    if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
+                            return (char) (((char)-1)*(((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
+                        }
+                    }
+                    break;
+                case 4:
+                    if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
+                            return (char) ((((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
+                        }
+                    }
+                    break;
+            }
+#endif
+            if (sizeof(char) <= sizeof(long)) {
+                __PYX_VERIFY_RETURN_INT_EXC(char, long, PyLong_AsLong(x))
+#ifdef HAVE_LONG_LONG
+            } else if (sizeof(char) <= sizeof(PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT_EXC(char, PY_LONG_LONG, PyLong_AsLongLong(x))
+#endif
+            }
+        }
+        {
+#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
+            PyErr_SetString(PyExc_RuntimeError,
+                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
+#else
+            char val;
+            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
+ #if PY_MAJOR_VERSION < 3
+            if (likely(v) && !PyLong_Check(v)) {
+                PyObject *tmp = v;
+                v = PyNumber_Long(tmp);
+                Py_DECREF(tmp);
+            }
+ #endif
+            if (likely(v)) {
+                int one = 1; int is_little = (int)*(unsigned char *)&one;
+                unsigned char *bytes = (unsigned char *)&val;
+                int ret = _PyLong_AsByteArray((PyLongObject *)v,
+                                              bytes, sizeof(val),
+                                              is_little, !is_unsigned);
+                Py_DECREF(v);
+                if (likely(!ret))
+                    return val;
+            }
+#endif
+            return (char) -1;
+        }
+    } else {
+        char val;
+        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
+        if (!tmp) return (char) -1;
+        val = __Pyx_PyInt_As_char(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+raise_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "value too large to convert to char");
+    return (char) -1;
+raise_neg_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "can't convert negative value to char");
+    return (char) -1;
+}
+
+/* CIntFromPy */
+                static CYTHON_INLINE int16_t __Pyx_PyInt_As_int16_t(PyObject *x) {
+    const int16_t neg_one = (int16_t) -1, const_zero = (int16_t) 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_MAJOR_VERSION < 3
+    if (likely(PyInt_Check(x))) {
+        if (sizeof(int16_t) < sizeof(long)) {
+            __PYX_VERIFY_RETURN_INT(int16_t, long, PyInt_AS_LONG(x))
+        } else {
+            long val = PyInt_AS_LONG(x);
+            if (is_unsigned && unlikely(val < 0)) {
+                goto raise_neg_overflow;
+            }
+            return (int16_t) val;
+        }
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+#if CYTHON_USE_PYLONG_INTERNALS
+            const digit* digits = ((PyLongObject*)x)->ob_digit;
+            switch (Py_SIZE(x)) {
+                case  0: return (int16_t) 0;
+                case  1: __PYX_VERIFY_RETURN_INT(int16_t, digit, digits[0])
+                case 2:
+                    if (8 * sizeof(int16_t) > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int16_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int16_t) >= 2 * PyLong_SHIFT) {
+                            return (int16_t) (((((int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0]));
+                        }
+                    }
+                    break;
+                case 3:
+                    if (8 * sizeof(int16_t) > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int16_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int16_t) >= 3 * PyLong_SHIFT) {
+                            return (int16_t) (((((((int16_t)digits[2]) << PyLong_SHIFT) | (int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0]));
+                        }
+                    }
+                    break;
+                case 4:
+                    if (8 * sizeof(int16_t) > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int16_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int16_t) >= 4 * PyLong_SHIFT) {
+                            return (int16_t) (((((((((int16_t)digits[3]) << PyLong_SHIFT) | (int16_t)digits[2]) << PyLong_SHIFT) | (int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0]));
+                        }
+                    }
+                    break;
+            }
+#endif
+#if CYTHON_COMPILING_IN_CPYTHON
+            if (unlikely(Py_SIZE(x) < 0)) {
+                goto raise_neg_overflow;
+            }
+#else
+            {
+                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
+                if (unlikely(result < 0))
+                    return (int16_t) -1;
+                if (unlikely(result == 1))
+                    goto raise_neg_overflow;
+            }
+#endif
+            if (sizeof(int16_t) <= sizeof(unsigned long)) {
+                __PYX_VERIFY_RETURN_INT_EXC(int16_t, unsigned long, PyLong_AsUnsignedLong(x))
+#ifdef HAVE_LONG_LONG
+            } else if (sizeof(int16_t) <= sizeof(unsigned PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT_EXC(int16_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
+#endif
+            }
+        } else {
+#if CYTHON_USE_PYLONG_INTERNALS
+            const digit* digits = ((PyLongObject*)x)->ob_digit;
+            switch (Py_SIZE(x)) {
+                case  0: return (int16_t) 0;
+                case -1: __PYX_VERIFY_RETURN_INT(int16_t, sdigit, (sdigit) (-(sdigit)digits[0]))
+                case  1: __PYX_VERIFY_RETURN_INT(int16_t,  digit, +digits[0])
+                case -2:
+                    if (8 * sizeof(int16_t) - 1 > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int16_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int16_t) - 1 > 2 * PyLong_SHIFT) {
+                            return (int16_t) (((int16_t)-1)*(((((int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0])));
+                        }
+                    }
+                    break;
+                case 2:
+                    if (8 * sizeof(int16_t) > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int16_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int16_t) - 1 > 2 * PyLong_SHIFT) {
+                            return (int16_t) ((((((int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0])));
+                        }
+                    }
+                    break;
+                case -3:
+                    if (8 * sizeof(int16_t) - 1 > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int16_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int16_t) - 1 > 3 * PyLong_SHIFT) {
+                            return (int16_t) (((int16_t)-1)*(((((((int16_t)digits[2]) << PyLong_SHIFT) | (int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0])));
+                        }
+                    }
+                    break;
+                case 3:
+                    if (8 * sizeof(int16_t) > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int16_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int16_t) - 1 > 3 * PyLong_SHIFT) {
+                            return (int16_t) ((((((((int16_t)digits[2]) << PyLong_SHIFT) | (int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0])));
+                        }
+                    }
+                    break;
+                case -4:
+                    if (8 * sizeof(int16_t) - 1 > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int16_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int16_t) - 1 > 4 * PyLong_SHIFT) {
+                            return (int16_t) (((int16_t)-1)*(((((((((int16_t)digits[3]) << PyLong_SHIFT) | (int16_t)digits[2]) << PyLong_SHIFT) | (int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0])));
+                        }
+                    }
+                    break;
+                case 4:
+                    if (8 * sizeof(int16_t) > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(int16_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(int16_t) - 1 > 4 * PyLong_SHIFT) {
+                            return (int16_t) ((((((((((int16_t)digits[3]) << PyLong_SHIFT) | (int16_t)digits[2]) << PyLong_SHIFT) | (int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0])));
+                        }
+                    }
+                    break;
+            }
+#endif
+            if (sizeof(int16_t) <= sizeof(long)) {
+                __PYX_VERIFY_RETURN_INT_EXC(int16_t, long, PyLong_AsLong(x))
+#ifdef HAVE_LONG_LONG
+            } else if (sizeof(int16_t) <= sizeof(PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT_EXC(int16_t, PY_LONG_LONG, PyLong_AsLongLong(x))
+#endif
+            }
+        }
+        {
+#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
+            PyErr_SetString(PyExc_RuntimeError,
+                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
+#else
+            int16_t val;
+            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
+ #if PY_MAJOR_VERSION < 3
+            if (likely(v) && !PyLong_Check(v)) {
+                PyObject *tmp = v;
+                v = PyNumber_Long(tmp);
+                Py_DECREF(tmp);
+            }
+ #endif
+            if (likely(v)) {
+                int one = 1; int is_little = (int)*(unsigned char *)&one;
+                unsigned char *bytes = (unsigned char *)&val;
+                int ret = _PyLong_AsByteArray((PyLongObject *)v,
+                                              bytes, sizeof(val),
+                                              is_little, !is_unsigned);
+                Py_DECREF(v);
+                if (likely(!ret))
+                    return val;
+            }
+#endif
+            return (int16_t) -1;
+        }
+    } else {
+        int16_t val;
+        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
+        if (!tmp) return (int16_t) -1;
+        val = __Pyx_PyInt_As_int16_t(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+raise_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "value too large to convert to int16_t");
+    return (int16_t) -1;
+raise_neg_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "can't convert negative value to int16_t");
+    return (int16_t) -1;
+}
+
+/* ObjectAsUCS4 */
+                static Py_UCS4 __Pyx__PyObject_AsPy_UCS4(PyObject* x) {
+   long ival;
+   ival = __Pyx_PyInt_As_long(x);
+   if (unlikely(ival < 0)) {
+       if (!PyErr_Occurred())
+           PyErr_SetString(PyExc_OverflowError,
+                           "cannot convert negative value to Py_UCS4");
+       return (Py_UCS4)-1;
+   } else if (unlikely(ival > 1114111)) {
+       PyErr_SetString(PyExc_OverflowError,
+                       "value too large to convert to Py_UCS4");
+       return (Py_UCS4)-1;
+   }
+   return (Py_UCS4)ival;
+}
+
+/* CIntFromPy */
+                static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
+    const long neg_one = (long) -1, const_zero = (long) 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_MAJOR_VERSION < 3
+    if (likely(PyInt_Check(x))) {
+        if (sizeof(long) < sizeof(long)) {
+            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
+        } else {
+            long val = PyInt_AS_LONG(x);
+            if (is_unsigned && unlikely(val < 0)) {
+                goto raise_neg_overflow;
+            }
+            return (long) val;
+        }
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+#if CYTHON_USE_PYLONG_INTERNALS
+            const digit* digits = ((PyLongObject*)x)->ob_digit;
+            switch (Py_SIZE(x)) {
+                case  0: return (long) 0;
+                case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
+                case 2:
+                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
+                            return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
+                        }
+                    }
+                    break;
+                case 3:
+                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
+                            return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
+                        }
+                    }
+                    break;
+                case 4:
+                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
+                            return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
+                        }
+                    }
+                    break;
+            }
+#endif
+#if CYTHON_COMPILING_IN_CPYTHON
+            if (unlikely(Py_SIZE(x) < 0)) {
+                goto raise_neg_overflow;
+            }
+#else
+            {
+                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
+                if (unlikely(result < 0))
+                    return (long) -1;
+                if (unlikely(result == 1))
+                    goto raise_neg_overflow;
+            }
+#endif
+            if (sizeof(long) <= sizeof(unsigned long)) {
+                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
+#ifdef HAVE_LONG_LONG
+            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
+#endif
+            }
+        } else {
+#if CYTHON_USE_PYLONG_INTERNALS
+            const digit* digits = ((PyLongObject*)x)->ob_digit;
+            switch (Py_SIZE(x)) {
+                case  0: return (long) 0;
+                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
+                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
+                case -2:
+                    if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
+                            return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
+                        }
+                    }
+                    break;
+                case 2:
+                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
+                            return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
+                        }
+                    }
+                    break;
+                case -3:
+                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
+                            return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
+                        }
+                    }
+                    break;
+                case 3:
+                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
+                            return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
+                        }
+                    }
+                    break;
+                case -4:
+                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
+                            return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
+                        }
+                    }
+                    break;
+                case 4:
+                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
+                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
+                            return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
+                        }
+                    }
+                    break;
+            }
+#endif
+            if (sizeof(long) <= sizeof(long)) {
+                __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
+#ifdef HAVE_LONG_LONG
+            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
+#endif
+            }
+        }
+        {
+#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
+            PyErr_SetString(PyExc_RuntimeError,
+                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
+#else
+            long val;
+            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
+ #if PY_MAJOR_VERSION < 3
+            if (likely(v) && !PyLong_Check(v)) {
+                PyObject *tmp = v;
+                v = PyNumber_Long(tmp);
+                Py_DECREF(tmp);
+            }
+ #endif
+            if (likely(v)) {
+                int one = 1; int is_little = (int)*(unsigned char *)&one;
+                unsigned char *bytes = (unsigned char *)&val;
+                int ret = _PyLong_AsByteArray((PyLongObject *)v,
+                                              bytes, sizeof(val),
+                                              is_little, !is_unsigned);
+                Py_DECREF(v);
+                if (likely(!ret))
+                    return val;
+            }
+#endif
+            return (long) -1;
+        }
+    } else {
+        long val;
+        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
+        if (!tmp) return (long) -1;
+        val = __Pyx_PyInt_As_long(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+raise_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "value too large to convert to long");
+    return (long) -1;
+raise_neg_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "can't convert negative value to long");
+    return (long) -1;
+}
+
+/* Generator */
+                static PyMethodDef __pyx_Generator_methods[] = {
+    {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
+     (char*) PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")},
+    {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS,
+     (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")},
+    {"close", (PyCFunction) __Pyx_Coroutine_Close, METH_NOARGS,
+     (char*) PyDoc_STR("close() -> raise GeneratorExit inside generator.")},
+    {0, 0, 0, 0}
+};
+static PyMemberDef __pyx_Generator_memberlist[] = {
+    {(char *) "gi_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL},
+    {(char*) "gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
+     (char*) PyDoc_STR("object being iterated by 'yield from', or None")},
+    {0, 0, 0, 0, 0}
+};
+static PyGetSetDef __pyx_Generator_getsets[] = {
+    {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
+     (char*) PyDoc_STR("name of the generator"), 0},
+    {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
+     (char*) PyDoc_STR("qualified name of the generator"), 0},
+    {0, 0, 0, 0, 0}
+};
+static PyTypeObject __pyx_GeneratorType_type = {
+    PyVarObject_HEAD_INIT(0, 0)
+    "generator",
+    sizeof(__pyx_CoroutineObject),
+    0,
+    (destructor) __Pyx_Coroutine_dealloc,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE,
+    0,
+    (traverseproc) __Pyx_Coroutine_traverse,
+    0,
+    0,
+    offsetof(__pyx_CoroutineObject, gi_weakreflist),
+    0,
+    (iternextfunc) __Pyx_Generator_Next,
+    __pyx_Generator_methods,
+    __pyx_Generator_memberlist,
+    __pyx_Generator_getsets,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+#if PY_VERSION_HEX >= 0x030400a1
+    0,
+#else
+    __Pyx_Coroutine_del,
+#endif
+    0,
+#if PY_VERSION_HEX >= 0x030400a1
+    __Pyx_Coroutine_del,
+#endif
+};
+static int __pyx_Generator_init(void) {
+    __pyx_GeneratorType_type.tp_getattro = PyObject_GenericGetAttr;
+    __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter;
+    __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type);
+    if (unlikely(!__pyx_GeneratorType)) {
+        return -1;
+    }
+    return 0;
+}
+
+/* CheckBinaryVersion */
+                static int __Pyx_check_binary_version(void) {
+    char ctversion[4], rtversion[4];
+    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
+    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
+    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
+        char message[200];
+        PyOS_snprintf(message, sizeof(message),
+                      "compiletime version %s of module '%.100s' "
+                      "does not match runtime version %s",
+                      ctversion, __Pyx_MODULE_NAME, rtversion);
+        return PyErr_WarnEx(NULL, message, 1);
+    }
+    return 0;
+}
+
+/* VoidPtrExport */
+                static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig) {
+    PyObject *d;
+    PyObject *cobj = 0;
+    d = PyDict_GetItem(__pyx_d, __pyx_n_s_pyx_capi);
+    Py_XINCREF(d);
+    if (!d) {
+        d = PyDict_New();
+        if (!d)
+            goto bad;
+        if (__Pyx_PyObject_SetAttrStr(__pyx_m, __pyx_n_s_pyx_capi, d) < 0)
+            goto bad;
+    }
+#if PY_VERSION_HEX >= 0x02070000
+    cobj = PyCapsule_New(p, sig, 0);
+#else
+    cobj = PyCObject_FromVoidPtrAndDesc(p, (void *)sig, 0);
+#endif
+    if (!cobj)
+        goto bad;
+    if (PyDict_SetItem(d, name, cobj) < 0)
+        goto bad;
+    Py_DECREF(cobj);
+    Py_DECREF(d);
+    return 0;
+bad:
+    Py_XDECREF(cobj);
+    Py_XDECREF(d);
+    return -1;
+}
+
+/* ModuleImport */
+                #ifndef __PYX_HAVE_RT_ImportModule
+#define __PYX_HAVE_RT_ImportModule
+static PyObject *__Pyx_ImportModule(const char *name) {
+    PyObject *py_name = 0;
+    PyObject *py_module = 0;
+    py_name = __Pyx_PyIdentifier_FromString(name);
+    if (!py_name)
+        goto bad;
+    py_module = PyImport_Import(py_name);
+    Py_DECREF(py_name);
+    return py_module;
+bad:
+    Py_XDECREF(py_name);
+    return 0;
+}
+#endif
+
+/* TypeImport */
+                #ifndef __PYX_HAVE_RT_ImportType
+#define __PYX_HAVE_RT_ImportType
+static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
+    size_t size, int strict)
+{
+    PyObject *py_module = 0;
+    PyObject *result = 0;
+    PyObject *py_name = 0;
+    char warning[200];
+    Py_ssize_t basicsize;
+#ifdef Py_LIMITED_API
+    PyObject *py_basicsize;
+#endif
+    py_module = __Pyx_ImportModule(module_name);
+    if (!py_module)
+        goto bad;
+    py_name = __Pyx_PyIdentifier_FromString(class_name);
+    if (!py_name)
+        goto bad;
+    result = PyObject_GetAttr(py_module, py_name);
+    Py_DECREF(py_name);
+    py_name = 0;
+    Py_DECREF(py_module);
+    py_module = 0;
+    if (!result)
+        goto bad;
+    if (!PyType_Check(result)) {
+        PyErr_Format(PyExc_TypeError,
+            "%.200s.%.200s is not a type object",
+            module_name, class_name);
+        goto bad;
+    }
+#ifndef Py_LIMITED_API
+    basicsize = ((PyTypeObject *)result)->tp_basicsize;
+#else
+    py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
+    if (!py_basicsize)
+        goto bad;
+    basicsize = PyLong_AsSsize_t(py_basicsize);
+    Py_DECREF(py_basicsize);
+    py_basicsize = 0;
+    if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
+        goto bad;
+#endif
+    if (!strict && (size_t)basicsize > size) {
+        PyOS_snprintf(warning, sizeof(warning),
+            "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
+            module_name, class_name, basicsize, size);
+        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
+    }
+    else if ((size_t)basicsize != size) {
+        PyErr_Format(PyExc_ValueError,
+            "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
+            module_name, class_name, basicsize, size);
+        goto bad;
+    }
+    return (PyTypeObject *)result;
+bad:
+    Py_XDECREF(py_module);
+    Py_XDECREF(result);
+    return NULL;
+}
+#endif
+
+/* InitStrings */
+                static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
+    while (t->p) {
+        #if PY_MAJOR_VERSION < 3
+        if (t->is_unicode) {
+            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
+        } else if (t->intern) {
+            *t->p = PyString_InternFromString(t->s);
+        } else {
+            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
+        }
+        #else
+        if (t->is_unicode | t->is_str) {
+            if (t->intern) {
+                *t->p = PyUnicode_InternFromString(t->s);
+            } else if (t->encoding) {
+                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
+            } else {
+                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
+            }
+        } else {
+            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
+        }
+        #endif
+        if (!*t->p)
+            return -1;
+        ++t;
+    }
+    return 0;
+}
+
+static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
+    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
+}
+static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
+    Py_ssize_t ignore;
+    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
+}
+static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
+#if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
+    if (
+#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
+            __Pyx_sys_getdefaultencoding_not_ascii &&
+#endif
+            PyUnicode_Check(o)) {
+#if PY_VERSION_HEX < 0x03030000
+        char* defenc_c;
+        PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
+        if (!defenc) return NULL;
+        defenc_c = PyBytes_AS_STRING(defenc);
+#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
+        {
+            char* end = defenc_c + PyBytes_GET_SIZE(defenc);
+            char* c;
+            for (c = defenc_c; c < end; c++) {
+                if ((unsigned char) (*c) >= 128) {
+                    PyUnicode_AsASCIIString(o);
+                    return NULL;
+                }
+            }
+        }
+#endif
+        *length = PyBytes_GET_SIZE(defenc);
+        return defenc_c;
+#else
+        if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
+#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
+        if (PyUnicode_IS_ASCII(o)) {
+            *length = PyUnicode_GET_LENGTH(o);
+            return PyUnicode_AsUTF8(o);
+        } else {
+            PyUnicode_AsASCIIString(o);
+            return NULL;
+        }
+#else
+        return PyUnicode_AsUTF8AndSize(o, length);
+#endif
+#endif
+    } else
+#endif
+#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
+    if (PyByteArray_Check(o)) {
+        *length = PyByteArray_GET_SIZE(o);
+        return PyByteArray_AS_STRING(o);
+    } else
+#endif
+    {
+        char* result;
+        int r = PyBytes_AsStringAndSize(o, &result, length);
+        if (unlikely(r < 0)) {
+            return NULL;
+        } else {
+            return result;
+        }
+    }
+}
+static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
+   int is_true = x == Py_True;
+   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
+   else return PyObject_IsTrue(x);
+}
+static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
+#if CYTHON_USE_TYPE_SLOTS
+  PyNumberMethods *m;
+#endif
+  const char *name = NULL;
+  PyObject *res = NULL;
+#if PY_MAJOR_VERSION < 3
+  if (PyInt_Check(x) || PyLong_Check(x))
+#else
+  if (PyLong_Check(x))
+#endif
+    return __Pyx_NewRef(x);
+#if CYTHON_USE_TYPE_SLOTS
+  m = Py_TYPE(x)->tp_as_number;
+  #if PY_MAJOR_VERSION < 3
+  if (m && m->nb_int) {
+    name = "int";
+    res = PyNumber_Int(x);
+  }
+  else if (m && m->nb_long) {
+    name = "long";
+    res = PyNumber_Long(x);
+  }
+  #else
+  if (m && m->nb_int) {
+    name = "int";
+    res = PyNumber_Long(x);
+  }
+  #endif
+#else
+  res = PyNumber_Int(x);
+#endif
+  if (res) {
+#if PY_MAJOR_VERSION < 3
+    if (!PyInt_Check(res) && !PyLong_Check(res)) {
+#else
+    if (!PyLong_Check(res)) {
+#endif
+      PyErr_Format(PyExc_TypeError,
+                   "__%.4s__ returned non-%.4s (type %.200s)",
+                   name, name, Py_TYPE(res)->tp_name);
+      Py_DECREF(res);
+      return NULL;
+    }
+  }
+  else if (!PyErr_Occurred()) {
+    PyErr_SetString(PyExc_TypeError,
+                    "an integer is required");
+  }
+  return res;
+}
+static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
+  Py_ssize_t ival;
+  PyObject *x;
+#if PY_MAJOR_VERSION < 3
+  if (likely(PyInt_CheckExact(b))) {
+    if (sizeof(Py_ssize_t) >= sizeof(long))
+        return PyInt_AS_LONG(b);
+    else
+        return PyInt_AsSsize_t(x);
+  }
+#endif
+  if (likely(PyLong_CheckExact(b))) {
+    #if CYTHON_USE_PYLONG_INTERNALS
+    const digit* digits = ((PyLongObject*)b)->ob_digit;
+    const Py_ssize_t size = Py_SIZE(b);
+    if (likely(__Pyx_sst_abs(size) <= 1)) {
+        ival = likely(size) ? digits[0] : 0;
+        if (size == -1) ival = -ival;
+        return ival;
+    } else {
+      switch (size) {
+         case 2:
+           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
+             return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
+           }
+           break;
+         case -2:
+           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
+             return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
+           }
+           break;
+         case 3:
+           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
+             return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
+           }
+           break;
+         case -3:
+           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
+             return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
+           }
+           break;
+         case 4:
+           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
+             return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
+           }
+           break;
+         case -4:
+           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
+             return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
+           }
+           break;
+      }
+    }
+    #endif
+    return PyLong_AsSsize_t(b);
+  }
+  x = PyNumber_Index(b);
+  if (!x) return -1;
+  ival = PyInt_AsSsize_t(x);
+  Py_DECREF(x);
+  return ival;
+}
+static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
+    return PyInt_FromSize_t(ival);
+}
+
+
+#endif /* Py_PYTHON_H */
diff --git a/asyncpg/protocol/protocol.pxd b/asyncpg/protocol/protocol.pxd
new file mode 100644 (file)
index 0000000..190b3ae
--- /dev/null
@@ -0,0 +1,62 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+# cython: language_level=3
+
+
+from libc.stdint cimport int16_t, int32_t, uint16_t, uint32_t, int64_t, uint64_t
+
+from .debug cimport ASYNCPG_DEBUG
+
+include "consts.pxi"
+include "pgtypes.pxi"
+
+include "buffer.pxd"
+include "codecs/base.pxd"
+include "settings.pxd"
+include "coreproto.pxd"
+include "prepared_stmt.pxd"
+
+
+cdef class BaseProtocol(CoreProtocol):
+
+    cdef:
+        object loop
+        object address
+        ConnectionSettings settings
+        object cancel_sent_waiter
+        object cancel_waiter
+        object waiter
+        bint return_extra
+        object create_future
+        object timeout_handle
+        object timeout_callback
+        object completed_callback
+        object connection
+
+        str last_query
+
+        int uid_counter
+        bint closing
+
+        readonly uint64_t queries_count
+
+        PreparedStatementState statement
+
+    cdef _ensure_clear_state(self)
+    cdef _new_waiter(self, timeout)
+
+    cdef _on_result__connect(self, object waiter)
+    cdef _on_result__prepare(self, object waiter)
+    cdef _on_result__bind_and_exec(self, object waiter)
+    cdef _on_result__close_stmt_or_portal(self, object waiter)
+    cdef _on_result__simple_query(self, object waiter)
+    cdef _on_result__bind(self, object waiter)
+
+    cdef _handle_waiter_on_connection_lost(self, cause)
+
+    cdef _dispatch_result(self)
diff --git a/asyncpg/protocol/protocol.pyx b/asyncpg/protocol/protocol.pyx
new file mode 100644 (file)
index 0000000..6fdad83
--- /dev/null
@@ -0,0 +1,532 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+# cython: language_level=3
+
+cimport cython
+cimport cpython
+
+import asyncio
+import codecs
+import collections
+import socket
+
+from libc.stdint cimport int8_t, uint8_t, int16_t, uint16_t, \
+                         int32_t, uint32_t, int64_t, uint64_t
+
+from asyncpg.protocol cimport record
+
+from asyncpg.protocol.python cimport (
+                     PyMem_Malloc, PyMem_Realloc, PyMem_Calloc, PyMem_Free,
+                     PyMemoryView_GET_BUFFER, PyMemoryView_Check,
+                     PyUnicode_AsUTF8AndSize, PyByteArray_AsString,
+                     PyByteArray_Check, PyUnicode_AsUCS4Copy,
+                     PyUnicode_FromKindAndData, PyUnicode_4BYTE_KIND)
+
+from cpython cimport PyBuffer_FillInfo, PyBytes_AsString
+
+from asyncpg.exceptions import _base as apg_exc_base
+from asyncpg import types as apg_types
+from asyncpg import exceptions as apg_exc
+
+from asyncpg.protocol cimport hton
+
+include "consts.pxi"
+include "pgtypes.pxi"
+
+include "encodings.pyx"
+include "settings.pyx"
+include "buffer.pyx"
+
+include "codecs/base.pyx"
+include "codecs/textutils.pyx"
+
+# String types.  Need to go first, as other codecs may rely on
+# text decoding/encoding.
+include "codecs/bytea.pyx"
+include "codecs/text.pyx"
+
+# Builtin types, in lexicographical order.
+include "codecs/bits.pyx"
+include "codecs/datetime.pyx"
+include "codecs/float.pyx"
+include "codecs/geometry.pyx"
+include "codecs/int.pyx"
+include "codecs/json.pyx"
+include "codecs/money.pyx"
+include "codecs/network.pyx"
+include "codecs/numeric.pyx"
+include "codecs/tsearch.pyx"
+include "codecs/txid.pyx"
+include "codecs/uuid.pyx"
+
+# Various pseudotypes and system types
+include "codecs/misc.pyx"
+
+# nonscalar
+include "codecs/array.pyx"
+include "codecs/range.pyx"
+include "codecs/record.pyx"
+
+# contrib
+include "codecs/hstore.pyx"
+
+include "coreproto.pyx"
+include "prepared_stmt.pyx"
+
+
+cdef class BaseProtocol(CoreProtocol):
+    def __init__(self, addr, connected_fut, con_args, loop):
+        CoreProtocol.__init__(self, con_args)
+
+        self.loop = loop
+        self.waiter = connected_fut
+        self.cancel_waiter = None
+        self.cancel_sent_waiter = None
+
+        self.address = addr
+        self.settings = ConnectionSettings(
+            (self.address, con_args.get('database')))
+
+        self.uid_counter = 0
+        self.statement = None
+        self.return_extra = False
+
+        self.last_query = None
+
+        self.closing = False
+
+        self.timeout_handle = None
+        self.timeout_callback = self._on_timeout
+        self.completed_callback = self._on_waiter_completed
+
+        self.queries_count = 0
+
+        try:
+            self.create_future = loop.create_future
+        except AttributeError:
+            self.create_future = self._create_future_fallback
+
+    def set_connection(self, connection):
+        self.connection = connection
+
+    def get_server_pid(self):
+        return self.backend_pid
+
+    def get_settings(self):
+        return self.settings
+
+    async def prepare(self, stmt_name, query, timeout):
+        if self.cancel_waiter is not None:
+            await self.cancel_waiter
+        if self.cancel_sent_waiter is not None:
+            await self.cancel_sent_waiter
+            self.cancel_sent_waiter = None
+
+        self._ensure_clear_state()
+
+        if stmt_name is None:
+            self.uid_counter += 1
+            stmt_name = 'stmt_{}'.format(self.uid_counter)
+
+        self._prepare(stmt_name, query)
+        self.last_query = query
+        self.statement = PreparedStatementState(stmt_name, query, self)
+
+        return await self._new_waiter(timeout)
+
+    async def bind_execute(self, PreparedStatementState state, args,
+                           str portal_name, int limit, return_extra,
+                           timeout):
+
+        if self.cancel_waiter is not None:
+            await self.cancel_waiter
+        if self.cancel_sent_waiter is not None:
+            await self.cancel_sent_waiter
+            self.cancel_sent_waiter = None
+
+        self._ensure_clear_state()
+
+        self._bind_execute(
+            portal_name,
+            state.name,
+            state._encode_bind_msg(args),
+            limit)
+
+        self.last_query = state.query
+        self.statement = state
+        self.return_extra = return_extra
+        self.queries_count += 1
+
+        return await self._new_waiter(timeout)
+
+    async def bind_execute_many(self, PreparedStatementState state, args,
+                                str portal_name, timeout):
+
+        if self.cancel_waiter is not None:
+            await self.cancel_waiter
+        if self.cancel_sent_waiter is not None:
+            await self.cancel_sent_waiter
+            self.cancel_sent_waiter = None
+
+        self._ensure_clear_state()
+
+        # Make sure the argument sequence is encoded lazily with
+        # this generator expression to keep the memory pressure under
+        # control.
+        data_gen = (state._encode_bind_msg(b) for b in args)
+        arg_bufs = iter(data_gen)
+
+        waiter = self._new_waiter(timeout)
+
+        self._bind_execute_many(
+            portal_name,
+            state.name,
+            arg_bufs)
+
+        self.last_query = state.query
+        self.statement = state
+        self.return_extra = False
+        self.queries_count += 1
+
+        return await waiter
+
+    async def bind(self, PreparedStatementState state, args,
+                   str portal_name, timeout):
+
+        if self.cancel_waiter is not None:
+            await self.cancel_waiter
+        if self.cancel_sent_waiter is not None:
+            await self.cancel_sent_waiter
+            self.cancel_sent_waiter = None
+
+        self._ensure_clear_state()
+
+        self._bind(
+            portal_name,
+            state.name,
+            state._encode_bind_msg(args))
+
+        self.last_query = state.query
+        self.statement = state
+
+        return await self._new_waiter(timeout)
+
+    async def execute(self, PreparedStatementState state,
+                      str portal_name, int limit, return_extra,
+                      timeout):
+
+        if self.cancel_waiter is not None:
+            await self.cancel_waiter
+        if self.cancel_sent_waiter is not None:
+            await self.cancel_sent_waiter
+            self.cancel_sent_waiter = None
+
+        self._ensure_clear_state()
+
+        self._execute(
+            portal_name,
+            limit)
+
+        self.last_query = state.query
+        self.statement = state
+        self.return_extra = return_extra
+        self.queries_count += 1
+
+        return await self._new_waiter(timeout)
+
+    async def query(self, query, timeout):
+        if self.cancel_waiter is not None:
+            await self.cancel_waiter
+        if self.cancel_sent_waiter is not None:
+            await self.cancel_sent_waiter
+            self.cancel_sent_waiter = None
+
+        self._ensure_clear_state()
+
+        self._simple_query(query)
+        self.last_query = query
+        self.queries_count += 1
+
+        return await self._new_waiter(timeout)
+
+    async def close_statement(self, PreparedStatementState state, timeout):
+        if self.cancel_waiter is not None:
+            await self.cancel_waiter
+        if self.cancel_sent_waiter is not None:
+            await self.cancel_sent_waiter
+            self.cancel_sent_waiter = None
+
+        self._ensure_clear_state()
+
+        if state.refs != 0:
+            raise RuntimeError(
+                'cannot close prepared statement; refs == {} != 0'.format(
+                    state.refs))
+
+        self._close(state.name, False)
+        state.closed = True
+        return await self._new_waiter(timeout)
+
+    def is_closed(self):
+        return self.closing
+
+    def is_connected(self):
+        return not self.closing and self.con_status == CONNECTION_OK
+
+    def abort(self):
+        if self.closing:
+            return
+        self.closing = True
+        self._handle_waiter_on_connection_lost(None)
+        self._terminate()
+        self.transport.abort()
+
+    async def close(self):
+        if self.cancel_waiter is not None:
+            await self.cancel_waiter
+        if self.cancel_sent_waiter is not None:
+            await self.cancel_sent_waiter
+            self.cancel_sent_waiter = None
+
+        self._handle_waiter_on_connection_lost(None)
+        assert self.waiter is None
+
+        if self.closing:
+            return
+
+        self._terminate()
+        self.waiter = self.create_future()
+        self.closing = True
+        self.transport.abort()
+        return await self.waiter
+
+    def _request_cancel(self):
+        self.cancel_waiter = self.create_future()
+        self.cancel_sent_waiter = self.create_future()
+        self.connection._cancel_current_command(self.cancel_sent_waiter)
+
+    def _on_timeout(self, fut):
+        if self.waiter is not fut or fut.done() or \
+                self.cancel_waiter is not None or \
+                self.timeout_handle is None:
+            return
+        self._request_cancel()
+        self.waiter.set_exception(asyncio.TimeoutError())
+
+    def _on_waiter_completed(self, fut):
+        if fut is not self.waiter or self.cancel_waiter is not None:
+            return
+        if fut.cancelled():
+            if self.timeout_handle:
+                self.timeout_handle.cancel()
+                self.timeout_handle = None
+            self._request_cancel()
+
+    def _create_future_fallback(self):
+        return asyncio.Future(loop=self.loop)
+
+    cdef _handle_waiter_on_connection_lost(self, cause):
+        if self.waiter is not None and not self.waiter.done():
+            exc = apg_exc.ConnectionDoesNotExistError(
+                'connection was closed in the middle of '
+                'operation')
+            if cause is not None:
+                exc.__cause__ = cause
+            self.waiter.set_exception(exc)
+        self.waiter = None
+
+    cdef _set_server_parameter(self, name, val):
+        self.settings.add_setting(name, val)
+
+    cdef _ensure_clear_state(self):
+        if self.cancel_waiter is not None:
+            raise apg_exc.InterfaceError(
+                'cannot perform operation: another operation is cancelling')
+        if self.closing:
+            raise apg_exc.InterfaceError(
+                'cannot perform operation: connection is closed')
+        if self.waiter is not None or self.timeout_handle is not None:
+            raise apg_exc.InterfaceError(
+                'cannot perform operation: another operation is in progress')
+
+    cdef _new_waiter(self, timeout):
+        self.waiter = self.create_future()
+        if timeout is not False:
+            timeout = timeout or self.connection._command_timeout
+            if timeout is not None and timeout > 0:
+                self.timeout_handle = self.connection._loop.call_later(
+                    timeout, self.timeout_callback, self.waiter)
+        self.waiter.add_done_callback(self.completed_callback)
+        return self.waiter
+
+    cdef _on_result__connect(self, object waiter):
+        waiter.set_result(True)
+
+    cdef _on_result__prepare(self, object waiter):
+        if ASYNCPG_DEBUG:
+            if self.statement is None:
+                raise RuntimeError(
+                    '_on_result__prepare: statement is None')
+
+        if self.result_param_desc is not None:
+            self.statement._set_args_desc(self.result_param_desc)
+        if self.result_row_desc is not None:
+            self.statement._set_row_desc(self.result_row_desc)
+        waiter.set_result(self.statement)
+
+    cdef _on_result__bind_and_exec(self, object waiter):
+        if self.return_extra:
+            waiter.set_result((
+                self.result,
+                self.result_status_msg,
+                self.result_execute_completed))
+        else:
+            waiter.set_result(self.result)
+
+    cdef _on_result__bind(self, object waiter):
+        waiter.set_result(self.result)
+
+    cdef _on_result__close_stmt_or_portal(self, object waiter):
+        waiter.set_result(self.result)
+
+    cdef _on_result__simple_query(self, object waiter):
+        waiter.set_result(self.result_status_msg.decode(self.encoding))
+
+    cdef _decode_row(self, const char* buf, ssize_t buf_len):
+        if ASYNCPG_DEBUG:
+            if self.statement is None:
+                raise RuntimeError(
+                    '_decode_row: statement is None')
+
+        return self.statement._decode_row(buf, buf_len)
+
+    cdef _dispatch_result(self):
+        waiter = self.waiter
+        self.waiter = None
+
+        if ASYNCPG_DEBUG:
+            if waiter is None:
+                raise RuntimeError('_on_result: waiter is None')
+
+        if waiter.cancelled():
+            return
+
+        if waiter.done():
+            raise RuntimeError('_on_result: waiter is done')
+
+        if self.result_type == RESULT_FAILED:
+            if isinstance(self.result, dict):
+                exc = apg_exc_base.PostgresMessage.new(
+                    self.result, query=self.last_query)
+            else:
+                exc = self.result
+            waiter.set_exception(exc)
+            return
+
+        try:
+            if self.state == PROTOCOL_AUTH:
+                self._on_result__connect(waiter)
+
+            elif self.state == PROTOCOL_PREPARE:
+                self._on_result__prepare(waiter)
+
+            elif self.state == PROTOCOL_BIND_EXECUTE:
+                self._on_result__bind_and_exec(waiter)
+
+            elif self.state == PROTOCOL_BIND_EXECUTE_MANY:
+                self._on_result__bind_and_exec(waiter)
+
+            elif self.state == PROTOCOL_EXECUTE:
+                self._on_result__bind_and_exec(waiter)
+
+            elif self.state == PROTOCOL_BIND:
+                self._on_result__bind(waiter)
+
+            elif self.state == PROTOCOL_CLOSE_STMT_PORTAL:
+                self._on_result__close_stmt_or_portal(waiter)
+
+            elif self.state == PROTOCOL_SIMPLE_QUERY:
+                self._on_result__simple_query(waiter)
+
+            else:
+                raise RuntimeError(
+                    'got result for unknown protocol state {}'.
+                    format(self.state))
+
+        except Exception as exc:
+            waiter.set_exception(exc)
+
+    cdef _on_result(self):
+        if self.timeout_handle is not None:
+            self.timeout_handle.cancel()
+            self.timeout_handle = None
+
+        if self.cancel_waiter is not None:
+            if self.waiter is None or not self.waiter.cancelled():
+                self.cancel_waiter.set_result(
+                    RuntimeError('invalid state after cancellation'))
+            else:
+                self.cancel_waiter.set_result(None)
+            self.cancel_waiter = None
+            self.waiter = None
+            return
+
+        try:
+            self._dispatch_result()
+        finally:
+            self.statement = None
+            self.last_query = None
+            self.return_extra = False
+
+    cdef _on_notification(self, pid, channel, payload):
+        self.connection._notify(pid, channel, payload)
+
+    cdef _on_connection_lost(self, exc):
+        if self.closing:
+            # The connection was lost because
+            # Protocol.close() was called
+            if self.waiter is not None and not self.waiter.done():
+                if exc is None:
+                    self.waiter.set_result(None)
+                else:
+                    self.waiter.set_exception(exc)
+            self.waiter = None
+        else:
+            # The connection was lost because it was
+            # terminated or due to another error;
+            # Throw an error in any awaiting waiter.
+            self.closing = True
+            self._handle_waiter_on_connection_lost(exc)
+
+
+class Protocol(BaseProtocol, asyncio.Protocol):
+    pass
+
+
+def _create_record(object mapping, tuple elems):
+    # Exposed only for testing purposes.
+
+    cdef:
+        object rec
+        int32_t i
+
+    if mapping is None:
+        desc = record.ApgRecordDesc_New({}, ())
+    else:
+        desc = record.ApgRecordDesc_New(
+            mapping, tuple(mapping) if mapping else ())
+
+    rec = record.ApgRecord_New(desc, len(elems))
+    for i in range(len(elems)):
+        elem = elems[i]
+        cpython.Py_INCREF(elem)
+        record.ApgRecord_SET_ITEM(rec, i, elem)
+    return rec
+
+
+record.ApgRecord_InitTypes()
diff --git a/asyncpg/protocol/python.pxd b/asyncpg/protocol/python.pxd
new file mode 100644 (file)
index 0000000..869eed3
--- /dev/null
@@ -0,0 +1,27 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+from cpython cimport Py_buffer
+
+cdef extern from "Python.h":
+    void* PyMem_Malloc(size_t n)
+    void* PyMem_Realloc(void *p, size_t n)
+    void* PyMem_Calloc(size_t nelem, size_t elsize)  # Python >= 3.5!
+    void PyMem_Free(void *p)
+
+    int PyByteArray_Check(object)
+
+    int PyMemoryView_Check(object)
+    Py_buffer *PyMemoryView_GET_BUFFER(object)
+
+    char* PyUnicode_AsUTF8AndSize(object unicode, ssize_t *size) except NULL
+    char* PyByteArray_AsString(object)
+    Py_UCS4* PyUnicode_AsUCS4Copy(object)
+    object PyUnicode_FromKindAndData(
+        int kind, const void *buffer, Py_ssize_t size)
+
+    int PyUnicode_4BYTE_KIND
diff --git a/asyncpg/protocol/record/__init__.pxd b/asyncpg/protocol/record/__init__.pxd
new file mode 100644 (file)
index 0000000..cd28d20
--- /dev/null
@@ -0,0 +1,16 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+cdef extern from "record/recordobj.h":
+
+       int ApgRecord_InitTypes() except -1
+
+       int ApgRecord_CheckExact(object)
+       object ApgRecord_New(object, int)
+       void ApgRecord_SET_ITEM(object, int, object)
+
+       object ApgRecordDesc_New(object, object)
diff --git a/asyncpg/protocol/record/recordobj.c b/asyncpg/protocol/record/recordobj.c
new file mode 100644 (file)
index 0000000..eed1c56
--- /dev/null
@@ -0,0 +1,953 @@
+/* Big parts of this file are copied (with modifications) from
+   CPython/Objects/tupleobject.c.
+
+   Portions Copyright (c) PSF (and other CPython copyright holders).
+   Portions Copyright (c) 2016-present MagicStack Inc.
+   License: PSFL v2; see CPython/LICENSE for details.
+*/
+
+#include "recordobj.h"
+
+
+static PyObject * record_iter(PyObject *);
+static PyObject * record_new_items_iter(PyObject *);
+
+static ApgRecordObject *free_list[ApgRecord_MAXSAVESIZE];
+static int numfree[ApgRecord_MAXSAVESIZE];
+
+
+PyObject *
+ApgRecord_New(PyObject *desc, Py_ssize_t size)
+{
+    ApgRecordObject *o;
+    Py_ssize_t i;
+
+    if (size < 0 || desc == NULL || !ApgRecordDesc_CheckExact(desc)) {
+        PyErr_BadInternalCall();
+        return NULL;
+    }
+
+    if (size < ApgRecord_MAXSAVESIZE && (o = free_list[size]) != NULL) {
+        free_list[size] = (ApgRecordObject *) o->ob_item[0];
+        numfree[size]--;
+        _Py_NewReference((PyObject *)o);
+    }
+    else {
+        /* Check for overflow */
+        if ((size_t)size > ((size_t)PY_SSIZE_T_MAX - sizeof(ApgRecordObject) -
+                    sizeof(PyObject *)) / sizeof(PyObject *)) {
+            return PyErr_NoMemory();
+        }
+        o = PyObject_GC_NewVar(ApgRecordObject, &ApgRecord_Type, size);
+        if (o == NULL) {
+            return NULL;
+        }
+    }
+
+    for (i = 0; i < size; i++) {
+        o->ob_item[i] = NULL;
+    }
+
+    Py_INCREF(desc);
+    o->desc = (ApgRecordDescObject*)desc;
+    o->self_hash = -1;
+    PyObject_GC_Track(o);
+    return (PyObject *) o;
+}
+
+
+static void
+record_dealloc(ApgRecordObject *o)
+{
+    Py_ssize_t i;
+    Py_ssize_t len = Py_SIZE(o);
+
+    PyObject_GC_UnTrack(o);
+
+    o->self_hash = -1;
+
+    Py_CLEAR(o->desc);
+
+    Py_TRASHCAN_SAFE_BEGIN(o)
+    if (len > 0) {
+        i = len;
+        while (--i >= 0) {
+            Py_CLEAR(o->ob_item[i]);
+        }
+
+        if (len < ApgRecord_MAXSAVESIZE &&
+            numfree[len] < ApgRecord_MAXFREELIST &&
+            ApgRecord_CheckExact(o))
+        {
+            o->ob_item[0] = (PyObject *) free_list[len];
+            numfree[len]++;
+            free_list[len] = o;
+            goto done; /* return */
+        }
+    }
+    Py_TYPE(o)->tp_free((PyObject *)o);
+done:
+    Py_TRASHCAN_SAFE_END(o)
+}
+
+
+static int
+record_traverse(ApgRecordObject *o, visitproc visit, void *arg)
+{
+    Py_ssize_t i;
+
+    Py_VISIT(o->desc);
+
+    for (i = Py_SIZE(o); --i >= 0;) {
+        if (o->ob_item[i] != NULL) {
+            Py_VISIT(o->ob_item[i]);
+        }
+    }
+
+    return 0;
+}
+
+
+static Py_ssize_t
+record_length(ApgRecordObject *o)
+{
+    return Py_SIZE(o);
+}
+
+
+static Py_hash_t
+record_hash(ApgRecordObject *v)
+{
+    Py_uhash_t x;  /* Unsigned for defined overflow behavior. */
+    Py_hash_t y;
+    Py_ssize_t len;
+    PyObject **p;
+    Py_uhash_t mult;
+
+    if (v->self_hash != -1) {
+        return v->self_hash;
+    }
+
+    len = Py_SIZE(v);
+    mult = _PyHASH_MULTIPLIER;
+
+    x = 0x345678UL;
+    p = v->ob_item;
+    while (--len >= 0) {
+        y = PyObject_Hash(*p++);
+        if (y == -1) {
+            return -1;
+        }
+        x = (x ^ (Py_uhash_t)y) * mult;
+        /* the cast might truncate len; that doesn't change hash stability */
+        mult += (Py_uhash_t)(82520UL + (size_t)len + (size_t)len);
+    }
+    x += 97531UL;
+    if (x == (Py_uhash_t)-1) {
+        x = (Py_uhash_t)-2;
+    }
+    v->self_hash = (Py_hash_t)x;
+    return (Py_hash_t)x;
+}
+
+
+static PyObject *
+record_richcompare(PyObject *v, PyObject *w, int op)
+{
+    Py_ssize_t i;
+    Py_ssize_t vlen, wlen;
+    int v_is_tuple = 0;
+    int w_is_tuple = 0;
+    int comp;
+
+    if (!ApgRecord_CheckExact(v)) {
+        if (!PyTuple_Check(v)) {
+            Py_RETURN_NOTIMPLEMENTED;
+        }
+        v_is_tuple = 1;
+    }
+
+    if (!ApgRecord_CheckExact(w)) {
+        if (!PyTuple_Check(w)) {
+            Py_RETURN_NOTIMPLEMENTED;
+        }
+        w_is_tuple = 1;
+    }
+
+#define V_ITEM(i) \
+    (v_is_tuple ? (PyTuple_GET_ITEM(v, i)) : (ApgRecord_GET_ITEM(v, i)))
+#define W_ITEM(i) \
+    (w_is_tuple ? (PyTuple_GET_ITEM(w, i)) : (ApgRecord_GET_ITEM(w, i)))
+
+    vlen = Py_SIZE(v);
+    wlen = Py_SIZE(w);
+
+    if (op == Py_EQ && vlen != wlen) {
+        /* Checking if v == w, but len(v) != len(w): return False */
+        Py_RETURN_FALSE;
+    }
+
+    if (op == Py_NE && vlen != wlen) {
+        /* Checking if v != w, and len(v) != len(w): return True */
+        Py_RETURN_TRUE;
+    }
+
+    /* Search for the first index where items are different.
+     * Note that because tuples are immutable, it's safe to reuse
+     * vlen and wlen across the comparison calls.
+     */
+    for (i = 0; i < vlen && i < wlen; i++) {
+        comp = PyObject_RichCompareBool(V_ITEM(i), W_ITEM(i), Py_EQ);
+        if (comp < 0) {
+            return NULL;
+        }
+        if (!comp) {
+            break;
+        }
+    }
+
+    if (i >= vlen || i >= wlen) {
+        /* No more items to compare -- compare sizes */
+        int cmp;
+        switch (op) {
+            case Py_LT: cmp = vlen <  wlen; break;
+            case Py_LE: cmp = vlen <= wlen; break;
+            case Py_EQ: cmp = vlen == wlen; break;
+            case Py_NE: cmp = vlen != wlen; break;
+            case Py_GT: cmp = vlen >  wlen; break;
+            case Py_GE: cmp = vlen >= wlen; break;
+            default: return NULL; /* cannot happen */
+        }
+        if (cmp) {
+            Py_RETURN_TRUE;
+        }
+        else {
+            Py_RETURN_FALSE;
+        }
+    }
+
+    /* We have an item that differs -- shortcuts for EQ/NE */
+    if (op == Py_EQ) {
+        Py_RETURN_FALSE;
+    }
+    if (op == Py_NE) {
+        Py_RETURN_TRUE;
+    }
+
+    /* Compare the final item again using the proper operator */
+    return PyObject_RichCompare(V_ITEM(i), W_ITEM(i), op);
+
+#undef V_ITEM
+#undef W_ITEM
+}
+
+
+static PyObject *
+record_item(ApgRecordObject *o, Py_ssize_t i)
+{
+    if (i < 0 || i >= Py_SIZE(o)) {
+        PyErr_SetString(PyExc_IndexError, "record index out of range");
+        return NULL;
+    }
+    Py_INCREF(o->ob_item[i]);
+    return o->ob_item[i];
+}
+
+
+static PyObject *
+record_subscript(ApgRecordObject* o, PyObject* item)
+{
+    if (PyIndex_Check(item)) {
+        Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
+        if (i == -1 && PyErr_Occurred())
+            return NULL;
+        if (i < 0) {
+            i += Py_SIZE(o);
+        }
+        return record_item(o, i);
+    }
+    else if (PySlice_Check(item)) {
+        Py_ssize_t start, stop, step, slicelength, cur, i;
+        PyObject* result;
+        PyObject* it;
+        PyObject **src, **dest;
+
+        if (PySlice_GetIndicesEx(
+                item,
+                Py_SIZE(o),
+                &start, &stop, &step, &slicelength) < 0)
+        {
+            return NULL;
+        }
+
+        if (slicelength <= 0) {
+            return PyTuple_New(0);
+        }
+        else {
+            result = PyTuple_New(slicelength);
+            if (!result) return NULL;
+
+            src = o->ob_item;
+            dest = ((PyTupleObject *)result)->ob_item;
+            for (cur = start, i = 0; i < slicelength; cur += step, i++) {
+                it = src[cur];
+                Py_INCREF(it);
+                dest[i] = it;
+            }
+
+            return result;
+        }
+    }
+    else {
+        PyObject *mapped;
+        mapped = PyObject_GetItem(o->desc->mapping, item);
+        if (mapped != NULL) {
+            Py_ssize_t i;
+            PyObject *result;
+
+            if (!PyIndex_Check(mapped)) {
+                Py_DECREF(mapped);
+                goto noitem;
+            }
+
+            i = PyNumber_AsSsize_t(mapped, PyExc_IndexError);
+            Py_DECREF(mapped);
+
+            if (i < 0) {
+                if (PyErr_Occurred()) {
+                    PyErr_Clear();
+                }
+                goto noitem;
+            }
+
+            result = record_item(o, i);
+            if (result == NULL) {
+                PyErr_Clear();
+                goto noitem;
+            }
+            return result;
+        }
+        else {
+            goto noitem;
+        }
+    }
+
+noitem:
+    _PyErr_SetKeyError(item);
+    return NULL;
+}
+
+
+static PyObject *
+record_repr(ApgRecordObject *v)
+{
+    Py_ssize_t i, n;
+    PyObject *keys_iter;
+    _PyUnicodeWriter writer;
+
+    n = Py_SIZE(v);
+    if (n == 0) {
+        return PyUnicode_FromString("<Record>");
+    }
+
+    keys_iter = PyObject_GetIter(v->desc->keys);
+    if (keys_iter == NULL) {
+        return NULL;
+    }
+
+    i = Py_ReprEnter((PyObject *)v);
+    if (i != 0) {
+        Py_DECREF(keys_iter);
+        return i > 0 ? PyUnicode_FromString("<Record ...>") : NULL;
+    }
+
+    _PyUnicodeWriter_Init(&writer);
+    writer.overallocate = 1;
+    writer.min_length = 12; /* <Record a=1> */
+
+    if (_PyUnicodeWriter_WriteASCIIString(&writer, "<Record ", 8) < 0) {
+        goto error;
+    }
+
+    for (i = 0; i < n; ++i) {
+        PyObject *key;
+        PyObject *key_repr;
+        PyObject *val_repr;
+
+        if (i > 0) {
+            if (_PyUnicodeWriter_WriteChar(&writer, ' ') < 0) {
+                goto error;
+            }
+        }
+
+        if (Py_EnterRecursiveCall(" while getting the repr of a record")) {
+            goto error;
+        }
+        val_repr = PyObject_Repr(v->ob_item[i]);
+        Py_LeaveRecursiveCall();
+        if (val_repr == NULL) {
+            goto error;
+        }
+
+        key = PyIter_Next(keys_iter);
+        if (key == NULL) {
+            Py_DECREF(val_repr);
+            PyErr_SetString(PyExc_RuntimeError, "invalid record mapping");
+            goto error;
+        }
+
+        key_repr = PyObject_Str(key);
+        Py_DECREF(key);
+        if (key_repr == NULL) {
+            Py_DECREF(val_repr);
+            goto error;
+        }
+
+        if (_PyUnicodeWriter_WriteStr(&writer, key_repr) < 0) {
+            Py_DECREF(key_repr);
+            Py_DECREF(val_repr);
+            goto error;
+        }
+        Py_DECREF(key_repr);
+
+        if (_PyUnicodeWriter_WriteChar(&writer, '=') < 0) {
+            Py_DECREF(val_repr);
+            goto error;
+        }
+
+        if (_PyUnicodeWriter_WriteStr(&writer, val_repr) < 0) {
+            Py_DECREF(val_repr);
+            goto error;
+        }
+        Py_DECREF(val_repr);
+    }
+
+    writer.overallocate = 0;
+    if (_PyUnicodeWriter_WriteChar(&writer, '>') < 0) {
+        goto error;
+    }
+
+    Py_DECREF(keys_iter);
+    Py_ReprLeave((PyObject *)v);
+    return _PyUnicodeWriter_Finish(&writer);
+
+error:
+    Py_DECREF(keys_iter);
+    _PyUnicodeWriter_Dealloc(&writer);
+    Py_ReprLeave((PyObject *)v);
+    return NULL;
+}
+
+
+
+static PyObject *
+record_values(PyObject *o, PyObject *args)
+{
+    return record_iter(o);
+}
+
+
+static PyObject *
+record_keys(PyObject *o, PyObject *args)
+{
+    if (!ApgRecord_CheckExact(o)) {
+        PyErr_BadInternalCall();
+        return NULL;
+    }
+
+    return PyObject_GetIter(((ApgRecordObject*)o)->desc->mapping);
+}
+
+
+static PyObject *
+record_items(PyObject *o, PyObject *args)
+{
+    if (!ApgRecord_CheckExact(o)) {
+        PyErr_BadInternalCall();
+        return NULL;
+    }
+
+    return record_new_items_iter(o);
+}
+
+
+static int
+record_contains(ApgRecordObject *o, PyObject *arg)
+{
+    if (!ApgRecord_CheckExact(o)) {
+        PyErr_BadInternalCall();
+        return -1;
+    }
+
+    return PySequence_Contains(o->desc->mapping, arg);
+}
+
+
+static PySequenceMethods record_as_sequence = {
+    (lenfunc)record_length,                          /* sq_length */
+    0,                                               /* sq_concat */
+    0,                                               /* sq_repeat */
+    (ssizeargfunc)record_item,                       /* sq_item */
+    0,                                               /* sq_slice */
+    0,                                               /* sq_ass_item */
+    0,                                               /* sq_ass_slice */
+    (objobjproc)record_contains,                     /* sq_contains */
+};
+
+
+static PyMappingMethods record_as_mapping = {
+    (lenfunc)record_length,                          /* mp_length */
+    (binaryfunc)record_subscript,                    /* mp_subscript */
+    0                                                /* mp_ass_subscript */
+};
+
+
+static PyMethodDef record_methods[] = {
+    {"values",          (PyCFunction)record_values, METH_NOARGS},
+    {"keys",            (PyCFunction)record_keys, METH_NOARGS},
+    {"items",           (PyCFunction)record_items, METH_NOARGS},
+    {NULL,              NULL}           /* sentinel */
+};
+
+
+PyTypeObject ApgRecord_Type = {
+    PyVarObject_HEAD_INIT(NULL, 0)
+    "Record",                                        /* tp_name */
+    sizeof(ApgRecordObject) - sizeof(PyObject *),    /* tp_basic_size */
+    sizeof(PyObject *),                              /* tp_itemsize */
+    (destructor)record_dealloc,                      /* tp_dealloc */
+    0,                                               /* tp_print */
+    0,                                               /* tp_getattr */
+    0,                                               /* tp_setattr */
+    0,                                               /* tp_reserved */
+    (reprfunc)record_repr,                           /* tp_repr */
+    0,                                               /* tp_as_number */
+    &record_as_sequence,                             /* tp_as_sequence */
+    &record_as_mapping,                              /* tp_as_mapping */
+    (hashfunc)record_hash,                           /* tp_hash */
+    0,                                               /* tp_call */
+    0,                                               /* tp_str */
+    PyObject_GenericGetAttr,                         /* tp_getattro */
+    0,                                               /* tp_setattro */
+    0,                                               /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
+        Py_TPFLAGS_BASETYPE,                         /* tp_flags */
+    0,                                               /* tp_doc */
+    (traverseproc)record_traverse,                   /* tp_traverse */
+    0,                                               /* tp_clear */
+    record_richcompare,                              /* tp_richcompare */
+    0,                                               /* tp_weaklistoffset */
+    record_iter,                                     /* tp_iter */
+    0,                                               /* tp_iternext */
+    record_methods,                                  /* tp_methods */
+    0,                                               /* tp_members */
+    0,                                               /* tp_getset */
+    0,                                               /* tp_base */
+    0,                                               /* tp_dict */
+    0,                                               /* tp_descr_get */
+    0,                                               /* tp_descr_set */
+    0,                                               /* tp_dictoffset */
+    0,                                               /* tp_init */
+    0,                                               /* tp_alloc */
+    0,                                               /* tp_new */
+    PyObject_GC_Del,                                 /* tp_free */
+};
+
+
+/* Record Iterator */
+
+
+typedef struct {
+    PyObject_HEAD
+    Py_ssize_t it_index;
+    ApgRecordObject *it_seq; /* Set to NULL when iterator is exhausted */
+} ApgRecordIterObject;
+
+
+static void
+record_iter_dealloc(ApgRecordIterObject *it)
+{
+    PyObject_GC_UnTrack(it);
+    Py_CLEAR(it->it_seq);
+    PyObject_GC_Del(it);
+}
+
+
+static int
+record_iter_traverse(ApgRecordIterObject *it, visitproc visit, void *arg)
+{
+    Py_VISIT(it->it_seq);
+    return 0;
+}
+
+
+static PyObject *
+record_iter_next(ApgRecordIterObject *it)
+{
+    ApgRecordObject *seq;
+    PyObject *item;
+
+    assert(it != NULL);
+    seq = it->it_seq;
+    if (seq == NULL)
+        return NULL;
+    assert(ApgRecord_CheckExact(seq));
+
+    if (it->it_index < Py_SIZE(seq)) {
+        item = ApgRecord_GET_ITEM(seq, it->it_index);
+        ++it->it_index;
+        Py_INCREF(item);
+        return item;
+    }
+
+    it->it_seq = NULL;
+    Py_DECREF(seq);
+    return NULL;
+}
+
+
+static PyObject *
+record_iter_len(ApgRecordIterObject *it)
+{
+    Py_ssize_t len = 0;
+    if (it->it_seq) {
+        len = Py_SIZE(it->it_seq) - it->it_index;
+    }
+    return PyLong_FromSsize_t(len);
+}
+
+
+PyDoc_STRVAR(record_iter_len_doc,
+             "Private method returning an estimate of len(list(it)).");
+
+
+static PyMethodDef record_iter_methods[] = {
+    {"__length_hint__", (PyCFunction)record_iter_len, METH_NOARGS,
+        record_iter_len_doc},
+    {NULL,              NULL}           /* sentinel */
+};
+
+
+PyTypeObject ApgRecordIter_Type = {
+    PyVarObject_HEAD_INIT(NULL, 0)
+    "RecordIterator",                           /* tp_name */
+    sizeof(ApgRecordIterObject),                /* tp_basicsize */
+    0,                                          /* tp_itemsize */
+    /* methods */
+    (destructor)record_iter_dealloc,            /* tp_dealloc */
+    0,                                          /* tp_print */
+    0,                                          /* tp_getattr */
+    0,                                          /* tp_setattr */
+    0,                                          /* tp_reserved */
+    0,                                          /* tp_repr */
+    0,                                          /* tp_as_number */
+    0,                                          /* tp_as_sequence */
+    0,                                          /* tp_as_mapping */
+    0,                                          /* tp_hash */
+    0,                                          /* tp_call */
+    0,                                          /* tp_str */
+    PyObject_GenericGetAttr,                    /* tp_getattro */
+    0,                                          /* tp_setattro */
+    0,                                          /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,    /* tp_flags */
+    0,                                          /* tp_doc */
+    (traverseproc)record_iter_traverse,         /* tp_traverse */
+    0,                                          /* tp_clear */
+    0,                                          /* tp_richcompare */
+    0,                                          /* tp_weaklistoffset */
+    PyObject_SelfIter,                          /* tp_iter */
+    (iternextfunc)record_iter_next,             /* tp_iternext */
+    record_iter_methods,                        /* tp_methods */
+    0,
+};
+
+
+static PyObject *
+record_iter(PyObject *seq)
+{
+    ApgRecordIterObject *it;
+
+    if (!ApgRecord_CheckExact(seq)) {
+        PyErr_BadInternalCall();
+        return NULL;
+    }
+    it = PyObject_GC_New(ApgRecordIterObject, &ApgRecordIter_Type);
+    if (it == NULL)
+        return NULL;
+    it->it_index = 0;
+    Py_INCREF(seq);
+    it->it_seq = (ApgRecordObject *)seq;
+    PyObject_GC_Track(it);
+    return (PyObject *)it;
+}
+
+
+/* Record Items Iterator */
+
+
+typedef struct {
+    PyObject_HEAD
+    Py_ssize_t it_index;
+    PyObject *it_map_iter;
+    ApgRecordObject *it_seq; /* Set to NULL when iterator is exhausted */
+} ApgRecordItemsObject;
+
+
+static void
+record_items_dealloc(ApgRecordItemsObject *it)
+{
+    PyObject_GC_UnTrack(it);
+    Py_CLEAR(it->it_map_iter);
+    Py_CLEAR(it->it_seq);
+    PyObject_GC_Del(it);
+}
+
+
+static int
+record_items_traverse(ApgRecordItemsObject *it, visitproc visit, void *arg)
+{
+    Py_VISIT(it->it_map_iter);
+    Py_VISIT(it->it_seq);
+    return 0;
+}
+
+
+static PyObject *
+record_items_next(ApgRecordItemsObject *it)
+{
+    ApgRecordObject *seq;
+    PyObject *key;
+    PyObject *val;
+    PyObject *tup;
+
+    assert(it != NULL);
+    seq = it->it_seq;
+    if (seq == NULL) {
+        return NULL;
+    }
+    assert(ApgRecord_CheckExact(seq));
+    assert(it->it_map_iter != NULL);
+
+    key = PyIter_Next(it->it_map_iter);
+    if (key == NULL) {
+        /* likely it_map_iter had less items than seq has values */
+        goto exhausted;
+    }
+
+    if (it->it_index < Py_SIZE(seq)) {
+        val = ApgRecord_GET_ITEM(seq, it->it_index);
+        ++it->it_index;
+        Py_INCREF(val);
+    }
+    else {
+        /* it_map_iter had more items than seq has values */
+        Py_DECREF(key);
+        goto exhausted;
+    }
+
+    tup = PyTuple_New(2);
+    if (tup == NULL) {
+        Py_DECREF(val);
+        Py_DECREF(key);
+        goto exhausted;
+    }
+
+    PyTuple_SET_ITEM(tup, 0, key);
+    PyTuple_SET_ITEM(tup, 1, val);
+    return tup;
+
+exhausted:
+    Py_CLEAR(it->it_map_iter);
+    Py_CLEAR(it->it_seq);
+    return NULL;
+}
+
+
+static PyObject *
+record_items_len(ApgRecordItemsObject *it)
+{
+    Py_ssize_t len = 0;
+    if (it->it_seq) {
+        len = Py_SIZE(it->it_seq) - it->it_index;
+    }
+    return PyLong_FromSsize_t(len);
+}
+
+
+PyDoc_STRVAR(record_items_len_doc,
+             "Private method returning an estimate of len(list(it())).");
+
+
+static PyMethodDef record_items_methods[] = {
+    {"__length_hint__", (PyCFunction)record_items_len, METH_NOARGS,
+        record_items_len_doc},
+    {NULL,              NULL}           /* sentinel */
+};
+
+
+PyTypeObject ApgRecordItems_Type = {
+    PyVarObject_HEAD_INIT(NULL, 0)
+    "RecordItemsIterator",                      /* tp_name */
+    sizeof(ApgRecordItemsObject),               /* tp_basicsize */
+    0,                                          /* tp_itemsize */
+    /* methods */
+    (destructor)record_items_dealloc,           /* tp_dealloc */
+    0,                                          /* tp_print */
+    0,                                          /* tp_getattr */
+    0,                                          /* tp_setattr */
+    0,                                          /* tp_reserved */
+    0,                                          /* tp_repr */
+    0,                                          /* tp_as_number */
+    0,                                          /* tp_as_sequence */
+    0,                                          /* tp_as_mapping */
+    0,                                          /* tp_hash */
+    0,                                          /* tp_call */
+    0,                                          /* tp_str */
+    PyObject_GenericGetAttr,                    /* tp_getattro */
+    0,                                          /* tp_setattro */
+    0,                                          /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,    /* tp_flags */
+    0,                                          /* tp_doc */
+    (traverseproc)record_items_traverse,        /* tp_traverse */
+    0,                                          /* tp_clear */
+    0,                                          /* tp_richcompare */
+    0,                                          /* tp_weaklistoffset */
+    PyObject_SelfIter,                          /* tp_iter */
+    (iternextfunc)record_items_next,            /* tp_iternext */
+    record_items_methods,                       /* tp_methods */
+    0,
+};
+
+
+static PyObject *
+record_new_items_iter(PyObject *seq)
+{
+    ApgRecordItemsObject *it;
+    PyObject *map_iter;
+
+    if (!ApgRecord_CheckExact(seq)) {
+        PyErr_BadInternalCall();
+        return NULL;
+    }
+
+    map_iter = PyObject_GetIter(((ApgRecordObject*)seq)->desc->mapping);
+    if (map_iter == NULL) {
+        return NULL;
+    }
+
+    it = PyObject_GC_New(ApgRecordItemsObject, &ApgRecordItems_Type);
+    if (it == NULL)
+        return NULL;
+
+    it->it_map_iter = map_iter;
+    it->it_index = 0;
+    Py_INCREF(seq);
+    it->it_seq = (ApgRecordObject *)seq;
+    PyObject_GC_Track(it);
+
+    return (PyObject *)it;
+}
+
+
+int ApgRecord_InitTypes(void)
+{
+    if (PyType_Ready(&ApgRecord_Type) < 0) {
+        return -1;
+    }
+
+    if (PyType_Ready(&ApgRecordDesc_Type) < 0) {
+        return -1;
+    }
+
+    if (PyType_Ready(&ApgRecordIter_Type) < 0) {
+        return -1;
+    }
+
+    if (PyType_Ready(&ApgRecordItems_Type) < 0) {
+        return -1;
+    }
+
+    return 0;
+}
+
+
+/* ----------------- */
+
+
+static void
+record_desc_dealloc(ApgRecordDescObject *o)
+{
+    PyObject_GC_UnTrack(o);
+    Py_CLEAR(o->mapping);
+    Py_CLEAR(o->keys);
+    PyObject_GC_Del(o);
+}
+
+
+static int
+record_desc_traverse(ApgRecordDescObject *o, visitproc visit, void *arg)
+{
+    Py_VISIT(o->mapping);
+    Py_VISIT(o->keys);
+    return 0;
+}
+
+
+PyTypeObject ApgRecordDesc_Type = {
+    PyVarObject_HEAD_INIT(NULL, 0)
+    "RecordDescriptor",                         /* tp_name */
+    sizeof(ApgRecordDescObject),                /* tp_basicsize */
+    0,                                          /* tp_itemsize */
+    /* methods */
+    (destructor)record_desc_dealloc,            /* tp_dealloc */
+    0,                                          /* tp_print */
+    0,                                          /* tp_getattr */
+    0,                                          /* tp_setattr */
+    0,                                          /* tp_reserved */
+    0,                                          /* tp_repr */
+    0,                                          /* tp_as_number */
+    0,                                          /* tp_as_sequence */
+    0,                                          /* tp_as_mapping */
+    0,                                          /* tp_hash */
+    0,                                          /* tp_call */
+    0,                                          /* tp_str */
+    PyObject_GenericGetAttr,                    /* tp_getattro */
+    0,                                          /* tp_setattro */
+    0,                                          /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,    /* tp_flags */
+    0,                                          /* tp_doc */
+    (traverseproc)record_desc_traverse,         /* tp_traverse */
+    0,                                          /* tp_clear */
+    0,                                          /* tp_richcompare */
+    0,                                          /* tp_weaklistoffset */
+    PyObject_SelfIter,                          /* tp_iter */
+    0,                                          /* tp_iternext */
+    0,                                          /* tp_methods */
+    0,
+};
+
+
+PyObject *
+ApgRecordDesc_New(PyObject *mapping, PyObject *keys)
+{
+    ApgRecordDescObject *o;
+
+    if (!mapping || !keys || !PyTuple_CheckExact(keys)) {
+        PyErr_BadInternalCall();
+        return NULL;
+    }
+
+    o = PyObject_GC_New(ApgRecordDescObject, &ApgRecordDesc_Type);
+    if (o == NULL) {
+        return NULL;
+    }
+
+    Py_INCREF(mapping);
+    o->mapping = mapping;
+
+    Py_INCREF(keys);
+    o->keys = keys;
+
+    PyObject_GC_Track(o);
+    return (PyObject *) o;
+}
diff --git a/asyncpg/protocol/record/recordobj.h b/asyncpg/protocol/record/recordobj.h
new file mode 100644 (file)
index 0000000..c64cbc6
--- /dev/null
@@ -0,0 +1,52 @@
+#ifndef APG_RECORDOBJ_H
+#define APG_RECORDOBJ_H
+
+#include "Python.h"
+
+
+/* Largest record to save on free list */
+#define ApgRecord_MAXSAVESIZE 20
+
+/* Maximum number of records of each size to save */
+#define ApgRecord_MAXFREELIST 2000
+
+
+typedef struct {
+    PyObject_HEAD
+    PyObject *mapping;
+    PyObject *keys;
+} ApgRecordDescObject;
+
+
+typedef struct {
+    PyObject_VAR_HEAD
+    Py_hash_t self_hash;
+    ApgRecordDescObject *desc;
+    PyObject *ob_item[1];
+
+    /* ob_item contains space for 'ob_size' elements.
+     * Items must normally not be NULL, except during construction when
+     * the record is not yet visible outside the function that builds it.
+     */
+} ApgRecordObject;
+
+
+extern PyTypeObject ApgRecord_Type;
+extern PyTypeObject ApgRecordIter_Type;
+extern PyTypeObject ApgRecordItems_Type;
+
+extern PyTypeObject ApgRecordDesc_Type;
+
+#define ApgRecord_CheckExact(o) (Py_TYPE(o) == &ApgRecord_Type)
+#define ApgRecordDesc_CheckExact(o) (Py_TYPE(o) == &ApgRecordDesc_Type)
+
+#define ApgRecord_SET_ITEM(op, i, v) \
+                       (((ApgRecordObject *)(op))->ob_item[i] = v)
+#define ApgRecord_GET_ITEM(op, i) \
+                       (((ApgRecordObject *)(op))->ob_item[i])
+
+int ApgRecord_InitTypes(void);
+PyObject * ApgRecord_New(PyObject *, Py_ssize_t);
+PyObject * ApgRecordDesc_New(PyObject *, PyObject *);
+
+#endif
diff --git a/asyncpg/protocol/settings.pxd b/asyncpg/protocol/settings.pxd
new file mode 100644 (file)
index 0000000..b50fe14
--- /dev/null
@@ -0,0 +1,25 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+cdef class ConnectionSettings:
+    cdef:
+        str _encoding
+        object _codec
+        dict _settings
+        bint _is_utf8
+        DataCodecConfig _data_codecs
+
+    cdef add_setting(self, str name, str val)
+    cdef inline is_encoding_utf8(self)
+    cpdef inline get_text_codec(self)
+    cpdef inline register_data_types(self, types)
+    cpdef inline add_python_codec(
+        self, typeoid, typename, typeschema, typekind, encoder,
+        decoder, binary)
+    cpdef inline set_builtin_type_codec(
+        self, typeoid, typename, typeschema, typekind, alias_to)
+    cpdef inline Codec get_data_codec(self, uint32_t oid, CodecFormat format=*)
diff --git a/asyncpg/protocol/settings.pyx b/asyncpg/protocol/settings.pyx
new file mode 100644 (file)
index 0000000..9360c45
--- /dev/null
@@ -0,0 +1,62 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+@cython.final
+cdef class ConnectionSettings:
+
+    def __cinit__(self, conn_key):
+        self._encoding = 'utf-8'
+        self._is_utf8 = True
+        self._settings = {}
+        self._codec = codecs.lookup('utf-8')
+        self._data_codecs = DataCodecConfig(conn_key)
+
+    cdef add_setting(self, str name, str val):
+        self._settings[name] = val
+        if name == 'client_encoding':
+            py_enc = get_python_encoding(val)
+            self._codec = codecs.lookup(py_enc)
+            self._encoding = self._codec.name
+            self._is_utf8 = self._encoding == 'utf-8'
+
+    cdef inline is_encoding_utf8(self):
+        return self._is_utf8
+
+    cpdef inline get_text_codec(self):
+        return self._codec
+
+    cpdef inline register_data_types(self, types):
+        self._data_codecs.add_types(types)
+
+    cpdef inline add_python_codec(self, typeoid, typename, typeschema,
+                                  typekind, encoder, decoder, binary):
+        self._data_codecs.add_python_codec(typeoid, typename, typeschema,
+                                           typekind, encoder, decoder, binary)
+
+    cpdef inline set_builtin_type_codec(self, typeoid, typename, typeschema,
+                                        typekind, alias_to):
+        self._data_codecs.set_builtin_type_codec(typeoid, typename, typeschema,
+                                          typekind, alias_to)
+
+    cpdef inline Codec get_data_codec(self, uint32_t oid,
+                                      CodecFormat format=PG_FORMAT_ANY):
+        if format == PG_FORMAT_ANY:
+            codec = self._data_codecs.get_codec(oid, PG_FORMAT_BINARY)
+            if codec is None:
+                codec = self._data_codecs.get_codec(oid, PG_FORMAT_TEXT)
+            return codec
+        else:
+            return self._data_codecs.get_codec(oid, format)
+
+    def __getattr__(self, name):
+        if not name.startswith('_'):
+            try:
+                return self._settings[name]
+            except KeyError:
+                raise AttributeError(name) from None
+
+        return object.__getattr__(self, name)
diff --git a/asyncpg/serverversion.py b/asyncpg/serverversion.py
new file mode 100644 (file)
index 0000000..2e31031
--- /dev/null
@@ -0,0 +1,33 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+from . import types
+
+
+def split_server_version_string(version_string):
+    version_string = version_string.strip()
+    if version_string.startswith('PostgreSQL '):
+        version_string = version_string[len('PostgreSQL '):]
+
+    parts = version_string.strip().split('.')
+    if not parts[-1].isdigit():
+        # release level specified
+        level = parts[-1].rstrip('0123456789').lower()
+        serial = parts[-1][level:]
+        versions = [int(p) for p in parts[:-1]][:3]
+    else:
+        level = 'final'
+        serial = 0
+        versions = [int(p) for p in parts][:3]
+
+    if len(versions) < 3:
+        versions += [0] * (3 - len(versions))
+
+    versions.append(level)
+    versions.append(serial)
+
+    return types.ServerVersion(*versions)
diff --git a/asyncpg/transaction.py b/asyncpg/transaction.py
new file mode 100644 (file)
index 0000000..edbdeec
--- /dev/null
@@ -0,0 +1,212 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import enum
+
+from . import exceptions as apg_errors
+
+
+class TransactionState(enum.Enum):
+    NEW = 0
+    STARTED = 1
+    COMMITTED = 2
+    ROLLEDBACK = 3
+    FAILED = 4
+
+
+ISOLATION_LEVELS = {'read_committed', 'serializable', 'repeatable_read'}
+
+
+class Transaction:
+    """Represents a transaction or savepoint block.
+
+    Transactions are created by calling the
+    :meth:`Connection.transaction() <connection.Connection.transaction>`
+    function.
+    """
+
+    __slots__ = ('_connection', '_isolation', '_readonly', '_deferrable',
+                 '_state', '_nested', '_id', '_managed')
+
+    def __init__(self, connection, isolation, readonly, deferrable):
+        if isolation not in ISOLATION_LEVELS:
+            raise ValueError(
+                'isolation is expected to be either of {}, '
+                'got {!r}'.format(ISOLATION_LEVELS, isolation))
+
+        if isolation != 'serializable':
+            if readonly:
+                raise ValueError(
+                    '"readonly" is only supported for '
+                    'serializable transactions')
+
+            if deferrable and not readonly:
+                raise ValueError(
+                    '"deferrable" is only supported for '
+                    'serializable readonly transactions')
+
+        self._connection = connection
+        self._isolation = isolation
+        self._readonly = readonly
+        self._deferrable = deferrable
+        self._state = TransactionState.NEW
+        self._nested = False
+        self._id = None
+        self._managed = False
+
+    async def __aenter__(self):
+        if self._managed:
+            raise apg_errors.InterfaceError(
+                'cannot enter context: already in an `async with` block')
+        self._managed = True
+        await self.start()
+
+    async def __aexit__(self, extype, ex, tb):
+        try:
+            if extype is not None:
+                await self.__rollback()
+            else:
+                await self.__commit()
+        finally:
+            self._managed = False
+
+    async def start(self):
+        """Enter the transaction or savepoint block."""
+        self.__check_state_base('start')
+        if self._state is TransactionState.STARTED:
+            raise apg_errors.InterfaceError(
+                'cannot start; the transaction is already started')
+
+        con = self._connection
+
+        if con._top_xact is None:
+            con._top_xact = self
+        else:
+            # Nested transaction block
+            top_xact = con._top_xact
+            if self._isolation != top_xact._isolation:
+                raise apg_errors.InterfaceError(
+                    'nested transaction has a different isolation level: '
+                    'current {!r} != outer {!r}'.format(
+                        self._isolation, top_xact._isolation))
+            self._nested = True
+
+        if self._nested:
+            self._id = con._get_unique_id()
+            query = 'SAVEPOINT {};'.format(self._id)
+        else:
+            if self._isolation == 'read_committed':
+                query = 'BEGIN;'
+            elif self._isolation == 'repeatable_read':
+                query = 'BEGIN ISOLATION LEVEL REPEATABLE READ;'
+            else:
+                query = 'BEGIN ISOLATION LEVEL SERIALIZABLE'
+                if self._readonly:
+                    query += ' READ ONLY'
+                if self._deferrable:
+                    query += ' DEFERRABLE'
+                query += ';'
+
+        try:
+            await self._connection.execute(query)
+        except:
+            self._state = TransactionState.FAILED
+            raise
+        else:
+            self._state = TransactionState.STARTED
+
+    def __check_state_base(self, opname):
+        if self._state is TransactionState.COMMITTED:
+            raise apg_errors.InterfaceError(
+                'cannot {}; the transaction is already committed'.format(
+                    opname))
+        if self._state is TransactionState.ROLLEDBACK:
+            raise apg_errors.InterfaceError(
+                'cannot {}; the transaction is already rolled back'.format(
+                    opname))
+        if self._state is TransactionState.FAILED:
+            raise apg_errors.InterfaceError(
+                'cannot {}; the transaction is in error state'.format(
+                    opname))
+
+    def __check_state(self, opname):
+        if self._state is not TransactionState.STARTED:
+            if self._state is TransactionState.NEW:
+                raise apg_errors.InterfaceError(
+                    'cannot {}; the transaction is not yet started'.format(
+                        opname))
+            self.__check_state_base(opname)
+
+    async def __commit(self):
+        self.__check_state('commit')
+
+        if self._connection._top_xact is self:
+            self._connection._top_xact = None
+
+        if self._nested:
+            query = 'RELEASE SAVEPOINT {};'.format(self._id)
+        else:
+            query = 'COMMIT;'
+
+        try:
+            await self._connection.execute(query)
+        except:
+            self._state = TransactionState.FAILED
+            raise
+        else:
+            self._state = TransactionState.COMMITTED
+
+    async def __rollback(self):
+        self.__check_state('rollback')
+
+        if self._connection._top_xact is self:
+            self._connection._top_xact = None
+
+        if self._nested:
+            query = 'ROLLBACK TO {};'.format(self._id)
+        else:
+            query = 'ROLLBACK;'
+
+        try:
+            await self._connection.execute(query)
+        except:
+            self._state = TransactionState.FAILED
+            raise
+        else:
+            self._state = TransactionState.ROLLEDBACK
+
+    async def commit(self):
+        """Exit the transaction or savepoint block and commit changes."""
+        if self._managed:
+            raise apg_errors.InterfaceError(
+                'cannot manually commit from within an `async with` block')
+        await self.__commit()
+
+    async def rollback(self):
+        """Exit the transaction or savepoint block and rollback changes."""
+        if self._managed:
+            raise apg_errors.InterfaceError(
+                'cannot manually rollback from within an `async with` block')
+        await self.__rollback()
+
+    def __repr__(self):
+        attrs = []
+        attrs.append('state:{}'.format(self._state.name.lower()))
+
+        attrs.append(self._isolation)
+        if self._readonly:
+            attrs.append('readonly')
+        if self._deferrable:
+            attrs.append('deferrable')
+
+        if self.__class__.__module__.startswith('asyncpg.'):
+            mod = 'asyncpg'
+        else:
+            mod = self.__class__.__module__
+
+        return '<{}.{} {} {:#x}>'.format(
+            mod, self.__class__.__name__, ' '.join(attrs), id(self))
diff --git a/asyncpg/types.py b/asyncpg/types.py
new file mode 100644 (file)
index 0000000..b2a8e46
--- /dev/null
@@ -0,0 +1,417 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import collections
+
+
+__all__ = (
+    'Type', 'Attribute', 'Range', 'BitString', 'Point', 'Path', 'Polygon',
+    'Box', 'Line', 'LineSegment', 'Circle', 'ServerVersion'
+)
+
+
+Type = collections.namedtuple('Type', ['oid', 'name', 'kind', 'schema'])
+Type.__doc__ = 'Database data type.'
+Type.oid.__doc__ = 'OID of the type.'
+Type.name.__doc__ = 'Type name.  For example "int2".'
+Type.kind.__doc__ = \
+    'Type kind.  Can be "scalar", "array", "composite" or "range".'
+Type.schema.__doc__ = 'Name of the database schema that defines the type.'
+
+
+Attribute = collections.namedtuple('Attribute', ['name', 'type'])
+Attribute.__doc__ = 'Database relation attribute.'
+Attribute.name.__doc__ = 'Attribute name.'
+Attribute.type.__doc__ = 'Attribute data type :class:`asyncpg.types.Type`.'
+
+
+ServerVersion = collections.namedtuple(
+    'ServerVersion', ['major', 'minor', 'micro', 'releaselevel', 'serial'])
+ServerVersion.__doc__ = 'PostgreSQL server version tuple.'
+
+
+class Range:
+    """Immutable representation of PostgreSQL `range` type."""
+
+    __slots__ = '_lower', '_upper', '_lower_inc', '_upper_inc', '_empty'
+
+    def __init__(self, lower=None, upper=None, *,
+                 lower_inc=True, upper_inc=False,
+                 empty=False):
+        self._empty = empty
+        if empty:
+            self._lower = self._upper = None
+            self._lower_inc = self._upper_inc = False
+        else:
+            self._lower = lower
+            self._upper = upper
+            self._lower_inc = lower is not None and lower_inc
+            self._upper_inc = upper is not None and upper_inc
+
+    @property
+    def lower(self):
+        return self._lower
+
+    @property
+    def lower_inc(self):
+        return self._lower_inc
+
+    @property
+    def lower_inf(self):
+        return self._lower is None and not self._empty
+
+    @property
+    def upper(self):
+        return self._upper
+
+    @property
+    def upper_inc(self):
+        return self._upper_inc
+
+    @property
+    def upper_inf(self):
+        return self._upper is None and not self._empty
+
+    @property
+    def isempty(self):
+        return self._empty
+
+    def __bool__(self):
+        return not self._empty
+
+    def __eq__(self, other):
+        if not isinstance(other, Range):
+            return NotImplemented
+
+        return (
+            self._lower,
+            self._upper,
+            self._lower_inc,
+            self._upper_inc,
+            self._empty
+        ) == (
+            other._lower,
+            other._upper,
+            other._lower_inc,
+            other._upper_inc,
+            other._empty
+        )
+
+    def __hash__(self, other):
+        return hash((
+            self._lower,
+            self._upper,
+            self._lower_inc,
+            self._upper_inc,
+            self._empty
+        ))
+
+    def __repr__(self):
+        if self._empty:
+            desc = 'empty'
+        else:
+            if self._lower is None or not self._lower_inc:
+                lb = '('
+            else:
+                lb = '['
+
+            if self._lower is not None:
+                lb += repr(self._lower)
+
+            if self._upper is not None:
+                ub = repr(self._upper)
+            else:
+                ub = ''
+
+            if self._upper is None or not self._upper_inc:
+                ub += ')'
+            else:
+                ub += ']'
+
+            desc = '{}, {}'.format(lb, ub)
+
+        return '<Range {}>'.format(desc)
+
+    __str__ = __repr__
+
+
+class BitString:
+    """Immutable representation of PostgreSQL `bit` and `varbit` types."""
+
+    __slots__ = '_bytes', '_bitlength'
+
+    def __init__(self, bitstring=None):
+        if not bitstring:
+            self._bytes = bytes()
+            self._bitlength = 0
+        else:
+            bytelen = len(bitstring) // 8 + 1
+            bytes_ = bytearray(bytelen)
+            byte = 0
+            byte_pos = 0
+            bit_pos = 0
+
+            for i, bit in enumerate(bitstring):
+                if bit == ' ':
+                    continue
+                bit = int(bit)
+                if bit != 0 and bit != 1:
+                    raise ValueError(
+                        'invalid bit value at position {}'.format(i))
+
+                byte |= bit << (8 - bit_pos - 1)
+                bit_pos += 1
+                if bit_pos == 8:
+                    bytes_[byte_pos] = byte
+                    byte = 0
+                    byte_pos += 1
+                    bit_pos = 0
+
+            if bit_pos != 0:
+                bytes_[byte_pos] = byte
+
+            bitlen = byte_pos * 8 + bit_pos
+            bytelen = byte_pos + (1 if bit_pos else 0)
+
+            self._bytes = bytes(bytes_[:bytelen])
+            self._bitlength = bitlen
+
+    @classmethod
+    def frombytes(cls, bytes_=None, bitlength=None):
+        if bitlength is None and bytes_ is None:
+            bytes_ = bytes()
+            bitlength = 0
+
+        elif bitlength is None:
+            bitlength = len(bytes_) * 8
+
+        else:
+            if bytes_ is None:
+                bytes_ = bytes(bitlength // 8 + 1)
+                bitlength = bitlength
+            else:
+                bytes_len = len(bytes_) * 8
+
+                if bytes_len == 0 and bitlength != 0:
+                    raise ValueError('invalid bit length specified')
+
+                if bytes_len != 0 and bitlength == 0:
+                    raise ValueError('invalid bit length specified')
+
+                if bitlength < bytes_len - 8:
+                    raise ValueError('invalid bit length specified')
+
+                if bitlength > bytes_len:
+                    raise ValueError('invalid bit length specified')
+
+        result = cls()
+        result._bytes = bytes_
+        result._bitlength = bitlength
+
+        return result
+
+    @property
+    def bytes(self):
+        return self._bytes
+
+    def as_string(self):
+        s = ''
+
+        for i in range(self._bitlength):
+            s += str(self._getitem(i))
+            if i % 4 == 3:
+                s += ' '
+
+        return s.strip()
+
+    def __repr__(self):
+        return '<BitString {}>'.format(self.as_string())
+
+    __str__ = __repr__
+
+    def __eq__(self, other):
+        if not isinstance(other, BitString):
+            return NotImplemented
+
+        return (self._bytes == other._bytes and
+                self._bitlength == other._bitlength)
+
+    def __hash__(self):
+        return hash((self._bytes, self._bitlength))
+
+    def _getitem(self, i):
+        byte = self._bytes[i // 8]
+        shift = 8 - i % 8 - 1
+        return (byte >> shift) & 0x1
+
+    def __getitem__(self, i):
+        if isinstance(i, slice):
+            raise NotImplementedError('BitString does not support slices')
+
+        if i >= self._bitlength:
+            raise IndexError('index out of range')
+
+        return self._getitem(i)
+
+    def __len__(self):
+        return self._bitlength
+
+
+class Point(tuple):
+    """Immutable representation of PostgreSQL `point` type."""
+
+    __slots__ = ()
+
+    def __new__(cls, x, y):
+        return super().__new__(cls, (float(x), float(y)))
+
+    def __repr__(self):
+        return '{}.{}({})'.format(
+            type(self).__module__,
+            type(self).__name__,
+            tuple.__repr__(self)
+        )
+
+    @property
+    def x(self):
+        return self[0]
+
+    @property
+    def y(self):
+        return self[1]
+
+
+class Box(tuple):
+    """Immutable representation of PostgreSQL `box` type."""
+
+    __slots__ = ()
+
+    def __new__(cls, high, low):
+        return super().__new__(cls, (Point(*high), Point(*low)))
+
+    def __repr__(self):
+        return '{}.{}({})'.format(
+            type(self).__module__,
+            type(self).__name__,
+            tuple.__repr__(self)
+        )
+
+    @property
+    def high(self):
+        return self[0]
+
+    @property
+    def low(self):
+        return self[1]
+
+
+class Line(tuple):
+    """Immutable representation of PostgreSQL `line` type."""
+
+    __slots__ = ()
+
+    def __new__(cls, A, B, C):
+        return super().__new__(cls, (A, B, C))
+
+    @property
+    def A(self):
+        return self[0]
+
+    @property
+    def B(self):
+        return self[1]
+
+    @property
+    def C(self):
+        return self[2]
+
+
+class LineSegment(tuple):
+    """Immutable representation of PostgreSQL `lseg` type."""
+
+    __slots__ = ()
+
+    def __new__(cls, p1, p2):
+        return super().__new__(cls, (Point(*p1), Point(*p2)))
+
+    def __repr__(self):
+        return '{}.{}({})'.format(
+            type(self).__module__,
+            type(self).__name__,
+            tuple.__repr__(self)
+        )
+
+    @property
+    def p1(self):
+        return self[0]
+
+    @property
+    def p2(self):
+        return self[1]
+
+
+class Path:
+    """Immutable representation of PostgreSQL `path` type."""
+
+    __slots__ = '_is_closed', 'points'
+
+    def __init__(self, *points, is_closed=False):
+        self.points = tuple(Point(*p) for p in points)
+        self._is_closed = is_closed
+
+    @property
+    def is_closed(self):
+        return self._is_closed
+
+    def __eq__(self, other):
+        if not isinstance(other, Path):
+            return NotImplemented
+
+        return (self.points == other.points and
+                self._is_closed == other._is_closed)
+
+    def __hash__(self):
+        return hash((self.points, self.is_closed))
+
+    def __iter__(self):
+        return iter(self.points)
+
+    def __len__(self):
+        return len(self.points)
+
+    def __getitem__(self, i):
+        return self.points[i]
+
+    def __contains__(self, point):
+        return point in self.points
+
+
+class Polygon(Path):
+    """Immutable representation of PostgreSQL `polygon` type."""
+
+    __slots__ = ()
+
+    def __init__(self, *points):
+        # polygon is always closed
+        super().__init__(*points, is_closed=True)
+
+
+class Circle(tuple):
+    """Immutable representation of PostgreSQL `circle` type."""
+
+    __slots__ = ()
+
+    def __new__(cls, center, radius):
+        return super().__new__(cls, (center, radius))
+
+    @property
+    def center(self):
+        return self[0]
+
+    @property
+    def radius(self):
+        return self[1]
diff --git a/docs/api/index.rst b/docs/api/index.rst
new file mode 100644 (file)
index 0000000..43486bd
--- /dev/null
@@ -0,0 +1,329 @@
+.. _asyncpg-api-reference:
+
+=============
+API Reference
+=============
+
+.. module:: asyncpg
+    :synopsis: A fast PostgreSQL Database Client Library for Python/asyncio
+
+.. currentmodule:: asyncpg
+
+
+.. _asyncpg-api-connection:
+
+Connection
+==========
+
+.. autofunction:: asyncpg.connection.connect
+
+
+.. autoclass:: asyncpg.connection.Connection
+   :members:
+
+
+.. _asyncpg-api-prepared-stmt:
+
+Prepared Statements
+===================
+
+Prepared statements are a PostgreSQL feature that can be used to optimize the
+performance of queries that are executed more than once.  When a query
+is *prepared* by a call to :meth:`Connection.prepare`, the server parses,
+analyzes and compiles the query allowing to reuse that work once there is
+a need to run the same query again.
+
+.. code-block:: pycon
+
+   >>> import asyncpg, asyncio
+   >>> loop = asyncio.get_event_loop()
+   >>> async def run():
+   ...     conn = await asyncpg.connect()
+   ...     stmt = await conn.prepare('''SELECT 2 ^ $1''')
+   ...     print(await stmt.fetchval(10))
+   ...     print(await stmt.fetchval(20))
+   ...
+   >>> loop.run_until_complete(run())
+   1024.0
+   1048576.0
+
+.. note::
+
+   asyncpg automatically maintains a small LRU cache for queries executed
+   during calls to the :meth:`~Connection.fetch`, :meth:`~Connection.fetchrow`,
+   or :meth:`~Connection.fetchval` methods.
+
+
+.. autoclass:: asyncpg.prepared_stmt.PreparedStatement()
+   :members:
+
+
+.. _asyncpg-api-transaction:
+
+Transactions
+============
+
+The most common way to use transactions is through an ``async with`` statement:
+
+.. code-block:: python
+
+   async with connection.transaction():
+       await connection.execute("INSERT INTO mytable VALUES(1, 2, 3)")
+
+
+asyncpg supports nested transactions (a nested transaction context will create
+a `savepoint`_.):
+
+.. code-block:: python
+
+   async with connection.transaction():
+       await connection.execute('CREATE TABLE mytab (a int)')
+
+       try:
+           # Create a nested transaction:
+           async with connection.transaction():
+               await connection.execute('INSERT INTO mytab (a) VALUES (1), (2)')
+               # This nested transaction will be automatically rolled back:
+               raise Exception
+       except:
+           # Ignore exception
+           pass
+
+       # Because the nested transaction was rolled back, there
+       # will be nothing in `mytab`.
+       assert await connection.fetch('SELECT a FROM mytab') == []
+
+Alternatively, transactions can be used without an ``async with`` block:
+
+.. code-block:: python
+
+    tr = connection.transaction()
+    await tr.start()
+    try:
+        ...
+    except:
+        await tr.rollback()
+        raise
+    finally:
+        await tr.commit()
+
+
+See also the
+:meth:`Connection.transaction() <asyncpg.connection.Connection.transaction>`
+function.
+
+.. _savepoint: https://www.postgresql.org/docs/current/static/sql-savepoint.html
+
+
+.. autoclass:: asyncpg.transaction.Transaction()
+   :members:
+
+   .. describe:: async with c:
+
+      start and commit/rollback the transaction or savepoint block
+      automatically when entering and exiting the code inside the
+      context manager block.
+
+
+.. _asyncpg-api-cursor:
+
+Cursors
+=======
+
+Cursors are useful when there is a need to iterate over the results of
+a large query without fetching all rows at once.  The cursor interface
+provided by asyncpg supports *asynchronous iteration* via the ``async for``
+statement, and also a way to read row chunks and skip forward over the
+result set.
+
+To iterate over a cursor using a connection object use
+:meth:`Connection.cursor() <asyncpg.connection.Connection.cursor>`.
+To make the iteration efficient, the cursor will prefetch records to
+reduce the number of queries sent to the server:
+
+.. code-block:: python
+
+    async def iterate(con: Connection):
+        async with con.transaction():
+            # Postgres requires non-scrollable cursors to be created
+            # and used in a transaction.
+            async for record in con.cursor('SELECT generate_series(0, 100)'):
+                print(record)
+
+Or, alternatively, you can iterate over the cursor manually (cursor
+won't be prefetching any rows):
+
+.. code-block:: python
+
+    async def iterate(con: Connection):
+        async with con.transaction():
+            # Postgres requires non-scrollable cursors to be created
+            # and used in a transaction.
+
+            async with con.transaction():
+                # Create a Cursor object
+                cur = await con.cursor('SELECT generate_series(0, 100)')
+
+                # Move the cursor 10 rows forward
+                await cur.forward(10)
+
+                # Fetch one row and print it
+                print(await cur.fetchrow())
+
+                # Fetch a list of 5 rows and print it
+                print(await cur.fetch(5))
+
+It's also possible to create cursors from prepared statements:
+
+.. code-block:: python
+
+    async def iterate(con: Connection):
+        # Create a prepared statement that will accept one argument
+        stmt = await con.prepare('SELECT generate_series(0, $1)')
+
+        async with con.transaction():
+            # Postgres requires non-scrollable cursors to be created
+            # and used in a transaction.
+
+            # Execute the prepared statement passing `10` as the
+            # argument -- that will generate a series or records
+            # from 0..10.  Iterate over all of them and print every
+            # record.
+            async for record in stmt.cursor(10):
+                print(record)
+
+
+.. note::
+
+   Cursors created by a call to
+   :meth:`Connection.cursor() <asyncpg.connection.Connection.cursor>` or
+   :meth:`PreparedStatement.cursor() <asyncpg.prepared_stmt.PreparedStatement.cursor>`
+   are *non-scrollable*: they can only be read forwards.  To create a scrollable
+   cursor, use the ``DECLARE ... SCROLL CURSOR`` SQL statement directly.
+
+.. warning::
+
+   Cursors created by a call to
+   :meth:`Connection.cursor() <asyncpg.connection.Connection.cursor>` or
+   :meth:`PreparedStatement.cursor() <asyncpg.prepared_stmt.PreparedStatement.cursor>`
+   cannot be used outside of a transaction.  Any such attempt will result in
+   :exc:`~asyncpg.exceptions.InterfaceError`.
+
+   To create a cursor usable outside of a transaction, use the
+   ``DECLARE ... CURSOR WITH HOLD`` SQL statement directly.
+
+
+.. autoclass:: asyncpg.cursor.CursorFactory()
+   :members:
+
+   .. describe:: async for row in c
+
+      Execute the statement and iterate over the results asynchronously.
+
+   .. describe:: await c
+
+      Execute the statement and return an instance of
+      :class:`~asyncpg.cursor.Cursor` which can be used to navigate over and
+      fetch subsets of the query results.
+
+
+.. autoclass:: asyncpg.cursor.Cursor()
+   :members:
+
+
+.. _asyncpg-api-pool:
+
+Connection Pool
+===============
+
+.. autofunction:: asyncpg.pool.create_pool
+
+
+.. autoclass:: asyncpg.pool.Pool()
+   :members:
+
+
+.. _asyncpg-api-record:
+
+Record Objects
+==============
+
+Each row (or composite type value) returned by calls to ``fetch*`` methods
+is represented by an instance of the ``Record`` object.  ``Record`` objects
+are similar to instances of ``collections.namedtuple`` and allow addressing
+of values either by a numeric index or by a field name:
+
+.. code-block:: pycon
+
+    >>> import asyncpg
+    >>> import asyncio
+    >>> loop = asyncio.get_event_loop()
+    >>> conn = loop.run_until_complete(asyncpg.connect())
+    >>> r = loop.run_until_complete(conn.fetchrow('''
+    ...     SELECT oid, rolname, rolsuper FROM pg_roles WHERE rolname = user'''))
+    >>> r
+    <Record oid=16388 rolname='elvis' rolsuper=True>
+    >>> r['oid']
+    16388
+    >>> r[0]
+    16388
+
+
+.. class:: Record()
+
+   A read-only representation of PostgreSQL row.
+
+   .. describe:: len(r)
+
+      Return the number of fields in record *r*.
+
+   .. describe:: r[field]
+
+      Return the field of *r* with field name or index *field*.
+
+   .. describe:: name in r
+
+      Return ``True`` if record *r* has a field named *name*.
+
+   .. describe:: iter(r)
+
+      Return an iterator over the *values* of the record *r*.
+
+   .. method:: values()
+
+      Return an iterator over the record values.
+
+   .. method:: keys()
+
+      Return an iterator over the record field names.
+
+   .. method:: items()
+
+      Return an iterator over ``(field, value)`` pairs.
+
+
+.. class:: ConnectionSettings()
+
+    A read-only collection of Connection settings.
+
+    .. describe:: settings.setting_name
+
+       Return the value of the "setting_name" setting.  Raises an
+       ``AttributeError`` if the setting is not defined.
+
+       Example:
+
+       .. code-block:: pycon
+
+           >>> connection.get_settings().client_encoding
+           'UTF8'
+
+
+Introspection
+=============
+
+.. autoclass:: asyncpg.types.Type()
+   :members:
+
+.. autoclass:: asyncpg.types.Attribute()
+   :members:
diff --git a/docs/conf.py b/docs/conf.py
new file mode 100644 (file)
index 0000000..b25e0e2
--- /dev/null
@@ -0,0 +1,93 @@
+#!/usr/bin/env python3
+
+import alabaster
+import os
+import re
+import sys
+
+sys.path.insert(0, os.path.abspath('..'))
+
+with open(os.path.abspath('../setup.py'), 'rt') as f:
+    _m = re.search(
+        r'''VERSION\s*=\s*(?P<q>'|")(?P<ver>[\d\.]+)(?P=q)''', f.read())
+    if not _m:
+        raise RuntimeError('unable to read the version from setup.py')
+    version = _m.group('ver')
+
+
+# -- General configuration ------------------------------------------------
+
+extensions = [
+    'sphinx.ext.autodoc',
+    'sphinx.ext.doctest',
+    'sphinx.ext.viewcode',
+    'sphinx.ext.githubpages',
+    'sphinxcontrib.asyncio',
+]
+
+add_module_names = False
+
+templates_path = ['_templates']
+source_suffix = '.rst'
+master_doc = 'index'
+project = 'asyncpg'
+copyright = '2016-present, the ayncpg authors and contributors'
+author = '<See AUTHORS file>'
+release = version
+language = None
+exclude_patterns = ['_build']
+pygments_style = 'sphinx'
+todo_include_todos = False
+suppress_warnings = ['image.nonlocal_uri']
+
+# -- Options for HTML output ----------------------------------------------
+
+html_theme = 'sphinx_rtd_theme'
+# html_theme_options = {
+#     'description': 'asyncpg is a fast PostgreSQL client library for the '
+#                    'Python asyncio framework',
+#     'show_powered_by': False,
+# }
+html_theme_path = [alabaster.get_path()]
+html_title = 'asyncpg Documentation'
+html_short_title = 'asyncpg'
+html_static_path = []
+html_sidebars = {
+    '**': [
+        'about.html',
+        'navigation.html',
+    ]
+}
+html_show_sourcelink = False
+html_show_sphinx = False
+html_show_copyright = True
+htmlhelp_basename = 'asyncpgdoc'
+
+
+# -- Options for LaTeX output ---------------------------------------------
+
+latex_elements = {}
+
+latex_documents = [
+    (master_doc, 'asyncpg.tex', 'asyncpg Documentation',
+     author, 'manual'),
+]
+
+
+# -- Options for manual page output ---------------------------------------
+
+man_pages = [
+    (master_doc, 'asyncpg', 'asyncpg Documentation',
+     [author], 1)
+]
+
+
+# -- Options for Texinfo output -------------------------------------------
+
+texinfo_documents = [
+    (master_doc, 'asyncpg', 'asyncpg Documentation',
+     author, 'asyncpg',
+     'asyncpg is a fast PostgreSQL client library for the '
+     'Python asyncio framework',
+     'Miscellaneous'),
+]
diff --git a/docs/examples.rst b/docs/examples.rst
new file mode 100644 (file)
index 0000000..67bf568
--- /dev/null
@@ -0,0 +1,47 @@
+.. _asyncpg-examples:
+
+
+Usage Examples
+==============
+
+Below is an example of how **asyncpg** can be used to implement a simple
+Web service that computes the requested power of two.
+
+
+.. code-block:: python
+
+    import asyncio
+    import asyncpg
+    from aiohttp import web
+
+
+    async def handle(request):
+        """Handle incoming requests."""
+        pool = request.app['pool']
+        power = int(request.match_info.get('power', 10))
+
+        # Take a connection from the pool.
+        async with pool.acquire() as connection:
+            # Open a transaction.
+            async with connection.transaction():
+                # Run the query passing the request argument.
+                result = await connection.fetchval('select 2 ^ $1', power)
+                return web.Response(
+                    text="2 ^ {} is {}".format(power, result))
+
+
+    async def init_app():
+        """Initialize the application server."""
+        app = web.Application()
+        # Create a database connection pool
+        app['pool'] = await asyncpg.create_pool(database='postgres',
+                                                user='postgres')
+        # Configure service routes
+        app.router.add_route('GET', '/{power:\d+}', handle)
+        app.router.add_route('GET', '/', handle)
+        return app
+
+
+    loop = asyncio.get_event_loop()
+    app = loop.run_until_complete(init_app())
+    web.run_app(app)
diff --git a/docs/index.rst b/docs/index.rst
new file mode 100644 (file)
index 0000000..33d61a4
--- /dev/null
@@ -0,0 +1,29 @@
+.. image:: https://travis-ci.org/MagicStack/asyncpg.svg?branch=master
+    :target: https://travis-ci.org/MagicStack/asyncpg
+
+.. image:: https://img.shields.io/pypi/status/asyncpg.svg?maxAge=2592000?style=plastic
+    :target: https://pypi.python.org/pypi/asyncpg
+
+
+=======
+asyncpg
+=======
+
+**asyncpg** is a database interface library designed specifically for
+PostgreSQL and Python/asyncio.  asyncpg is an efficient, clean implementation
+of PostgreSQL server binary protocol for use with Python's ``asyncio``
+framework.
+
+**asyncpg** is a C extension and it is only currently compatible with
+CPython 3.5.
+
+
+Contents
+--------
+
+.. toctree::
+   :maxdepth: 2
+
+   installation
+   examples
+   api/index
diff --git a/docs/installation.rst b/docs/installation.rst
new file mode 100644 (file)
index 0000000..44c7eb4
--- /dev/null
@@ -0,0 +1,57 @@
+.. _asyncpg-installation:
+
+
+Installation
+============
+
+**asyncpg** has no external dependencies and the recommended way to
+install it is to use **pip**:
+
+.. code-block:: bash
+
+    $ pip install asyncpg
+
+
+.. note::
+
+   It is recommended to use **pip** version **8.1** or later to take
+   advantage of the precompiled wheel packages.  Older versions of pip
+   will ignore the wheel packages and install asyncpg from the source
+   package.  In that case a working C compiler is required.
+
+
+Building from source
+--------------------
+
+If you want to build **asyncpg** from a Git checkout you will need:
+
+  * A working C compiler.
+  * CPython header files.  These can usually be obtained by installing
+    the relevant Python development package: **python3-dev** on Debian/Ubuntu,
+    **python3-devel** on RHEL/Fedora.
+  * Cython version 0.24 or later.  The easiest way to install it to use
+    virtualenv and pip, however a system package should also suffice.
+  * GNU make
+
+Once the above requirements are satisfied, run:
+
+.. code-block:: bash
+
+    $ make
+
+At this point you can run the usual ``setup.py`` commands or
+``pip install -e .`` to install the newly built version.
+
+.. note::
+
+   A debug build can be created by running ``make debug``.
+
+
+Running tests
+-------------
+
+To execute the testsuite simply run:
+
+.. code-block:: bash
+
+    $ make test
diff --git a/performance.png b/performance.png
new file mode 100644 (file)
index 0000000..14f4cd8
Binary files /dev/null and b/performance.png differ
diff --git a/setup.cfg b/setup.cfg
new file mode 100644 (file)
index 0000000..861a9f5
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,5 @@
+[egg_info]
+tag_build = 
+tag_date = 0
+tag_svn_revision = 0
+
diff --git a/setup.py b/setup.py
new file mode 100644 (file)
index 0000000..94e7c5f
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,213 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import os
+import os.path
+import platform
+import re
+import sys
+import unittest
+
+import setuptools
+from setuptools.command import build_ext as _build_ext
+
+
+if sys.version_info < (3, 5):
+    raise RuntimeError('asyncpg requires Python 3.5 or greater')
+
+VERSION = '0.8.4'
+CFLAGS = ['-O2']
+LDFLAGS = []
+
+if platform.uname().system == 'Windows':
+    LDFLAGS.append('ws2_32.lib')
+else:
+    CFLAGS.extend(['-Wall', '-Wsign-compare', '-Wconversion'])
+
+
+def discover_tests():
+    test_loader = unittest.TestLoader()
+    test_suite = test_loader.discover('tests', pattern='test_*.py')
+    return test_suite
+
+
+class build_ext(_build_ext.build_ext):
+    user_options = _build_ext.build_ext.user_options + [
+        ('cython-always', None,
+            'run cythonize() even if .c files are present'),
+        ('cython-annotate', None,
+            'Produce a colorized HTML version of the Cython source.'),
+        ('cython-directives=', None,
+            'Cythion compiler directives'),
+    ]
+
+    def initialize_options(self):
+        super(build_ext, self).initialize_options()
+        self.cython_always = False
+        self.cython_annotate = None
+        self.cython_directives = None
+
+    def finalize_options(self):
+        need_cythonize = self.cython_always
+        cfiles = {}
+
+        for extension in self.distribution.ext_modules:
+            for i, sfile in enumerate(extension.sources):
+                if sfile.endswith('.pyx'):
+                    prefix, ext = os.path.splitext(sfile)
+                    cfile = prefix + '.c'
+
+                    if os.path.exists(cfile) and not self.cython_always:
+                        extension.sources[i] = cfile
+                    else:
+                        if os.path.exists(cfile):
+                            cfiles[cfile] = os.path.getmtime(cfile)
+                        else:
+                            cfiles[cfile] = 0
+                        need_cythonize = True
+
+        if need_cythonize:
+            try:
+                import Cython
+            except ImportError:
+                raise RuntimeError(
+                    'please install Cython to compile asyncpg from source')
+
+            if Cython.__version__ < '0.24':
+                raise RuntimeError(
+                    'asyncpg requires Cython version 0.24 or greater')
+
+            from Cython.Build import cythonize
+
+            directives = {}
+            if self.cython_directives:
+                for directive in self.cython_directives.split(','):
+                    k, _, v = directive.partition('=')
+                    if v.lower() == 'false':
+                        v = False
+                    if v.lower() == 'true':
+                        v = True
+
+                    directives[k] = v
+
+            self.distribution.ext_modules[:] = cythonize(
+                self.distribution.ext_modules,
+                compiler_directives=directives,
+                annotate=self.cython_annotate)
+
+            for cfile, timestamp in cfiles.items():
+                if os.path.getmtime(cfile) != timestamp:
+                    # The file was recompiled, patch
+                    self._patch_cfile(cfile)
+
+        super(build_ext, self).finalize_options()
+
+    def _patch_cfile(self, cfile):
+        # Script to patch Cython 'async def' coroutines to have a 'tp_iter'
+        # slot, which makes them compatible with 'yield from' without the
+        # `asyncio.coroutine` decorator.
+
+        with open(cfile, 'rt') as f:
+            src = f.read()
+
+        src = re.sub(
+            r'''
+            \s* offsetof\(__pyx_CoroutineObject,\s*gi_weakreflist\),
+            \s* 0,
+            \s* 0,
+            \s* __pyx_Coroutine_methods,
+            \s* __pyx_Coroutine_memberlist,
+            \s* __pyx_Coroutine_getsets,
+            ''',
+
+            r'''
+            offsetof(__pyx_CoroutineObject, gi_weakreflist),
+            __Pyx_Coroutine_await, /* tp_iter */
+            (iternextfunc) __Pyx_Generator_Next, /* tp_iternext */
+            __pyx_Coroutine_methods,
+            __pyx_Coroutine_memberlist,
+            __pyx_Coroutine_getsets,
+            ''',
+
+            src, flags=re.X)
+
+        # Fix a segfault in Cython.
+        src = re.sub(
+            r'''
+            \s* __Pyx_Coroutine_get_qualname\(__pyx_CoroutineObject\s+\*self\)
+            \s* {
+            \s* Py_INCREF\(self->gi_qualname\);
+            ''',
+
+            r'''
+            __Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self)
+            {
+                if (self->gi_qualname == NULL) { return __pyx_empty_unicode; }
+                Py_INCREF(self->gi_qualname);
+            ''',
+
+            src, flags=re.X)
+
+        src = re.sub(
+            r'''
+            \s* __Pyx_Coroutine_get_name\(__pyx_CoroutineObject\s+\*self\)
+            \s* {
+            \s* Py_INCREF\(self->gi_name\);
+            ''',
+
+            r'''
+            __Pyx_Coroutine_get_name(__pyx_CoroutineObject *self)
+            {
+                if (self->gi_name == NULL) { return __pyx_empty_unicode; }
+                Py_INCREF(self->gi_name);
+            ''',
+
+            src, flags=re.X)
+
+        with open(cfile, 'wt') as f:
+            f.write(src)
+
+
+with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as f:
+    readme = f.read()
+
+
+setuptools.setup(
+    name='asyncpg',
+    version=VERSION,
+    description='An asyncio PosgtreSQL driver',
+    long_description=readme,
+    classifiers=[
+        'License :: OSI Approved :: Apache Software License',
+        'Intended Audience :: Developers',
+        'Programming Language :: Python :: 3 :: Only',
+        'Programming Language :: Python :: 3.5',
+        'Programming Language :: Python :: 3.6',
+        'Operating System :: POSIX',
+        'Operating System :: MacOS :: MacOS X',
+        'Operating System :: Microsoft :: Windows',
+        'Development Status :: 4 - Beta',
+    ],
+    platforms=['POSIX'],
+    author='MagicStack Inc',
+    author_email='hello@magic.io',
+    url='https://github.com/MagicStack/asyncpg',
+    license='Apache License, Version 2.0',
+    packages=['asyncpg'],
+    provides=['asyncpg'],
+    include_package_data=True,
+    ext_modules=[
+        setuptools.Extension(
+            "asyncpg.protocol.protocol",
+            ["asyncpg/protocol/record/recordobj.c",
+             "asyncpg/protocol/protocol.pyx"],
+            extra_compile_args=CFLAGS,
+            extra_link_args=LDFLAGS)
+    ],
+    cmdclass={'build_ext': build_ext},
+    test_suite='setup.discover_tests',
+)
diff --git a/tests/test_cancellation.py b/tests/test_cancellation.py
new file mode 100644 (file)
index 0000000..898b752
--- /dev/null
@@ -0,0 +1,96 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import asyncio
+import asyncpg
+
+from asyncpg import _testbase as tb
+
+
+class TestCancellation(tb.ConnectedTestCase):
+
+    async def test_cancellation_01(self):
+        st1000 = await self.con.prepare('SELECT 1000')
+
+        async def test0():
+            val = await self.con.execute('SELECT 42')
+            self.assertEqual(val, 'SELECT 1')
+
+        async def test1():
+            val = await self.con.fetchval('SELECT 42')
+            self.assertEqual(val, 42)
+
+        async def test2():
+            val = await self.con.fetchrow('SELECT 42')
+            self.assertEqual(val, (42,))
+
+        async def test3():
+            val = await self.con.fetch('SELECT 42')
+            self.assertEqual(val, [(42,)])
+
+        async def test4():
+            val = await self.con.prepare('SELECT 42')
+            self.assertEqual(await val.fetchval(), 42)
+
+        async def test5():
+            self.assertEqual(await st1000.fetchval(), 1000)
+
+        async def test6():
+            self.assertEqual(await st1000.fetchrow(), (1000,))
+
+        async def test7():
+            self.assertEqual(await st1000.fetch(), [(1000,)])
+
+        async def test8():
+            cur = await st1000.cursor()
+            self.assertEqual(await cur.fetchrow(), (1000,))
+
+        for test in {test0, test1, test2, test3, test4, test5,
+                     test6, test7, test8}:
+
+            with self.subTest(testfunc=test), self.assertRunUnder(1):
+                st = await self.con.prepare('SELECT pg_sleep(20)')
+                task = self.loop.create_task(st.fetch())
+                await asyncio.sleep(0.05, loop=self.loop)
+                task.cancel()
+
+                with self.assertRaises(asyncio.CancelledError):
+                    await task
+
+                async with self.con.transaction():
+                    await test()
+
+    async def test_cancellation_02(self):
+        st = await self.con.prepare('SELECT 1')
+        task = self.loop.create_task(st.fetch())
+        await asyncio.sleep(0.05, loop=self.loop)
+        task.cancel()
+        self.assertEqual(await task, [(1,)])
+
+    async def test_cancellation_03(self):
+        with self.assertRaises(asyncpg.InFailedSQLTransactionError):
+            async with self.con.transaction():
+                task = self.loop.create_task(
+                    self.con.fetch('SELECT pg_sleep(20)'))
+                await asyncio.sleep(0.05, loop=self.loop)
+                task.cancel()
+
+                with self.assertRaises(asyncio.CancelledError):
+                    await task
+
+                await self.con.fetch('SELECT generate_series(0, 100)')
+
+        self.assertEqual(
+            await self.con.fetchval('SELECT 42'),
+            42)
+
+    async def test_cancellation_04(self):
+        await self.con.fetchval('SELECT pg_sleep(0)')
+        waiter = asyncio.Future(loop=self.loop)
+        self.con._cancel_current_command(waiter)
+        await waiter
+        self.assertEqual(await self.con.fetchval('SELECT 42'), 42)
diff --git a/tests/test_codecs.py b/tests/test_codecs.py
new file mode 100644 (file)
index 0000000..34c8786
--- /dev/null
@@ -0,0 +1,1020 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import datetime
+import decimal
+import ipaddress
+import math
+import random
+import struct
+import unittest
+import uuid
+
+import asyncpg
+from asyncpg import _testbase as tb
+
+
+def _timezone(offset):
+    minutes = offset // 60
+    return datetime.timezone(datetime.timedelta(minutes=minutes))
+
+
+infinity_datetime = datetime.datetime(
+    datetime.MAXYEAR, 12, 31, 23, 59, 59, 999999)
+negative_infinity_datetime = datetime.datetime(
+    datetime.MINYEAR, 1, 1, 0, 0, 0, 0)
+
+infinity_date = datetime.date(datetime.MAXYEAR, 12, 31)
+negative_infinity_date = datetime.date(datetime.MINYEAR, 1, 1)
+
+
+type_samples = [
+    ('bool', 'bool', (
+        True, False,
+    )),
+    ('smallint', 'int2', (
+        -2 ** 15 + 1, 2 ** 15 - 1,
+        -1, 0, 1,
+    )),
+    ('int', 'int4', (
+        -2 ** 31 + 1, 2 ** 31 - 1,
+        -1, 0, 1,
+    )),
+    ('bigint', 'int8', (
+        -2 ** 63 + 1, 2 ** 63 - 1,
+        -1, 0, 1,
+    )),
+    ('numeric', 'numeric', (
+        -(2 ** 64),
+        2 ** 64,
+        -(2 ** 128),
+        2 ** 128,
+        -1, 0, 1,
+        decimal.Decimal("0.00000000000000"),
+        decimal.Decimal("1.00000000000000"),
+        decimal.Decimal("-1.00000000000000"),
+        decimal.Decimal("-2.00000000000000"),
+        decimal.Decimal("1000000000000000.00000000000000"),
+        decimal.Decimal("-0.00000000000000"),
+        decimal.Decimal(1234),
+        decimal.Decimal(-1234),
+        decimal.Decimal("1234000000.00088883231"),
+        decimal.Decimal(str(1234.00088883231)),
+        decimal.Decimal("3123.23111"),
+        decimal.Decimal("-3123000000.23111"),
+        decimal.Decimal("3123.2311100000"),
+        decimal.Decimal("-03123.0023111"),
+        decimal.Decimal("3123.23111"),
+        decimal.Decimal("3123.23111"),
+        decimal.Decimal("10000.23111"),
+        decimal.Decimal("100000.23111"),
+        decimal.Decimal("1000000.23111"),
+        decimal.Decimal("10000000.23111"),
+        decimal.Decimal("100000000.23111"),
+        decimal.Decimal("1000000000.23111"),
+        decimal.Decimal("1000000000.3111"),
+        decimal.Decimal("1000000000.111"),
+        decimal.Decimal("1000000000.11"),
+        decimal.Decimal("100000000.0"),
+        decimal.Decimal("10000000.0"),
+        decimal.Decimal("1000000.0"),
+        decimal.Decimal("100000.0"),
+        decimal.Decimal("10000.0"),
+        decimal.Decimal("1000.0"),
+        decimal.Decimal("100.0"),
+        decimal.Decimal("100"),
+        decimal.Decimal("100.1"),
+        decimal.Decimal("100.12"),
+        decimal.Decimal("100.123"),
+        decimal.Decimal("100.1234"),
+        decimal.Decimal("100.12345"),
+        decimal.Decimal("100.123456"),
+        decimal.Decimal("100.1234567"),
+        decimal.Decimal("100.12345679"),
+        decimal.Decimal("100.123456790"),
+        decimal.Decimal("100.123456790000000000000000"),
+        decimal.Decimal("1.0"),
+        decimal.Decimal("0.0"),
+        decimal.Decimal("-1.0"),
+        decimal.Decimal("1.0E-1000"),
+        decimal.Decimal("1.0E1000"),
+        decimal.Decimal("0.000000000000000000000000001"),
+        decimal.Decimal("0.000000000000010000000000001"),
+        decimal.Decimal("0.00000000000000000000000001"),
+        decimal.Decimal("0.00000000100000000000000001"),
+        decimal.Decimal("0.0000000000000000000000001"),
+        decimal.Decimal("0.000000000000000000000001"),
+        decimal.Decimal("0.00000000000000000000001"),
+        decimal.Decimal("0.0000000000000000000001"),
+        decimal.Decimal("0.000000000000000000001"),
+        decimal.Decimal("0.00000000000000000001"),
+        decimal.Decimal("0.0000000000000000001"),
+        decimal.Decimal("0.000000000000000001"),
+        decimal.Decimal("0.00000000000000001"),
+        decimal.Decimal("0.0000000000000001"),
+        decimal.Decimal("0.000000000000001"),
+        decimal.Decimal("0.00000000000001"),
+        decimal.Decimal("0.0000000000001"),
+        decimal.Decimal("0.000000000001"),
+        decimal.Decimal("0.00000000001"),
+        decimal.Decimal("0.0000000001"),
+        decimal.Decimal("0.000000001"),
+        decimal.Decimal("0.00000001"),
+        decimal.Decimal("0.0000001"),
+        decimal.Decimal("0.000001"),
+        decimal.Decimal("0.00001"),
+        decimal.Decimal("0.0001"),
+        decimal.Decimal("0.001"),
+        decimal.Decimal("0.01"),
+        decimal.Decimal("0.1"),
+    )),
+    ('bytea', 'bytea', (
+        bytes(range(256)),
+        bytes(range(255, -1, -1)),
+        b'\x00\x00',
+        b'foo',
+        b'f' * 1024 * 1024,
+        dict(input=bytearray(b'\x02\x01'), output=b'\x02\x01'),
+    )),
+    ('text', 'text', (
+        '',
+        'A' * (1024 * 1024 + 11)
+    )),
+    ('"char"', 'char', (
+        b'a',
+        b'b',
+        b'\x00'
+    )),
+    ('timestamp', 'timestamp', [
+        datetime.datetime(3000, 5, 20, 5, 30, 10),
+        datetime.datetime(2000, 1, 1, 5, 25, 10),
+        datetime.datetime(500, 1, 1, 5, 25, 10),
+        datetime.datetime(250, 1, 1, 5, 25, 10),
+        infinity_datetime,
+        negative_infinity_datetime,
+        {'textinput': 'infinity', 'output': infinity_datetime},
+        {'textinput': '-infinity', 'output': negative_infinity_datetime},
+    ]),
+    ('date', 'date', [
+        datetime.date(3000, 5, 20),
+        datetime.date(2000, 1, 1),
+        datetime.date(500, 1, 1),
+        infinity_date,
+        negative_infinity_date,
+        {'textinput': 'infinity', 'output': infinity_date},
+        {'textinput': '-infinity', 'output': negative_infinity_date},
+    ]),
+    ('time', 'time', [
+        datetime.time(12, 15, 20),
+        datetime.time(0, 1, 1),
+        datetime.time(23, 59, 59),
+    ]),
+    ('timestamptz', 'timestamptz', [
+        # It's converted to UTC. When it comes back out, it will be in UTC
+        # again. The datetime comparison will take the tzinfo into account.
+        datetime.datetime(1990, 5, 12, 10, 10, 0, tzinfo=_timezone(4000)),
+        datetime.datetime(1982, 5, 18, 10, 10, 0, tzinfo=_timezone(6000)),
+        datetime.datetime(1950, 1, 1, 10, 10, 0, tzinfo=_timezone(7000)),
+        datetime.datetime(1800, 1, 1, 10, 10, 0, tzinfo=_timezone(2000)),
+        datetime.datetime(2400, 1, 1, 10, 10, 0, tzinfo=_timezone(2000)),
+        infinity_datetime,
+        negative_infinity_datetime,
+    ]),
+    ('timetz', 'timetz', [
+        # timetz retains the offset
+        datetime.time(10, 10, 0, tzinfo=_timezone(4000)),
+        datetime.time(10, 10, 0, tzinfo=_timezone(6000)),
+        datetime.time(10, 10, 0, tzinfo=_timezone(7000)),
+        datetime.time(10, 10, 0, tzinfo=_timezone(2000)),
+        datetime.time(22, 30, 0, tzinfo=_timezone(0)),
+    ]),
+    ('interval', 'interval', [
+        # no months :(
+        datetime.timedelta(40, 10, 1234),
+        datetime.timedelta(0, 0, 4321),
+        datetime.timedelta(0, 0),
+        datetime.timedelta(-100, 0),
+        datetime.timedelta(-100, -400),
+    ]),
+    ('uuid', 'uuid', [
+        uuid.UUID('38a4ff5a-3a56-11e6-a6c2-c8f73323c6d4'),
+        uuid.UUID('00000000-0000-0000-0000-000000000000'),
+        {'input': '00000000-0000-0000-0000-000000000000',
+         'output': uuid.UUID('00000000-0000-0000-0000-000000000000')}
+    ]),
+    ('uuid[]', 'uuid[]', [
+        [uuid.UUID('38a4ff5a-3a56-11e6-a6c2-c8f73323c6d4'),
+         uuid.UUID('00000000-0000-0000-0000-000000000000')],
+        []
+    ]),
+    ('json', 'json', [
+        '[1, 2, 3, 4]',
+        '{"a": [1, 2], "b": 0}'
+    ], (9, 2)),
+    ('jsonb', 'jsonb', [
+        '[1, 2, 3, 4]',
+        '{"a": [1, 2], "b": 0}'
+    ], (9, 4)),
+    ('oid[]', 'oid[]', [
+        [1, 2, 3, 4],
+        []
+    ]),
+    ('smallint[]', 'int2[]', [
+        [1, 2, 3, 4],
+        [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],
+        []
+    ]),
+    ('bigint[]', 'int8[]', [
+        [2 ** 42, -2 ** 54, 0],
+        []
+    ]),
+    ('int[]', 'int4[]', [
+        [2 ** 22, -2 ** 24, 0],
+        []
+    ]),
+    ('time[]', 'time[]', [
+        [datetime.time(12, 15, 20), datetime.time(0, 1, 1)],
+        []
+    ]),
+    ('text[]', 'text[]', [
+        ['ABCDE', 'EDCBA'],
+        [],
+        ['A' * 1024 * 1024] * 10
+    ]),
+    ('float8', 'float8', [
+        1.1,
+        -1.1,
+        0,
+        2,
+        1e-4,
+        -1e-20,
+        122.2e-100,
+        2e5,
+        math.pi,
+        math.e,
+        math.inf,
+        -math.inf,
+        math.nan
+    ]),
+    ('float4', 'float4', [
+        1.1,
+        -1.1,
+        0,
+        2,
+        1e-4,
+        -1e-20,
+        2e5,
+        math.pi,
+        math.e,
+        math.inf,
+        -math.inf,
+        math.nan
+    ]),
+    ('cidr', 'cidr', [
+        ipaddress.IPv4Network('255.255.255.255/32'),
+        ipaddress.IPv4Network('127.0.0.0/8'),
+        ipaddress.IPv4Network('127.1.0.0/16'),
+        ipaddress.IPv4Network('127.1.0.0/18'),
+        ipaddress.IPv4Network('10.0.0.0/32'),
+        ipaddress.IPv4Network('0.0.0.0/0'),
+        ipaddress.IPv6Network('ffff' + ':ffff' * 7 + '/128'),
+        ipaddress.IPv6Network('::1/128'),
+        ipaddress.IPv6Network('::/0'),
+    ]),
+    ('inet', 'inet', [
+        ipaddress.IPv4Address('255.255.255.255'),
+        ipaddress.IPv4Address('127.0.0.1'),
+        ipaddress.IPv4Address('0.0.0.0'),
+        ipaddress.IPv6Address('ffff' + ':ffff' * 7),
+        ipaddress.IPv6Address('::1'),
+        ipaddress.IPv6Address('::'),
+        dict(
+            input='127.0.0.0/8',
+            output=ipaddress.IPv4Network('127.0.0.0/8')),
+        dict(
+            input='127.0.0.1/32',
+            output=ipaddress.IPv4Network('127.0.0.1/32')),
+    ]),
+    ('macaddr', 'macaddr', [
+        '00:00:00:00:00:00',
+        'ff:ff:ff:ff:ff:ff'
+    ]),
+    ('txid_snapshot', 'txid_snapshot', [
+        (100, 1000, (100, 200, 300, 400))
+    ]),
+    ('varbit', 'varbit', [
+        asyncpg.BitString('0000 0001'),
+        asyncpg.BitString('00010001'),
+        asyncpg.BitString(''),
+        asyncpg.BitString(),
+        asyncpg.BitString.frombytes(b'\x00', bitlength=3),
+        asyncpg.BitString('0000 0000 1'),
+        dict(input=b'\x01', output=asyncpg.BitString('0000 0001')),
+        dict(input=bytearray(b'\x02'), output=asyncpg.BitString('0000 0010')),
+    ]),
+    ('path', 'path', [
+        asyncpg.Path(asyncpg.Point(0.0, 0.0), asyncpg.Point(1.0, 1.0)),
+        asyncpg.Path(asyncpg.Point(0.0, 0.0), asyncpg.Point(1.0, 1.0),
+                     is_closed=True),
+        dict(input=((0.0, 0.0), (1.0, 1.0)),
+             output=asyncpg.Path(asyncpg.Point(0.0, 0.0),
+                                 asyncpg.Point(1.0, 1.0),
+                                 is_closed=True)),
+        dict(input=[(0.0, 0.0), (1.0, 1.0)],
+             output=asyncpg.Path(asyncpg.Point(0.0, 0.0),
+                                 asyncpg.Point(1.0, 1.0),
+                                 is_closed=False)),
+    ]),
+    ('point', 'point', [
+        asyncpg.Point(0.0, 0.0),
+        asyncpg.Point(1.0, 2.0),
+    ]),
+    ('box', 'box', [
+        asyncpg.Box((1.0, 2.0), (0.0, 0.0)),
+    ]),
+    ('line', 'line', [
+        asyncpg.Line(1, 2, 3),
+    ], (9, 4)),
+    ('lseg', 'lseg', [
+        asyncpg.LineSegment((1, 2), (2, 2)),
+    ]),
+    ('polygon', 'polygon', [
+        asyncpg.Polygon(asyncpg.Point(0.0, 0.0), asyncpg.Point(1.0, 0.0),
+                        asyncpg.Point(1.0, 1.0), asyncpg.Point(0.0, 1.0)),
+    ]),
+    ('circle', 'circle', [
+        asyncpg.Circle((0.0, 0.0), 100),
+    ]),
+]
+
+
+class TestCodecs(tb.ConnectedTestCase):
+
+    async def test_standard_codecs(self):
+        """Test encoding/decoding of standard data types and arrays thereof."""
+        for (typname, intname, sample_data, *metadata) in type_samples:
+            if metadata and self.server_version < metadata[0]:
+                continue
+
+            st = await self.con.prepare(
+                "SELECT $1::" + typname
+            )
+
+            textst = await self.con.prepare(
+                "SELECT $1::text::" + typname
+            )
+
+            for sample in sample_data:
+                with self.subTest(sample=sample, typname=typname):
+                    stmt = st
+                    if isinstance(sample, dict):
+                        if 'textinput' in sample:
+                            inputval = sample['textinput']
+                            stmt = textst
+                        else:
+                            inputval = sample['input']
+                        outputval = sample['output']
+                    else:
+                        inputval = outputval = sample
+
+                    result = await stmt.fetchval(inputval)
+                    err_msg = (
+                        "unexpected result for {} when passing {!r}: "
+                        "received {!r}, expected {!r}".format(
+                            typname, inputval, result, outputval))
+
+                    if typname.startswith('float'):
+                        if math.isnan(outputval):
+                            if not math.isnan(result):
+                                self.fail(err_msg)
+                        else:
+                            self.assertTrue(
+                                math.isclose(result, outputval, rel_tol=1e-6),
+                                err_msg)
+                    else:
+                        self.assertEqual(result, outputval, err_msg)
+
+            with self.subTest(sample=None, typname=typname):
+                # Test that None is handled for all types.
+                rsample = await st.fetchval(None)
+                self.assertIsNone(rsample)
+
+            at = st.get_attributes()
+            self.assertEqual(at[0].type.name, intname)
+
+    async def test_all_builtin_types_handled(self):
+        from asyncpg.protocol.protocol import TYPEMAP
+
+        for oid, typename in TYPEMAP.items():
+            codec = self.con.get_settings().get_data_codec(oid)
+            self.assertIsNotNone(
+                codec,
+                'core type {} ({}) is unhandled'.format(typename, oid))
+
+    async def test_void(self):
+        res = await self.con.fetchval('select pg_sleep(0)')
+        self.assertIsNone(res)
+        await self.con.fetchval('select now($1::void)', '')
+
+    def test_bitstring(self):
+        bitlen = random.randint(0, 1000)
+        bs = ''.join(random.choice(('1', '0', ' ')) for _ in range(bitlen))
+        bits = asyncpg.BitString(bs)
+        sanitized_bs = bs.replace(' ', '')
+        self.assertEqual(sanitized_bs,
+                         bits.as_string().replace(' ', ''))
+
+        expected_bytelen = \
+            len(sanitized_bs) // 8 + (1 if len(sanitized_bs) % 8 else 0)
+
+        self.assertEqual(len(bits.bytes), expected_bytelen)
+
+    async def test_unhandled_type_fallback(self):
+        await self.con.execute('''
+            CREATE EXTENSION IF NOT EXISTS isn
+        ''')
+
+        try:
+            input_val = '1436-4522'
+
+            res = await self.con.fetchrow('''
+                SELECT $1::issn AS issn, 42 AS int
+            ''', input_val)
+
+            self.assertEqual(res['issn'], input_val)
+            self.assertEqual(res['int'], 42)
+
+        finally:
+            await self.con.execute('''
+                DROP EXTENSION isn
+            ''')
+
+    async def test_invalid_input(self):
+        cases = [
+            ('bytea', TypeError, 'a bytes-like object is required', [
+                1,
+                'aaa'
+            ]),
+            ('bool', TypeError, 'a boolean is required', [
+                1,
+            ]),
+            ('int2', TypeError, 'an integer is required', [
+                '2',
+                'aa',
+            ]),
+            ('smallint', ValueError, 'integer too large', [
+                32768,
+                -32768
+            ]),
+            ('float4', ValueError, 'float value too large', [
+                4.1 * 10 ** 40,
+                -4.1 * 10 ** 40,
+            ]),
+            ('int4', TypeError, 'an integer is required', [
+                '2',
+                'aa',
+            ]),
+            ('int8', TypeError, 'an integer is required', [
+                '2',
+                'aa',
+            ])
+        ]
+
+        for typname, errcls, errmsg, data in cases:
+            stmt = await self.con.prepare("SELECT $1::" + typname)
+
+            for sample in data:
+                with self.subTest(sample=sample, typname=typname):
+                    with self.assertRaisesRegex(errcls, errmsg):
+                        await stmt.fetchval(sample)
+
+    async def test_arrays(self):
+        """Test encoding/decoding of arrays (particularly multidimensional)."""
+        cases = [
+            (
+                r"SELECT '[1:3][-1:0]={{1,2},{4,5},{6,7}}'::int[]",
+                [[1, 2], [4, 5], [6, 7]]
+            ),
+            (
+                r"SELECT '{{{{{{1}}}}}}'::int[]",
+                [[[[[[1]]]]]]
+            ),
+            (
+                r"SELECT '{1, 2, NULL}'::int[]::anyarray",
+                [1, 2, None]
+            ),
+        ]
+
+        for sql, expected in cases:
+            with self.subTest(sql=sql):
+                res = await self.con.fetchval(sql)
+                self.assertEqual(res, expected)
+
+        with self.assertRaises(asyncpg.ProgramLimitExceededError):
+            await self.con.fetchval("SELECT '{{{{{{{1}}}}}}}'::int[]")
+
+        cases = [
+            [None],
+            [1, 2, 3, 4, 5, 6],
+            [[1, 2], [4, 5], [6, 7]],
+            [[[1], [2]], [[4], [5]], [[None], [7]]],
+            [[[[[[1]]]]]],
+            [[[[[[None]]]]]]
+        ]
+
+        st = await self.con.prepare(
+            "SELECT $1::int[]"
+        )
+
+        for case in cases:
+            with self.subTest(case=case):
+                result = await st.fetchval(case)
+                err_msg = (
+                    "failed to return array data as-is; "
+                    "gave {!r}, received {!r}".format(
+                        case, result))
+
+                self.assertEqual(result, case, err_msg)
+
+        with self.assertRaisesRegex(ValueError, 'dimensions'):
+            await self.con.fetchval(
+                "SELECT $1::int[]",
+                [[[[[[[1]]]]]]])
+
+        with self.assertRaisesRegex(ValueError, 'non-homogeneous'):
+            await self.con.fetchval(
+                "SELECT $1::int[]",
+                [1, [1]])
+
+        with self.assertRaisesRegex(ValueError, 'non-homogeneous'):
+            await self.con.fetchval(
+                "SELECT $1::int[]",
+                [[1], 1, [2]])
+
+        with self.assertRaisesRegex(ValueError, 'invalid array element'):
+            await self.con.fetchval(
+                "SELECT $1::int[]",
+                [1, 't', 2])
+
+        with self.assertRaisesRegex(ValueError, 'invalid array element'):
+            await self.con.fetchval(
+                "SELECT $1::int[]",
+                [[1], ['t'], [2]])
+
+        with self.assertRaisesRegex(TypeError,
+                                    'non-trivial iterable expected'):
+            await self.con.fetchval(
+                "SELECT $1::int[]",
+                1)
+
+    async def test_composites(self):
+        """Test encoding/decoding of composite types."""
+        await self.con.execute('''
+            CREATE TYPE test_composite AS (
+                a int,
+                b text,
+                c int[]
+            )
+        ''')
+
+        st = await self.con.prepare('''
+            SELECT ROW(NULL, 1234, '5678', ROW(42, '42'))
+        ''')
+
+        res = await st.fetchval()
+
+        self.assertEqual(res, (None, 1234, '5678', (42, '42')))
+
+        try:
+            st = await self.con.prepare('''
+                SELECT ROW(
+                    NULL,
+                    '5678',
+                    ARRAY[9, NULL, 11]::int[]
+                )::test_composite AS test
+            ''')
+
+            res = await st.fetch()
+            res = res[0]['test']
+
+            self.assertIsNone(res['a'])
+            self.assertEqual(res['b'], '5678')
+            self.assertEqual(res['c'], [9, None, 11])
+
+            self.assertIsNone(res[0])
+            self.assertEqual(res[1], '5678')
+            self.assertEqual(res[2], [9, None, 11])
+
+            at = st.get_attributes()
+            self.assertEqual(len(at), 1)
+            self.assertEqual(at[0].name, 'test')
+            self.assertEqual(at[0].type.name, 'test_composite')
+            self.assertEqual(at[0].type.kind, 'composite')
+
+            res = await self.con.fetchval('''
+                SELECT $1::test_composite
+            ''', res)
+
+        finally:
+            await self.con.execute('DROP TYPE test_composite')
+
+    async def test_domains(self):
+        """Test encoding/decoding of composite types."""
+        await self.con.execute('''
+            CREATE DOMAIN my_dom AS int
+        ''')
+
+        await self.con.execute('''
+            CREATE DOMAIN my_dom2 AS my_dom
+        ''')
+
+        try:
+            st = await self.con.prepare('''
+                SELECT 3::my_dom2
+            ''')
+            res = await st.fetchval()
+
+            self.assertEqual(res, 3)
+
+            st = await self.con.prepare('''
+                SELECT NULL::my_dom2
+            ''')
+            res = await st.fetchval()
+
+            self.assertIsNone(res)
+
+            at = st.get_attributes()
+            self.assertEqual(len(at), 1)
+            self.assertEqual(at[0].name, 'my_dom2')
+            self.assertEqual(at[0].type.name, 'int4')
+            self.assertEqual(at[0].type.kind, 'scalar')
+
+        finally:
+            await self.con.execute('DROP DOMAIN my_dom2')
+            await self.con.execute('DROP DOMAIN my_dom')
+
+    async def test_range_types(self):
+        """Test encoding/decoding of range types."""
+
+        if self.server_version < (9, 2):
+            raise unittest.SkipTest(
+                'PostgreSQL servers < 9.2 do not support range types.')
+
+        cases = [
+            ('int4range', [
+                [(1, 9), asyncpg.Range(1, 10)],
+                [asyncpg.Range(0, 9, lower_inc=False, upper_inc=True),
+                 asyncpg.Range(1, 10)],
+                [(), asyncpg.Range(empty=True)],
+                [asyncpg.Range(empty=True), asyncpg.Range(empty=True)],
+                [(None, 2), asyncpg.Range(None, 3)],
+                [asyncpg.Range(None, 2, upper_inc=True),
+                 asyncpg.Range(None, 3)],
+                [(2,), asyncpg.Range(2, None)],
+                [(2, None), asyncpg.Range(2, None)],
+                [asyncpg.Range(2, None), asyncpg.Range(2, None)],
+                [(None, None), asyncpg.Range(None, None)],
+                [asyncpg.Range(None, None), asyncpg.Range(None, None)]
+            ])
+        ]
+
+        for (typname, sample_data) in cases:
+            st = await self.con.prepare(
+                "SELECT $1::" + typname
+            )
+
+            for sample, expected in sample_data:
+                with self.subTest(sample=sample, typname=typname):
+                    result = await st.fetchval(sample)
+                    self.assertEqual(result, expected)
+
+        with self.assertRaisesRegex(
+                TypeError, 'list, tuple or Range object expected'):
+            await self.con.fetch("SELECT $1::int4range", 'aa')
+
+        with self.assertRaisesRegex(
+                ValueError, 'expected 0, 1 or 2 elements'):
+            await self.con.fetch("SELECT $1::int4range", (0, 2, 3))
+
+    async def test_extra_codec_alias(self):
+        """Test encoding/decoding of a builtin non-pg_catalog codec."""
+        await self.con.execute('''
+            CREATE EXTENSION IF NOT EXISTS hstore
+        ''')
+
+        try:
+            await self.con.set_builtin_type_codec(
+                'hstore', codec_name='pg_contrib.hstore')
+
+            cases = [
+                {'ham': 'spam', 'nada': None},
+                {}
+            ]
+
+            st = await self.con.prepare('''
+                SELECT $1::hstore AS result
+            ''')
+
+            for case in cases:
+                res = await st.fetchval(case)
+                self.assertEqual(res, case)
+
+            res = await self.con.fetchval('''
+                SELECT $1::hstore AS result
+            ''', (('foo', 2), ('bar', 3)))
+
+            self.assertEqual(res, {'foo': '2', 'bar': '3'})
+
+            with self.assertRaisesRegex(ValueError, 'null value not allowed'):
+                await self.con.fetchval('''
+                    SELECT $1::hstore AS result
+                ''', {None: '1'})
+
+        finally:
+            await self.con.execute('''
+                DROP EXTENSION hstore
+            ''')
+
+    async def test_custom_codec_text(self):
+        """Test encoding/decoding using a custom codec in text mode."""
+        await self.con.execute('''
+            CREATE EXTENSION IF NOT EXISTS hstore
+        ''')
+
+        def hstore_decoder(data):
+            result = {}
+            items = data.split(',')
+            for item in items:
+                k, _, v = item.partition('=>')
+                result[k.strip('"')] = v.strip('"')
+
+            return result
+
+        def hstore_encoder(obj):
+            return ','.join('{}=>{}'.format(k, v) for k, v in obj.items())
+
+        try:
+            await self.con.set_type_codec('hstore', encoder=hstore_encoder,
+                                          decoder=hstore_decoder)
+
+            st = await self.con.prepare('''
+                SELECT $1::hstore AS result
+            ''')
+
+            res = await st.fetchrow({'ham': 'spam'})
+            res = res['result']
+
+            self.assertEqual(res, {'ham': 'spam'})
+
+            pt = st.get_parameters()
+            self.assertTrue(isinstance(pt, tuple))
+            self.assertEqual(len(pt), 1)
+            self.assertEqual(pt[0].name, 'hstore')
+            self.assertEqual(pt[0].kind, 'scalar')
+            self.assertEqual(pt[0].schema, 'public')
+
+            at = st.get_attributes()
+            self.assertTrue(isinstance(at, tuple))
+            self.assertEqual(len(at), 1)
+            self.assertEqual(at[0].name, 'result')
+            self.assertEqual(at[0].type, pt[0])
+
+            err = 'cannot use custom codec on non-scalar type public._hstore'
+            with self.assertRaisesRegex(ValueError, err):
+                await self.con.set_type_codec('_hstore',
+                                              encoder=hstore_encoder,
+                                              decoder=hstore_decoder)
+
+            await self.con.execute('''
+                CREATE TYPE mytype AS (a int);
+            ''')
+
+            try:
+                err = 'cannot use custom codec on non-scalar type ' + \
+                      'public.mytype'
+                with self.assertRaisesRegex(ValueError, err):
+                    await self.con.set_type_codec(
+                        'mytype', encoder=hstore_encoder,
+                        decoder=hstore_decoder)
+            finally:
+                await self.con.execute('''
+                    DROP TYPE mytype;
+                ''')
+
+        finally:
+            await self.con.execute('''
+                DROP EXTENSION hstore
+            ''')
+
+    async def test_custom_codec_binary(self):
+        """Test encoding/decoding using a custom codec in binary mode."""
+        await self.con.execute('''
+            CREATE EXTENSION IF NOT EXISTS hstore
+        ''')
+
+        longstruct = struct.Struct('!L')
+        ulong_unpack = lambda b: longstruct.unpack_from(b)[0]
+        ulong_pack = longstruct.pack
+
+        def hstore_decoder(data):
+            result = {}
+            n = ulong_unpack(data)
+            view = memoryview(data)
+            ptr = 4
+
+            for i in range(n):
+                klen = ulong_unpack(view[ptr:ptr + 4])
+                ptr += 4
+                k = bytes(view[ptr:ptr + klen]).decode()
+                ptr += klen
+                vlen = ulong_unpack(view[ptr:ptr + 4])
+                ptr += 4
+                if vlen == -1:
+                    v = None
+                else:
+                    v = bytes(view[ptr:ptr + vlen]).decode()
+                    ptr += vlen
+
+                result[k] = v
+
+            return result
+
+        def hstore_encoder(obj):
+            buffer = bytearray(ulong_pack(len(obj)))
+
+            for k, v in obj.items():
+                kenc = k.encode()
+                buffer += ulong_pack(len(kenc)) + kenc
+
+                if v is None:
+                    buffer += b'\xFF\xFF\xFF\xFF'  # -1
+                else:
+                    venc = v.encode()
+                    buffer += ulong_pack(len(venc)) + venc
+
+            return buffer
+
+        try:
+            await self.con.set_type_codec('hstore', encoder=hstore_encoder,
+                                          decoder=hstore_decoder,
+                                          binary=True)
+
+            st = await self.con.prepare('''
+                SELECT $1::hstore AS result
+            ''')
+
+            res = await st.fetchrow({'ham': 'spam'})
+            res = res['result']
+
+            self.assertEqual(res, {'ham': 'spam'})
+
+            pt = st.get_parameters()
+            self.assertTrue(isinstance(pt, tuple))
+            self.assertEqual(len(pt), 1)
+            self.assertEqual(pt[0].name, 'hstore')
+            self.assertEqual(pt[0].kind, 'scalar')
+            self.assertEqual(pt[0].schema, 'public')
+
+            at = st.get_attributes()
+            self.assertTrue(isinstance(at, tuple))
+            self.assertEqual(len(at), 1)
+            self.assertEqual(at[0].name, 'result')
+            self.assertEqual(at[0].type, pt[0])
+
+        finally:
+            await self.con.execute('''
+                DROP EXTENSION hstore
+            ''')
+
+    async def test_composites_in_arrays(self):
+        await self.con.execute('''
+            CREATE TYPE t AS (a text, b int);
+            CREATE TABLE tab (d t[]);
+        ''')
+
+        try:
+            await self.con.execute(
+                'INSERT INTO tab (d) VALUES ($1)',
+                [('a', 1)])
+
+            r = await self.con.fetchval('''
+                SELECT d FROM tab
+            ''')
+
+            self.assertEqual(r, [('a', 1)])
+        finally:
+            await self.con.execute('''
+                DROP TABLE tab;
+                DROP TYPE t;
+            ''')
+
+    async def test_table_as_composite(self):
+        await self.con.execute('''
+            CREATE TABLE tab (a text, b int);
+            INSERT INTO tab VALUES ('1', 1);
+        ''')
+
+        try:
+            r = await self.con.fetchrow('''
+                SELECT tab FROM tab
+            ''')
+
+            self.assertEqual(r, (('1', 1),))
+
+        finally:
+            await self.con.execute('''
+                DROP TABLE tab;
+            ''')
+
+    async def test_relacl_array_type(self):
+        await self.con.execute(r'''
+            CREATE USER """u1'";
+            CREATE USER "{u2";
+            CREATE USER ",u3";
+            CREATE USER "u4}";
+            CREATE USER "u5""";
+            CREATE USER "u6\""";
+            CREATE USER "u7\";
+            CREATE USER norm1;
+            CREATE USER norm2;
+            CREATE TABLE t0 (); GRANT SELECT ON t0 TO norm1;
+            CREATE TABLE t1 (); GRANT SELECT ON t1 TO """u1'";
+            CREATE TABLE t2 (); GRANT SELECT ON t2 TO "{u2";
+            CREATE TABLE t3 (); GRANT SELECT ON t3 TO ",u3";
+            CREATE TABLE t4 (); GRANT SELECT ON t4 TO "u4}";
+            CREATE TABLE t5 (); GRANT SELECT ON t5 TO "u5""";
+            CREATE TABLE t6 (); GRANT SELECT ON t6 TO "u6\""";
+            CREATE TABLE t7 (); GRANT SELECT ON t7 TO "u7\";
+
+            CREATE TABLE a1 ();
+                GRANT SELECT ON a1 TO """u1'";
+                GRANT SELECT ON a1 TO "{u2";
+                GRANT SELECT ON a1 TO ",u3";
+                GRANT SELECT ON a1 TO "norm1";
+                GRANT SELECT ON a1 TO "u4}";
+                GRANT SELECT ON a1 TO "u5""";
+                GRANT SELECT ON a1 TO "u6\""";
+                GRANT SELECT ON a1 TO "u7\";
+                GRANT SELECT ON a1 TO "norm2";
+
+            CREATE TABLE a2 ();
+                GRANT SELECT ON a2 TO """u1'" WITH GRANT OPTION;
+                GRANT SELECT ON a2 TO "{u2"   WITH GRANT OPTION;
+                GRANT SELECT ON a2 TO ",u3"   WITH GRANT OPTION;
+                GRANT SELECT ON a2 TO "norm1" WITH GRANT OPTION;
+                GRANT SELECT ON a2 TO "u4}"   WITH GRANT OPTION;
+                GRANT SELECT ON a2 TO "u5"""  WITH GRANT OPTION;
+                GRANT SELECT ON a2 TO "u6\""" WITH GRANT OPTION;
+                GRANT SELECT ON a2 TO "u7\"   WITH GRANT OPTION;
+
+            SET SESSION AUTHORIZATION """u1'"; GRANT SELECT ON a2 TO "norm2";
+            SET SESSION AUTHORIZATION "{u2";   GRANT SELECT ON a2 TO "norm2";
+            SET SESSION AUTHORIZATION ",u3";   GRANT SELECT ON a2 TO "norm2";
+            SET SESSION AUTHORIZATION "u4}";   GRANT SELECT ON a2 TO "norm2";
+            SET SESSION AUTHORIZATION "u5""";  GRANT SELECT ON a2 TO "norm2";
+            SET SESSION AUTHORIZATION "u6\"""; GRANT SELECT ON a2 TO "norm2";
+            SET SESSION AUTHORIZATION "u7\";   GRANT SELECT ON a2 TO "norm2";
+            RESET SESSION AUTHORIZATION;
+        ''')
+
+        try:
+            rows = await self.con.fetch('''
+                SELECT
+                    relacl,
+                    relacl::text[] AS chk,
+                    relacl::text[]::text AS text_
+                FROM
+                    pg_catalog.pg_class
+                WHERE
+                    relacl IS NOT NULL
+            ''')
+
+            for row in rows:
+                self.assertEqual(row['relacl'], row['chk'],)
+
+        finally:
+            await self.con.execute(r'''
+                DROP TABLE t0;
+                DROP TABLE t1;
+                DROP TABLE t2;
+                DROP TABLE t3;
+                DROP TABLE t4;
+                DROP TABLE t5;
+                DROP TABLE t6;
+                DROP TABLE t7;
+                DROP TABLE a1;
+                DROP TABLE a2;
+                DROP USER """u1'";
+                DROP USER "{u2";
+                DROP USER ",u3";
+                DROP USER "u4}";
+                DROP USER "u5""";
+                DROP USER "u6\""";
+                DROP USER "u7\";
+                DROP USER norm1;
+                DROP USER norm2;
+            ''')
diff --git a/tests/test_connect.py b/tests/test_connect.py
new file mode 100644 (file)
index 0000000..09c987e
--- /dev/null
@@ -0,0 +1,384 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import contextlib
+import ipaddress
+import os
+import platform
+import unittest
+
+import asyncpg
+from asyncpg import _testbase as tb
+from asyncpg.connection import _parse_connect_params
+
+_system = platform.uname().system
+
+
+class TestSettings(tb.ConnectedTestCase):
+
+    async def test_get_settings_01(self):
+        self.assertEqual(
+            self.con.get_settings().client_encoding,
+            'UTF8')
+
+
+class TestAuthentication(tb.ConnectedTestCase):
+    def setUp(self):
+        super().setUp()
+
+        if not self.cluster.is_managed():
+            self.skipTest('unmanaged cluster')
+
+        methods = [
+            ('trust', None),
+            ('reject', None),
+            ('md5', 'correctpassword'),
+            ('password', 'correctpassword'),
+        ]
+
+        self.cluster.reset_hba()
+
+        create_script = []
+        for method, password in methods:
+            create_script.append(
+                'CREATE ROLE {}_user WITH LOGIN{};'.format(
+                    method,
+                    ' PASSWORD {!r}'.format(password) if password else ''
+                )
+            )
+
+            if _system != 'Windows':
+                self.cluster.add_hba_entry(
+                    type='local',
+                    database='postgres', user='{}_user'.format(method),
+                    auth_method=method)
+
+            self.cluster.add_hba_entry(
+                type='host', address=ipaddress.ip_network('127.0.0.0/24'),
+                database='postgres', user='{}_user'.format(method),
+                auth_method=method)
+
+            self.cluster.add_hba_entry(
+                type='host', address=ipaddress.ip_network('::1/128'),
+                database='postgres', user='{}_user'.format(method),
+                auth_method=method)
+
+        # Put hba changes into effect
+        self.cluster.reload()
+
+        create_script = '\n'.join(create_script)
+        self.loop.run_until_complete(self.con.execute(create_script))
+
+    def tearDown(self):
+        # Reset cluster's pg_hba.conf since we've meddled with it
+        self.cluster.trust_local_connections()
+
+        methods = [
+            'trust',
+            'reject',
+            'md5',
+            'password',
+        ]
+
+        drop_script = []
+        for method in methods:
+            drop_script.append('DROP ROLE {}_user;'.format(method))
+
+        drop_script = '\n'.join(drop_script)
+        self.loop.run_until_complete(self.con.execute(drop_script))
+
+        super().tearDown()
+
+    async def test_auth_bad_user(self):
+        with self.assertRaises(
+                asyncpg.InvalidAuthorizationSpecificationError):
+            await self.cluster.connect(user='__nonexistent__',
+                                       database='postgres',
+                                       loop=self.loop)
+
+    async def test_auth_trust(self):
+        conn = await self.cluster.connect(
+            user='trust_user', database='postgres', loop=self.loop)
+        await conn.close()
+
+    async def test_auth_reject(self):
+        with self.assertRaisesRegex(
+                asyncpg.InvalidAuthorizationSpecificationError,
+                'pg_hba.conf rejects connection'):
+            for tried in range(3):
+                try:
+                    await self.cluster.connect(
+                        user='reject_user', database='postgres',
+                        loop=self.loop)
+                except asyncpg.ConnectionDoesNotExistError:
+                    if _system == 'Windows':
+                        # On Windows the server sometimes just closes
+                        # the connection sooner than we receive the
+                        # actual error.
+                        continue
+                    else:
+                        raise
+                else:
+                    break
+
+    async def test_auth_password_cleartext(self):
+        conn = await self.cluster.connect(
+            user='password_user', database='postgres',
+            password='correctpassword', loop=self.loop)
+        await conn.close()
+
+        with self.assertRaisesRegex(
+                asyncpg.InvalidPasswordError,
+                'password authentication failed for user "password_user"'):
+            await self.cluster.connect(
+                user='password_user', database='postgres',
+                password='wrongpassword', loop=self.loop)
+
+    async def test_auth_password_md5(self):
+        conn = await self.cluster.connect(
+            user='md5_user', database='postgres', password='correctpassword',
+            loop=self.loop)
+        await conn.close()
+
+        with self.assertRaisesRegex(
+                asyncpg.InvalidPasswordError,
+                'password authentication failed for user "md5_user"'):
+            await self.cluster.connect(
+                user='md5_user', database='postgres', password='wrongpassword',
+                loop=self.loop)
+
+    async def test_auth_unsupported(self):
+        pass
+
+
+class TestConnectParams(unittest.TestCase):
+
+    TESTS = [
+        {
+            'env': {
+                'PGUSER': 'user',
+                'PGDATABASE': 'testdb',
+                'PGPASSWORD': 'passw',
+                'PGHOST': 'host',
+                'PGPORT': '123'
+            },
+            'result': (['host'], 123, {
+                'user': 'user',
+                'password': 'passw',
+                'database': 'testdb'})
+        },
+
+        {
+            'env': {
+                'PGUSER': 'user',
+                'PGDATABASE': 'testdb',
+                'PGPASSWORD': 'passw',
+                'PGHOST': 'host',
+                'PGPORT': '123'
+            },
+
+            'host': 'host2',
+            'port': '456',
+            'user': 'user2',
+            'password': 'passw2',
+            'database': 'db2',
+
+            'result': (['host2'], 456, {
+                'user': 'user2',
+                'password': 'passw2',
+                'database': 'db2'})
+        },
+
+        {
+            'env': {
+                'PGUSER': 'user',
+                'PGDATABASE': 'testdb',
+                'PGPASSWORD': 'passw',
+                'PGHOST': 'host',
+                'PGPORT': '123'
+            },
+
+            'dsn': 'postgres://user3:123123@localhost/abcdef',
+
+            'host': 'host2',
+            'port': '456',
+            'user': 'user2',
+            'password': 'passw2',
+            'database': 'db2',
+
+            'result': (['host2'], 456, {
+                'user': 'user2',
+                'password': 'passw2',
+                'database': 'db2'})
+        },
+
+        {
+            'env': {
+                'PGUSER': 'user',
+                'PGDATABASE': 'testdb',
+                'PGPASSWORD': 'passw',
+                'PGHOST': 'host',
+                'PGPORT': '123'
+            },
+
+            'dsn': 'postgres://user3:123123@localhost:5555/abcdef',
+
+            'result': (['localhost'], 5555, {
+                'user': 'user3',
+                'password': '123123',
+                'database': 'abcdef'})
+        },
+
+        {
+            'dsn': 'postgres://user3:123123@localhost:5555/abcdef',
+            'result': (['localhost'], 5555, {
+                'user': 'user3',
+                'password': '123123',
+                'database': 'abcdef'})
+        },
+
+        {
+            'dsn': 'postgresql://user3:123123@localhost:5555/'
+                   'abcdef?param=sss&param=123&host=testhost&user=testuser'
+                   '&port=2222&database=testdb',
+            'host': '127.0.0.1',
+            'port': '888',
+            'user': 'me',
+            'password': 'ask',
+            'database': 'db',
+            'result': (['127.0.0.1'], 888, {
+                'param': '123',
+                'user': 'me',
+                'password': 'ask',
+                'database': 'db'})
+        },
+
+        {
+            'dsn': 'postgresql:///dbname?host=/unix_sock/test&user=spam',
+            'result': (['/unix_sock/test'], 5432, {
+                'user': 'spam',
+                'database': 'dbname'})
+        },
+
+        {
+            'dsn': 'pq:///dbname?host=/unix_sock/test&user=spam',
+            'error': (ValueError, 'invalid DSN')
+        },
+    ]
+
+    @contextlib.contextmanager
+    def environ(self, **kwargs):
+        old_vals = {}
+        for key in kwargs:
+            if key in os.environ:
+                old_vals[key] = os.environ[key]
+
+        for key, val in kwargs.items():
+            if val is None:
+                if key in os.environ:
+                    del os.environ[key]
+            else:
+                os.environ[key] = val
+
+        try:
+            yield
+        finally:
+            for key in kwargs:
+                if key in os.environ:
+                    del os.environ[key]
+            for key, val in old_vals.items():
+                os.environ[key] = val
+
+    def run_testcase(self, testcase):
+        env = testcase.get('env', {})
+        test_env = {'PGHOST': None, 'PGPORT': None,
+                    'PGUSER': None, 'PGPASSWORD': None,
+                    'PGDATABASE': None}
+        test_env.update(env)
+
+        dsn = testcase.get('dsn')
+        opts = testcase.get('opts', {})
+        user = testcase.get('user')
+        port = testcase.get('port')
+        host = testcase.get('host')
+        password = testcase.get('password')
+        database = testcase.get('database')
+
+        expected = testcase.get('result')
+        expected_error = testcase.get('error')
+        if expected is None and expected_error is None:
+            raise RuntimeError(
+                'invalid test case: either "result" or "error" key '
+                'has to be specified')
+        if expected is not None and expected_error is not None:
+            raise RuntimeError(
+                'invalid test case: either "result" or "error" key '
+                'has to be specified, got both')
+
+        with contextlib.ExitStack() as es:
+            es.enter_context(self.subTest(dsn=dsn, opts=opts, env=env))
+            es.enter_context(self.environ(**test_env))
+
+            if expected_error:
+                es.enter_context(self.assertRaisesRegex(*expected_error))
+
+            result = _parse_connect_params(
+                dsn=dsn, host=host, port=port, user=user, password=password,
+                database=database, opts=opts)
+
+        if expected is not None:
+            self.assertEqual(expected, result)
+
+    def test_test_connect_params_environ(self):
+        self.assertNotIn('AAAAAAAAAA123', os.environ)
+        self.assertNotIn('AAAAAAAAAA456', os.environ)
+        self.assertNotIn('AAAAAAAAAA789', os.environ)
+
+        try:
+
+            os.environ['AAAAAAAAAA456'] = '123'
+            os.environ['AAAAAAAAAA789'] = '123'
+
+            with self.environ(AAAAAAAAAA123='1',
+                              AAAAAAAAAA456='2',
+                              AAAAAAAAAA789=None):
+
+                self.assertEqual(os.environ['AAAAAAAAAA123'], '1')
+                self.assertEqual(os.environ['AAAAAAAAAA456'], '2')
+                self.assertNotIn('AAAAAAAAAA789', os.environ)
+
+            self.assertNotIn('AAAAAAAAAA123', os.environ)
+            self.assertEqual(os.environ['AAAAAAAAAA456'], '123')
+            self.assertEqual(os.environ['AAAAAAAAAA789'], '123')
+
+        finally:
+            for key in {'AAAAAAAAAA123', 'AAAAAAAAAA456', 'AAAAAAAAAA789'}:
+                if key in os.environ:
+                    del os.environ[key]
+
+    def test_test_connect_params_run_testcase(self):
+        with self.environ(PGPORT='777'):
+            self.run_testcase({
+                'env': {
+                    'PGUSER': '__test__'
+                },
+                'host': 'abc',
+                'result': (['abc'], 5432, {'user': '__test__'})
+            })
+
+        with self.assertRaises(AssertionError):
+            self.run_testcase({
+                'env': {
+                    'PGUSER': '__test__'
+                },
+                'host': 'abc',
+                'result': (['abc'], 5432, {'user': 'wrong_user'})
+            })
+
+    def test_connect_params(self):
+        for testcase in self.TESTS:
+            self.run_testcase(testcase)
diff --git a/tests/test_cursor.py b/tests/test_cursor.py
new file mode 100644 (file)
index 0000000..fc85480
--- /dev/null
@@ -0,0 +1,151 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import asyncpg
+import inspect
+
+from asyncpg import _testbase as tb
+
+
+class TestIterableCursor(tb.ConnectedTestCase):
+
+    async def test_cursor_iterable_01(self):
+        st = await self.con.prepare('SELECT generate_series(0, 20)')
+        expected = await st.fetch()
+
+        for prefetch in range(1, 25):
+            with self.subTest(prefetch=prefetch):
+                async with self.con.transaction():
+                    result = []
+                    async for rec in st.cursor(prefetch=prefetch):
+                        result.append(rec)
+
+                self.assertEqual(
+                    result, expected,
+                    'result != expected for prefetch={}'.format(prefetch))
+
+    async def test_cursor_iterable_02(self):
+        # Test that it's not possible to create a cursor without hold
+        # outside of a transaction
+        s = await self.con.prepare(
+            'DECLARE t BINARY CURSOR WITHOUT HOLD FOR SELECT 1')
+        with self.assertRaises(asyncpg.NoActiveSQLTransactionError):
+            await s.fetch()
+
+        # Now test that statement.cursor() does not let you
+        # iterate over it outside of a transaction
+        st = await self.con.prepare('SELECT generate_series(0, 20)')
+
+        it = st.cursor(prefetch=5).__aiter__()
+        if inspect.isawaitable(it):
+            it = await it
+
+        with self.assertRaisesRegex(asyncpg.NoActiveSQLTransactionError,
+                                    'cursor cannot be created.*transaction'):
+            await it.__anext__()
+
+    async def test_cursor_iterable_03(self):
+        st = await self.con.prepare('SELECT generate_series(0, 20)')
+
+        it = st.cursor().__aiter__()
+        if inspect.isawaitable(it):
+            it = await it
+
+        st._state.mark_closed()
+
+        with self.assertRaisesRegex(asyncpg.InterfaceError,
+                                    'statement is closed'):
+            async for _ in it:  # NOQA
+                pass
+
+    async def test_cursor_iterable_04(self):
+        st = await self.con.prepare('SELECT generate_series(0, 20)')
+        st._state.mark_closed()
+
+        with self.assertRaisesRegex(asyncpg.InterfaceError,
+                                    'statement is closed'):
+            async for _ in st.cursor():  # NOQA
+                pass
+
+    async def test_cursor_iterable_05(self):
+        st = await self.con.prepare('SELECT generate_series(0, 20)')
+        for prefetch in range(-1, 1):
+            with self.subTest(prefetch=prefetch):
+                with self.assertRaisesRegex(asyncpg.InterfaceError,
+                                            'must be greater than zero'):
+                    async for _ in st.cursor(prefetch=prefetch):  # NOQA
+                        pass
+
+    async def test_cursor_iterable_06(self):
+        recs = []
+
+        async with self.con.transaction():
+            async for rec in self.con.cursor(
+                    'SELECT generate_series(0, $1::int)', 10):
+                recs.append(rec)
+
+        self.assertEqual(recs, [(i,) for i in range(11)])
+
+
+class TestCursor(tb.ConnectedTestCase):
+
+    async def test_cursor_01(self):
+        st = await self.con.prepare('SELECT generate_series(0, 20)')
+        with self.assertRaisesRegex(asyncpg.NoActiveSQLTransactionError,
+                                    'cursor cannot be created.*transaction'):
+            await st.cursor()
+
+    async def test_cursor_02(self):
+        st = await self.con.prepare('SELECT generate_series(0, 20)')
+        async with self.con.transaction():
+            cur = await st.cursor()
+
+            for i in range(-1, 1):
+                with self.assertRaisesRegex(asyncpg.InterfaceError,
+                                            'greater than zero'):
+                    await cur.fetch(i)
+
+            res = await cur.fetch(2)
+            self.assertEqual(res, [(0,), (1,)])
+
+            rec = await cur.fetchrow()
+            self.assertEqual(rec, (2,))
+
+            r = repr(cur)
+            self.assertTrue(r.startswith('<asyncpg.Cursor '))
+            self.assertNotIn(' exhausted ', r)
+            self.assertIn('"SELECT generate', r)
+
+            moved = await cur.forward(5)
+            self.assertEqual(moved, 5)
+
+            rec = await cur.fetchrow()
+            self.assertEqual(rec, (8,))
+
+            res = await cur.fetch(100)
+            self.assertEqual(res, [(i,) for i in range(9, 21)])
+
+            self.assertIsNone(await cur.fetchrow())
+            self.assertEqual(await cur.fetch(5), [])
+
+            r = repr(cur)
+            self.assertTrue(r.startswith('<asyncpg.Cursor '))
+            self.assertIn(' exhausted ', r)
+            self.assertIn('"SELECT generate', r)
+
+    async def test_cursor_03(self):
+        st = await self.con.prepare('SELECT generate_series(0, 20)')
+        async with self.con.transaction():
+            with self.assertRaisesRegex(asyncpg.InterfaceError,
+                                        'prefetch argument can only'):
+                await st.cursor(prefetch=10)
+
+    async def test_cursor_04(self):
+        async with self.con.transaction():
+            st = await self.con.cursor('SELECT generate_series(0, 100)')
+            await st.forward(42)
+            self.assertEqual(await st.fetchrow(), (42,))
diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py
new file mode 100644 (file)
index 0000000..d904f6b
--- /dev/null
@@ -0,0 +1,34 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import asyncpg
+from asyncpg import _testbase as tb
+
+
+class TestExceptions(tb.ConnectedTestCase):
+
+    def test_exceptions_exported(self):
+        for err in ('PostgresError', 'SubstringError', 'InterfaceError'):
+            self.assertTrue(hasattr(asyncpg, err))
+            self.assertIn(err, asyncpg.__all__)
+
+        for err in ('PostgresMessage',):
+            self.assertFalse(hasattr(asyncpg, err))
+            self.assertNotIn(err, asyncpg.__all__)
+
+        self.assertIsNone(asyncpg.PostgresError.schema_name)
+
+    async def test_exceptions_unpacking(self):
+        with self.assertRaises(asyncpg.UndefinedTableError):
+            try:
+                await self.con.execute('SELECT * FROM _nonexistent_')
+            except asyncpg.UndefinedTableError as e:
+                self.assertEqual(e.sqlstate, '42P01')
+                self.assertEqual(e.position, '15')
+                self.assertEqual(e.query, 'SELECT * FROM _nonexistent_')
+                self.assertIsNotNone(e.severity)
+                raise
diff --git a/tests/test_execute.py b/tests/test_execute.py
new file mode 100644 (file)
index 0000000..c471015
--- /dev/null
@@ -0,0 +1,134 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import asyncio
+import asyncpg
+
+from asyncpg import _testbase as tb
+
+
+class TestExecuteScript(tb.ConnectedTestCase):
+
+    async def test_execute_script_1(self):
+        self.assertEqual(self.con._protocol.queries_count, 0)
+        status = await self.con.execute('''
+            SELECT 1;
+
+            SELECT true FROM pg_type WHERE false = true;
+
+            SELECT generate_series(0, 9);
+        ''')
+        self.assertEqual(self.con._protocol.queries_count, 1)
+        self.assertEqual(status, 'SELECT 10')
+
+    async def test_execute_script_2(self):
+        status = await self.con.execute('''
+            CREATE TABLE mytab (a int);
+        ''')
+        self.assertEqual(status, 'CREATE TABLE')
+
+        try:
+            status = await self.con.execute('''
+                INSERT INTO mytab (a) VALUES ($1), ($2)
+            ''', 10, 20)
+            self.assertEqual(status, 'INSERT 0 2')
+        finally:
+            await self.con.execute('DROP TABLE mytab')
+
+    async def test_execute_script_3(self):
+        with self.assertRaisesRegex(asyncpg.PostgresSyntaxError,
+                                    'cannot insert multiple commands'):
+
+            await self.con.execute('''
+                CREATE TABLE mytab (a int);
+                INSERT INTO mytab (a) VALUES ($1), ($2);
+            ''', 10, 20)
+
+    async def test_execute_script_check_transactionality(self):
+        with self.assertRaises(asyncpg.PostgresError):
+            await self.con.execute('''
+                CREATE TABLE mytab (a int);
+                SELECT * FROM mytab WHERE 1 / 0 = 1;
+            ''')
+
+        with self.assertRaisesRegex(asyncpg.PostgresError,
+                                    '"mytab" does not exist'):
+
+            await self.con.prepare('''
+                SELECT * FROM mytab
+            ''')
+
+    async def test_execute_exceptions_1(self):
+        with self.assertRaisesRegex(asyncpg.PostgresError,
+                                    'relation "__dne__" does not exist'):
+
+            await self.con.execute('select * from __dne__')
+
+    async def test_execute_script_interrupted_close(self):
+        fut = self.loop.create_task(
+            self.con.execute('''SELECT pg_sleep(10)'''))
+
+        await asyncio.sleep(0.2, loop=self.loop)
+
+        self.assertFalse(self.con.is_closed())
+        await self.con.close()
+        self.assertTrue(self.con.is_closed())
+
+        with self.assertRaisesRegex(asyncpg.ConnectionDoesNotExistError,
+                                    'closed in the middle'):
+            await fut
+
+    async def test_execute_script_interrupted_terminate(self):
+        fut = self.loop.create_task(
+            self.con.execute('''SELECT pg_sleep(10)'''))
+
+        await asyncio.sleep(0.2, loop=self.loop)
+
+        self.assertFalse(self.con.is_closed())
+        self.con.terminate()
+        self.assertTrue(self.con.is_closed())
+
+        with self.assertRaisesRegex(asyncpg.ConnectionDoesNotExistError,
+                                    'closed in the middle'):
+            await fut
+
+        self.con.terminate()
+
+    async def test_execute_many_1(self):
+        await self.con.execute('CREATE TEMP TABLE exmany (a text, b int)')
+
+        try:
+            result = await self.con.executemany('''
+                INSERT INTO exmany VALUES($1, $2)
+            ''', [
+                ('a', 1), ('b', 2), ('c', 3), ('d', 4)
+            ])
+
+            self.assertIsNone(result)
+
+            result = await self.con.fetch('''
+                SELECT * FROM exmany
+            ''')
+
+            self.assertEqual(result, [
+                ('a', 1), ('b', 2), ('c', 3), ('d', 4)
+            ])
+
+            # Empty set
+            result = await self.con.executemany('''
+                INSERT INTO exmany VALUES($1, $2)
+            ''', ())
+
+            result = await self.con.fetch('''
+                SELECT * FROM exmany
+            ''')
+
+            self.assertEqual(result, [
+                ('a', 1), ('b', 2), ('c', 3), ('d', 4)
+            ])
+        finally:
+            await self.con.execute('DROP TABLE exmany')
diff --git a/tests/test_listeners.py b/tests/test_listeners.py
new file mode 100644 (file)
index 0000000..158a97a
--- /dev/null
@@ -0,0 +1,76 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import asyncio
+
+from asyncpg import _testbase as tb
+
+
+class TestListeners(tb.ClusterTestCase):
+
+    async def test_listen_01(self):
+        async with self.create_pool(database='postgres') as pool:
+            async with pool.acquire() as con:
+
+                q1 = asyncio.Queue(loop=self.loop)
+                q2 = asyncio.Queue(loop=self.loop)
+
+                def listener1(*args):
+                    q1.put_nowait(args)
+
+                def listener2(*args):
+                    q2.put_nowait(args)
+
+                await con.add_listener('test', listener1)
+                await con.add_listener('test', listener2)
+
+                await con.execute("NOTIFY test, 'aaaa'")
+
+                self.assertEqual(
+                    await q1.get(),
+                    (con, con.get_server_pid(), 'test', 'aaaa'))
+                self.assertEqual(
+                    await q2.get(),
+                    (con, con.get_server_pid(), 'test', 'aaaa'))
+
+                await con.remove_listener('test', listener2)
+
+                await con.execute("NOTIFY test, 'aaaa'")
+
+                self.assertEqual(
+                    await q1.get(),
+                    (con, con.get_server_pid(), 'test', 'aaaa'))
+                with self.assertRaises(asyncio.TimeoutError):
+                    await asyncio.wait_for(q2.get(),
+                                           timeout=0.05, loop=self.loop)
+
+                await con.reset()
+                await con.remove_listener('test', listener1)
+                await con.execute("NOTIFY test, 'aaaa'")
+
+                with self.assertRaises(asyncio.TimeoutError):
+                    await asyncio.wait_for(q1.get(),
+                                           timeout=0.05, loop=self.loop)
+                with self.assertRaises(asyncio.TimeoutError):
+                    await asyncio.wait_for(q2.get(),
+                                           timeout=0.05, loop=self.loop)
+
+    async def test_listen_02(self):
+        async with self.create_pool(database='postgres') as pool:
+            async with pool.acquire() as con1, pool.acquire() as con2:
+
+                q1 = asyncio.Queue(loop=self.loop)
+
+                def listener1(*args):
+                    q1.put_nowait(args)
+
+                await con1.add_listener('ipc', listener1)
+                await con2.execute("NOTIFY ipc, 'hello'")
+
+                self.assertEqual(
+                    await q1.get(),
+                    (con1, con2.get_server_pid(), 'ipc', 'hello'))
diff --git a/tests/test_pool.py b/tests/test_pool.py
new file mode 100644 (file)
index 0000000..a6faf9a
--- /dev/null
@@ -0,0 +1,223 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import asyncio
+import platform
+import os
+import unittest
+
+from asyncpg import _testbase as tb
+from asyncpg import cluster as pg_cluster
+from asyncpg import pool as pg_pool
+
+_system = platform.uname().system
+
+
+class TestPool(tb.ConnectedTestCase):
+
+    async def test_pool_01(self):
+        for n in {1, 3, 5, 10, 20, 100}:
+            with self.subTest(tasksnum=n):
+                pool = await self.create_pool(database='postgres',
+                                              min_size=5, max_size=10)
+
+                async def worker():
+                    con = await pool.acquire()
+                    self.assertEqual(await con.fetchval('SELECT 1'), 1)
+                    await pool.release(con)
+
+                tasks = [worker() for _ in range(n)]
+                await asyncio.gather(*tasks, loop=self.loop)
+                await pool.close()
+
+    async def test_pool_02(self):
+        for n in {1, 3, 5, 10, 20, 100}:
+            with self.subTest(tasksnum=n):
+                async with self.create_pool(database='postgres',
+                                            min_size=5, max_size=5) as pool:
+
+                    async def worker():
+                        con = await pool.acquire(timeout=5)
+                        self.assertEqual(await con.fetchval('SELECT 1'), 1)
+                        await pool.release(con)
+
+                    tasks = [worker() for _ in range(n)]
+                    await asyncio.gather(*tasks, loop=self.loop)
+
+    async def test_pool_03(self):
+        pool = await self.create_pool(database='postgres',
+                                      min_size=1, max_size=1)
+
+        con = await pool.acquire(timeout=1)
+        with self.assertRaises(asyncio.TimeoutError):
+            await pool.acquire(timeout=0.03)
+
+        pool.terminate()
+        del con
+
+    async def test_pool_04(self):
+        pool = await self.create_pool(database='postgres',
+                                      min_size=1, max_size=1)
+
+        con = await pool.acquire(timeout=0.1)
+        con.terminate()
+        await pool.release(con)
+
+        async with pool.acquire(timeout=0.1):
+            con.terminate()
+
+        con = await pool.acquire(timeout=0.1)
+        self.assertEqual(await con.fetchval('SELECT 1'), 1)
+
+        await pool.close()
+
+    async def test_pool_05(self):
+        for n in {1, 3, 5, 10, 20, 100}:
+            with self.subTest(tasksnum=n):
+                pool = await self.create_pool(database='postgres',
+                                              min_size=5, max_size=10)
+
+                async def worker():
+                    async with pool.acquire() as con:
+                        self.assertEqual(await con.fetchval('SELECT 1'), 1)
+
+                tasks = [worker() for _ in range(n)]
+                await asyncio.gather(*tasks, loop=self.loop)
+                await pool.close()
+
+    async def test_pool_06(self):
+        fut = asyncio.Future(loop=self.loop)
+
+        async def setup(con):
+            fut.set_result(con)
+
+        async with self.create_pool(database='postgres',
+                                    min_size=5, max_size=5,
+                                    setup=setup) as pool:
+            con = await pool.acquire()
+
+        self.assertIs(con, await fut)
+
+    async def test_pool_auth(self):
+        if not self.cluster.is_managed():
+            self.skipTest('unmanaged cluster')
+
+        self.cluster.reset_hba()
+
+        if _system != 'Windows':
+            self.cluster.add_hba_entry(
+                type='local',
+                database='postgres', user='pooluser',
+                auth_method='md5')
+
+        self.cluster.add_hba_entry(
+            type='host', address='127.0.0.1/32',
+            database='postgres', user='pooluser',
+            auth_method='md5')
+
+        self.cluster.add_hba_entry(
+            type='host', address='::1/128',
+            database='postgres', user='pooluser',
+            auth_method='md5')
+
+        self.cluster.reload()
+
+        try:
+            await self.con.execute('''
+                CREATE ROLE pooluser WITH LOGIN PASSWORD 'poolpassword'
+            ''')
+
+            pool = await self.create_pool(database='postgres',
+                                          user='pooluser',
+                                          password='poolpassword',
+                                          min_size=5, max_size=10)
+
+            async def worker():
+                con = await pool.acquire()
+                self.assertEqual(await con.fetchval('SELECT 1'), 1)
+                await pool.release(con)
+
+            tasks = [worker() for _ in range(5)]
+            await asyncio.gather(*tasks, loop=self.loop)
+            await pool.close()
+
+        finally:
+            await self.con.execute('DROP ROLE pooluser')
+
+            # Reset cluster's pg_hba.conf since we've meddled with it
+            self.cluster.trust_local_connections()
+            self.cluster.reload()
+
+
+@unittest.skipIf(os.environ.get('PGHOST'), 'using remote cluster for testing')
+class TestHostStandby(tb.ConnectedTestCase):
+    @classmethod
+    def setUpClass(cls):
+        super().setUpClass()
+
+        cls.master_cluster = cls.start_cluster(
+            pg_cluster.TempCluster,
+            server_settings={
+                'max_wal_senders': 10,
+                'wal_level': 'hot_standby'
+            })
+
+        con = None
+
+        try:
+            con = cls.loop.run_until_complete(
+                cls.master_cluster.connect(database='postgres', loop=cls.loop))
+
+            cls.loop.run_until_complete(
+                con.execute('''
+                    CREATE ROLE replication WITH LOGIN REPLICATION
+                '''))
+
+            cls.master_cluster.trust_local_replication_by('replication')
+
+            conn_spec = cls.master_cluster.get_connection_spec()
+
+            cls.standby_cluster = cls.start_cluster(
+                pg_cluster.HotStandbyCluster,
+                cluster_kwargs={
+                    'master': conn_spec,
+                    'replication_user': 'replication'
+                },
+                server_settings={
+                    'hot_standby': True
+                })
+
+        finally:
+            if con is not None:
+                cls.loop.run_until_complete(con.close())
+
+    @classmethod
+    def tearDownMethod(cls):
+        cls.standby_cluster.stop()
+        cls.standby_cluster.destroy()
+        cls.master_cluster.stop()
+        cls.master_cluster.destroy()
+
+    def create_pool(self, **kwargs):
+        conn_spec = self.standby_cluster.get_connection_spec()
+        conn_spec.update(kwargs)
+        return pg_pool.create_pool(loop=self.loop, **conn_spec)
+
+    async def test_standby_pool_01(self):
+        for n in {1, 3, 5, 10, 20, 100}:
+            with self.subTest(tasksnum=n):
+                pool = await self.create_pool(database='postgres',
+                                              min_size=5, max_size=10)
+
+                async def worker():
+                    con = await pool.acquire()
+                    self.assertEqual(await con.fetchval('SELECT 1'), 1)
+                    await pool.release(con)
+
+                tasks = [worker() for _ in range(n)]
+                await asyncio.gather(*tasks, loop=self.loop)
+                await pool.close()
diff --git a/tests/test_prepare.py b/tests/test_prepare.py
new file mode 100644 (file)
index 0000000..d09187c
--- /dev/null
@@ -0,0 +1,408 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import asyncio
+import asyncpg
+import gc
+import unittest
+
+from asyncpg import _testbase as tb
+
+
+class TestPrepare(tb.ConnectedTestCase):
+
+    async def test_prepare_01(self):
+        self.assertEqual(self.con._protocol.queries_count, 0)
+        st = await self.con.prepare('SELECT 1 = $1 AS test')
+        self.assertEqual(self.con._protocol.queries_count, 0)
+        self.assertEqual(st.get_query(), 'SELECT 1 = $1 AS test')
+
+        rec = await st.fetchrow(1)
+        self.assertEqual(self.con._protocol.queries_count, 1)
+        self.assertTrue(rec['test'])
+        self.assertEqual(len(rec), 1)
+
+        self.assertEqual(False, await st.fetchval(10))
+        self.assertEqual(self.con._protocol.queries_count, 2)
+
+    async def test_prepare_02(self):
+        with self.assertRaisesRegex(Exception, 'column "a" does not exist'):
+            await self.con.prepare('SELECT a')
+
+    async def test_prepare_03(self):
+        cases = [
+            ('text', ("'NULL'", 'NULL'), [
+                'aaa',
+                None
+            ]),
+
+            ('decimal', ('0', 0), [
+                123,
+                123.5,
+                None
+            ])
+        ]
+
+        for type, (none_name, none_val), vals in cases:
+            st = await self.con.prepare('''
+                    SELECT CASE WHEN $1::{type} IS NULL THEN {default}
+                    ELSE $1::{type} END'''.format(
+                type=type, default=none_name))
+
+            for val in vals:
+                with self.subTest(type=type, value=val):
+                    res = await st.fetchval(val)
+                    if val is None:
+                        self.assertEqual(res, none_val)
+                    else:
+                        self.assertEqual(res, val)
+
+    async def test_prepare_04(self):
+        s = await self.con.prepare('SELECT $1::smallint')
+        self.assertEqual(await s.fetchval(10), 10)
+
+        s = await self.con.prepare('SELECT $1::smallint * 2')
+        self.assertEqual(await s.fetchval(10), 20)
+
+        s = await self.con.prepare('SELECT generate_series(5,10)')
+        self.assertEqual(await s.fetchval(), 5)
+        # Since the "execute" message was sent with a limit=1,
+        # we will receive a PortalSuspended message, instead of
+        # CommandComplete.  Which means there will be no status
+        # message set.
+        self.assertIsNone(s.get_statusmsg())
+        # Repeat the same test for 'fetchrow()'.
+        self.assertEqual(await s.fetchrow(), (5,))
+        self.assertIsNone(s.get_statusmsg())
+
+    async def test_prepare_05_unknownoid(self):
+        s = await self.con.prepare("SELECT 'test'")
+        self.assertEqual(await s.fetchval(), 'test')
+
+    async def test_prepare_06_interrupted_close(self):
+        stmt = await self.con.prepare('''SELECT pg_sleep(10)''')
+        fut = self.loop.create_task(stmt.fetch())
+
+        await asyncio.sleep(0.2, loop=self.loop)
+
+        self.assertFalse(self.con.is_closed())
+        await self.con.close()
+        self.assertTrue(self.con.is_closed())
+
+        with self.assertRaisesRegex(asyncpg.ConnectionDoesNotExistError,
+                                    'closed in the middle'):
+            await fut
+
+        # Test that it's OK to call close again
+        await self.con.close()
+
+    async def test_prepare_07_interrupted_terminate(self):
+        stmt = await self.con.prepare('''SELECT pg_sleep(10)''')
+        fut = self.loop.create_task(stmt.fetchval())
+
+        await asyncio.sleep(0.2, loop=self.loop)
+
+        self.assertFalse(self.con.is_closed())
+        self.con.terminate()
+        self.assertTrue(self.con.is_closed())
+
+        with self.assertRaisesRegex(asyncpg.ConnectionDoesNotExistError,
+                                    'closed in the middle'):
+            await fut
+
+        # Test that it's OK to call terminate again
+        self.con.terminate()
+
+    async def test_prepare_08_big_result(self):
+        stmt = await self.con.prepare('select generate_series(0,10000)')
+        result = await stmt.fetch()
+
+        self.assertEqual(len(result), 10001)
+        self.assertEqual(
+            [r[0] for r in result],
+            list(range(10001)))
+
+    async def test_prepare_09_raise_error(self):
+        # Stress test ReadBuffer.read_cstr()
+        msg = '0' * 1024 * 100
+        query = """
+        DO language plpgsql $$
+        BEGIN
+        RAISE EXCEPTION '{}';
+        END
+        $$;""".format(msg)
+
+        stmt = await self.con.prepare(query)
+        with self.assertRaisesRegex(asyncpg.RaiseError, msg):
+            with tb.silence_asyncio_long_exec_warning():
+                await stmt.fetchval()
+
+    async def test_prepare_10_stmt_lru(self):
+        query = 'select {}'
+        cache_max = self.con._stmt_cache_max_size
+        iter_max = cache_max * 2 + 11
+
+        # First, we have no cached statements.
+        self.assertEqual(len(self.con._stmt_cache), 0)
+
+        stmts = []
+        for i in range(iter_max):
+            s = await self.con.prepare(query.format(i))
+            self.assertEqual(await s.fetchval(), i)
+            stmts.append(s)
+
+        # At this point our cache should be full.
+        self.assertEqual(len(self.con._stmt_cache), cache_max)
+        self.assertTrue(
+            all(not s.closed for s in self.con._stmt_cache.values()))
+
+        # Since there are references to the statements (`stmts` list),
+        # no statements are scheduled to be closed.
+        self.assertEqual(len(self.con._stmts_to_close), 0)
+
+        # Removing refs to statements and preparing a new statement
+        # will cause connection to cleanup any stale statements.
+        stmts.clear()
+        gc.collect()
+
+        # Now we have a bunch of statements that have no refs to them
+        # scheduled to be closed.
+        self.assertEqual(len(self.con._stmts_to_close), iter_max - cache_max)
+        self.assertTrue(all(s.closed for s in self.con._stmts_to_close))
+        self.assertTrue(
+            all(not s.closed for s in self.con._stmt_cache.values()))
+
+        zero = await self.con.prepare(query.format(0))
+        # Hence, all stale statements should be closed now.
+        self.assertEqual(len(self.con._stmts_to_close), 0)
+
+        # The number of cached statements will stay the same though.
+        self.assertEqual(len(self.con._stmt_cache), cache_max)
+        self.assertTrue(
+            all(not s.closed for s in self.con._stmt_cache.values()))
+
+        # After closing all statements will be closed.
+        await self.con.close()
+        self.assertEqual(len(self.con._stmts_to_close), 0)
+        self.assertEqual(len(self.con._stmt_cache), 0)
+
+        # An attempt to perform an operation on a closed statement
+        # will trigger an error.
+        with self.assertRaisesRegex(asyncpg.InterfaceError, 'is closed'):
+            await zero.fetchval()
+
+    async def test_prepare_11_stmt_gc(self):
+        # Test that prepared statements should stay in the cache after
+        # they are GCed.
+
+        # First, we have no cached statements.
+        self.assertEqual(len(self.con._stmt_cache), 0)
+        self.assertEqual(len(self.con._stmts_to_close), 0)
+
+        # The prepared statement that we'll create will be GCed
+        # right await.  However, its state should be still in
+        # in the statements LRU cache.
+        await self.con.prepare('select 1')
+        gc.collect()
+
+        self.assertEqual(len(self.con._stmt_cache), 1)
+        self.assertEqual(len(self.con._stmts_to_close), 0)
+
+    async def test_prepare_12_stmt_gc(self):
+        # Test that prepared statements are closed when there is no space
+        # for them in the LRU cache and there are no references to them.
+
+        # First, we have no cached statements.
+        self.assertEqual(len(self.con._stmt_cache), 0)
+        self.assertEqual(len(self.con._stmts_to_close), 0)
+
+        cache_max = self.con._stmt_cache_max_size
+
+        stmt = await self.con.prepare('select 100000000')
+        self.assertEqual(len(self.con._stmt_cache), 1)
+        self.assertEqual(len(self.con._stmts_to_close), 0)
+
+        for i in range(cache_max):
+            await self.con.prepare('select {}'.format(i))
+
+        self.assertEqual(len(self.con._stmt_cache), cache_max)
+        self.assertEqual(len(self.con._stmts_to_close), 0)
+
+        del stmt
+        gc.collect()
+
+        self.assertEqual(len(self.con._stmt_cache), cache_max)
+        self.assertEqual(len(self.con._stmts_to_close), 1)
+
+    async def test_prepare_13_connect(self):
+        v = await self.con.fetchval(
+            'SELECT $1::smallint AS foo', 10, column='foo')
+        self.assertEqual(v, 10)
+
+        r = await self.con.fetchrow('SELECT $1::smallint * 2 AS test', 10)
+        self.assertEqual(r['test'], 20)
+
+        rows = await self.con.fetch('SELECT generate_series(0,$1::int)', 3)
+        self.assertEqual([r[0] for r in rows], [0, 1, 2, 3])
+
+    async def test_prepare_14_explain(self):
+        # Test simple EXPLAIN.
+        stmt = await self.con.prepare('SELECT typname FROM pg_type')
+        plan = await stmt.explain()
+        self.assertEqual(plan[0]['Plan']['Relation Name'], 'pg_type')
+
+        # Test "EXPLAIN ANALYZE".
+        stmt = await self.con.prepare(
+            'SELECT typname, typlen FROM pg_type WHERE typlen > $1')
+        plan = await stmt.explain(2, analyze=True)
+        self.assertEqual(plan[0]['Plan']['Relation Name'], 'pg_type')
+        self.assertIn('Actual Total Time', plan[0]['Plan'])
+
+        # Test that 'EXPLAIN ANALYZE' is executed in a transaction
+        # that gets rollbacked.
+        tr = self.con.transaction()
+        await tr.start()
+        try:
+            await self.con.execute('CREATE TABLE mytab (a int)')
+            stmt = await self.con.prepare(
+                'INSERT INTO mytab (a) VALUES (1), (2)')
+            plan = await stmt.explain(analyze=True)
+            self.assertEqual(plan[0]['Plan']['Operation'], 'Insert')
+
+            # Check that no data was inserted
+            res = await self.con.fetch('SELECT * FROM mytab')
+            self.assertEqual(res, [])
+        finally:
+            await tr.rollback()
+
+    async def test_prepare_15_stmt_gc_cache_disabled(self):
+        # Test that even if the statements cache is off, we're still
+        # cleaning up GCed statements.
+
+        self.assertEqual(len(self.con._stmt_cache), 0)
+        self.assertEqual(len(self.con._stmts_to_close), 0)
+        # Disable cache
+        self.con._stmt_cache_max_size = 0
+
+        stmt = await self.con.prepare('select 100000000')
+        self.assertEqual(len(self.con._stmt_cache), 0)
+        self.assertEqual(len(self.con._stmts_to_close), 0)
+
+        del stmt
+        gc.collect()
+
+        # After GC, _stmts_to_close should contain stmt's state
+        self.assertEqual(len(self.con._stmt_cache), 0)
+        self.assertEqual(len(self.con._stmts_to_close), 1)
+
+        # Next "prepare" call will trigger a cleanup
+        stmt = await self.con.prepare('select 1')
+        self.assertEqual(len(self.con._stmt_cache), 0)
+        self.assertEqual(len(self.con._stmts_to_close), 0)
+
+        del stmt
+
+    async def test_prepare_16_command_result(self):
+        async def status(query):
+            stmt = await self.con.prepare(query)
+            await stmt.fetch()
+            return stmt.get_statusmsg()
+
+        try:
+            self.assertEqual(
+                await status('CREATE TABLE mytab (a int)'),
+                'CREATE TABLE')
+
+            self.assertEqual(
+                await status('INSERT INTO mytab (a) VALUES (1), (2)'),
+                'INSERT 0 2')
+
+            self.assertEqual(
+                await status('SELECT a FROM mytab'),
+                'SELECT 2')
+
+            self.assertEqual(
+                await status('UPDATE mytab SET a = 3 WHERE a = 1'),
+                'UPDATE 1')
+        finally:
+            self.assertEqual(
+                await status('DROP TABLE mytab'),
+                'DROP TABLE')
+
+    async def test_prepare_17_stmt_closed_lru(self):
+        st = await self.con.prepare('SELECT 1')
+        st._state.mark_closed()
+        with self.assertRaisesRegex(asyncpg.InterfaceError, 'is closed'):
+            await st.fetch()
+
+        st = await self.con.prepare('SELECT 1')
+        self.assertEqual(await st.fetchval(), 1)
+
+    async def test_prepare_18_empty_result(self):
+        # test EmptyQueryResponse protocol message
+        st = await self.con.prepare('')
+        self.assertEqual(await st.fetch(), [])
+        self.assertIsNone(await st.fetchval())
+        self.assertIsNone(await st.fetchrow())
+
+        self.assertEqual(await self.con.fetch(''), [])
+        self.assertIsNone(await self.con.fetchval(''))
+        self.assertIsNone(await self.con.fetchrow(''))
+
+    async def test_prepare_19_concurrent_calls(self):
+        st = self.loop.create_task(self.con.fetchval(
+            'SELECT ROW(pg_sleep(0.03), 1)'))
+
+        # Wait for some time to make sure the first query is fully
+        # prepared (!) and is now awaiting the results (!!).
+        await asyncio.sleep(0.01, loop=self.loop)
+
+        with self.assertRaisesRegex(asyncpg.InterfaceError,
+                                    'another operation'):
+            await self.con.execute('SELECT 2')
+
+        self.assertEqual(await st, (None, 1))
+
+    async def test_prepare_20_concurrent_calls(self):
+        expected = ((None, 1),)
+
+        for methname, val in [('fetch', [expected]),
+                              ('fetchval', expected[0]),
+                              ('fetchrow', expected)]:
+
+            with self.subTest(meth=methname):
+
+                meth = getattr(self.con, methname)
+
+                vf = self.loop.create_task(
+                    meth('SELECT ROW(pg_sleep(0.03), 1)'))
+
+                await asyncio.sleep(0.01, loop=self.loop)
+
+                with self.assertRaisesRegex(asyncpg.InterfaceError,
+                                            'another operation'):
+                    await meth('SELECT 2')
+
+                self.assertEqual(await vf, val)
+
+    async def test_prepare_21_errors(self):
+        stmt = await self.con.prepare('SELECT 10 / $1::int')
+
+        with self.assertRaises(asyncpg.DivisionByZeroError):
+            await stmt.fetchval(0)
+
+        self.assertEqual(await stmt.fetchval(5), 2)
+
+    async def test_prepare_22_empty(self):
+        # Support for empty target list was added in PostgreSQL 9.4
+        if self.server_version < (9, 4):
+            raise unittest.SkipTest(
+                'PostgreSQL servers < 9.4 do not support empty target list.')
+
+        result = await self.con.fetchrow('SELECT')
+        self.assertEqual(result, ())
+        self.assertEqual(repr(result), '<Record>')
diff --git a/tests/test_record.py b/tests/test_record.py
new file mode 100644 (file)
index 0000000..1ee1f8f
--- /dev/null
@@ -0,0 +1,299 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import contextlib
+import collections
+import gc
+import pickle
+import sys
+
+from asyncpg import _testbase as tb
+from asyncpg.protocol.protocol import _create_record as Record
+
+
+R_A = collections.OrderedDict([('a', 0)])
+R_AB = collections.OrderedDict([('a', 0), ('b', 1)])
+R_AC = collections.OrderedDict([('a', 0), ('c', 1)])
+R_ABC = collections.OrderedDict([('a', 0), ('b', 1), ('c', 2)])
+
+
+class TestRecord(tb.ConnectedTestCase):
+
+    @contextlib.contextmanager
+    def checkref(self, *objs):
+        cnt = [sys.getrefcount(objs[i]) for i in range(len(objs))]
+        yield
+        for _ in range(3):
+            gc.collect()
+        for i in range(len(objs)):
+            before = cnt[i]
+            after = sys.getrefcount(objs[i])
+            if before != after:
+                self.fail('refcounts differ for {!r}: {:+}'.format(
+                    objs[i], after - before))
+
+    def test_record_gc(self):
+        elem = object()
+        mapping = {}
+        with self.checkref(mapping, elem):
+            r = Record(mapping, (elem,))
+            del r
+
+        key = 'spam'
+        val = int('101010')
+        mapping = {key: val}
+        with self.checkref(key, val):
+            r = Record(mapping, (0,))
+            with self.assertRaises(KeyError):
+                r[key]
+            del r
+
+        key = 'spam'
+        val = 'ham'
+        mapping = {key: val}
+        with self.checkref(key, val):
+            r = Record(mapping, (0,))
+            with self.assertRaises(KeyError):
+                r[key]
+            del r
+
+    def test_record_freelist_ok(self):
+        for _ in range(10000):
+            Record(R_A, (42,))
+            Record(R_AB, (42, 42,))
+
+    def test_record_len_getindex(self):
+        r = Record(R_A, (42,))
+        self.assertEqual(len(r), 1)
+        self.assertEqual(r[0], 42)
+        self.assertEqual(r['a'], 42)
+
+        r = Record(R_AB, (42, 43))
+        self.assertEqual(len(r), 2)
+        self.assertEqual(r[0], 42)
+        self.assertEqual(r[1], 43)
+        self.assertEqual(r['a'], 42)
+        self.assertEqual(r['b'], 43)
+
+        with self.assertRaisesRegex(IndexError,
+                                    'record index out of range'):
+            r[1000]
+
+        with self.assertRaisesRegex(KeyError, 'spam'):
+            r['spam']
+
+        with self.assertRaisesRegex(KeyError, 'spam'):
+            Record(None, (1,))['spam']
+
+        with self.assertRaisesRegex(KeyError, 'spam'):
+            Record({'spam': 123}, (1,))['spam']
+
+    def test_record_slice(self):
+        r = Record(R_ABC, (1, 2, 3))
+        self.assertEqual(r[:], (1, 2, 3))
+        self.assertEqual(r[:1], (1,))
+        self.assertEqual(r[::-1], (3, 2, 1))
+        self.assertEqual(r[::-2], (3, 1))
+        self.assertEqual(r[1:2], (2,))
+        self.assertEqual(r[2:2], ())
+
+    def test_record_immutable(self):
+        r = Record(R_A, (42,))
+        with self.assertRaisesRegex(TypeError, 'does not support item'):
+            r[0] = 1
+
+    def test_record_repr(self):
+        self.assertEqual(
+            repr(Record(R_A, (42,))),
+            '<Record a=42>')
+
+        self.assertEqual(
+            repr(Record(R_AB, (42, -1))),
+            '<Record a=42 b=-1>')
+
+        # test invalid records just in case
+        with self.assertRaisesRegex(RuntimeError, 'invalid .* mapping'):
+            repr(Record(R_A, (42, 43)))
+        self.assertEqual(repr(Record(R_AB, (42,))), '<Record a=42>')
+
+        class Key:
+            def __str__(self):
+                1 / 0
+
+            def __repr__(self):
+                1 / 0
+
+        with self.assertRaises(ZeroDivisionError):
+            repr(Record({Key(): 0}, (42,)))
+        with self.assertRaises(ZeroDivisionError):
+            repr(Record(R_A, (Key(),)))
+
+    def test_record_iter(self):
+        r = Record(R_AB, (42, 43))
+        with self.checkref(r):
+            self.assertEqual(iter(r).__length_hint__(), 2)
+            self.assertEqual(tuple(r), (42, 43))
+
+    def test_record_values(self):
+        r = Record(R_AB, (42, 43))
+        vv = r.values()
+        self.assertEqual(tuple(vv), (42, 43))
+        self.assertTrue(repr(vv).startswith('<RecordIterator '))
+
+    def test_record_keys(self):
+        r = Record(R_AB, (42, 43))
+        vv = r.keys()
+        self.assertEqual(tuple(vv), ('a', 'b'))
+        self.assertEqual(list(Record(None, (42, 43)).keys()), [])
+
+    def test_record_items(self):
+        r = Record(R_AB, (42, 43))
+
+        self.assertEqual(dict(r), {'a': 42, 'b': 43})
+        self.assertEqual(
+            list(collections.OrderedDict(r).items()),
+            [('a', 42), ('b', 43)])
+
+        with self.checkref(r):
+            rk = r.items()
+            self.assertEqual(rk.__length_hint__(), 2)
+            self.assertEqual(next(rk), ('a', 42))
+            self.assertEqual(rk.__length_hint__(), 1)
+            self.assertEqual(next(rk), ('b', 43))
+            self.assertEqual(rk.__length_hint__(), 0)
+
+            with self.assertRaises(StopIteration):
+                next(rk)
+            with self.assertRaises(StopIteration):
+                next(rk)
+
+            self.assertEqual(rk.__length_hint__(), 0)
+
+        self.assertEqual(list(r.items()), [('a', 42), ('b', 43)])
+
+        # Check invalid records just in case
+        r = Record(R_A, (42, 43))
+        self.assertEqual(list(r.items()), [('a', 42)])
+        r = Record(R_AB, (42,))
+        self.assertEqual(list(r.items()), [('a', 42)])
+
+        # Try to iterate over exhausted items() iterator
+        r = Record(R_A, (42, 43))
+        it = r.items()
+        list(it)
+        list(it)
+
+    def test_record_hash(self):
+        AB = collections.namedtuple('AB', ('a', 'b'))
+        r1 = Record(R_AB, (42, 43))
+        r2 = Record(R_AB, (42, 43))
+        r3 = Record(R_AB, (42, 45))
+        r4 = (42, 43)
+        r5 = AB(42, 43)
+
+        self.assertEqual(hash(r1), hash(r2))
+        self.assertNotEqual(hash(r1), hash(r3))
+        self.assertEqual(hash(r1), hash(r4))
+        self.assertEqual(hash(r1), hash(r5))
+
+        d = {}
+        d[r1] = 123
+        self.assertEqual(d[r1], 123)
+        self.assertIn(r2, d)
+        self.assertEqual(d[r2], 123)
+        self.assertNotIn(r3, d)
+        self.assertIn(r4, d)
+
+    def test_record_contains(self):
+        r = Record(R_AB, (42, 43))
+        self.assertIn('a', r)
+        self.assertIn('b', r)
+        self.assertNotIn('z', r)
+
+        r = Record(None, (42, 43))
+        self.assertNotIn('a', r)
+
+        with self.assertRaises(TypeError):
+            type(r).__contains__(None, 'a')
+
+    def test_record_cmp(self):
+        AB = collections.namedtuple('AB', ('a', 'b'))
+
+        r1 = Record(R_AB, (42, 43))
+        r2 = Record(R_AB, (42, 43))
+        r3 = Record(R_AB.copy(), (42, 43))
+
+        r4 = Record(R_AB.copy(), (42, 45))
+        r5 = Record(R_ABC, (42, 46, 57))
+        r6 = Record(R_AC, (42, 43))
+
+        r7 = (42, 43)
+        r8 = [42, 43]
+
+        r9 = AB(42, 43)
+        r10 = AB(42, 44)
+
+        self.assertEqual(r1, r2)
+        self.assertEqual(r1, r3)
+        self.assertEqual(r1, r6)
+        self.assertEqual(r1, r7)
+        self.assertEqual(r1, r9)
+
+        self.assertNotEqual(r1, r4)
+        self.assertNotEqual(r1, r10)
+        self.assertNotEqual(r1, (42,))
+        self.assertNotEqual(r1, r5)
+        self.assertNotEqual(r4, r5)
+        self.assertNotEqual(r4, r6)
+        self.assertNotEqual(r6, r5)
+        self.assertNotEqual(r1, r8)
+        self.assertNotEqual(r8, r6)
+
+        self.assertLess(r1, r4)
+        self.assertGreater(r4, r1)
+
+        self.assertLess(r1, r5)
+        self.assertLess(r7, r5)
+        self.assertLess(r1, r10)
+        self.assertGreater(r5, r6)
+        self.assertGreater(r5, r7)
+        self.assertGreater(r5, r4)
+
+        with self.assertRaisesRegex(
+                TypeError, "unorderable|'<' not supported"):
+            r1 < r8
+
+        self.assertEqual(
+            sorted([r1, r2, r3, r4, r5, r6, r7]),
+            [r1, r2, r3, r6, r7, r4, r5])
+
+    def test_record_not_pickleable(self):
+        r = Record(R_A, (42,))
+        with self.assertRaises(Exception):
+            pickle.dumps(r)
+
+    def test_record_empty(self):
+        r = Record(None, ())
+        self.assertEqual(r, ())
+        self.assertLess(r, (1,))
+        self.assertEqual(len(r), 0)
+        self.assertFalse(r)
+        self.assertNotIn('a', r)
+        self.assertEqual(repr(r), '<Record>')
+        self.assertEqual(str(r), '<Record>')
+        with self.assertRaisesRegex(KeyError, 'aaa'):
+            r['aaa']
+        self.assertEqual(dict(r.items()), {})
+        self.assertEqual(list(r.keys()), [])
+        self.assertEqual(list(r.values()), [])
+
+    async def test_record_duplicate_colnames(self):
+        """Test that Record handles duplicate column names."""
+        r = await self.con.fetchrow('SELECT 1 as a, 2 as a')
+        self.assertEqual(r['a'], 2)
+        self.assertEqual(r[0], 1)
+        self.assertEqual(repr(r), '<Record a=1 a=2>')
diff --git a/tests/test_test.py b/tests/test_test.py
new file mode 100644 (file)
index 0000000..de19d30
--- /dev/null
@@ -0,0 +1,35 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import asyncio
+import types
+import unittest
+
+
+from asyncpg import _testbase as tb
+
+
+class BaseSimpleTestCase:
+
+    async def test_tests_zero_error(self):
+        await asyncio.sleep(0.01, loop=self.loop)
+        1 / 0
+
+
+class TestTests(unittest.TestCase):
+
+    def test_tests_fail_1(self):
+        SimpleTestCase = types.new_class('SimpleTestCase',
+                                         (BaseSimpleTestCase, tb.TestCase))
+
+        suite = unittest.TestSuite()
+        suite.addTest(SimpleTestCase('test_tests_zero_error'))
+
+        result = unittest.TestResult()
+        suite.run(result)
+
+        self.assertIn('ZeroDivisionError', result.errors[0][1])
diff --git a/tests/test_timeout.py b/tests/test_timeout.py
new file mode 100644 (file)
index 0000000..5b0b3ad
--- /dev/null
@@ -0,0 +1,125 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import asyncio
+import asyncpg
+
+from asyncpg import _testbase as tb
+
+
+MAX_RUNTIME = 0.5
+
+
+class TestTimeout(tb.ConnectedTestCase):
+
+    async def test_timeout_01(self):
+        for methname in {'fetch', 'fetchrow', 'fetchval', 'execute'}:
+            with self.assertRaises(asyncio.TimeoutError), \
+                    self.assertRunUnder(MAX_RUNTIME):
+                meth = getattr(self.con, methname)
+                await meth('select pg_sleep(10)', timeout=0.02)
+            self.assertEqual(await self.con.fetch('select 1'), [(1,)])
+
+    async def test_timeout_02(self):
+        st = await self.con.prepare('select pg_sleep(10)')
+
+        for methname in {'fetch', 'fetchrow', 'fetchval'}:
+            with self.assertRaises(asyncio.TimeoutError), \
+                    self.assertRunUnder(MAX_RUNTIME):
+                meth = getattr(st, methname)
+                await meth(timeout=0.02)
+            self.assertEqual(await self.con.fetch('select 1'), [(1,)])
+
+    async def test_timeout_03(self):
+        task = self.loop.create_task(
+            self.con.fetch('select pg_sleep(10)', timeout=0.2))
+        await asyncio.sleep(0.05, loop=self.loop)
+        task.cancel()
+        with self.assertRaises(asyncio.CancelledError), \
+                self.assertRunUnder(MAX_RUNTIME):
+            await task
+        self.assertEqual(await self.con.fetch('select 1'), [(1,)])
+
+    async def test_timeout_04(self):
+        st = await self.con.prepare('select pg_sleep(10)', timeout=0.1)
+        with self.assertRaises(asyncio.TimeoutError), \
+                self.assertRunUnder(MAX_RUNTIME):
+            async with self.con.transaction():
+                async for _ in st.cursor(timeout=0.1):  # NOQA
+                    pass
+        self.assertEqual(await self.con.fetch('select 1'), [(1,)])
+
+        st = await self.con.prepare('select pg_sleep(10)', timeout=0.1)
+        async with self.con.transaction():
+            cur = await st.cursor()
+            with self.assertRaises(asyncio.TimeoutError), \
+                    self.assertRunUnder(MAX_RUNTIME):
+                await cur.fetch(1, timeout=0.1)
+        self.assertEqual(await self.con.fetch('select 1'), [(1,)])
+
+    async def test_timeout_05(self):
+        # Stress-test timeouts - try to trigger a race condition
+        # between a cancellation request to Postgres and next
+        # query (SELECT 1)
+        for _ in range(500):
+            with self.assertRaises(asyncio.TimeoutError):
+                await self.con.fetch('SELECT pg_sleep(1)', timeout=1e-10)
+            self.assertEqual(await self.con.fetch('SELECT 1'), [(1,)])
+
+    async def test_timeout_06(self):
+        async with self.con.transaction():
+            with self.assertRaises(asyncio.TimeoutError), \
+                    self.assertRunUnder(MAX_RUNTIME):
+                async for _ in self.con.cursor(   # NOQA
+                        'select pg_sleep(10)', timeout=0.1):
+                    pass
+        self.assertEqual(await self.con.fetch('select 1'), [(1,)])
+
+        async with self.con.transaction():
+            cur = await self.con.cursor('select pg_sleep(10)')
+            with self.assertRaises(asyncio.TimeoutError), \
+                    self.assertRunUnder(MAX_RUNTIME):
+                await cur.fetch(1, timeout=0.1)
+
+        async with self.con.transaction():
+            cur = await self.con.cursor('select pg_sleep(10)')
+            with self.assertRaises(asyncio.TimeoutError), \
+                    self.assertRunUnder(MAX_RUNTIME):
+                await cur.forward(1, timeout=1e-10)
+
+        async with self.con.transaction():
+            cur = await self.con.cursor('select pg_sleep(10)')
+            with self.assertRaises(asyncio.TimeoutError), \
+                    self.assertRunUnder(MAX_RUNTIME):
+                await cur.fetchrow(timeout=0.1)
+
+        async with self.con.transaction():
+            cur = await self.con.cursor('select pg_sleep(10)')
+            with self.assertRaises(asyncio.TimeoutError), \
+                    self.assertRunUnder(MAX_RUNTIME):
+                await cur.fetchrow(timeout=0.1)
+
+            with self.assertRaises(asyncpg.InFailedSQLTransactionError):
+                await cur.fetch(1)
+
+        self.assertEqual(await self.con.fetch('select 1'), [(1,)])
+
+
+class TestConnectionCommandTimeout(tb.ConnectedTestCase):
+
+    def getExtraConnectOptions(self):
+        return {
+            'command_timeout': 0.02
+        }
+
+    async def test_command_timeout_01(self):
+        for methname in {'fetch', 'fetchrow', 'fetchval', 'execute'}:
+            with self.assertRaises(asyncio.TimeoutError), \
+                    self.assertRunUnder(MAX_RUNTIME):
+                meth = getattr(self.con, methname)
+                await meth('select pg_sleep(10)')
+            self.assertEqual(await self.con.fetch('select 1'), [(1,)])
diff --git a/tests/test_transaction.py b/tests/test_transaction.py
new file mode 100644 (file)
index 0000000..2f60637
--- /dev/null
@@ -0,0 +1,141 @@
+# Copyright (C) 2016-present the ayncpg authors and contributors
+# <see AUTHORS file>
+#
+# This module is part of asyncpg and is released under
+# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
+
+
+import asyncpg
+
+from asyncpg import _testbase as tb
+
+
+class TestTransaction(tb.ConnectedTestCase):
+
+    async def test_transaction_regular(self):
+        self.assertIsNone(self.con._top_xact)
+        tr = self.con.transaction()
+        self.assertIsNone(self.con._top_xact)
+
+        with self.assertRaises(ZeroDivisionError):
+            async with tr as with_tr:
+                self.assertIs(self.con._top_xact, tr)
+
+                # We don't return the transaction object from __aenter__,
+                # to make it harder for people to use '.rollback()' and
+                # '.commit()' from within an 'async with' block.
+                self.assertIsNone(with_tr)
+
+                await self.con.execute('''
+                    CREATE TABLE mytab (a int);
+                ''')
+
+                1 / 0
+
+        self.assertIsNone(self.con._top_xact)
+
+        with self.assertRaisesRegex(asyncpg.PostgresError,
+                                    '"mytab" does not exist'):
+            await self.con.prepare('''
+                SELECT * FROM mytab
+            ''')
+
+    async def test_transaction_nested(self):
+        self.assertIsNone(self.con._top_xact)
+        tr = self.con.transaction()
+        self.assertIsNone(self.con._top_xact)
+
+        with self.assertRaises(ZeroDivisionError):
+            async with tr:
+                self.assertIs(self.con._top_xact, tr)
+
+                await self.con.execute('''
+                    CREATE TABLE mytab (a int);
+                ''')
+
+                async with self.con.transaction():
+                    self.assertIs(self.con._top_xact, tr)
+
+                    await self.con.execute('''
+                        INSERT INTO mytab (a) VALUES (1), (2);
+                    ''')
+
+                self.assertIs(self.con._top_xact, tr)
+
+                with self.assertRaises(ZeroDivisionError):
+                    in_tr = self.con.transaction()
+                    async with in_tr:
+
+                        self.assertIs(self.con._top_xact, tr)
+
+                        await self.con.execute('''
+                            INSERT INTO mytab (a) VALUES (3), (4);
+                        ''')
+
+                        1 / 0
+
+                st = await self.con.prepare('SELECT * FROM mytab;')
+
+                recs = []
+                async for rec in st.cursor():
+                    recs.append(rec)
+
+                self.assertEqual(len(recs), 2)
+                self.assertEqual(recs[0][0], 1)
+                self.assertEqual(recs[1][0], 2)
+
+                self.assertIs(self.con._top_xact, tr)
+
+                1 / 0
+
+        self.assertIs(self.con._top_xact, None)
+
+        with self.assertRaisesRegex(asyncpg.PostgresError,
+                                    '"mytab" does not exist'):
+            await self.con.prepare('''
+                SELECT * FROM mytab
+            ''')
+
+    async def test_transaction_interface_errors(self):
+        self.assertIsNone(self.con._top_xact)
+
+        tr = self.con.transaction(readonly=True, isolation='serializable')
+        with self.assertRaisesRegex(asyncpg.InterfaceError,
+                                    'cannot start; .* already started'):
+            async with tr:
+                await tr.start()
+
+        self.assertTrue(repr(tr).startswith(
+            '<asyncpg.Transaction state:rolledback serializable readonly'))
+
+        self.assertIsNone(self.con._top_xact)
+
+        with self.assertRaisesRegex(asyncpg.InterfaceError,
+                                    'cannot start; .* already rolled back'):
+            async with tr:
+                pass
+
+        self.assertIsNone(self.con._top_xact)
+
+        tr = self.con.transaction()
+        with self.assertRaisesRegex(asyncpg.InterfaceError,
+                                    'cannot manually commit.*async with'):
+            async with tr:
+                await tr.commit()
+
+        self.assertIsNone(self.con._top_xact)
+
+        tr = self.con.transaction()
+        with self.assertRaisesRegex(asyncpg.InterfaceError,
+                                    'cannot manually rollback.*async with'):
+            async with tr:
+                await tr.rollback()
+
+        self.assertIsNone(self.con._top_xact)
+
+        tr = self.con.transaction()
+        with self.assertRaisesRegex(asyncpg.InterfaceError,
+                                    'cannot enter context:.*async with'):
+            async with tr:
+                async with tr:
+                    pass