/* Generated by Cython 0.27.3 */

/* BEGIN: Cython Metadata
{
    "distutils": {
        "depends": [
            "asyncpg/protocol/debug.h"
        ],
        "extra_compile_args": [
            "-O2",
            "-fsigned-char",
            "-Wall",
            "-Wsign-compare",
            "-Wconversion"
        ],
        "include_dirs": [
            "./asyncpg/protocol"
        ],
        "name": "asyncpg.protocol.protocol",
        "sources": [
            "asyncpg/protocol/protocol.pyx",
            "asyncpg/protocol/record/recordobj.c"
        ]
    },
    "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 < 0x03030000)
    #error Cython requires Python 2.6+ or Python 3.3+.
#else
#define CYTHON_ABI "0_27_3"
#define CYTHON_FUTURE_DIVISION 1
#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
#define __PYX_COMMA ,
#ifndef HAVE_LONG_LONG
  #if 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_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #if PY_VERSION_HEX < 0x03050000
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #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
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 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_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #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
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 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_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYTYPE_LOOKUP
    #define CYTHON_USE_PYTYPE_LOOKUP 0
  #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
    #define CYTHON_USE_PYTYPE_LOOKUP 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
  #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
    #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000)
  #endif
  #ifndef CYTHON_USE_TP_FINALIZE
    #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
  #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
#if PY_VERSION_HEX < 0x030700A0 || !defined(METH_FASTCALL)
  #ifndef METH_FASTCALL
     #define METH_FASTCALL 0x80
  #endif
  typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args, Py_ssize_t nargs);
  typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject **args,
                                                          Py_ssize_t nargs, PyObject *kwnames);
#else
  #define __Pyx_PyCFunctionFast _PyCFunctionFast
  #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
#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 | METH_KEYWORDS)))))
#else
#define __Pyx_PyFastCFunction_Check(func) 0
#endif
#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#elif PY_VERSION_HEX >= 0x03060000
  #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
#elif PY_VERSION_HEX >= 0x03000000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#else
  #define __Pyx_PyThreadState_Current _PyThreadState_Current
#endif
#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
#define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
#else
#define __Pyx_PyDict_NewPresized(n)  PyDict_New()
#endif
#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
  #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_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#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_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
#ifndef __has_attribute
  #define __has_attribute(x) 0
#endif
#ifndef __has_cpp_attribute
  #define __has_cpp_attribute(x) 0
#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
    #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  #endif
#else
  #define __Pyx_PyType_AsAsync(obj) NULL
#endif
#ifndef __Pyx_PyAsyncMethodsStruct
    typedef struct {
        unaryfunc am_await;
        unaryfunc am_aiter;
        unaryfunc am_anext;
    } __Pyx_PyAsyncMethodsStruct;
#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)
#ifdef _MSC_VER
    #ifndef _MSC_STDINT_H_
        #if _MSC_VER < 1300
           typedef unsigned char     uint8_t;
           typedef unsigned int      uint32_t;
        #else
           typedef unsigned __int8   uint8_t;
           typedef unsigned __int32  uint32_t;
        #endif
    #endif
#else
   #include <stdint.h>
#endif
#ifndef CYTHON_FALLTHROUGH
  #if defined(__cplusplus) && __cplusplus >= 201103L
    #if __has_cpp_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH [[fallthrough]]
    #elif __has_cpp_attribute(clang::fallthrough)
      #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
    #elif __has_cpp_attribute(gnu::fallthrough)
      #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
    #endif
  #endif
  #ifndef CYTHON_FALLTHROUGH
    #if __has_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
    #else
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
  #if defined(__clang__ ) && defined(__apple_build_version__)
    #if __apple_build_version__ < 7000000
      #undef  CYTHON_FALLTHROUGH
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
#endif

#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; \
}

#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 "hton.h"
#include <math.h>
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_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)
    #define __Pyx_sst_abs(value) ((Py_ssize_t)_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 const char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE const 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_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((const 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)
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);
}
#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);
#define __Pyx_PySequence_Tuple(obj)\
    (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
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 CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }

static PyObject *__pyx_m = NULL;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_cython_runtime;
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/protocol.pyx",
  "asyncpg/protocol/settings.pyx",
  "stringsource",
  "asyncpg/protocol/buffer.pyx",
  "asyncpg/protocol/codecs/base.pyx",
  "asyncpg/protocol/codecs/int.pyx",
  "asyncpg/protocol/codecs/array.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/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.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_copy_out;
struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in;
struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement;
struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close;
struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation;
struct __pyx_opt_args_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_data_codec;
struct __pyx_opt_args_7asyncpg_8protocol_8protocol_get_core_codec;
struct __pyx_opt_args_7asyncpg_8protocol_8protocol_get_any_core_codec;
struct __pyx_opt_args_7asyncpg_8protocol_8protocol_register_core_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 ServerDataFormat:             # <<<<<<<<<<<<<<
 *     PG_FORMAT_ANY = -1
 *     PG_FORMAT_TEXT = 0
 */
enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat {
  __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/codecs/base.pxd":40
 * 
 * 
 * cdef enum ClientExchangeFormat:             # <<<<<<<<<<<<<<
 *     PG_XFORMAT_OBJECT = 1
 *     PG_XFORMAT_TUPLE = 2
 */
enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat {
  __pyx_e_7asyncpg_8protocol_8protocol_PG_XFORMAT_OBJECT = 1,
  __pyx_e_7asyncpg_8protocol_8protocol_PG_XFORMAT_TUPLE = 2
};

/* "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_CANCELLED = 3,
  __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,
  __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_COPY_OUT = 18,
  __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_COPY_OUT_DATA = 19,
  __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_COPY_OUT_DONE = 20,
  __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_COPY_IN = 21,
  __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_COPY_IN_DATA = 22
};

/* "asyncpg/protocol/coreproto.pxd":36
 * 
 * 
 * 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":56
 * 
 * 
 * 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":61
 * 
 * 
 * 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":28
 *     cpdef inline set_builtin_type_codec(
 *         self, typeoid, typename, typeschema, typekind, alias_to)
 *     cpdef inline Codec get_data_codec(self, uint32_t oid, ServerDataFormat format=*)             # <<<<<<<<<<<<<<
 */
struct __pyx_opt_args_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_data_codec {
  int __pyx_n;
  enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat format;
};

/* "asyncpg/protocol/coreproto.pxd":69
 * 
 * 
 * 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":648
 * 
 * 
 * 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/base.pyx":649
 * 
 * 
 * cdef inline Codec get_core_codec(             # <<<<<<<<<<<<<<
 *         uint32_t oid, ServerDataFormat format,
 *         ClientExchangeFormat xformat=PG_XFORMAT_OBJECT):
 */
struct __pyx_opt_args_7asyncpg_8protocol_8protocol_get_core_codec {
  int __pyx_n;
  enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat xformat;
};

/* "asyncpg/protocol/codecs/base.pyx":668
 * 
 * 
 * cdef inline Codec get_any_core_codec(             # <<<<<<<<<<<<<<
 *         uint32_t oid, ServerDataFormat format,
 *         ClientExchangeFormat xformat=PG_XFORMAT_OBJECT):
 */
struct __pyx_opt_args_7asyncpg_8protocol_8protocol_get_any_core_codec {
  int __pyx_n;
  enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat xformat;
};

/* "asyncpg/protocol/codecs/base.pyx":689
 * 
 * 
 * cdef register_core_codec(uint32_t oid,             # <<<<<<<<<<<<<<
 *                          encode_func encode,
 *                          decode_func decode,
 */
struct __pyx_opt_args_7asyncpg_8protocol_8protocol_register_core_codec {
  int __pyx_n;
  enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat xformat;
};

/* "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:
 *         const char *buf
 */
struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory {
  PyObject_HEAD
  struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_Memory *__pyx_vtab;
  char const *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":122
 * 
 * 
 * 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":45
 * 
 * 
 * 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_ServerDataFormat format;
  enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat xformat;
  __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":168
 * 
 * 
 * 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":72
 * 
 * 
 * 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_params;
  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;
  int is_reading;
  PyObject *last_query;
  int writing_paused;
  int closing;
  uint64_t queries_count;
  struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *statement;
};


/* "asyncpg/protocol/protocol.pyx":149
 *             self.transport.pause_reading()
 * 
 *     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_ex;
  PyObject *__pyx_v_query;
  struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self;
  PyObject *__pyx_v_stmt_name;
  PyObject *__pyx_v_timeout;
  PyObject *__pyx_v_waiter;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
};


/* "asyncpg/protocol/protocol.pyx":170
 *             return await waiter
 * 
 *     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;
  PyObject *__pyx_v_args_buf;
  PyObject *__pyx_v_ex;
  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;
  PyObject *__pyx_v_waiter;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
};


/* "asyncpg/protocol/protocol.pyx":202
 *             return await waiter
 * 
 *     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_ex;
  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;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
};


/* "asyncpg/protocol/protocol.pyx":217
 *         # 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":237
 *             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_args_buf;
  PyObject *__pyx_v_ex;
  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;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
};


/* "asyncpg/protocol/protocol.pyx":265
 *             return await waiter
 * 
 *     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
  PyObject *__pyx_v_ex;
  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;
  PyObject *__pyx_v_waiter;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
};


/* "asyncpg/protocol/protocol.pyx":294
 *             return await waiter
 * 
 *     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_ex;
  PyObject *__pyx_v_query;
  struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self;
  PyObject *__pyx_v_timeout;
  PyObject *__pyx_v_waiter;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
};


/* "asyncpg/protocol/protocol.pyx":318
 *             return await waiter
 * 
 *     async def copy_out(self, copy_stmt, sink, timeout):             # <<<<<<<<<<<<<<
 *         if self.cancel_waiter is not None:
 *             await self.cancel_waiter
 */
struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out {
  PyObject_HEAD
  PyObject *__pyx_v_buffer;
  PyObject *__pyx_v_copy_stmt;
  PyObject *__pyx_v_done;
  PyObject *__pyx_v_ex;
  struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self;
  PyObject *__pyx_v_sink;
  PyObject *__pyx_v_status_msg;
  PyObject *__pyx_v_timeout;
  PyObject *__pyx_v_timer;
  PyObject *__pyx_v_waiter;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *__pyx_t_6;
};


/* "asyncpg/protocol/protocol.pyx":372
 *         return status_msg
 * 
 *     async def copy_in(self, copy_stmt, reader, data,             # <<<<<<<<<<<<<<
 *                       records, PreparedStatementState record_stmt, timeout):
 *         cdef:
 */
struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in {
  PyObject_HEAD
  PyObject *__pyx_v_aiter;
  PyObject *__pyx_v_chunk;
  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_codec;
  PyObject *__pyx_v_codecs;
  PyObject *__pyx_v_copy_stmt;
  PyObject *__pyx_v_data;
  PyObject *__pyx_v_e;
  Py_ssize_t __pyx_v_i;
  PyObject *__pyx_v_item;
  PyObject *__pyx_v_iterator;
  Py_ssize_t __pyx_v_num_cols;
  PyObject *__pyx_v_reader;
  struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_record_stmt;
  PyObject *__pyx_v_records;
  PyObject *__pyx_v_row;
  struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self;
  struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings;
  PyObject *__pyx_v_status_msg;
  PyObject *__pyx_v_timeout;
  PyObject *__pyx_v_timer;
  PyObject *__pyx_v_waiter;
  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_wbuf;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6;
  PyObject *__pyx_t_7;
  PyObject *__pyx_t_8;
  PyObject *__pyx_t_9;
  PyObject *__pyx_t_10;
  PyObject *__pyx_t_11;
};


/* "asyncpg/protocol/protocol.pyx":490
 *         return status_msg
 * 
 *     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_9_close_statement {
  PyObject_HEAD
  PyObject *__pyx_v_ex;
  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;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
};


/* "asyncpg/protocol/protocol.pyx":529
 *         self.transport.abort()
 * 
 *     async def close(self, timeout):             # <<<<<<<<<<<<<<
 *         if self.closing:
 *             return
 */
struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close {
  PyObject_HEAD
  struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self;
  PyObject *__pyx_v_timeout;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
};


/* "asyncpg/protocol/protocol.pyx":650
 *         )
 * 
 *     async def _wait_for_cancellation(self):             # <<<<<<<<<<<<<<
 *         if self.cancel_sent_waiter is not None:
 *             await self.cancel_sent_waiter
 */
struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation {
  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 const *, 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 const *, 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 const *, 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 const *, 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 const *(*_try_read_bytes)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *, Py_ssize_t);
  PyObject *(*_read)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *, char *, Py_ssize_t);
  PyObject *(*read)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *, Py_ssize_t);
  char const *(*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 *);
  int32_t (*has_message_type)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *, char);
  char const *(*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 *(*consume_messages)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *, char);
  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 const *__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 *, char *, Py_ssize_t);
static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *, Py_ssize_t);
static CYTHON_INLINE char const *__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 int32_t __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_has_message_type(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *, char);
static CYTHON_INLINE char const *__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_consume_messages(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *, char);
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":632
 * @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":18
 * 
 * @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_ServerDataFormat, enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat, __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_array_text)(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 *, enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat, PyObject *, PyObject *, PyObject *);
  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *(*new_python_codec)(uint32_t, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, __pyx_t_7asyncpg_8protocol_8protocol_encode_func, __pyx_t_7asyncpg_8protocol_8protocol_decode_func, enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat, enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat);
};
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_ServerDataFormat, enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat, __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_array_text(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 *, enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat, 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 *, __pyx_t_7asyncpg_8protocol_8protocol_encode_func, __pyx_t_7asyncpg_8protocol_8protocol_decode_func, enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat, enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat);


/* "asyncpg/protocol/codecs/base.pyx":376
 * 
 * 
 * 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_ServerDataFormat);
  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *(*get_local_codec)(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *, uint32_t);
};
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_ServerDataFormat);
static CYTHON_INLINE struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_15DataCodecConfig_get_local_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *, uint32_t);


/* "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 *(*remove_python_codec)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*clear_type_cache)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, 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_remove_python_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch);
static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_clear_type_cache(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, 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_params):
 */

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 *(*_process__copy_out)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, char);
  PyObject *(*_process__copy_out_data)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, char);
  PyObject *(*_process__copy_in)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, char);
  PyObject *(*_process__copy_in_data)(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_copy_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 *(*_write_copy_data_msg)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *);
  PyObject *(*_write_copy_done_msg)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *);
  PyObject *(*_write_copy_fail_msg)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *);
  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 *(*_copy_out)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *);
  PyObject *(*_copy_in)(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 *(*_on_notice)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, 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":12
 * 
 * @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":91
 * 
 * 
 * cdef class BaseProtocol(CoreProtocol):             # <<<<<<<<<<<<<<
 *     def __init__(self, addr, connected_fut, con_params, loop):
 *         # type of `con_params` is `_ConnectionParameters`
 */

struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol {
  struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol __pyx_base;
  PyObject *(*_get_timeout_impl)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *, PyObject *);
  PyObject *(*_check_state)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *);
  PyObject *(*_new_waiter)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *, PyObject *);
  PyObject *(*_coreproto_error)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *);
  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 *(*_on_result__copy_out)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *, PyObject *);
  PyObject *(*_on_result__copy_in)(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 *);
  PyObject *(*resume_reading)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *);
  PyObject *(*pause_reading)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *);
};
static struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_vtabptr_7asyncpg_8protocol_8protocol_BaseProtocol;
static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__get_timeout_impl(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *, PyObject *);
static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol_resume_reading(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *);
static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol_pause_reading(struct __pyx_obj_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);

/* PyThreadStateGet.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
#define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
#define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#define __Pyx_PyErr_Occurred()  PyErr_Occurred()
#endif

/* PyErrFetchRestore.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
#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);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
#else
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#endif
#else
#define __Pyx_PyErr_Clear() PyErr_Clear()
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchInState(tstate, 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);

/* 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

/* 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

/* ExtTypeTest.proto */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);

/* GetAttr.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);

/* GetAttr3.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);

/* KeywordStringCheck.proto */
static 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 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

/* py_dict_clear.proto */
#define __Pyx_PyDict_Clear(d) (PyDict_Clear(d), 0)

/* ArgTypeTest.proto */
#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
    ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
        __Pyx__ArgTypeTest(obj, type, name, exact))
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);

/* 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);

/* None.proto */
static CYTHON_INLINE long __Pyx_div_long(long, long);

/* None.proto */
static CYTHON_INLINE long __Pyx_mod_long(long, long);

/* None.proto */
static CYTHON_INLINE int64_t __Pyx_div_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

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_SubtractObjC(op1, op2, intval, inplace)\
    (inplace ? PyNumber_InPlaceSubtract(op1, op2) : PyNumber_Subtract(op1, op2))
#endif

/* HasAttr.proto */
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);

/* 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_string_utf16.proto */
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
    int byteorder = 0;
    return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
    int byteorder = -1;
    return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
    int byteorder = 1;
    return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}

/* 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 */
#define __Pyx_unpack_tuple2(tuple, value1, value2, is_tuple, has_known_size, decref_tuple)\
    (likely(is_tuple || PyTuple_Check(tuple)) ?\
        (likely(has_known_size || PyTuple_GET_SIZE(tuple) == 2) ?\
            __Pyx_unpack_tuple2_exact(tuple, value1, value2, decref_tuple) :\
            (__Pyx_UnpackTupleError(tuple, 2), -1)) :\
        __Pyx_unpack_tuple2_generic(tuple, value1, value2, has_known_size, decref_tuple))
static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
    PyObject* tuple, PyObject** value1, PyObject** value2, int decref_tuple);
static int __Pyx_unpack_tuple2_generic(
    PyObject* tuple, PyObject** value1, PyObject** value2, 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);

/* 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));
}

/* FetchCommonType.proto */
static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);

/* PyObjectCallMethod1.proto */
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);
static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg);

/* CoroutineBase.proto */
typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyThreadState *, 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 __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
            __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name);
static int __Pyx_Coroutine_clear(PyObject *self);
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_SwapException(self) {\
    __Pyx_ExceptionSwap(&(self)->exc_type, &(self)->exc_value, &(self)->exc_traceback);\
    __Pyx_Coroutine_ResetFrameBackpointer(self);\
    }
#define __Pyx_Coroutine_ResetAndClearException(self) {\
    __Pyx_ExceptionReset((self)->exc_type, (self)->exc_value, (self)->exc_traceback);\
    (self)->exc_type = (self)->exc_value = (self)->exc_traceback = NULL;\
    }
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
    __Pyx_PyGen__FetchStopIterationValue(__pyx_tstate, pvalue)
#else
#define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
    __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue)
#endif
static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue);
static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__pyx_CoroutineObject *self);

/* 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_CoroutineAwait_CheckExact(obj) (Py_TYPE(obj) == __pyx_CoroutineAwaitType)
#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);
typedef struct {
    PyObject_HEAD
    PyObject *coroutine;
} __pyx_CoroutineAwaitObject;
static PyObject *__Pyx_CoroutineAwait_Close(__pyx_CoroutineAwaitObject *self);
static PyObject *__Pyx_CoroutineAwait_Throw(__pyx_CoroutineAwaitObject *self, PyObject *args);

/* GetAwaitIter.proto */
static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAwaitableIter(PyObject *o);
static PyObject *__Pyx__Coroutine_GetAwaitableIter(PyObject *o);

/* CoroutineYieldFrom.proto */
static CYTHON_INLINE PyObject* __Pyx_Coroutine_Yield_From(__pyx_CoroutineObject *gen, PyObject *source);

/* 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);

/* PyObjectLookupSpecial.proto */
#if CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name) {
    PyObject *res;
    PyTypeObject *tp = Py_TYPE(obj);
#if PY_MAJOR_VERSION < 3
    if (unlikely(PyInstance_Check(obj)))
        return __Pyx_PyObject_GetAttrStr(obj, attr_name);
#endif
    res = _PyType_Lookup(tp, attr_name);
    if (likely(res)) {
        descrgetfunc f = Py_TYPE(res)->tp_descr_get;
        if (!f) {
            Py_INCREF(res);
        } else {
            res = f(res, obj, (PyObject *)tp);
        }
    } else {
        PyErr_SetObject(PyExc_AttributeError, attr_name);
    }
    return res;
}
#else
#define __Pyx_PyObject_LookupSpecial(o,n) __Pyx_PyObject_GetAttrStr(o,n)
#endif

/* CythonFunction.proto */
#define __Pyx_CyFunction_USED 1
#include <structmember.h>
#define __Pyx_CYFUNCTION_STATICMETHOD  0x01
#define __Pyx_CYFUNCTION_CLASSMETHOD   0x02
#define __Pyx_CYFUNCTION_CCLASS        0x04
#define __Pyx_CyFunction_GetClosure(f)\
    (((__pyx_CyFunctionObject *) (f))->func_closure)
#define __Pyx_CyFunction_GetClassObj(f)\
    (((__pyx_CyFunctionObject *) (f))->func_classobj)
#define __Pyx_CyFunction_Defaults(type, f)\
    ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
    ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
typedef struct {
    PyCFunctionObject func;
#if PY_VERSION_HEX < 0x030500A0
    PyObject *func_weakreflist;
#endif
    PyObject *func_dict;
    PyObject *func_name;
    PyObject *func_qualname;
    PyObject *func_doc;
    PyObject *func_globals;
    PyObject *func_code;
    PyObject *func_closure;
    PyObject *func_classobj;
    void *defaults;
    int defaults_pyobjects;
    int flags;
    PyObject *defaults_tuple;
    PyObject *defaults_kwdict;
    PyObject *(*defaults_getter)(PyObject *);
    PyObject *func_annotations;
} __pyx_CyFunctionObject;
static PyTypeObject *__pyx_CyFunctionType = 0;
#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\
    __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
                                      int flags, PyObject* qualname,
                                      PyObject *self,
                                      PyObject *module, PyObject *globals,
                                      PyObject* code);
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
                                                         size_t size,
                                                         int pyobjects);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
                                                            PyObject *tuple);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
                                                             PyObject *dict);
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
                                                              PyObject *dict);
static int __pyx_CyFunction_init(void);

/* Import.proto */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);

/* ImportFrom.proto */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);

/* SetVTable.proto */
static int __Pyx_SetVtable(PyObject *dict, void *vtable);

/* SetupReduce.proto */
static int __Pyx_setup_reduce(PyObject* type_obj);

/* PatchInspect.proto */
static PyObject* __Pyx_patch_inspect(PyObject* module);

/* PatchAsyncIO.proto */
static PyObject* __Pyx_patch_asyncio(PyObject* module);

/* 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);

/* CLineInTraceback.proto */
#ifdef CYTHON_CLINE_IN_TRACEBACK
#define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
#else
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
#endif

/* 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_int32_t(int32_t value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ResultType(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType 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_enum____pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint64_t(uint64_t value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat 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_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_int64_t(int64_t value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_PY_LONG_LONG(PY_LONG_LONG value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint8_t(uint8_t value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint16_t(uint16_t value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_ptrdiff_t(ptrdiff_t value);

/* CIntFromPy.proto */
static CYTHON_INLINE int32_t __Pyx_PyInt_As_int32_t(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus __Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType __Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ResultType(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState __Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ProtocolState(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus __Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE uint64_t __Pyx_PyInt_As_uint64_t(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE uint32_t __Pyx_PyInt_As_uint32_t(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat __Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(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 long __Pyx_PyInt_As_long(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat __Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE int8_t __Pyx_PyInt_As_int8_t(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE int16_t __Pyx_PyInt_As_int16_t(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE char __Pyx_PyInt_As_char(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*);

/* FastTypeChecks.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
#else
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
#endif

/* 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_format, CYTHON_UNUSED int __pyx_skip_dispatch); /* proto*/
static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_remove_python_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, PyObject *__pyx_v_typeoid, PyObject *__pyx_v_typename, PyObject *__pyx_v_typeschema, CYTHON_UNUSED int __pyx_skip_dispatch); /* proto*/
static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_clear_type_cache(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_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 const *__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 const *__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 const *__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, char *__pyx_v_buf, Py_ssize_t __pyx_v_nbytes); /* proto*/
static 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 char const *__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 int32_t __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_has_message_type(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self, char __pyx_v_mtype); /* proto*/
static CYTHON_INLINE char const *__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_consume_messages(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self, char __pyx_v_mtype); /* 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_ServerDataFormat __pyx_v_format, enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat __pyx_v_xformat, __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_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_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, enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat __pyx_v_format, 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, __pyx_t_7asyncpg_8protocol_8protocol_encode_func __pyx_v_c_encoder, __pyx_t_7asyncpg_8protocol_8protocol_decode_func __pyx_v_c_decoder, enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat __pyx_v_format, enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat __pyx_v_xformat); /* 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_ServerDataFormat __pyx_v_format); /* proto*/
static CYTHON_INLINE struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_15DataCodecConfig_get_local_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *__pyx_v_self, uint32_t __pyx_v_oid); /* 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__process__copy_out(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, char __pyx_v_mtype); /* proto*/
static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__copy_out_data(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, char __pyx_v_mtype); /* proto*/
static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__copy_in(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, char __pyx_v_mtype); /* proto*/
static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__copy_in_data(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_copy_data_msgs(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self); /* proto*/
static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__write_copy_data_msg(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_data); /* proto*/
static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__write_copy_done_msg(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self); /* proto*/
static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__write_copy_fail_msg(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_cause); /* 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__copy_out(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_copy_stmt); /* proto*/
static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__copy_in(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_copy_stmt); /* 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_notice(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_parsed); /* 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 CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol_resume_reading(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self); /* proto*/
static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol_pause_reading(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self); /* 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__get_timeout_impl(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_timeout); /* proto*/
static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__check_state(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self); /* proto*/
static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__coreproto_error(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__on_result__copy_out(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__copy_in(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_notice(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_parsed); /* 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' */

/* 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_copy_out = 0;
static PyTypeObject *__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in = 0;
static PyTypeObject *__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement = 0;
static PyTypeObject *__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close = 0;
static PyTypeObject *__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation = 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) * 2)];
static void *__pyx_v_7asyncpg_8protocol_8protocol_text_codec_map[((0x1000 + 1) * 2)];
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_ServerDataFormat, struct __pyx_opt_args_7asyncpg_8protocol_8protocol_get_core_codec *__pyx_optional_args); /*proto*/
static CYTHON_INLINE struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_get_any_core_codec(uint32_t, enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat, struct __pyx_opt_args_7asyncpg_8protocol_8protocol_get_any_core_codec *__pyx_optional_args); /*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_ServerDataFormat, struct __pyx_opt_args_7asyncpg_8protocol_8protocol_register_core_codec *__pyx_optional_args); /*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_ServerDataFormat); /*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_ServerDataFormat); /*proto*/
static CYTHON_INLINE uint32_t __pyx_f_7asyncpg_8protocol_8protocol__apg_tolower(uint32_t); /*proto*/
static int __pyx_f_7asyncpg_8protocol_8protocol_apg_strcasecmp(Py_UCS4 const *, Py_UCS4 const *); /*proto*/
static int __pyx_f_7asyncpg_8protocol_8protocol_apg_strcasecmp_char(char const *, char 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_encode_tuple(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_date_decode_tuple(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_encode_tuple(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_timestamp_decode_tuple(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_encode_tuple(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_time_decode_tuple(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_encode_tuple(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_timetz_decode_tuple(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_encode_tuple(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_interval_decode_tuple(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 uint8_t __pyx_f_7asyncpg_8protocol_8protocol__ip_max_prefix_len(int32_t); /*proto*/
static CYTHON_INLINE int32_t __pyx_f_7asyncpg_8protocol_8protocol__ip_addr_len(int32_t); /*proto*/
static CYTHON_INLINE int8_t __pyx_f_7asyncpg_8protocol_8protocol__ver_to_family(int32_t); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol__net_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, int8_t, uint32_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_text(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_text(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_numeric_encode_binary(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_binary(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *); /*proto*/
static CYTHON_INLINE char *__pyx_f_7asyncpg_8protocol_8protocol__unpack_digit_stripping_lzeros(char *, int64_t); /*proto*/
static CYTHON_INLINE char *__pyx_f_7asyncpg_8protocol_8protocol__unpack_digit(char *, int64_t); /*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 PyObject *__pyx_f_7asyncpg_8protocol_8protocol__write_textarray_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 *, Py_UCS4); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_textarray_encode(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *, PyObject *, __pyx_t_7asyncpg_8protocol_8protocol_encode_func_ex, void const *, Py_UCS4); /*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 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*/
static PyObject *__pyx_f_7asyncpg_8protocol_8protocol___pyx_unpickle_Memory__set_state(struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *, PyObject *); /*proto*/
static PyObject *__pyx_f_7asyncpg_8protocol_8protocol___pyx_unpickle_FastReadBuffer__set_state(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *, PyObject *); /*proto*/
static PyObject *__pyx_f_7asyncpg_8protocol_8protocol___pyx_unpickle_DataCodecConfig__set_state(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *, PyObject *); /*proto*/
static PyObject *__pyx_f_7asyncpg_8protocol_8protocol___pyx_unpickle_CoreProtocol__set_state(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *); /*proto*/
static PyObject *__pyx_f_7asyncpg_8protocol_8protocol___pyx_unpickle_BaseProtocol__set_state(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *, PyObject *); /*proto*/
#define __Pyx_MODULE_NAME "asyncpg.protocol.protocol"
extern int __pyx_module_is_main_asyncpg__protocol__protocol;
int __pyx_module_is_main_asyncpg__protocol__protocol = 0;

/* Implementation of 'asyncpg.protocol.protocol' */
static PyObject *__pyx_builtin_object;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_KeyError;
static PyObject *__pyx_builtin_AttributeError;
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_RuntimeError;
static PyObject *__pyx_builtin_MemoryError;
static PyObject *__pyx_builtin_chr;
static PyObject *__pyx_builtin_print;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_enumerate;
static PyObject *__pyx_builtin_NotImplementedError;
static PyObject *__pyx_builtin_OverflowError;
static PyObject *__pyx_builtin_reversed;
static PyObject *__pyx_builtin_memoryview;
static PyObject *__pyx_builtin_StopIteration;
static PyObject *__pyx_builtin_TimeoutError;
static PyObject *__pyx_builtin_ConnectionResetError;
static const char __pyx_k_F[] = "F";
static const char __pyx_k_N[] = "N";
static const char __pyx_k_c[] = "c";
static const char __pyx_k_d[] = "d";
static const char __pyx_k_e[] = "e";
static const char __pyx_k_i[] = "i";
static const char __pyx_k_n[] = "n";
static const char __pyx_k_r[] = "r";
static const char __pyx_k_s[] = "s";
static const char __pyx_k_w[] = "w";
static const char __pyx_k_x[] = "x";
static const char __pyx_k_y[] = "y";
static const char __pyx_k_NA[] = "NA";
static const char __pyx_k__3[] = "_";
static const char __pyx_k_et[] = "et";
static const char __pyx_k_ns[] = "ns";
static const char __pyx_k_tb[] = "tb";
static const char __pyx_k_Box[] = "Box";
static const char __pyx_k_Dec[] = "_Dec";
static const char __pyx_k_NaN[] = "NaN";
static const char __pyx_k__22[] = "";
static const char __pyx_k__23[] = "\000";
static const char __pyx_k__36[] = "{}[]";
static const char __pyx_k__64[] = "\"\"";
static const char __pyx_k__87[] = "'{}'";
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_pop[] = "pop";
static const char __pyx_k_rec[] = "rec";
static const char __pyx_k_set[] = "set";
static const char __pyx_k_tid[] = "tid";
static const char __pyx_k_utc[] = "utc";
static const char __pyx_k_was[] = "was";
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_NULL[] = "NULL";
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_data[] = "data";
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_dict[] = "__dict__";
static const char __pyx_k_done[] = "done";
static const char __pyx_k_elem[] = "elem";
static const char __pyx_k_exit[] = "__exit__";
static const char __pyx_k_find[] = "find";
static const char __pyx_k_hint[] = "hint";
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_self[] = "self";
static const char __pyx_k_send[] = "send";
static const char __pyx_k_sign[] = "sign";
static const char __pyx_k_sink[] = "sink";
static const char __pyx_k_sjis[] = "sjis";
static const char __pyx_k_smgr[] = "smgr";
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_wait[] = "wait";
static const char __pyx_k_were[] = "were";
static const char __pyx_k_Event[] = "Event";
static const char __pyx_k_Point[] = "Point";
static const char __pyx_k_Range[] = "Range";
static const char __pyx_k_Timer[] = "Timer";
static const char __pyx_k_abort[] = "abort";
static const char __pyx_k_aiter[] = "__aiter__";
static const char __pyx_k_anext[] = "__anext__";
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_clear[] = "clear";
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_enter[] = "__enter__";
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_new_2[] = "__new__";
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_tuple[] = "tuple";
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_NULL_2[] = "\"NULL\"";
static const char __pyx_k_PGCOPY[] = "PGCOPY\n\377\r\n\000";
static const char __pyx_k_Record[] = "Record";
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_budget[] = "budget";
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_compat[] = "compat";
static const char __pyx_k_config[] = "_config";
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_digits[] = "digits";
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_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_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_pickle[] = "pickle";
static const char __pyx_k_reader[] = "reader";
static const char __pyx_k_record[] = "record";
static const char __pyx_k_reduce[] = "__reduce__";
static const char __pyx_k_scalar[] = "scalar";
static const char __pyx_k_schema[] = "schema";
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_update[] = "update";
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_copy_in[] = "copy_in";
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_records[] = "records";
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_release[] = "release";
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_started[] = "_started";
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_xformat[] = "xformat";
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_as_tuple[] = "as_tuple";
static const char __pyx_k_auth_msg[] = "auth_msg";
static const char __pyx_k_basetype[] = "basetype";
static const char __pyx_k_budget_2[] = "_budget";
static const char __pyx_k_builtins[] = "builtins";
static const char __pyx_k_conn_key[] = "conn_key";
static const char __pyx_k_copy_out[] = "copy_out";
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_exponent[] = "exponent";
static const char __pyx_k_getstate[] = "__getstate__";
static const char __pyx_k_internal[] = "internal";
static const char __pyx_k_interval[] = "interval";
static const char __pyx_k_macaddr8[] = "macaddr8";
static const char __pyx_k_on_error[] = "_on_error";
static const char __pyx_k_password[] = "password";
static const char __pyx_k_position[] = "position";
static const char __pyx_k_protocol[] = "protocol";
static const char __pyx_k_pyx_capi[] = "__pyx_capi__";
static const char __pyx_k_pyx_type[] = "__pyx_type";
static const char __pyx_k_qualname[] = "__qualname__";
static const char __pyx_k_regclass[] = "regclass";
static const char __pyx_k_reversed[] = "reversed";
static const char __pyx_k_setstate[] = "__setstate__";
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_wait_for[] = "wait_for";
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_copy_stmt[] = "copy_stmt";
static const char __pyx_k_data_type[] = "data_type";
static const char __pyx_k_elemdelim[] = "elemdelim";
static const char __pyx_k_enumerate[] = "enumerate";
static const char __pyx_k_exception[] = "exception";
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_monotonic[] = "monotonic";
static const char __pyx_k_prefixlen[] = "prefixlen";
static const char __pyx_k_prepare_2[] = "__prepare__";
static const char __pyx_k_pyx_state[] = "__pyx_state";
static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
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_NO_TIMEOUT[] = "NO_TIMEOUT";
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_con_params[] = "con_params";
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_result[] = "__pyx_result";
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_PickleError[] = "PickleError";
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_get_timeout[] = "_get_timeout";
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_record_stmt[] = "record_stmt";
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_Timer___exit[] = "Timer.__exit__";
static const char __pyx_k_Timer___init[] = "Timer.__init__";
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_ndistinct[] = "pg_ndistinct";
static const char __pyx_k_pg_node_tree[] = "pg_node_tree";
static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
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_stringsource[] = "stringsource";
static const char __pyx_k_OverflowError[] = "OverflowError";
static const char __pyx_k_PostgresError[] = "PostgresError";
static const char __pyx_k_StopIteration[] = "StopIteration";
static const char __pyx_k_Timer___enter[] = "Timer.__enter__";
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_pause_reading[] = "pause_reading";
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_reduce_cython[] = "__reduce_cython__";
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_resume_reading[] = "resume_reading";
static const char __pyx_k_shift_jis_2004[] = "shift_jis_2004";
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_pg_dependencies[] = "pg_dependencies";
static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
static const char __pyx_k_server_settings[] = "server_settings";
static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
static const char __pyx_k_string_too_long[] = "string too long";
static const char __pyx_k_writing_allowed[] = "writing_allowed";
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_clear_type_cache[] = "clear_type_cache";
static const char __pyx_k_expected_str_got[] = "expected str, got {}";
static const char __pyx_k_index_am_handler[] = "index_am_handler";
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_StopAsyncIteration[] = "StopAsyncIteration";
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_cline_in_traceback[] = "cline_in_traceback";
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_InternalClientError[] = "InternalClientError";
static const char __pyx_k_NotImplementedError[] = "NotImplementedError";
static const char __pyx_k_invalid_data_format[] = "invalid data format: {}";
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_process_log_message[] = "_process_log_message";
static const char __pyx_k_pyx_unpickle_Memory[] = "__pyx_unpickle_Memory";
static const char __pyx_k_remove_python_codec[] = "remove_python_codec";
static const char __pyx_k_BaseProtocol_copy_in[] = "BaseProtocol.copy_in";
static const char __pyx_k_BaseProtocol_execute[] = "BaseProtocol.execute";
static const char __pyx_k_BaseProtocol_prepare[] = "BaseProtocol.prepare";
static const char __pyx_k_ConnectionResetError[] = "ConnectionResetError";
static const char __pyx_k_ConnectionSettings_r[] = "<ConnectionSettings {!r}>";
static const char __pyx_k_get_remaining_budget[] = "get_remaining_budget";
static const char __pyx_k_process_notification[] = "_process_notification";
static const char __pyx_k_text_binary_or_tuple[] = "'text', 'binary' or 'tuple'";
static const char __pyx_k_unknown_alias_target[] = "unknown alias target: {}";
static const char __pyx_k_BaseProtocol_copy_out[] = "BaseProtocol.copy_out";
static const char __pyx_k_copy_in_locals_lambda[] = "copy_in.<locals>.<lambda>";
static const char __pyx_k_invalid_array_element[] = "invalid array element: {}";
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_wait_for_cancellation[] = "_wait_for_cancellation";
static const char __pyx_k_cancel_current_command[] = "_cancel_current_command";
static const char __pyx_k_copy_out_locals_lambda[] = "copy_out.<locals>.<lambda>";
static const char __pyx_k_create_future_fallback[] = "_create_future_fallback";
static const char __pyx_k_declare_fallback_codec[] = "declare_fallback_codec";
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_unexpected_data_format[] = "unexpected data format: {}";
static const char __pyx_k_unexpected_ndims_value[] = "unexpected ndims value: {}";
static const char __pyx_k_Codec_oid_elem_oid_core[] = "<Codec oid={} elem_oid={} core={}>";
static const char __pyx_k_unexpected_JSONB_format[] = "unexpected JSONB format: {}";
static const char __pyx_k_OutdatedSchemaCacheError[] = "OutdatedSchemaCacheError";
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_set_builtin_type_codec_2[] = "_set_builtin_type_codec";
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_pyx_unpickle_BaseProtocol[] = "__pyx_unpickle_BaseProtocol";
static const char __pyx_k_pyx_unpickle_CoreProtocol[] = "__pyx_unpickle_CoreProtocol";
static const char __pyx_k_read_cstr_buffer_overread[] = "read_cstr: buffer overread";
static const char __pyx_k_Timer_get_remaining_budget[] = "Timer.get_remaining_budget";
static const char __pyx_k_TimoutError_was_not_raised[] = "TimoutError was not raised";
static const char __pyx_k_negative_infinity_datetime[] = "negative_infinity_datetime";
static const char __pyx_k_unexpected_exchange_format[] = "unexpected exchange format: {}";
static const char __pyx_k_ConnectionDoesNotExistError[] = "ConnectionDoesNotExistError";
static const char __pyx_k_pyx_unpickle_FastReadBuffer[] = "__pyx_unpickle_FastReadBuffer";
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_pyx_unpickle_DataCodecConfig[] = "__pyx_unpickle_DataCodecConfig";
static const char __pyx_k_asyncpg_protocol_protocol_pyx[] = "asyncpg/protocol/protocol.pyx";
static const char __pyx_k_missing_array_dimension_value[] = "missing array dimension value";
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_Note_that_parameters_are_suppor[] = "  Note that parameters are supported only in SELECT, INSERT, UPDATE, DELETE, and VALUES statements, and will *not* work in statements  like CREATE VIEW or DECLARE CURSOR.";
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_invalid_address_family_in_value[] = "invalid address family in \"{}\" value";
static const char __pyx_k_invalid_address_length_in_value[] = "invalid address length in \"{}\" value";
static const char __pyx_k_list_or_tuple_expected_got_type[] = "list or tuple expected (got 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_the_server_expects_x_argument_s[] = "the server expects {x} argument{s} for this query, {y} {w} passed";
static const char __pyx_k_txid_snapshot_value_is_too_long[] = "txid_snapshot value is too long";
static const char __pyx_k_type_does_not_support_tuple_exc[] = "{} type does not support 'tuple' exchange format";
static const char __pyx_k_type_record_missing_field_types[] = "type record missing field types for composite {}";
static const char __pyx_k_unexpected_instance_of_anyarray[] = "unexpected instance of 'anyarray' type";
static const char __pyx_k_unexpected_number_of_attributes[] = "unexpected number of attributes of composite type: {}, expected {}";
static const char __pyx_k_BaseProtocol__wait_for_cancellat[] = "BaseProtocol._wait_for_cancellation";
static const char __pyx_k_Check_the_query_against_the_pass[] = "Check the query against the passed list of arguments.";
static const char __pyx_k_Deallocating_buffer_with_attache[] = "Deallocating buffer with attached memoryviews";
static const char __pyx_k_Incompatible_checksums_s_vs_0x19[] = "Incompatible checksums (%s vs 0x197884c = (_discard_data, _execute_iter, _execute_portal_name, _execute_stmt_name, _skip_discard, backend_pid, backend_secret, buffer, con_params, con_status, encoding, result, result_execute_completed, result_param_desc, result_row_desc, result_status_msg, result_type, state, transport, xact_status))";
static const char __pyx_k_Incompatible_checksums_s_vs_0x30[] = "Incompatible checksums (%s vs 0x30f806c = (_discard_data, _execute_iter, _execute_portal_name, _execute_stmt_name, _skip_discard, address, backend_pid, backend_secret, buffer, cancel_sent_waiter, cancel_waiter, closing, completed_callback, con_params, con_status, connection, create_future, encoding, is_reading, last_query, loop, queries_count, result, result_execute_completed, result_param_desc, result_row_desc, result_status_msg, result_type, return_extra, settings, state, statement, timeout_callback, timeout_handle, transport, waiter, writing_paused, xact_status))";
static const char __pyx_k_Incompatible_checksums_s_vs_0x7e[] = "Incompatible checksums (%s vs 0x7ea5e72 = (buf, len))";
static const char __pyx_k_Incompatible_checksums_s_vs_0xb7[] = "Incompatible checksums (%s vs 0xb75bfc9 = (_local_type_codecs, _type_codecs_cache))";
static const char __pyx_k_Incompatible_checksums_s_vs_0xe0[] = "Incompatible checksums (%s vs 0xe0abff4 = (buf, length, owner))";
static const char __pyx_k_bind_execute_many_locals_genexpr[] = "bind_execute_many.<locals>.genexpr";
static const char __pyx_k_cannot_encode_Decimal_value_into[] = "cannot encode Decimal value into numeric: exponent is too small";
static const char __pyx_k_cannot_encode_type_text_encoding[] = "cannot encode type \"{}\".\"{}\": text encoding of range types is not supported";
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_date_tuple_encoder_expecting_1_e[] = "date tuple encoder: expecting 1 element in tuple, got {}";
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_int_too_big_to_be_encoded_as_INT[] = "int too big to be encoded as INT2: {!r}";
static const char __pyx_k_interval_tuple_encoder_expecting[] = "interval tuple encoder: expecting 3 elements in tuple, got {}";
static const char __pyx_k_invalid_format_argument_expected[] = "invalid `format` argument, expected {}, got {!r}";
static const char __pyx_k_invalid_network_prefix_length_in[] = "invalid network prefix length in \"{}\" value";
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_timeout_value_expected_n[] = "invalid timeout value: expected non-negative float (got {!r})";
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_binary_format_encoder_for_typ[] = "no binary format encoder for type {} (OID {})";
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_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__";
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_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_numeric_type_does_not_support_in[] = "numeric type does not support infinite values";
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_reader_is_not_an_asynchronous_it[] = "reader is not an asynchronous iterable";
static const char __pyx_k_specified_array_dimensions_do_no[] = "specified array dimensions do not match array content";
static const char __pyx_k_the_number_of_query_arguments_ca[] = "the number of query arguments cannot exceed 32767";
static const char __pyx_k_time_tuple_encoder_expecting_1_e[] = "time tuple encoder: expecting 1 element in tuple, got {}";
static const char __pyx_k_time_tuple_encoder_expecting_2_e[] = "time tuple encoder: expecting 2 elements2 in tuple, got {}";
static const char __pyx_k_timestamp_tuple_encoder_expectin[] = "timestamp tuple encoder: expecting 1 element in tuple, got {}";
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_waiter_is_not_done_while_handlin[] = "waiter is not done while handling critical protocol error";
static const char __pyx_k_cannot_encode_Decimal_value_into_2[] = "cannot encode Decimal value into numeric: exponent is too large";
static const char __pyx_k_cannot_encode_Decimal_value_into_3[] = "cannot encode Decimal value into numeric: number of digits is too large";
static const char __pyx_k_cannot_encode_type_text_encoding_2[] = "cannot encode type \"{}\".\"{}\": text encoding of composite types is not supported";
static const char __pyx_k_cannot_perform_operation_another_2[] = "cannot perform operation: another operation is in progress";
static const char __pyx_k_int_too_big_to_be_encoded_as_INT_2[] = "int too big to be encoded as INT4: {!r}";
static const char __pyx_k_int_too_big_to_be_encoded_as_INT_3[] = "int too big to be encoded as INT8: {!r}";
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__wait_for_cancellat;
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_copy_in;
static PyObject *__pyx_n_s_BaseProtocol_copy_out;
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_kp_u_Check_the_query_against_the_pass;
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_ConnectionResetError;
static PyObject *__pyx_kp_u_ConnectionSettings_r;
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_Event;
static PyObject *__pyx_n_u_F;
static PyObject *__pyx_n_s_Future;
static PyObject *__pyx_n_s_IPPROTO_TCP;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x19;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x30;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x7e;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xb7;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xe0;
static PyObject *__pyx_n_s_InterfaceError;
static PyObject *__pyx_n_s_InternalClientError;
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_N;
static PyObject *__pyx_n_u_NA;
static PyObject *__pyx_n_s_NO_TIMEOUT;
static PyObject *__pyx_n_b_NULL;
static PyObject *__pyx_kp_b_NULL_2;
static PyObject *__pyx_n_u_NaN;
static PyObject *__pyx_n_s_NotImplementedError;
static PyObject *__pyx_kp_u_Note_that_parameters_are_suppor;
static PyObject *__pyx_n_s_OrderedDict;
static PyObject *__pyx_n_s_OutdatedSchemaCacheError;
static PyObject *__pyx_n_s_OverflowError;
static PyObject *__pyx_kp_b_PGCOPY;
static PyObject *__pyx_n_s_Path;
static PyObject *__pyx_n_s_PickleError;
static PyObject *__pyx_n_s_Point;
static PyObject *__pyx_n_s_Polygon;
static PyObject *__pyx_n_s_PostgresError;
static PyObject *__pyx_n_s_Protocol;
static PyObject *__pyx_n_s_Range;
static PyObject *__pyx_n_s_Record;
static PyObject *__pyx_n_s_RuntimeError;
static PyObject *__pyx_n_s_StopAsyncIteration;
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_u_TimeoutError;
static PyObject *__pyx_n_s_Timer;
static PyObject *__pyx_n_s_Timer___enter;
static PyObject *__pyx_n_s_Timer___exit;
static PyObject *__pyx_n_s_Timer___init;
static PyObject *__pyx_n_s_Timer_get_remaining_budget;
static PyObject *__pyx_kp_u_TimoutError_was_not_raised;
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__22;
static PyObject *__pyx_kp_u__22;
static PyObject *__pyx_kp_b__23;
static PyObject *__pyx_n_u__3;
static PyObject *__pyx_kp_u__36;
static PyObject *__pyx_kp_b__64;
static PyObject *__pyx_kp_u__87;
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_aiter;
static PyObject *__pyx_n_s_alias_to;
static PyObject *__pyx_kp_u_already_connected;
static PyObject *__pyx_n_u_alt;
static PyObject *__pyx_n_s_anext;
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_s_as_tuple;
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_kp_s_asyncpg_protocol_protocol_pyx;
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_u_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_n_s_budget;
static PyObject *__pyx_n_s_budget_2;
static PyObject *__pyx_kp_u_buffer_overread;
static PyObject *__pyx_n_s_builtins;
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_encode_Decimal_value_into;
static PyObject *__pyx_kp_u_cannot_encode_Decimal_value_into_2;
static PyObject *__pyx_kp_u_cannot_encode_Decimal_value_into_3;
static PyObject *__pyx_kp_u_cannot_encode_type_text_encoding;
static PyObject *__pyx_kp_u_cannot_encode_type_text_encoding_2;
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_s_clear;
static PyObject *__pyx_n_s_clear_type_cache;
static PyObject *__pyx_n_b_client_encoding;
static PyObject *__pyx_n_u_client_encoding;
static PyObject *__pyx_n_s_cline_in_traceback;
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_s_compat;
static PyObject *__pyx_n_u_composite;
static PyObject *__pyx_n_s_con_params;
static PyObject *__pyx_n_s_config;
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_s_copy_in;
static PyObject *__pyx_n_s_copy_in_locals_lambda;
static PyObject *__pyx_n_s_copy_out;
static PyObject *__pyx_n_s_copy_out_locals_lambda;
static PyObject *__pyx_n_s_copy_stmt;
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_s_data;
static PyObject *__pyx_n_s_data_type;
static PyObject *__pyx_n_s_database;
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_kp_u_date_tuple_encoder_expecting_1_e;
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_declare_fallback_codec;
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_n_s_dict;
static PyObject *__pyx_n_s_digits;
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_b_e;
static PyObject *__pyx_n_s_e;
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_enter;
static PyObject *__pyx_n_s_enumerate;
static PyObject *__pyx_n_s_et;
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_exception;
static PyObject *__pyx_n_s_exceptions;
static PyObject *__pyx_n_s_execute;
static PyObject *__pyx_n_s_exit;
static PyObject *__pyx_kp_u_expected_0_1_or_2_elements_in_ra;
static PyObject *__pyx_kp_u_expected_str_got;
static PyObject *__pyx_n_s_exponent;
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_get_remaining_budget;
static PyObject *__pyx_n_s_get_timeout;
static PyObject *__pyx_n_s_getattr;
static PyObject *__pyx_n_s_getstate;
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_n_s_hint;
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_index_am_handler;
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_int_too_big_to_be_encoded_as_INT;
static PyObject *__pyx_kp_u_int_too_big_to_be_encoded_as_INT_2;
static PyObject *__pyx_kp_u_int_too_big_to_be_encoded_as_INT_3;
static PyObject *__pyx_n_u_internal;
static PyObject *__pyx_n_u_interval;
static PyObject *__pyx_kp_u_interval_tuple_encoder_expecting;
static PyObject *__pyx_kp_u_invalid_address_family_in_value;
static PyObject *__pyx_kp_u_invalid_address_length_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_data_format;
static PyObject *__pyx_kp_u_invalid_format_argument_expected;
static PyObject *__pyx_kp_u_invalid_network_prefix_length_in;
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_timeout_value_expected_n;
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_u_macaddr8;
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_monotonic;
static PyObject *__pyx_n_u_n;
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_2;
static PyObject *__pyx_n_s_new_prefix;
static PyObject *__pyx_kp_u_no_binary_format_encoder_for_typ;
static PyObject *__pyx_kp_u_no_codec_for_composite_attribute;
static PyObject *__pyx_kp_u_no_decoder_for_OID;
static PyObject *__pyx_kp_u_no_decoder_for_composite_type_el;
static PyObject *__pyx_kp_s_no_default___reduce___due_to_non;
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_u_ns;
static PyObject *__pyx_kp_u_null_value_not_allowed_in_hstore;
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_kp_u_numeric_type_does_not_support_in;
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_path;
static PyObject *__pyx_kp_u_path_value_too_long;
static PyObject *__pyx_n_s_pause_reading;
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_u_pg_dependencies;
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_ndistinct;
static PyObject *__pyx_n_u_pg_node_tree;
static PyObject *__pyx_n_s_pickle;
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_pop;
static PyObject *__pyx_n_s_popleft;
static PyObject *__pyx_n_s_portal_name;
static PyObject *__pyx_n_s_position;
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_process_log_message;
static PyObject *__pyx_n_s_process_notification;
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_PickleError;
static PyObject *__pyx_n_s_pyx_capi;
static PyObject *__pyx_n_s_pyx_checksum;
static PyObject *__pyx_n_s_pyx_result;
static PyObject *__pyx_n_s_pyx_state;
static PyObject *__pyx_n_s_pyx_type;
static PyObject *__pyx_n_s_pyx_unpickle_BaseProtocol;
static PyObject *__pyx_n_s_pyx_unpickle_CoreProtocol;
static PyObject *__pyx_n_s_pyx_unpickle_DataCodecConfig;
static PyObject *__pyx_n_s_pyx_unpickle_FastReadBuffer;
static PyObject *__pyx_n_s_pyx_unpickle_Memory;
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_reader;
static PyObject *__pyx_kp_u_reader_is_not_an_asynchronous_it;
static PyObject *__pyx_n_s_rec;
static PyObject *__pyx_n_u_record;
static PyObject *__pyx_n_s_record_stmt;
static PyObject *__pyx_n_s_records;
static PyObject *__pyx_n_s_reduce;
static PyObject *__pyx_n_s_reduce_cython;
static PyObject *__pyx_n_s_reduce_ex;
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_s_release;
static PyObject *__pyx_n_u_reltime;
static PyObject *__pyx_n_s_remove_python_codec;
static PyObject *__pyx_n_s_replace;
static PyObject *__pyx_n_s_request_cancel;
static PyObject *__pyx_n_s_resume_reading;
static PyObject *__pyx_n_s_return_extra;
static PyObject *__pyx_n_s_reversed;
static PyObject *__pyx_n_s_s;
static PyObject *__pyx_n_u_s;
static PyObject *__pyx_n_u_scalar;
static PyObject *__pyx_n_s_schema;
static PyObject *__pyx_n_s_second;
static PyObject *__pyx_n_s_seconds;
static PyObject *__pyx_n_s_self;
static PyObject *__pyx_n_s_send;
static PyObject *__pyx_n_s_server_settings;
static PyObject *__pyx_n_s_set;
static PyObject *__pyx_n_s_set_builtin_type_codec;
static PyObject *__pyx_n_s_set_builtin_type_codec_2;
static PyObject *__pyx_n_s_set_exception;
static PyObject *__pyx_n_s_set_result;
static PyObject *__pyx_n_s_setsockopt;
static PyObject *__pyx_n_s_setstate;
static PyObject *__pyx_n_s_setstate_cython;
static PyObject *__pyx_n_u_shift_jis;
static PyObject *__pyx_n_u_shift_jis_2004;
static PyObject *__pyx_n_s_sign;
static PyObject *__pyx_n_s_sink;
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_started;
static PyObject *__pyx_n_s_startswith;
static PyObject *__pyx_n_s_state;
static PyObject *__pyx_n_s_stmt_name;
static PyObject *__pyx_kp_u_string_too_long;
static PyObject *__pyx_kp_s_stringsource;
static PyObject *__pyx_n_s_supernet;
static PyObject *__pyx_n_s_tb;
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_text_binary_or_tuple;
static PyObject *__pyx_kp_u_the_buffer_is_in_read_only_mode;
static PyObject *__pyx_kp_u_the_number_of_query_arguments_ca;
static PyObject *__pyx_kp_u_the_server_expects_x_argument_s;
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_kp_u_time_tuple_encoder_expecting_1_e;
static PyObject *__pyx_kp_u_time_tuple_encoder_expecting_2_e;
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_kp_u_timestamp_tuple_encoder_expectin;
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_tuple;
static PyObject *__pyx_n_u_txid_snapshot;
static PyObject *__pyx_kp_u_txid_snapshot_value_is_too_long;
static PyObject *__pyx_kp_u_type_does_not_support_tuple_exc;
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_format;
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_exchange_format;
static PyObject *__pyx_kp_u_unexpected_instance_of_anyarray;
static PyObject *__pyx_kp_u_unexpected_ndims_value;
static PyObject *__pyx_kp_u_unexpected_number_of_attributes;
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_update;
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_s_w;
static PyObject *__pyx_n_s_wait;
static PyObject *__pyx_n_s_wait_for;
static PyObject *__pyx_n_s_wait_for_cancellation;
static PyObject *__pyx_kp_u_waiter_is_not_done_while_handlin;
static PyObject *__pyx_n_u_was;
static PyObject *__pyx_n_u_were;
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_s_writing_allowed;
static PyObject *__pyx_n_s_x;
static PyObject *__pyx_n_s_xformat;
static PyObject *__pyx_n_u_xid;
static PyObject *__pyx_n_u_xml;
static PyObject *__pyx_n_s_y;
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_format); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_8remove_python_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, PyObject *__pyx_v_typeoid, PyObject *__pyx_v_typename, PyObject *__pyx_v_typeschema); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_10clear_type_cache(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_12set_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_14get_data_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, uint32_t __pyx_v_oid, enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat __pyx_v_format); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_16__getattr__(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, PyObject *__pyx_v_name); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_18__repr__(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_20__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_22__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_6Memory___reduce_cython__(struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_6Memory_2__setstate_cython__(struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* 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 PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_11WriteBuffer_8__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_11WriteBuffer_10__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_7asyncpg_8protocol_8protocol_10ReadBuffer___cinit__(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_10ReadBuffer_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_10ReadBuffer_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_14FastReadBuffer___reduce_cython__(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_14FastReadBuffer_2__setstate_cython__(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* 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 PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_5Codec_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_5Codec_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* 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_format, PyObject *__pyx_v_xformat); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig_6remove_python_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *__pyx_v_self, PyObject *__pyx_v_typeoid, CYTHON_UNUSED PyObject *__pyx_v_typename, CYTHON_UNUSED PyObject *__pyx_v_typeschema); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig_8_set_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, PyObject *__pyx_v_format); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig_10set_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, PyObject *__pyx_v_format); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig_12clear_type_cache(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig_14declare_fallback_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *__pyx_v_self, uint32_t __pyx_v_oid, PyObject *__pyx_v_name, PyObject *__pyx_v_schema); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig_16__reduce_cython__(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig_18__setstate_cython__(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_7asyncpg_8protocol_8protocol_12CoreProtocol___init__(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_con_params); /* 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 PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12CoreProtocol_8__reduce_cython__(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12CoreProtocol_10__setstate_cython__(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* 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 PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_14__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_16__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* 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_params, 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_8is_in_transaction(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_10prepare(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_13bind_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_16bind_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_19bind(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_22execute(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_25query(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_query, PyObject *__pyx_v_timeout); /* proto */
static PyObject *__pyx_lambda_funcdef_lambda1(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_28copy_out(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_copy_stmt, PyObject *__pyx_v_sink, PyObject *__pyx_v_timeout); /* proto */
static PyObject *__pyx_lambda_funcdef_lambda2(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_31copy_in(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_copy_stmt, PyObject *__pyx_v_reader, PyObject *__pyx_v_data, PyObject *__pyx_v_records, struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_record_stmt, PyObject *__pyx_v_timeout); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_34close_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_37is_closed(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_39is_connected(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_41abort(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_43close(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_timeout); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_46_request_cancel(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_48_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_50_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_52_create_future_fallback(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_54_get_timeout(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_timeout); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_56_is_cancelling(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_58_wait_for_cancellation(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_61pause_writing(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_63resume_writing(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_12BaseProtocol_65__reduce_cython__(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_67__setstate_cython__(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_5Timer___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_budget); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_5Timer_2__enter__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_5Timer_4__exit__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_et, CYTHON_UNUSED PyObject *__pyx_v_e, CYTHON_UNUSED PyObject *__pyx_v_tb); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_5Timer_6get_remaining_budget(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__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_pf_7asyncpg_8protocol_8protocol_2__pyx_unpickle_Memory(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_4__pyx_unpickle_FastReadBuffer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_6__pyx_unpickle_DataCodecConfig(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_8__pyx_unpickle_CoreProtocol(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_10__pyx_unpickle_BaseProtocol(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* 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_copy_out(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation(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_10;
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_100;
static PyObject *__pyx_int_114;
static PyObject *__pyx_int_142;
static PyObject *__pyx_int_194;
static PyObject *__pyx_int_210;
static PyObject *__pyx_int_325;
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_774;
static PyObject *__pyx_int_790;
static PyObject *__pyx_int_829;
static PyObject *__pyx_int_869;
static PyObject *__pyx_int_1000;
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_3361;
static PyObject *__pyx_int_3402;
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_524288;
static PyObject *__pyx_int_999999;
static PyObject *__pyx_int_26708044;
static PyObject *__pyx_int_51347564;
static PyObject *__pyx_int_132800114;
static PyObject *__pyx_int_192266185;
static PyObject *__pyx_int_235585524;
static PyObject *__pyx_int_9223372036854775807;
static PyObject *__pyx_int_neg_9223372036854775808;
static enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat __pyx_k__2;
static PyObject *__pyx_k__37;
static PyObject *__pyx_k__38;
static enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat __pyx_k__39;
static enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat __pyx_k__40;
static enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat __pyx_k__41;
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__35;
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__18;
static PyObject *__pyx_tuple__19;
static PyObject *__pyx_tuple__20;
static PyObject *__pyx_tuple__21;
static PyObject *__pyx_tuple__24;
static PyObject *__pyx_tuple__25;
static PyObject *__pyx_tuple__26;
static PyObject *__pyx_tuple__27;
static PyObject *__pyx_tuple__28;
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__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__65;
static PyObject *__pyx_tuple__66;
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__88;
static PyObject *__pyx_tuple__89;
static PyObject *__pyx_tuple__90;
static PyObject *__pyx_tuple__91;
static PyObject *__pyx_tuple__92;
static PyObject *__pyx_tuple__93;
static PyObject *__pyx_tuple__94;
static PyObject *__pyx_tuple__95;
static PyObject *__pyx_tuple__96;
static PyObject *__pyx_tuple__97;
static PyObject *__pyx_tuple__98;
static PyObject *__pyx_tuple__99;
static PyObject *__pyx_tuple__100;
static PyObject *__pyx_tuple__101;
static PyObject *__pyx_tuple__102;
static PyObject *__pyx_tuple__103;
static PyObject *__pyx_tuple__104;
static PyObject *__pyx_tuple__105;
static PyObject *__pyx_tuple__106;
static PyObject *__pyx_tuple__107;
static PyObject *__pyx_tuple__108;
static PyObject *__pyx_tuple__109;
static PyObject *__pyx_tuple__110;
static PyObject *__pyx_tuple__111;
static PyObject *__pyx_tuple__112;
static PyObject *__pyx_tuple__113;
static PyObject *__pyx_tuple__114;
static PyObject *__pyx_tuple__115;
static PyObject *__pyx_tuple__116;
static PyObject *__pyx_tuple__117;
static PyObject *__pyx_tuple__118;
static PyObject *__pyx_tuple__120;
static PyObject *__pyx_tuple__122;
static PyObject *__pyx_tuple__124;
static PyObject *__pyx_tuple__126;
static PyObject *__pyx_tuple__128;
static PyObject *__pyx_tuple__130;
static PyObject *__pyx_tuple__132;
static PyObject *__pyx_tuple__134;
static PyObject *__pyx_tuple__136;
static PyObject *__pyx_codeobj__119;
static PyObject *__pyx_codeobj__121;
static PyObject *__pyx_codeobj__123;
static PyObject *__pyx_codeobj__125;
static PyObject *__pyx_codeobj__127;
static PyObject *__pyx_codeobj__129;
static PyObject *__pyx_codeobj__131;
static PyObject *__pyx_codeobj__133;
static PyObject *__pyx_codeobj__135;
static PyObject *__pyx_codeobj__137;

/* "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 '%.30s'", "get");
    __PYX_ERR(8, 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(8, 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(8, 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(8, 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(8, 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(8, 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(8, 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(8, 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);
        CYTHON_FALLTHROUGH;
        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(1, 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(1, 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 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 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(1, 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(1, 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(1, 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(1, 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(1, 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(1, 19, __pyx_L1_error)
  }
  if (unlikely(PyDict_SetItem(__pyx_v_self->_settings, __pyx_v_name, __pyx_v_val) < 0)) __PYX_ERR(1, 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(1, 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(1, 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(1, 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(1, 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(1, 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(1, 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(1, 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(1, 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(1, 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(1, 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(1, 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(1, 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(1, 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(1, 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(1, 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(1, 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(1, 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(1, 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(1, 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(1, 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(1, 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, format):
 *         cdef:
 */

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_format, CYTHON_UNUSED int __pyx_skip_dispatch) {
  enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat __pyx_v__format;
  enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat __pyx_v_xformat;
  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;
  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/settings.pyx":41
 *             ClientExchangeFormat xformat
 * 
 *         if format == 'binary':             # <<<<<<<<<<<<<<
 *             _format = PG_FORMAT_BINARY
 *             xformat = PG_XFORMAT_OBJECT
 */
  __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_format, __pyx_n_u_binary, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 41, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "asyncpg/protocol/settings.pyx":42
 * 
 *         if format == 'binary':
 *             _format = PG_FORMAT_BINARY             # <<<<<<<<<<<<<<
 *             xformat = PG_XFORMAT_OBJECT
 *         elif format == 'text':
 */
    __pyx_v__format = __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY;

    /* "asyncpg/protocol/settings.pyx":43
 *         if format == 'binary':
 *             _format = PG_FORMAT_BINARY
 *             xformat = PG_XFORMAT_OBJECT             # <<<<<<<<<<<<<<
 *         elif format == 'text':
 *             _format = PG_FORMAT_TEXT
 */
    __pyx_v_xformat = __pyx_e_7asyncpg_8protocol_8protocol_PG_XFORMAT_OBJECT;

    /* "asyncpg/protocol/settings.pyx":41
 *             ClientExchangeFormat xformat
 * 
 *         if format == 'binary':             # <<<<<<<<<<<<<<
 *             _format = PG_FORMAT_BINARY
 *             xformat = PG_XFORMAT_OBJECT
 */
    goto __pyx_L3;
  }

  /* "asyncpg/protocol/settings.pyx":44
 *             _format = PG_FORMAT_BINARY
 *             xformat = PG_XFORMAT_OBJECT
 *         elif format == 'text':             # <<<<<<<<<<<<<<
 *             _format = PG_FORMAT_TEXT
 *             xformat = PG_XFORMAT_OBJECT
 */
  __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_format, __pyx_n_u_text, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 44, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "asyncpg/protocol/settings.pyx":45
 *             xformat = PG_XFORMAT_OBJECT
 *         elif format == 'text':
 *             _format = PG_FORMAT_TEXT             # <<<<<<<<<<<<<<
 *             xformat = PG_XFORMAT_OBJECT
 *         elif format == 'tuple':
 */
    __pyx_v__format = __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT;

    /* "asyncpg/protocol/settings.pyx":46
 *         elif format == 'text':
 *             _format = PG_FORMAT_TEXT
 *             xformat = PG_XFORMAT_OBJECT             # <<<<<<<<<<<<<<
 *         elif format == 'tuple':
 *             _format = PG_FORMAT_ANY
 */
    __pyx_v_xformat = __pyx_e_7asyncpg_8protocol_8protocol_PG_XFORMAT_OBJECT;

    /* "asyncpg/protocol/settings.pyx":44
 *             _format = PG_FORMAT_BINARY
 *             xformat = PG_XFORMAT_OBJECT
 *         elif format == 'text':             # <<<<<<<<<<<<<<
 *             _format = PG_FORMAT_TEXT
 *             xformat = PG_XFORMAT_OBJECT
 */
    goto __pyx_L3;
  }

  /* "asyncpg/protocol/settings.pyx":47
 *             _format = PG_FORMAT_TEXT
 *             xformat = PG_XFORMAT_OBJECT
 *         elif format == 'tuple':             # <<<<<<<<<<<<<<
 *             _format = PG_FORMAT_ANY
 *             xformat = PG_XFORMAT_TUPLE
 */
  __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_format, __pyx_n_u_tuple, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 47, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "asyncpg/protocol/settings.pyx":48
 *             xformat = PG_XFORMAT_OBJECT
 *         elif format == 'tuple':
 *             _format = PG_FORMAT_ANY             # <<<<<<<<<<<<<<
 *             xformat = PG_XFORMAT_TUPLE
 *         else:
 */
    __pyx_v__format = __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_ANY;

    /* "asyncpg/protocol/settings.pyx":49
 *         elif format == 'tuple':
 *             _format = PG_FORMAT_ANY
 *             xformat = PG_XFORMAT_TUPLE             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError(
 */
    __pyx_v_xformat = __pyx_e_7asyncpg_8protocol_8protocol_PG_XFORMAT_TUPLE;

    /* "asyncpg/protocol/settings.pyx":47
 *             _format = PG_FORMAT_TEXT
 *             xformat = PG_XFORMAT_OBJECT
 *         elif format == 'tuple':             # <<<<<<<<<<<<<<
 *             _format = PG_FORMAT_ANY
 *             xformat = PG_XFORMAT_TUPLE
 */
    goto __pyx_L3;
  }

  /* "asyncpg/protocol/settings.pyx":51
 *             xformat = PG_XFORMAT_TUPLE
 *         else:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 'invalid `format` argument, expected {}, got {!r}'.format(
 *                     "'text', 'binary' or 'tuple'", format
 */
  /*else*/ {

    /* "asyncpg/protocol/settings.pyx":52
 *         else:
 *             raise ValueError(
 *                 'invalid `format` argument, expected {}, got {!r}'.format(             # <<<<<<<<<<<<<<
 *                     "'text', 'binary' or 'tuple'", format
 *                 ))
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_invalid_format_argument_expected, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 52, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);

    /* "asyncpg/protocol/settings.pyx":53
 *             raise ValueError(
 *                 'invalid `format` argument, expected {}, got {!r}'.format(
 *                     "'text', 'binary' or 'tuple'", format             # <<<<<<<<<<<<<<
 *                 ))
 * 
 */
    __pyx_t_4 = NULL;
    __pyx_t_5 = 0;
    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);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_u_text_binary_or_tuple, __pyx_v_format};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 52, __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[3] = {__pyx_t_4, __pyx_kp_u_text_binary_or_tuple, __pyx_v_format};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 52, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 52, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (__pyx_t_4) {
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
      }
      __Pyx_INCREF(__pyx_kp_u_text_binary_or_tuple);
      __Pyx_GIVEREF(__pyx_kp_u_text_binary_or_tuple);
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_kp_u_text_binary_or_tuple);
      __Pyx_INCREF(__pyx_v_format);
      __Pyx_GIVEREF(__pyx_v_format);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_format);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 52, __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/settings.pyx":51
 *             xformat = PG_XFORMAT_TUPLE
 *         else:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 'invalid `format` argument, expected {}, got {!r}'.format(
 *                     "'text', 'binary' or 'tuple'", format
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 51, __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(1, 51, __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(1, 51, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "asyncpg/protocol/settings.pyx":56
 *                 ))
 * 
 *         self._data_codecs.add_python_codec(typeoid, typename, typeschema,             # <<<<<<<<<<<<<<
 *                                            typekind, encoder, decoder,
 *                                            _format, xformat)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->_data_codecs), __pyx_n_s_add_python_codec); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 56, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "asyncpg/protocol/settings.pyx":58
 *         self._data_codecs.add_python_codec(typeoid, typename, typeschema,
 *                                            typekind, encoder, decoder,
 *                                            _format, xformat)             # <<<<<<<<<<<<<<
 * 
 *     cpdef inline remove_python_codec(self, typeoid, typename, typeschema):
 */
  __pyx_t_6 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(__pyx_v__format); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 58, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat(__pyx_v_xformat); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 58, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_7 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && likely(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_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[9] = {__pyx_t_7, __pyx_v_typeoid, __pyx_v_typename, __pyx_v_typeschema, __pyx_v_typekind, __pyx_v_encoder, __pyx_v_decoder, __pyx_t_6, __pyx_t_4};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 8+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 56, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 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[9] = {__pyx_t_7, __pyx_v_typeoid, __pyx_v_typename, __pyx_v_typeschema, __pyx_v_typekind, __pyx_v_encoder, __pyx_v_decoder, __pyx_t_6, __pyx_t_4};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 8+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 56, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 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(8+__pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 56, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_7) {
      __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+__pyx_t_5, __pyx_v_typeoid);
    __Pyx_INCREF(__pyx_v_typename);
    __Pyx_GIVEREF(__pyx_v_typename);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_5, __pyx_v_typename);
    __Pyx_INCREF(__pyx_v_typeschema);
    __Pyx_GIVEREF(__pyx_v_typeschema);
    PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_5, __pyx_v_typeschema);
    __Pyx_INCREF(__pyx_v_typekind);
    __Pyx_GIVEREF(__pyx_v_typekind);
    PyTuple_SET_ITEM(__pyx_t_8, 3+__pyx_t_5, __pyx_v_typekind);
    __Pyx_INCREF(__pyx_v_encoder);
    __Pyx_GIVEREF(__pyx_v_encoder);
    PyTuple_SET_ITEM(__pyx_t_8, 4+__pyx_t_5, __pyx_v_encoder);
    __Pyx_INCREF(__pyx_v_decoder);
    __Pyx_GIVEREF(__pyx_v_decoder);
    PyTuple_SET_ITEM(__pyx_t_8, 5+__pyx_t_5, __pyx_v_decoder);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_8, 6+__pyx_t_5, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_8, 7+__pyx_t_5, __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(1, 56, __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_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/settings.pyx":35
 *         self._data_codecs.add_types(types)
 * 
 *     cpdef inline add_python_codec(self, typeoid, typename, typeschema,             # <<<<<<<<<<<<<<
 *                                   typekind, encoder, decoder, format):
 *         cdef:
 */

  /* 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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __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_format = 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_format,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);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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;
        CYTHON_FALLTHROUGH;
        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(1, 35, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        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(1, 35, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        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(1, 35, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        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(1, 35, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        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(1, 35, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_format)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_python_codec", 1, 7, 7, 6); __PYX_ERR(1, 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(1, 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_format = 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(1, 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_format);

  /* 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_format) {
  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_format, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 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":60
 *                                            _format, xformat)
 * 
 *     cpdef inline remove_python_codec(self, typeoid, typename, typeschema):             # <<<<<<<<<<<<<<
 *         self._data_codecs.remove_python_codec(typeoid, typename, typeschema)
 * 
 */

static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_9remove_python_codec(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_remove_python_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, PyObject *__pyx_v_typeoid, PyObject *__pyx_v_typename, PyObject *__pyx_v_typeschema, 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("remove_python_codec", 0);

  /* "asyncpg/protocol/settings.pyx":61
 * 
 *     cpdef inline remove_python_codec(self, typeoid, typename, typeschema):
 *         self._data_codecs.remove_python_codec(typeoid, typename, typeschema)             # <<<<<<<<<<<<<<
 * 
 *     cpdef inline clear_type_cache(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->_data_codecs), __pyx_n_s_remove_python_codec); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 61, __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_typeoid, __pyx_v_typename, __pyx_v_typeschema};
    __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(1, 61, __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_typeoid, __pyx_v_typename, __pyx_v_typeschema};
    __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(1, 61, __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(1, 61, __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_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 61, __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":60
 *                                            _format, xformat)
 * 
 *     cpdef inline remove_python_codec(self, typeoid, typename, typeschema):             # <<<<<<<<<<<<<<
 *         self._data_codecs.remove_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.remove_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_9remove_python_codec(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_9remove_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_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remove_python_codec (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_typeoid,&__pyx_n_s_typename,&__pyx_n_s_typeschema,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typename)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remove_python_codec", 1, 3, 3, 1); __PYX_ERR(1, 60, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typeschema)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remove_python_codec", 1, 3, 3, 2); __PYX_ERR(1, 60, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "remove_python_codec") < 0)) __PYX_ERR(1, 60, __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_typeoid = values[0];
    __pyx_v_typename = values[1];
    __pyx_v_typeschema = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("remove_python_codec", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 60, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("asyncpg.protocol.protocol.ConnectionSettings.remove_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_8remove_python_codec(((struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *)__pyx_v_self), __pyx_v_typeoid, __pyx_v_typename, __pyx_v_typeschema);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_8remove_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_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("remove_python_codec", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_remove_python_codec(__pyx_v_self, __pyx_v_typeoid, __pyx_v_typename, __pyx_v_typeschema, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 60, __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.remove_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":63
 *         self._data_codecs.remove_python_codec(typeoid, typename, typeschema)
 * 
 *     cpdef inline clear_type_cache(self):             # <<<<<<<<<<<<<<
 *         self._data_codecs.clear_type_cache()
 * 
 */

static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_11clear_type_cache(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_clear_type_cache(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, 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;
  __Pyx_RefNannySetupContext("clear_type_cache", 0);

  /* "asyncpg/protocol/settings.pyx":64
 * 
 *     cpdef inline clear_type_cache(self):
 *         self._data_codecs.clear_type_cache()             # <<<<<<<<<<<<<<
 * 
 *     cpdef inline set_builtin_type_codec(self, typeoid, typename, typeschema,
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->_data_codecs), __pyx_n_s_clear_type_cache); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 64, __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(1, 64, __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, 64, __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/settings.pyx":63
 *         self._data_codecs.remove_python_codec(typeoid, typename, typeschema)
 * 
 *     cpdef inline clear_type_cache(self):             # <<<<<<<<<<<<<<
 *         self._data_codecs.clear_type_cache()
 * 
 */

  /* 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.ConnectionSettings.clear_type_cache", __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_11clear_type_cache(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_11clear_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_18ConnectionSettings_10clear_type_cache(((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_10clear_type_cache(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("clear_type_cache", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_clear_type_cache(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 63, __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.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/settings.pyx":66
 *         self._data_codecs.clear_type_cache()
 * 
 *     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_13set_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":68
 *     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(1, 68, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "asyncpg/protocol/settings.pyx":69
 *                                         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(1, 68, __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(1, 68, __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(1, 68, __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(1, 68, __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":66
 *         self._data_codecs.clear_type_cache()
 * 
 *     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_13set_builtin_type_codec(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_13set_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);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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;
        CYTHON_FALLTHROUGH;
        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(1, 66, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        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(1, 66, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        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(1, 66, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        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(1, 66, __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(1, 66, __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(1, 66, __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_12set_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_12set_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(1, 66, __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":71
 *                                           typekind, alias_to)
 * 
 *     cpdef inline Codec get_data_codec(self, uint32_t oid,             # <<<<<<<<<<<<<<
 *                                       ServerDataFormat format=PG_FORMAT_ANY):
 *         if format == PG_FORMAT_ANY:
 */

static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_15get_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_ServerDataFormat __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":73
 *     cpdef inline Codec get_data_codec(self, uint32_t oid,
 *                                       ServerDataFormat 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":74
 *                                       ServerDataFormat 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(1, 74, __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":75
 *         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":76
 *             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(1, 76, __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":75
 *         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":77
 *             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":73
 *     cpdef inline Codec get_data_codec(self, uint32_t oid,
 *                                       ServerDataFormat 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":79
 *             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(1, 79, __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":71
 *                                           typekind, alias_to)
 * 
 *     cpdef inline Codec get_data_codec(self, uint32_t oid,             # <<<<<<<<<<<<<<
 *                                       ServerDataFormat 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_15get_data_codec(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_15get_data_codec(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  uint32_t __pyx_v_oid;
  enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat __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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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;
        CYTHON_FALLTHROUGH;
        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(1, 71, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        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(1, 71, __pyx_L3_error)
    if (values[1]) {
      __pyx_v_format = ((enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)__Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(values[1])); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 72, __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(1, 71, __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_14get_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_14get_data_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, uint32_t __pyx_v_oid, enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat __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(1, 71, __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":81
 *             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_17__getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_name); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_17__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_16__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_16__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":82
 * 
 *     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(1, 82, __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(1, 82, __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(1, 82, __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":83
 *     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":84
 *         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(1, 84, __pyx_L4_error)
        }
        __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_self->_settings, __pyx_v_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 84, __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":83
 *     def __getattr__(self, name):
 *         if not name.startswith('_'):
 *             try:             # <<<<<<<<<<<<<<
 *                 return self._settings[name]
 *             except KeyError:
 */
      }
      __pyx_L4_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "asyncpg/protocol/settings.pyx":85
 *             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(1, 85, __pyx_L6_except_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GOTREF(__pyx_t_9);

        /* "asyncpg/protocol/settings.pyx":86
 *                 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(1, 86, __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(1, 86, __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(1, 86, __pyx_L6_except_error)
      }
      goto __pyx_L6_except_error;
      __pyx_L6_except_error:;

      /* "asyncpg/protocol/settings.pyx":83
 *     def __getattr__(self, name):
 *         if not name.startswith('_'):
 *             try:             # <<<<<<<<<<<<<<
 *                 return self._settings[name]
 *             except KeyError:
 */
      __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_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":82
 * 
 *     def __getattr__(self, name):
 *         if not name.startswith('_'):             # <<<<<<<<<<<<<<
 *             try:
 *                 return self._settings[name]
 */
  }

  /* "asyncpg/protocol/settings.pyx":88
 *                 raise AttributeError(name) from None
 * 
 *         return object.__getattr__(self, name)             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_builtin_object, __pyx_n_s_getattr); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 88, __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(1, 88, __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(1, 88, __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(1, 88, __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(1, 88, __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":81
 *             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/settings.pyx":90
 *         return object.__getattr__(self, name)
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return '<ConnectionSettings {!r}>'.format(self._settings)
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_19__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_19__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_18__repr__(((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_18__repr__(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__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("__repr__", 0);

  /* "asyncpg/protocol/settings.pyx":91
 * 
 *     def __repr__(self):
 *         return '<ConnectionSettings {!r}>'.format(self._settings)             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_ConnectionSettings_r, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 91, __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->_settings); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 91, __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->_settings};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 91, __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->_settings};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 91, __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, 91, __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->_settings);
      __Pyx_GIVEREF(__pyx_v_self->_settings);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self->_settings);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 91, __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_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "asyncpg/protocol/settings.pyx":90
 *         return object.__getattr__(self, name)
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return '<ConnectionSettings {!r}>'.format(self._settings)
 */

  /* 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.ConnectionSettings.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_21__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_21__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_20__reduce_cython__(((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_20__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __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, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.ConnectionSettings.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_23__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_23__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_22__setstate_cython__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_18ConnectionSettings_22__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __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, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.ConnectionSettings.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __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(3, 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(const 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 const *__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(const 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(3, 26, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7asyncpg_8protocol_8protocol_Memory)))) __PYX_ERR(3, 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(const 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;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.buf, self.length, self.owner)
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_6Memory_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_6Memory_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_6Memory___reduce_cython__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_6Memory___reduce_cython__(struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *__pyx_v_self) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = NULL;
  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;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     cdef bint use_setstate
 *     state = (self.buf, self.length, self.owner)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->length); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 3, __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_INCREF(__pyx_v_self->owner);
  __Pyx_GIVEREF(__pyx_v_self->owner);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_self->owner);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "(tree fragment)":4
 *     cdef bint use_setstate
 *     state = (self.buf, self.length, self.owner)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_3 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v__dict = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":5
 *     state = (self.buf, self.length, self.owner)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_4 = (__pyx_v__dict != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "(tree fragment)":6
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v__dict);
    __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "(tree fragment)":7
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.owner is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":5
 *     state = (self.buf, self.length, self.owner)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         use_setstate = True
 *     else:
 *         use_setstate = self.owner is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_Memory, (type(self), 0xe0abff4, None), state
 */
  /*else*/ {
    __pyx_t_5 = (__pyx_v_self->owner != Py_None);
    __pyx_v_use_setstate = __pyx_t_5;
  }
  __pyx_L3:;

  /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.owner is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Memory, (type(self), 0xe0abff4, None), state
 *     else:
 */
  __pyx_t_5 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_5) {

    /* "(tree fragment)":11
 *         use_setstate = self.owner is not None
 *     if use_setstate:
 *         return __pyx_unpickle_Memory, (type(self), 0xe0abff4, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_Memory, (type(self), 0xe0abff4, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_Memory); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_235585524);
    __Pyx_GIVEREF(__pyx_int_235585524);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_235585524);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_3, 2, Py_None);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.owner is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Memory, (type(self), 0xe0abff4, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         return __pyx_unpickle_Memory, (type(self), 0xe0abff4, None), state
 *     else:
 *         return __pyx_unpickle_Memory, (type(self), 0xe0abff4, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Memory__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_Memory); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_235585524);
    __Pyx_GIVEREF(__pyx_int_235585524);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_235585524);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_state);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.buf, self.length, self.owner)
 */

  /* 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.Memory.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_Memory, (type(self), 0xe0abff4, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Memory__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_6Memory_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_6Memory_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_6Memory_2__setstate_cython__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_6Memory_2__setstate_cython__(struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":15
 *         return __pyx_unpickle_Memory, (type(self), 0xe0abff4, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Memory__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol___pyx_unpickle_Memory__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_Memory, (type(self), 0xe0abff4, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Memory__set_state(self, __pyx_state)
 */

  /* 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.Memory.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__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__7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 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(3, 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, 1, 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 == ((int)-1))) __PYX_ERR(3, 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(3, 68, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 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(3, 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(3, 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(3, 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(3, 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(3, 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(3, 112, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 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(3, 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(3, 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(3, 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(3, 124, __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(3, 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(3, 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(3, 127, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 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(3, 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(3, 129, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 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(3, 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
 * 
 */
  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(3, 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(3, 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(3, 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(3, 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 == ((int)-1))) __PYX_ERR(3, 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(3, 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 == ((int)-1))) __PYX_ERR(3, 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(3, 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, const 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(3, 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(3, 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(3, 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(3, 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(3, 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(3, 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(3, 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(3, 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, const 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 const *__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, const 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(3, 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, const 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(3, 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, const 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(3, 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(3, 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
 * 
 */
  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(3, 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(3, 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
 * 
 */
  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(3, 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(3, 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
 * 
 */
  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(3, 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(3, 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
 * 
 */
  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(3, 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(3, 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
 * 
 */
  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(3, 217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7asyncpg_8protocol_8protocol_WriteBuffer)))) __PYX_ERR(3, 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(3, 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(3, 224, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7asyncpg_8protocol_8protocol_WriteBuffer)))) __PYX_ERR(3, 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;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_11WriteBuffer_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_11WriteBuffer_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_11WriteBuffer_8__reduce_cython__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_11WriteBuffer_8__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __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, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.WriteBuffer.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_11WriteBuffer_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_11WriteBuffer_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_11WriteBuffer_10__setstate_cython__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_11WriteBuffer_10__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __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, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.WriteBuffer.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__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(3, 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(3, 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(3, 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(3, 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(3, 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(3, 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(3, 255, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 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(3, 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(3, 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(3, 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(3, 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(3, 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(3, 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(3, 275, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 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(3, 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(3, 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(3, 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(3, 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(3, 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(3, 291, __pyx_L1_error)
  }
  __pyx_t_4 = PyBytes_GET_SIZE(__pyx_t_2); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(3, 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__17, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 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(3, 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 const char* _try_read_bytes(self, ssize_t nbytes):             # <<<<<<<<<<<<<<
 *         # Try to read *nbytes* from the first buffer.
 *         #
 */

static CYTHON_INLINE char const *__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 const *__pyx_v_result;
  char const *__pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("_try_read_bytes", 0);

  /* "asyncpg/protocol/buffer.pyx":310
 *             const 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":311
 * 
 *         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":312
 *         if ASYNCPG_DEBUG:
 *             if nbytes > self._length:
 *                 return NULL             # <<<<<<<<<<<<<<
 * 
 *         if self._current_message_ready:
 */
      __pyx_r = NULL;
      goto __pyx_L0;

      /* "asyncpg/protocol/buffer.pyx":311
 * 
 *         if ASYNCPG_DEBUG:
 *             if nbytes > self._length:             # <<<<<<<<<<<<<<
 *                 return NULL
 * 
 */
    }

    /* "asyncpg/protocol/buffer.pyx":310
 *             const char *result
 * 
 *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
 *             if nbytes > self._length:
 *                 return NULL
 */
  }

  /* "asyncpg/protocol/buffer.pyx":314
 *                 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":315
 * 
 *         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":316
 *         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":315
 * 
 *         if self._current_message_ready:
 *             if self._current_message_len_unread < nbytes:             # <<<<<<<<<<<<<<
 *                 return NULL
 * 
 */
    }

    /* "asyncpg/protocol/buffer.pyx":314
 *                 return NULL
 * 
 *         if self._current_message_ready:             # <<<<<<<<<<<<<<
 *             if self._current_message_len_unread < nbytes:
 *                 return NULL
 */
  }

  /* "asyncpg/protocol/buffer.pyx":318
 *                 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":319
 * 
 *         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":320
 *         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":321
 *             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":322
 *             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":323
 *             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":324
 *             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":323
 *             self._pos0 += nbytes
 *             self._length -= nbytes
 *             if self._current_message_ready:             # <<<<<<<<<<<<<<
 *                 self._current_message_len_unread -= nbytes
 *             return result
 */
    }

    /* "asyncpg/protocol/buffer.pyx":325
 *             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":318
 *                 return NULL
 * 
 *         if self._pos0 + nbytes <= self._len0:             # <<<<<<<<<<<<<<
 *             result = cpython.PyBytes_AS_STRING(self._buf0)
 *             result += self._pos0
 */
  }

  /* "asyncpg/protocol/buffer.pyx":327
 *             return result
 *         else:
 *             return NULL             # <<<<<<<<<<<<<<
 * 
 *     cdef inline _read(self, char *buf, ssize_t nbytes):
 */
  /*else*/ {
    __pyx_r = NULL;
    goto __pyx_L0;
  }

  /* "asyncpg/protocol/buffer.pyx":298
 *                     'debug: second buffer of ReadBuffer is empty')
 * 
 *     cdef inline const char* _try_read_bytes(self, ssize_t nbytes):             # <<<<<<<<<<<<<<
 *         # Try to read *nbytes* from the first buffer.
 *         #
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/buffer.pyx":329
 *             return NULL
 * 
 *     cdef inline _read(self, char *buf, ssize_t nbytes):             # <<<<<<<<<<<<<<
 *         cdef:
 *             ssize_t nread
 */

static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__read(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self, char *__pyx_v_buf, Py_ssize_t __pyx_v_nbytes) {
  Py_ssize_t __pyx_v_nread;
  char *__pyx_v_buf0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  __Pyx_RefNannySetupContext("_read", 0);

  /* "asyncpg/protocol/buffer.pyx":334
 *             char *buf0
 * 
 *         while True:             # <<<<<<<<<<<<<<
 *             buf0 = cpython.PyBytes_AS_STRING(self._buf0)
 * 
 */
  while (1) {

    /* "asyncpg/protocol/buffer.pyx":335
 * 
 *         while True:
 *             buf0 = cpython.PyBytes_AS_STRING(self._buf0)             # <<<<<<<<<<<<<<
 * 
 *             if self._pos0 + nbytes > self._len0:
 */
    __pyx_t_1 = __pyx_v_self->_buf0;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_v_buf0 = PyBytes_AS_STRING(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/buffer.pyx":337
 *             buf0 = cpython.PyBytes_AS_STRING(self._buf0)
 * 
 *             if self._pos0 + nbytes > self._len0:             # <<<<<<<<<<<<<<
 *                 nread = self._len0 - self._pos0
 *                 memcpy(buf, buf0 + self._pos0, <size_t>nread)
 */
    __pyx_t_2 = (((__pyx_v_self->_pos0 + __pyx_v_nbytes) > __pyx_v_self->_len0) != 0);
    if (__pyx_t_2) {

      /* "asyncpg/protocol/buffer.pyx":338
 * 
 *             if self._pos0 + nbytes > self._len0:
 *                 nread = self._len0 - self._pos0             # <<<<<<<<<<<<<<
 *                 memcpy(buf, buf0 + self._pos0, <size_t>nread)
 *                 self._pos0 = self._len0
 */
      __pyx_v_nread = (__pyx_v_self->_len0 - __pyx_v_self->_pos0);

      /* "asyncpg/protocol/buffer.pyx":339
 *             if self._pos0 + nbytes > self._len0:
 *                 nread = self._len0 - self._pos0
 *                 memcpy(buf, buf0 + self._pos0, <size_t>nread)             # <<<<<<<<<<<<<<
 *                 self._pos0 = self._len0
 *                 self._length -= nread
 */
      memcpy(__pyx_v_buf, (__pyx_v_buf0 + __pyx_v_self->_pos0), ((size_t)__pyx_v_nread));

      /* "asyncpg/protocol/buffer.pyx":340
 *                 nread = self._len0 - self._pos0
 *                 memcpy(buf, buf0 + self._pos0, <size_t>nread)
 *                 self._pos0 = self._len0             # <<<<<<<<<<<<<<
 *                 self._length -= nread
 *                 nbytes -= nread
 */
      __pyx_t_3 = __pyx_v_self->_len0;
      __pyx_v_self->_pos0 = __pyx_t_3;

      /* "asyncpg/protocol/buffer.pyx":341
 *                 memcpy(buf, buf0 + self._pos0, <size_t>nread)
 *                 self._pos0 = self._len0
 *                 self._length -= nread             # <<<<<<<<<<<<<<
 *                 nbytes -= nread
 *                 buf += nread
 */
      __pyx_v_self->_length = (__pyx_v_self->_length - __pyx_v_nread);

      /* "asyncpg/protocol/buffer.pyx":342
 *                 self._pos0 = self._len0
 *                 self._length -= nread
 *                 nbytes -= nread             # <<<<<<<<<<<<<<
 *                 buf += nread
 *                 self._ensure_first_buf()
 */
      __pyx_v_nbytes = (__pyx_v_nbytes - __pyx_v_nread);

      /* "asyncpg/protocol/buffer.pyx":343
 *                 self._length -= nread
 *                 nbytes -= nread
 *                 buf += nread             # <<<<<<<<<<<<<<
 *                 self._ensure_first_buf()
 * 
 */
      __pyx_v_buf = (__pyx_v_buf + __pyx_v_nread);

      /* "asyncpg/protocol/buffer.pyx":344
 *                 nbytes -= nread
 *                 buf += 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(3, 344, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "asyncpg/protocol/buffer.pyx":337
 *             buf0 = cpython.PyBytes_AS_STRING(self._buf0)
 * 
 *             if self._pos0 + nbytes > self._len0:             # <<<<<<<<<<<<<<
 *                 nread = self._len0 - self._pos0
 *                 memcpy(buf, buf0 + self._pos0, <size_t>nread)
 */
      goto __pyx_L5;
    }

    /* "asyncpg/protocol/buffer.pyx":347
 * 
 *             else:
 *                 memcpy(buf, buf0 + self._pos0, <size_t>nbytes)             # <<<<<<<<<<<<<<
 *                 self._pos0 += nbytes
 *                 self._length -= nbytes
 */
    /*else*/ {
      memcpy(__pyx_v_buf, (__pyx_v_buf0 + __pyx_v_self->_pos0), ((size_t)__pyx_v_nbytes));

      /* "asyncpg/protocol/buffer.pyx":348
 *             else:
 *                 memcpy(buf, buf0 + self._pos0, <size_t>nbytes)
 *                 self._pos0 += nbytes             # <<<<<<<<<<<<<<
 *                 self._length -= nbytes
 *                 break
 */
      __pyx_v_self->_pos0 = (__pyx_v_self->_pos0 + __pyx_v_nbytes);

      /* "asyncpg/protocol/buffer.pyx":349
 *                 memcpy(buf, buf0 + self._pos0, <size_t>nbytes)
 *                 self._pos0 += nbytes
 *                 self._length -= nbytes             # <<<<<<<<<<<<<<
 *                 break
 * 
 */
      __pyx_v_self->_length = (__pyx_v_self->_length - __pyx_v_nbytes);

      /* "asyncpg/protocol/buffer.pyx":350
 *                 self._pos0 += nbytes
 *                 self._length -= nbytes
 *                 break             # <<<<<<<<<<<<<<
 * 
 *     cdef read(self, ssize_t nbytes):
 */
      goto __pyx_L4_break;
    }
    __pyx_L5:;
  }
  __pyx_L4_break:;

  /* "asyncpg/protocol/buffer.pyx":329
 *             return NULL
 * 
 *     cdef inline _read(self, char *buf, ssize_t nbytes):             # <<<<<<<<<<<<<<
 *         cdef:
 *             ssize_t nread
 */

  /* 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.ReadBuffer._read", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/buffer.pyx":352
 *                 break
 * 
 *     cdef read(self, ssize_t nbytes):             # <<<<<<<<<<<<<<
 *         cdef:
 *             bytearray result
 */

static 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;
  char const *__pyx_v_cbuf;
  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;
  __Pyx_RefNannySetupContext("read", 0);

  /* "asyncpg/protocol/buffer.pyx":359
 *             char *buf
 * 
 *         self._ensure_first_buf()             # <<<<<<<<<<<<<<
 *         cbuf = self._try_read_bytes(nbytes)
 *         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(3, 359, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/buffer.pyx":360
 * 
 *         self._ensure_first_buf()
 *         cbuf = self._try_read_bytes(nbytes)             # <<<<<<<<<<<<<<
 *         if cbuf != NULL:
 *             return Memory.new(cbuf, self._buf0, nbytes)
 */
  __pyx_v_cbuf = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__try_read_bytes(__pyx_v_self, __pyx_v_nbytes);

  /* "asyncpg/protocol/buffer.pyx":361
 *         self._ensure_first_buf()
 *         cbuf = self._try_read_bytes(nbytes)
 *         if cbuf != NULL:             # <<<<<<<<<<<<<<
 *             return Memory.new(cbuf, self._buf0, nbytes)
 * 
 */
  __pyx_t_2 = ((__pyx_v_cbuf != NULL) != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/buffer.pyx":362
 *         cbuf = self._try_read_bytes(nbytes)
 *         if cbuf != NULL:
 *             return Memory.new(cbuf, 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_cbuf, __pyx_t_1, __pyx_v_nbytes)); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 362, __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":361
 *         self._ensure_first_buf()
 *         cbuf = self._try_read_bytes(nbytes)
 *         if cbuf != NULL:             # <<<<<<<<<<<<<<
 *             return Memory.new(cbuf, self._buf0, nbytes)
 * 
 */
  }

  /* "asyncpg/protocol/buffer.pyx":364
 *             return Memory.new(cbuf, 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":365
 * 
 *         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(3, 365, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);

    /* "asyncpg/protocol/buffer.pyx":366
 *         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(3, 366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_nbytes); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 366, __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, 366, __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, 366, __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, 366, __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, 366, __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, 366, __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(3, 365, __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(3, 365, __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(3, 365, __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(3, 365, __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(3, 365, __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(3, 365, __pyx_L1_error)

    /* "asyncpg/protocol/buffer.pyx":364
 *             return Memory.new(cbuf, self._buf0, nbytes)
 * 
 *         if nbytes > self._length:             # <<<<<<<<<<<<<<
 *             raise BufferError(
 *                 'not enough data to read {} bytes'.format(nbytes))
 */
  }

  /* "asyncpg/protocol/buffer.pyx":368
 *                 '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":369
 * 
 *         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":370
 *         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":371
 *             self._current_message_len_unread -= nbytes
 *             if self._current_message_len_unread < 0:
 *                 raise BufferError('buffer overread')             # <<<<<<<<<<<<<<
 * 
 *         result = PyByteArray_FromStringAndSize(NULL, nbytes)
 */
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_BufferError); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 371, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 371, __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(3, 371, __pyx_L1_error)

      /* "asyncpg/protocol/buffer.pyx":370
 *         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":368
 *                 '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":373
 *                 raise BufferError('buffer overread')
 * 
 *         result = PyByteArray_FromStringAndSize(NULL, nbytes)             # <<<<<<<<<<<<<<
 *         buf = PyByteArray_AsString(result)
 *         self._read(buf, nbytes)
 */
  __pyx_t_1 = PyByteArray_FromStringAndSize(NULL, __pyx_v_nbytes); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 373, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyByteArray_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(3, 373, __pyx_L1_error)
  __pyx_v_result = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "asyncpg/protocol/buffer.pyx":374
 * 
 *         result = PyByteArray_FromStringAndSize(NULL, nbytes)
 *         buf = PyByteArray_AsString(result)             # <<<<<<<<<<<<<<
 *         self._read(buf, nbytes)
 * 
 */
  __pyx_v_buf = PyByteArray_AsString(__pyx_v_result);

  /* "asyncpg/protocol/buffer.pyx":375
 *         result = PyByteArray_FromStringAndSize(NULL, nbytes)
 *         buf = PyByteArray_AsString(result)
 *         self._read(buf, nbytes)             # <<<<<<<<<<<<<<
 * 
 *         return Memory.new(buf, result, nbytes)
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__read(__pyx_v_self, __pyx_v_buf, __pyx_v_nbytes); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/buffer.pyx":377
 *         self._read(buf, nbytes)
 * 
 *         return Memory.new(buf, result, nbytes)             # <<<<<<<<<<<<<<
 * 
 *     cdef inline read_byte(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_6Memory_new(__pyx_v_buf, __pyx_v_result, __pyx_v_nbytes)); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "asyncpg/protocol/buffer.pyx":352
 *                 break
 * 
 *     cdef read(self, ssize_t nbytes):             # <<<<<<<<<<<<<<
 *         cdef:
 *             bytearray result
 */

  /* 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.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":379
 *         return Memory.new(buf, result, nbytes)
 * 
 *     cdef inline read_byte(self):             # <<<<<<<<<<<<<<
 *         cdef const 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 const *__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":382
 *         cdef const 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":383
 * 
 *         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":384
 *         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__19, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 384, __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(3, 384, __pyx_L1_error)

      /* "asyncpg/protocol/buffer.pyx":383
 * 
 *         if ASYNCPG_DEBUG:
 *             if not self._buf0:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(
 *                     'debug: first buffer of ReadBuffer is empty')
 */
    }

    /* "asyncpg/protocol/buffer.pyx":382
 *         cdef const char *first_byte
 * 
 *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
 *             if not self._buf0:
 *                 raise RuntimeError(
 */
  }

  /* "asyncpg/protocol/buffer.pyx":387
 *                     '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(3, 387, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/buffer.pyx":388
 * 
 *         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":389
 *         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":390
 *         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(3, 390, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 390, __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(3, 390, __pyx_L1_error)

    /* "asyncpg/protocol/buffer.pyx":389
 *         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":392
 *             raise BufferError('not enough data to read one byte')
 * 
 *         return first_byte[0]             # <<<<<<<<<<<<<<
 * 
 *     cdef inline const char* read_bytes(self, ssize_t n) except NULL:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __Pyx_PyInt_From_char((__pyx_v_first_byte[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 392, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "asyncpg/protocol/buffer.pyx":379
 *         return Memory.new(buf, result, nbytes)
 * 
 *     cdef inline read_byte(self):             # <<<<<<<<<<<<<<
 *         cdef const 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":394
 *         return first_byte[0]
 * 
 *     cdef inline const char* read_bytes(self, ssize_t n) except NULL:             # <<<<<<<<<<<<<<
 *         cdef:
 *             Memory mem
 */

static CYTHON_INLINE char const *__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 const *__pyx_v_cbuf;
  char const *__pyx_r;
  __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":399
 *             const 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(3, 399, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/buffer.pyx":400
 * 
 *         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":401
 *         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":402
 *         cbuf = self._try_read_bytes(n)
 *         if cbuf != NULL:
 *             return cbuf             # <<<<<<<<<<<<<<
 *         else:
 *             mem = <Memory>(self.read(n))
 */
    __pyx_r = __pyx_v_cbuf;
    goto __pyx_L0;

    /* "asyncpg/protocol/buffer.pyx":401
 *         self._ensure_first_buf()
 *         cbuf = self._try_read_bytes(n)
 *         if cbuf != NULL:             # <<<<<<<<<<<<<<
 *             return cbuf
 *         else:
 */
  }

  /* "asyncpg/protocol/buffer.pyx":404
 *             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(3, 404, __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":405
 *         else:
 *             mem = <Memory>(self.read(n))
 *             return mem.buf             # <<<<<<<<<<<<<<
 * 
 *     cdef inline read_int32(self):
 */
    __pyx_r = __pyx_v_mem->buf;
    goto __pyx_L0;
  }

  /* "asyncpg/protocol/buffer.pyx":394
 *         return first_byte[0]
 * 
 *     cdef inline const char* read_bytes(self, ssize_t n) except NULL:             # <<<<<<<<<<<<<<
 *         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 = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_mem);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/buffer.pyx":407
 *             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 const *__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":412
 *             const 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(3, 412, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/buffer.pyx":413
 * 
 *         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":414
 *         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":415
 *         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(unpack_int32(__pyx_v_cbuf)); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 415, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "asyncpg/protocol/buffer.pyx":414
 *         self._ensure_first_buf()
 *         cbuf = self._try_read_bytes(4)
 *         if cbuf != NULL:             # <<<<<<<<<<<<<<
 *             return hton.unpack_int32(cbuf)
 *         else:
 */
  }

  /* "asyncpg/protocol/buffer.pyx":417
 *             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(3, 417, __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":418
 *         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(unpack_int32(__pyx_v_mem->buf)); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 418, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "asyncpg/protocol/buffer.pyx":407
 *             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":420
 *             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 const *__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":425
 *             const 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(3, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/buffer.pyx":426
 * 
 *         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":427
 *         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":428
 *         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(unpack_int16(__pyx_v_cbuf)); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 428, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "asyncpg/protocol/buffer.pyx":427
 *         self._ensure_first_buf()
 *         cbuf = self._try_read_bytes(2)
 *         if cbuf != NULL:             # <<<<<<<<<<<<<<
 *             return hton.unpack_int16(cbuf)
 *         else:
 */
  }

  /* "asyncpg/protocol/buffer.pyx":430
 *             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(3, 430, __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":431
 *         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(unpack_int16(__pyx_v_mem->buf)); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 431, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "asyncpg/protocol/buffer.pyx":420
 *             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":433
 *             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 const *__pyx_v_buf;
  char const *__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":434
 * 
 *     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":435
 *     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(3, 435, __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(3, 435, __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(3, 435, __pyx_L1_error)

    /* "asyncpg/protocol/buffer.pyx":434
 * 
 *     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":446
 *             const 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(3, 446, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/buffer.pyx":448
 *         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":449
 * 
 *         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":450
 *         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":451
 *         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":452
 *         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":453
 *             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":454
 *                 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":455
 *                 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":456
 *                 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(3, 456, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_r = __pyx_t_3;
        __pyx_t_3 = 0;
        goto __pyx_L0;

        /* "asyncpg/protocol/buffer.pyx":455
 *                 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":458
 *                     return cpython.PyBytes_FromStringAndSize(buf, nread)
 *                 else:
 *                     break             # <<<<<<<<<<<<<<
 *             else:
 *                 buf += 1
 */
      /*else*/ {
        goto __pyx_L5_break;
      }

      /* "asyncpg/protocol/buffer.pyx":451
 *         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":460
 *                     break
 *             else:
 *                 buf += 1             # <<<<<<<<<<<<<<
 * 
 *         result = b''
 */
    /*else*/ {
      __pyx_v_buf = (__pyx_v_buf + 1);
    }
  }
  __pyx_L5_break:;

  /* "asyncpg/protocol/buffer.pyx":462
 *                 buf += 1
 * 
 *         result = b''             # <<<<<<<<<<<<<<
 *         while True:
 *             pos = self._buf0.find(b'\x00', self._pos0)
 */
  __Pyx_INCREF(__pyx_kp_b__22);
  __pyx_v_result = __pyx_kp_b__22;

  /* "asyncpg/protocol/buffer.pyx":463
 * 
 *         result = b''
 *         while True:             # <<<<<<<<<<<<<<
 *             pos = self._buf0.find(b'\x00', self._pos0)
 *             if pos >= 0:
 */
  while (1) {

    /* "asyncpg/protocol/buffer.pyx":464
 *         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(3, 464, __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(3, 464, __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__23, __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(3, 464, __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__23, __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(3, 464, __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(3, 464, __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__23);
      __Pyx_GIVEREF(__pyx_kp_b__23);
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_kp_b__23);
      __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(3, 464, __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(3, 464, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_pos = __pyx_t_8;

    /* "asyncpg/protocol/buffer.pyx":465
 *         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":466
 *             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(3, 466, __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(3, 466, __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(3, 466, __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":467
 *             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":468
 *                 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":469
 *                 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":471
 *                 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":472
 * 
 *                 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":473
 *                 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(3, 473, __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(3, 473, __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(3, 473, __pyx_L1_error)

        /* "asyncpg/protocol/buffer.pyx":472
 * 
 *                 self._current_message_len_unread -= nread
 *                 if self._current_message_len_unread < 0:             # <<<<<<<<<<<<<<
 *                     raise BufferError('read_cstr: buffer overread')
 * 
 */
      }

      /* "asyncpg/protocol/buffer.pyx":475
 *                     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":465
 *         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":478
 * 
 *             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(3, 478, __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(3, 478, __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(3, 478, __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":479
 *             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":480
 *                 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":481
 *                 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":483
 *                 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":484
 * 
 *                 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":485
 *                 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(3, 485, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 485, __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(3, 485, __pyx_L1_error)

        /* "asyncpg/protocol/buffer.pyx":484
 * 
 *                 self._current_message_len_unread -= nread
 *                 if self._current_message_len_unread < 0:             # <<<<<<<<<<<<<<
 *                     raise BufferError('read_cstr: buffer overread')
 * 
 */
      }

      /* "asyncpg/protocol/buffer.pyx":487
 *                     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(3, 487, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
  }

  /* "asyncpg/protocol/buffer.pyx":433
 *             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":489
 *                 self._ensure_first_buf()
 * 
 *     cdef int32_t has_message(self) except -1:             # <<<<<<<<<<<<<<
 *         cdef:
 *             const char *cbuf
 */

static int32_t __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_has_message(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self) {
  char const *__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":493
 *             const 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":494
 * 
 *         if self._current_message_ready:
 *             return 1             # <<<<<<<<<<<<<<
 * 
 *         if self._current_message_type == 0:
 */
    __pyx_r = 1;
    goto __pyx_L0;

    /* "asyncpg/protocol/buffer.pyx":493
 *             const char *cbuf
 * 
 *         if self._current_message_ready:             # <<<<<<<<<<<<<<
 *             return 1
 * 
 */
  }

  /* "asyncpg/protocol/buffer.pyx":496
 *             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":497
 * 
 *         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":498
 *         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":497
 * 
 *         if self._current_message_type == 0:
 *             if self._length < 1:             # <<<<<<<<<<<<<<
 *                 return 0
 *             self._ensure_first_buf()
 */
    }

    /* "asyncpg/protocol/buffer.pyx":499
 *             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(3, 499, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "asyncpg/protocol/buffer.pyx":500
 *                 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":501
 *             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":502
 *             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(3, 502, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 502, __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(3, 502, __pyx_L1_error)

      /* "asyncpg/protocol/buffer.pyx":501
 *             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":504
 *                 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":496
 *             return 1
 * 
 *         if self._current_message_type == 0:             # <<<<<<<<<<<<<<
 *             if self._length < 1:
 *                 return 0
 */
  }

  /* "asyncpg/protocol/buffer.pyx":506
 *             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":507
 * 
 *         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":508
 *         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":507
 * 
 *         if self._current_message_len == 0:
 *             if self._length < 4:             # <<<<<<<<<<<<<<
 *                 return 0
 * 
 */
    }

    /* "asyncpg/protocol/buffer.pyx":510
 *                 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(3, 510, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "asyncpg/protocol/buffer.pyx":511
 * 
 *             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":512
 *             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":513
 *             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 = unpack_int32(__pyx_v_cbuf);

      /* "asyncpg/protocol/buffer.pyx":512
 *             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":515
 *                 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(3, 515, __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(3, 515, __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":517
 *                 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":506
 *             self._current_message_type = cbuf[0]
 * 
 *         if self._current_message_len == 0:             # <<<<<<<<<<<<<<
 *             if self._length < 4:
 *                 return 0
 */
  }

  /* "asyncpg/protocol/buffer.pyx":519
 *             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":520
 * 
 *         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":519
 *             self._current_message_len_unread = self._current_message_len - 4
 * 
 *         if self._length < self._current_message_len_unread:             # <<<<<<<<<<<<<<
 *             return 0
 * 
 */
  }

  /* "asyncpg/protocol/buffer.pyx":522
 *             return 0
 * 
 *         self._current_message_ready = 1             # <<<<<<<<<<<<<<
 *         return 1
 * 
 */
  __pyx_v_self->_current_message_ready = 1;

  /* "asyncpg/protocol/buffer.pyx":523
 * 
 *         self._current_message_ready = 1
 *         return 1             # <<<<<<<<<<<<<<
 * 
 *     cdef inline int32_t has_message_type(self, char mtype) except -1:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "asyncpg/protocol/buffer.pyx":489
 *                 self._ensure_first_buf()
 * 
 *     cdef int32_t has_message(self) except -1:             # <<<<<<<<<<<<<<
 *         cdef:
 *             const 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":525
 *         return 1
 * 
 *     cdef inline int32_t has_message_type(self, char mtype) except -1:             # <<<<<<<<<<<<<<
 *         return self.has_message() and self.get_message_type() == mtype
 * 
 */

static CYTHON_INLINE int32_t __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_has_message_type(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self, char __pyx_v_mtype) {
  int32_t __pyx_r;
  __Pyx_RefNannyDeclarations
  int32_t __pyx_t_1;
  int32_t __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("has_message_type", 0);

  /* "asyncpg/protocol/buffer.pyx":526
 * 
 *     cdef inline int32_t has_message_type(self, char mtype) except -1:
 *         return self.has_message() and self.get_message_type() == mtype             # <<<<<<<<<<<<<<
 * 
 *     cdef inline const char* try_consume_message(self, ssize_t* len):
 */
  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_has_message(__pyx_v_self); if (unlikely(__pyx_t_2 == ((int32_t)-1))) __PYX_ERR(3, 526, __pyx_L1_error)
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L3_bool_binop_done;
  }
  __pyx_t_3 = (__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_get_message_type(__pyx_v_self) == __pyx_v_mtype);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L3_bool_binop_done:;
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  /* "asyncpg/protocol/buffer.pyx":525
 *         return 1
 * 
 *     cdef inline int32_t has_message_type(self, char mtype) except -1:             # <<<<<<<<<<<<<<
 *         return self.has_message() and self.get_message_type() == mtype
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("asyncpg.protocol.protocol.ReadBuffer.has_message_type", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/buffer.pyx":528
 *         return self.has_message() and self.get_message_type() == mtype
 * 
 *     cdef inline const char* try_consume_message(self, ssize_t* len):             # <<<<<<<<<<<<<<
 *         cdef:
 *             ssize_t buf_len
 */

static CYTHON_INLINE char const *__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 const *__pyx_v_buf;
  char const *__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":533
 *             const char *buf
 * 
 *         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":534
 * 
 *         if not self._current_message_ready:
 *             return NULL             # <<<<<<<<<<<<<<
 * 
 *         self._ensure_first_buf()
 */
    __pyx_r = NULL;
    goto __pyx_L0;

    /* "asyncpg/protocol/buffer.pyx":533
 *             const char *buf
 * 
 *         if not self._current_message_ready:             # <<<<<<<<<<<<<<
 *             return NULL
 * 
 */
  }

  /* "asyncpg/protocol/buffer.pyx":536
 *             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(3, 536, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/buffer.pyx":537
 * 
 *         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":538
 *         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":539
 *         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":540
 *         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":541
 *         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(3, 541, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "asyncpg/protocol/buffer.pyx":539
 *         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":542
 *             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":528
 *         return self.has_message() and self.get_message_type() == mtype
 * 
 *     cdef inline const 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, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/buffer.pyx":544
 *         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":545
 * 
 *     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":546
 *     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(3, 546, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__27, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 546, __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(3, 546, __pyx_L1_error)

    /* "asyncpg/protocol/buffer.pyx":545
 * 
 *     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":547
 *         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":548
 *             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(3, 548, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_mem = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "asyncpg/protocol/buffer.pyx":547
 *         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":550
 *             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":551
 *         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(3, 551, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/buffer.pyx":552
 *             mem = None
 *         self._discard_message()
 *         return mem             # <<<<<<<<<<<<<<
 * 
 *     cdef bytearray consume_messages(self, char mtype):
 */
  __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(3, 552, __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":544
 *         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":554
 *         return mem
 * 
 *     cdef bytearray consume_messages(self, char mtype):             # <<<<<<<<<<<<<<
 *         """Consume consecutive messages of the same type."""
 *         cdef:
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_messages(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self, char __pyx_v_mtype) {
  char *__pyx_v_buf;
  Py_ssize_t __pyx_v_nbytes;
  Py_ssize_t __pyx_v_total_bytes;
  PyObject *__pyx_v_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int32_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  __Pyx_RefNannySetupContext("consume_messages", 0);

  /* "asyncpg/protocol/buffer.pyx":559
 *             char *buf
 *             ssize_t nbytes
 *             ssize_t total_bytes = 0             # <<<<<<<<<<<<<<
 *             bytearray result
 * 
 */
  __pyx_v_total_bytes = 0;

  /* "asyncpg/protocol/buffer.pyx":562
 *             bytearray result
 * 
 *         if not self.has_message_type(mtype):             # <<<<<<<<<<<<<<
 *             return None
 * 
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_has_message_type(__pyx_v_self, __pyx_v_mtype); if (unlikely(__pyx_t_1 == ((int32_t)-1))) __PYX_ERR(3, 562, __pyx_L1_error)
  __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/buffer.pyx":563
 * 
 *         if not self.has_message_type(mtype):
 *             return None             # <<<<<<<<<<<<<<
 * 
 *         # consume_messages is a volume-oriented method, so
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = ((PyObject*)Py_None);
    goto __pyx_L0;

    /* "asyncpg/protocol/buffer.pyx":562
 *             bytearray result
 * 
 *         if not self.has_message_type(mtype):             # <<<<<<<<<<<<<<
 *             return None
 * 
 */
  }

  /* "asyncpg/protocol/buffer.pyx":568
 *         # we assume that the remainder of the buffer will contain
 *         # messages of the requested type.
 *         result = PyByteArray_FromStringAndSize(NULL, self._length)             # <<<<<<<<<<<<<<
 *         buf = PyByteArray_AsString(result)
 * 
 */
  __pyx_t_3 = PyByteArray_FromStringAndSize(NULL, __pyx_v_self->_length); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 568, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (!(likely(PyByteArray_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(3, 568, __pyx_L1_error)
  __pyx_v_result = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "asyncpg/protocol/buffer.pyx":569
 *         # messages of the requested type.
 *         result = PyByteArray_FromStringAndSize(NULL, self._length)
 *         buf = PyByteArray_AsString(result)             # <<<<<<<<<<<<<<
 * 
 *         while self.has_message_type(mtype):
 */
  __pyx_v_buf = PyByteArray_AsString(__pyx_v_result);

  /* "asyncpg/protocol/buffer.pyx":571
 *         buf = PyByteArray_AsString(result)
 * 
 *         while self.has_message_type(mtype):             # <<<<<<<<<<<<<<
 *             nbytes = self._current_message_len_unread
 *             self._read(buf, nbytes)
 */
  while (1) {
    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_has_message_type(__pyx_v_self, __pyx_v_mtype); if (unlikely(__pyx_t_1 == ((int32_t)-1))) __PYX_ERR(3, 571, __pyx_L1_error)
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (!__pyx_t_2) break;

    /* "asyncpg/protocol/buffer.pyx":572
 * 
 *         while self.has_message_type(mtype):
 *             nbytes = self._current_message_len_unread             # <<<<<<<<<<<<<<
 *             self._read(buf, nbytes)
 *             buf += nbytes
 */
    __pyx_t_4 = __pyx_v_self->_current_message_len_unread;
    __pyx_v_nbytes = __pyx_t_4;

    /* "asyncpg/protocol/buffer.pyx":573
 *         while self.has_message_type(mtype):
 *             nbytes = self._current_message_len_unread
 *             self._read(buf, nbytes)             # <<<<<<<<<<<<<<
 *             buf += nbytes
 *             total_bytes += nbytes
 */
    __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__read(__pyx_v_self, __pyx_v_buf, __pyx_v_nbytes); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 573, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "asyncpg/protocol/buffer.pyx":574
 *             nbytes = self._current_message_len_unread
 *             self._read(buf, nbytes)
 *             buf += nbytes             # <<<<<<<<<<<<<<
 *             total_bytes += nbytes
 *             self._discard_message()
 */
    __pyx_v_buf = (__pyx_v_buf + __pyx_v_nbytes);

    /* "asyncpg/protocol/buffer.pyx":575
 *             self._read(buf, nbytes)
 *             buf += nbytes
 *             total_bytes += nbytes             # <<<<<<<<<<<<<<
 *             self._discard_message()
 * 
 */
    __pyx_v_total_bytes = (__pyx_v_total_bytes + __pyx_v_nbytes);

    /* "asyncpg/protocol/buffer.pyx":576
 *             buf += nbytes
 *             total_bytes += nbytes
 *             self._discard_message()             # <<<<<<<<<<<<<<
 * 
 *         # Clamp the result to an actual size read.
 */
    __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__discard_message(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 576, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }

  /* "asyncpg/protocol/buffer.pyx":579
 * 
 *         # Clamp the result to an actual size read.
 *         PyByteArray_Resize(result, total_bytes)             # <<<<<<<<<<<<<<
 * 
 *         return result
 */
  PyByteArray_Resize(__pyx_v_result, __pyx_v_total_bytes);

  /* "asyncpg/protocol/buffer.pyx":581
 *         PyByteArray_Resize(result, total_bytes)
 * 
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     cdef discard_message(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "asyncpg/protocol/buffer.pyx":554
 *         return mem
 * 
 *     cdef bytearray consume_messages(self, char mtype):             # <<<<<<<<<<<<<<
 *         """Consume consecutive messages of the same type."""
 *         cdef:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.ReadBuffer.consume_messages", __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":583
 *         return result
 * 
 *     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":584
 * 
 *     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":586
 *         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":584
 * 
 *     cdef discard_message(self):
 *         if self._current_message_type == 0:             # <<<<<<<<<<<<<<
 *             # Already discarded
 *             return
 */
  }

  /* "asyncpg/protocol/buffer.pyx":588
 *             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":589
 * 
 *         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(3, 589, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 589, __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(3, 589, __pyx_L1_error)

    /* "asyncpg/protocol/buffer.pyx":588
 *             return
 * 
 *         if not self._current_message_ready:             # <<<<<<<<<<<<<<
 *             raise BufferError('no message to discard')
 * 
 */
  }

  /* "asyncpg/protocol/buffer.pyx":591
 *             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":592
 * 
 *         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":593
 *         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(3, 593, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 593, __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(3, 593, __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":592
 * 
 *         if self._current_message_len_unread:
 *             if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
 *                 mtype = chr(self._current_message_type)
 * 
 */
    }

    /* "asyncpg/protocol/buffer.pyx":595
 *                 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(3, 595, __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":597
 *             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":598
 * 
 *             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(3, 598, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);

      /* "asyncpg/protocol/buffer.pyx":599
 *             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(3, 599, __pyx_L1_error) }

      /* "asyncpg/protocol/buffer.pyx":600
 *                 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(3, 600, __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(3, 598, __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(3, 598, __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(3, 598, __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(3, 598, __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":598
 * 
 *             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(3, 598, __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(3, 598, __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":597
 *             discarded = self.consume_message()
 * 
 *             if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
 *                 print('!!! discarding message {!r} unread data: {!r}'.format(
 *                     mtype,
 */
    }

    /* "asyncpg/protocol/buffer.pyx":591
 *             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":602
 *                     (<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(3, 602, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/buffer.pyx":583
 *         return result
 * 
 *     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":604
 *         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":605
 * 
 *     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":606
 *     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":607
 *         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":608
 *         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":604
 *         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":610
 *         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":611
 * 
 *     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":610
 *         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":613
 *         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":614
 * 
 *     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":613
 *         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":617
 * 
 *     @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":620
 *         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(3, 620, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7asyncpg_8protocol_8protocol_ReadBuffer)))) __PYX_ERR(3, 620, __pyx_L1_error)
  __pyx_v_buf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "asyncpg/protocol/buffer.pyx":621
 * 
 *         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(3, 621, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/buffer.pyx":623
 *         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":624
 * 
 *         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":626
 *         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":617
 * 
 *     @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;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_10ReadBuffer_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_10ReadBuffer_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_10ReadBuffer_2__reduce_cython__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_10ReadBuffer_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __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, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.ReadBuffer.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_10ReadBuffer_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_10ReadBuffer_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_10ReadBuffer_4__setstate_cython__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_10ReadBuffer_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __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, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.ReadBuffer.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/buffer.pyx":634
 * 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":637
 *         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":638
 * 
 *         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(3, 638, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "asyncpg/protocol/buffer.pyx":637
 *         cdef const char *result
 * 
 *         if n > self.len:             # <<<<<<<<<<<<<<
 *             self._raise_ins_err(n, self.len)
 * 
 */
  }

  /* "asyncpg/protocol/buffer.pyx":640
 *             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":641
 * 
 *         result = self.buf
 *         self.buf += n             # <<<<<<<<<<<<<<
 *         self.len -= n
 * 
 */
  __pyx_v_self->buf = (__pyx_v_self->buf + __pyx_v_n);

  /* "asyncpg/protocol/buffer.pyx":642
 *         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":644
 *         self.len -= n
 * 
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     cdef inline const char* read_all(self):
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "asyncpg/protocol/buffer.pyx":634
 * 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":646
 *         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":648
 *     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":649
 *         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":650
 *         result = self.buf
 *         self.buf += self.len
 *         self.len = 0             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
  __pyx_v_self->len = 0;

  /* "asyncpg/protocol/buffer.pyx":651
 *         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":646
 *         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":653
 *         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":655
 *     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 == ((char const *)NULL))) __PYX_ERR(3, 655, __pyx_L1_error)
  __pyx_v_self->buf = __pyx_t_1;

  /* "asyncpg/protocol/buffer.pyx":656
 *                                           ssize_t len):
 *         self.buf = source.read(len)
 *         self.len = len             # <<<<<<<<<<<<<<
 *         return self
 * 
 */
  __pyx_v_self->len = __pyx_v_len;

  /* "asyncpg/protocol/buffer.pyx":657
 *         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":653
 *         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":659
 *         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":660
 * 
 *     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(3, 660, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "asyncpg/protocol/buffer.pyx":661
 *     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(3, 661, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "asyncpg/protocol/buffer.pyx":662
 *         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(3, 662, __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(3, 662, __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(3, 662, __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(3, 662, __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(3, 662, __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(3, 662, __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(3, 660, __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(3, 660, __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(3, 660, __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(3, 660, __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(3, 660, __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(3, 660, __pyx_L1_error)

  /* "asyncpg/protocol/buffer.pyx":659
 *         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":665
 * 
 *     @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":666
 *     @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(3, 666, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7asyncpg_8protocol_8protocol_FastReadBuffer)))) __PYX_ERR(3, 666, __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":665
 * 
 *     @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;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.buf, self.len)
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_14FastReadBuffer_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_14FastReadBuffer_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_14FastReadBuffer___reduce_cython__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_14FastReadBuffer___reduce_cython__(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_self) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = NULL;
  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;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     cdef bint use_setstate
 *     state = (self.buf, self.len)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->len); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 3, __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_v_state = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":4
 *     cdef bint use_setstate
 *     state = (self.buf, self.len)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_3 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v__dict = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":5
 *     state = (self.buf, self.len)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_4 = (__pyx_v__dict != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "(tree fragment)":6
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v__dict);
    __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "(tree fragment)":7
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = False
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":5
 *     state = (self.buf, self.len)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         use_setstate = True
 *     else:
 *         use_setstate = False             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_FastReadBuffer, (type(self), 0x7ea5e72, None), state
 */
  /*else*/ {
    __pyx_v_use_setstate = 0;
  }
  __pyx_L3:;

  /* "(tree fragment)":10
 *     else:
 *         use_setstate = False
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_FastReadBuffer, (type(self), 0x7ea5e72, None), state
 *     else:
 */
  __pyx_t_5 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_5) {

    /* "(tree fragment)":11
 *         use_setstate = False
 *     if use_setstate:
 *         return __pyx_unpickle_FastReadBuffer, (type(self), 0x7ea5e72, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_FastReadBuffer, (type(self), 0x7ea5e72, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_FastReadBuffer); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_132800114);
    __Pyx_GIVEREF(__pyx_int_132800114);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_132800114);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_3, 2, Py_None);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":10
 *     else:
 *         use_setstate = False
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_FastReadBuffer, (type(self), 0x7ea5e72, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         return __pyx_unpickle_FastReadBuffer, (type(self), 0x7ea5e72, None), state
 *     else:
 *         return __pyx_unpickle_FastReadBuffer, (type(self), 0x7ea5e72, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_FastReadBuffer__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_FastReadBuffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_132800114);
    __Pyx_GIVEREF(__pyx_int_132800114);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_132800114);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_state);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.buf, self.len)
 */

  /* 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.FastReadBuffer.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_FastReadBuffer, (type(self), 0x7ea5e72, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_FastReadBuffer__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_14FastReadBuffer_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_14FastReadBuffer_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_14FastReadBuffer_2__setstate_cython__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_14FastReadBuffer_2__setstate_cython__(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":15
 *         return __pyx_unpickle_FastReadBuffer, (type(self), 0x7ea5e72, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_FastReadBuffer__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol___pyx_unpickle_FastReadBuffer__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_FastReadBuffer, (type(self), 0x7ea5e72, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_FastReadBuffer__set_state(self, __pyx_state)
 */

  /* 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.FastReadBuffer.__setstate_cython__", __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":20
 * 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);
        CYTHON_FALLTHROUGH;
        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(4, 20, __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(4, 20, __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(4, 20, __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":21
 * 
 *     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":22
 *     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":20
 * 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":24
 *         self.type = CODEC_UNDEFINED
 * 
 *     cdef init(self, str name, str schema, str kind,             # <<<<<<<<<<<<<<
 *               CodecType type, ServerDataFormat format,
 *               ClientExchangeFormat xformat,
 */

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_ServerDataFormat __pyx_v_format, enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat __pyx_v_xformat, __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;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("init", 0);

  /* "asyncpg/protocol/codecs/base.pyx":33
 *               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":34
 * 
 *         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":35
 *         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":36
 *         self.schema = schema
 *         self.kind = kind
 *         self.type = type             # <<<<<<<<<<<<<<
 *         self.format = format
 *         self.xformat = xformat
 */
  __pyx_v_self->type = __pyx_v_type;

  /* "asyncpg/protocol/codecs/base.pyx":37
 *         self.kind = kind
 *         self.type = type
 *         self.format = format             # <<<<<<<<<<<<<<
 *         self.xformat = xformat
 *         self.c_encoder = c_encoder
 */
  __pyx_v_self->format = __pyx_v_format;

  /* "asyncpg/protocol/codecs/base.pyx":38
 *         self.type = type
 *         self.format = format
 *         self.xformat = xformat             # <<<<<<<<<<<<<<
 *         self.c_encoder = c_encoder
 *         self.c_decoder = c_decoder
 */
  __pyx_v_self->xformat = __pyx_v_xformat;

  /* "asyncpg/protocol/codecs/base.pyx":39
 *         self.format = format
 *         self.xformat = xformat
 *         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":40
 *         self.xformat = xformat
 *         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":41
 *         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":42
 *         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":43
 *         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":44
 *         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":45
 *         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":46
 *         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":48
 *         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":50
 *         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 = __Pyx_PySequence_Tuple(__pyx_v_element_names); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 50, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);

    /* "asyncpg/protocol/codecs/base.pyx":49
 * 
 *         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(4, 49, __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":48
 *         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":52
 *                 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":54
 *             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":55
 * 
 *         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":56
 *         if type == CODEC_C:
 *             self.encoder = <codec_encode_func>&self.encode_scalar
 *             self.decoder = <codec_decode_func>&self.decode_scalar             # <<<<<<<<<<<<<<
 *         elif type == CODEC_ARRAY:
 *             if format == PG_FORMAT_BINARY:
 */
    __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":54
 *             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":57
 *             self.encoder = <codec_encode_func>&self.encode_scalar
 *             self.decoder = <codec_decode_func>&self.decode_scalar
 *         elif type == CODEC_ARRAY:             # <<<<<<<<<<<<<<
 *             if format == PG_FORMAT_BINARY:
 *                 self.encoder = <codec_encode_func>&self.encode_array
 */
    case __pyx_e_7asyncpg_8protocol_8protocol_CODEC_ARRAY:

    /* "asyncpg/protocol/codecs/base.pyx":58
 *             self.decoder = <codec_decode_func>&self.decode_scalar
 *         elif type == CODEC_ARRAY:
 *             if format == PG_FORMAT_BINARY:             # <<<<<<<<<<<<<<
 *                 self.encoder = <codec_encode_func>&self.encode_array
 *                 self.decoder = <codec_decode_func>&self.decode_array
 */
    __pyx_t_2 = ((__pyx_v_format == __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY) != 0);
    if (__pyx_t_2) {

      /* "asyncpg/protocol/codecs/base.pyx":59
 *         elif type == CODEC_ARRAY:
 *             if format == PG_FORMAT_BINARY:
 *                 self.encoder = <codec_encode_func>&self.encode_array             # <<<<<<<<<<<<<<
 *                 self.decoder = <codec_decode_func>&self.decode_array
 *             else:
 */
      __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":60
 *             if format == PG_FORMAT_BINARY:
 *                 self.encoder = <codec_encode_func>&self.encode_array
 *                 self.decoder = <codec_decode_func>&self.decode_array             # <<<<<<<<<<<<<<
 *             else:
 *                 self.encoder = <codec_encode_func>&self.encode_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":58
 *             self.decoder = <codec_decode_func>&self.decode_scalar
 *         elif type == CODEC_ARRAY:
 *             if format == PG_FORMAT_BINARY:             # <<<<<<<<<<<<<<
 *                 self.encoder = <codec_encode_func>&self.encode_array
 *                 self.decoder = <codec_decode_func>&self.decode_array
 */
      goto __pyx_L4;
    }

    /* "asyncpg/protocol/codecs/base.pyx":62
 *                 self.decoder = <codec_decode_func>&self.decode_array
 *             else:
 *                 self.encoder = <codec_encode_func>&self.encode_array_text             # <<<<<<<<<<<<<<
 *                 self.decoder = <codec_decode_func>&self.decode_array_text
 *         elif type == CODEC_RANGE:
 */
    /*else*/ {
      __pyx_v_self->encoder = ((__pyx_t_7asyncpg_8protocol_8protocol_codec_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_array_text));

      /* "asyncpg/protocol/codecs/base.pyx":63
 *             else:
 *                 self.encoder = <codec_encode_func>&self.encode_array_text
 *                 self.decoder = <codec_decode_func>&self.decode_array_text             # <<<<<<<<<<<<<<
 *         elif type == CODEC_RANGE:
 *             if format != PG_FORMAT_BINARY:
 */
      __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":57
 *             self.encoder = <codec_encode_func>&self.encode_scalar
 *             self.decoder = <codec_decode_func>&self.decode_scalar
 *         elif type == CODEC_ARRAY:             # <<<<<<<<<<<<<<
 *             if format == PG_FORMAT_BINARY:
 *                 self.encoder = <codec_encode_func>&self.encode_array
 */
    break;

    /* "asyncpg/protocol/codecs/base.pyx":64
 *                 self.encoder = <codec_encode_func>&self.encode_array_text
 *                 self.decoder = <codec_decode_func>&self.decode_array_text
 *         elif type == CODEC_RANGE:             # <<<<<<<<<<<<<<
 *             if format != PG_FORMAT_BINARY:
 *                 raise RuntimeError(
 */
    case __pyx_e_7asyncpg_8protocol_8protocol_CODEC_RANGE:

    /* "asyncpg/protocol/codecs/base.pyx":65
 *                 self.decoder = <codec_decode_func>&self.decode_array_text
 *         elif type == CODEC_RANGE:
 *             if format != PG_FORMAT_BINARY:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(
 *                     'cannot encode type "{}"."{}": text encoding of '
 */
    __pyx_t_2 = ((__pyx_v_format != __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY) != 0);
    if (__pyx_t_2) {

      /* "asyncpg/protocol/codecs/base.pyx":68
 *                 raise RuntimeError(
 *                     'cannot encode type "{}"."{}": text encoding of '
 *                     'range types is not supported'.format(schema, name))             # <<<<<<<<<<<<<<
 *             self.encoder = <codec_encode_func>&self.encode_range
 *             self.decoder = <codec_decode_func>&self.decode_range
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_cannot_encode_type_text_encoding, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 68, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __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_v_schema, __pyx_v_name};
        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 68, __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[3] = {__pyx_t_5, __pyx_v_schema, __pyx_v_name};
        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 68, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      {
        __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 68, __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_schema);
        __Pyx_GIVEREF(__pyx_v_schema);
        PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_schema);
        __Pyx_INCREF(__pyx_v_name);
        __Pyx_GIVEREF(__pyx_v_name);
        PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_name);
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 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;

      /* "asyncpg/protocol/codecs/base.pyx":66
 *         elif type == CODEC_RANGE:
 *             if format != PG_FORMAT_BINARY:
 *                 raise RuntimeError(             # <<<<<<<<<<<<<<
 *                     'cannot encode type "{}"."{}": text encoding of '
 *                     'range types is not supported'.format(schema, name))
 */
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 66, __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(4, 66, __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(4, 66, __pyx_L1_error)

      /* "asyncpg/protocol/codecs/base.pyx":65
 *                 self.decoder = <codec_decode_func>&self.decode_array_text
 *         elif type == CODEC_RANGE:
 *             if format != PG_FORMAT_BINARY:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(
 *                     'cannot encode type "{}"."{}": text encoding of '
 */
    }

    /* "asyncpg/protocol/codecs/base.pyx":69
 *                     'cannot encode type "{}"."{}": text encoding of '
 *                     'range types is not supported'.format(schema, name))
 *             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":70
 *                     'range types is not supported'.format(schema, name))
 *             self.encoder = <codec_encode_func>&self.encode_range
 *             self.decoder = <codec_decode_func>&self.decode_range             # <<<<<<<<<<<<<<
 *         elif type == CODEC_COMPOSITE:
 *             if format != PG_FORMAT_BINARY:
 */
    __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":64
 *                 self.encoder = <codec_encode_func>&self.encode_array_text
 *                 self.decoder = <codec_decode_func>&self.decode_array_text
 *         elif type == CODEC_RANGE:             # <<<<<<<<<<<<<<
 *             if format != PG_FORMAT_BINARY:
 *                 raise RuntimeError(
 */
    break;

    /* "asyncpg/protocol/codecs/base.pyx":71
 *             self.encoder = <codec_encode_func>&self.encode_range
 *             self.decoder = <codec_decode_func>&self.decode_range
 *         elif type == CODEC_COMPOSITE:             # <<<<<<<<<<<<<<
 *             if format != PG_FORMAT_BINARY:
 *                 raise RuntimeError(
 */
    case __pyx_e_7asyncpg_8protocol_8protocol_CODEC_COMPOSITE:

    /* "asyncpg/protocol/codecs/base.pyx":72
 *             self.decoder = <codec_decode_func>&self.decode_range
 *         elif type == CODEC_COMPOSITE:
 *             if format != PG_FORMAT_BINARY:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(
 *                     'cannot encode type "{}"."{}": text encoding of '
 */
    __pyx_t_2 = ((__pyx_v_format != __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY) != 0);
    if (__pyx_t_2) {

      /* "asyncpg/protocol/codecs/base.pyx":75
 *                 raise RuntimeError(
 *                     'cannot encode type "{}"."{}": text encoding of '
 *                     'composite types is not supported'.format(schema, name))             # <<<<<<<<<<<<<<
 *             self.encoder = <codec_encode_func>&self.encode_composite
 *             self.decoder = <codec_decode_func>&self.decode_composite
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_cannot_encode_type_text_encoding_2, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 75, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_UNPACK_METHODS && likely(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_6 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_schema, __pyx_v_name};
        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 75, __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_3)) {
        PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_schema, __pyx_v_name};
        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 75, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 75, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        if (__pyx_t_7) {
          __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL;
        }
        __Pyx_INCREF(__pyx_v_schema);
        __Pyx_GIVEREF(__pyx_v_schema);
        PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_v_schema);
        __Pyx_INCREF(__pyx_v_name);
        __Pyx_GIVEREF(__pyx_v_name);
        PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_v_name);
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 75, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "asyncpg/protocol/codecs/base.pyx":73
 *         elif type == CODEC_COMPOSITE:
 *             if format != PG_FORMAT_BINARY:
 *                 raise RuntimeError(             # <<<<<<<<<<<<<<
 *                     'cannot encode type "{}"."{}": text encoding of '
 *                     'composite types is not supported'.format(schema, name))
 */
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 73, __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(4, 73, __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(4, 73, __pyx_L1_error)

      /* "asyncpg/protocol/codecs/base.pyx":72
 *             self.decoder = <codec_decode_func>&self.decode_range
 *         elif type == CODEC_COMPOSITE:
 *             if format != PG_FORMAT_BINARY:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(
 *                     'cannot encode type "{}"."{}": text encoding of '
 */
    }

    /* "asyncpg/protocol/codecs/base.pyx":76
 *                     'cannot encode type "{}"."{}": text encoding of '
 *                     'composite types is not supported'.format(schema, name))
 *             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":77
 *                     'composite types is not supported'.format(schema, name))
 *             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":71
 *             self.encoder = <codec_encode_func>&self.encode_range
 *             self.decoder = <codec_decode_func>&self.decode_range
 *         elif type == CODEC_COMPOSITE:             # <<<<<<<<<<<<<<
 *             if format != PG_FORMAT_BINARY:
 *                 raise RuntimeError(
 */
    break;

    /* "asyncpg/protocol/codecs/base.pyx":78
 *             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":79
 *             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":80
 *         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":78
 *             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":82
 *             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(4, 82, __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(4, 82, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 82, __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_7, __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(4, 82, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 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_7, __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(4, 82, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_4);
        __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(4, 82, __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_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 82, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 82, __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(4, 82, __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(4, 82, __pyx_L1_error)
    break;
  }

  /* "asyncpg/protocol/codecs/base.pyx":24
 *         self.type = CODEC_UNDEFINED
 * 
 *     cdef init(self, str name, str schema, str kind,             # <<<<<<<<<<<<<<
 *               CodecType type, ServerDataFormat format,
 *               ClientExchangeFormat xformat,
 */

  /* 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.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":84
 *             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":87
 *         cdef Codec codec
 * 
 *         codec = Codec(self.oid)             # <<<<<<<<<<<<<<
 *         codec.init(self.name, self.schema, self.kind,
 *                    self.type, self.format, self.xformat,
 */
  __pyx_t_1 = __Pyx_PyInt_From_uint32_t(__pyx_v_self->oid); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 87, __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(4, 87, __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":88
 * 
 *         codec = Codec(self.oid)
 *         codec.init(self.name, self.schema, self.kind,             # <<<<<<<<<<<<<<
 *                    self.type, self.format, self.xformat,
 *                    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":91
 *                    self.type, self.format, self.xformat,
 *                    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":92
 *                    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":93
 *                    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":94
 *                    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":88
 * 
 *         codec = Codec(self.oid)
 *         codec.init(self.name, self.schema, self.kind,             # <<<<<<<<<<<<<<
 *                    self.type, self.format, self.xformat,
 *                    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->xformat, __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(4, 88, __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":96
 *                    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":84
 *             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":98
 *         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":100
 *     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(4, 100, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/base.pyx":98
 *         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":102
 *         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":104
 *     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(4, 104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/base.pyx":102
 *         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":108
 *                      <void*>(<cpython.PyObject>self.element_codec))
 * 
 *     cdef encode_array_text(self, ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
 *                            object obj):
 *         return textarray_encode(settings, buf, obj,
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode_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_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("encode_array_text", 0);

  /* "asyncpg/protocol/codecs/base.pyx":110
 *     cdef encode_array_text(self, ConnectionSettings settings, WriteBuffer buf,
 *                            object obj):
 *         return textarray_encode(settings, buf, obj,             # <<<<<<<<<<<<<<
 *                                 codec_encode_func_ex,
 *                                 <void*>(<cpython.PyObject>self.element_codec),
 */
  __Pyx_XDECREF(__pyx_r);

  /* "asyncpg/protocol/codecs/base.pyx":113
 *                                 codec_encode_func_ex,
 *                                 <void*>(<cpython.PyObject>self.element_codec),
 *                                 self.element_delimiter)             # <<<<<<<<<<<<<<
 * 
 *     cdef encode_range(self, ConnectionSettings settings, WriteBuffer buf,
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_textarray_encode(__pyx_v_settings, __pyx_v_buf, __pyx_v_obj, __pyx_f_7asyncpg_8protocol_8protocol_codec_encode_func_ex, ((void *)__pyx_v_self->element_codec), __pyx_v_self->element_delimiter); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 110, __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":108
 *                      <void*>(<cpython.PyObject>self.element_codec))
 * 
 *     cdef encode_array_text(self, ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
 *                            object obj):
 *         return textarray_encode(settings, buf, obj,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.encode_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":115
 *                                 self.element_delimiter)
 * 
 *     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":117
 *     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(4, 117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/base.pyx":115
 *                                 self.element_delimiter)
 * 
 *     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":121
 *                      <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":126
 *             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":129
 *             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 == ((Py_ssize_t)-1))) __PYX_ERR(4, 129, __pyx_L1_error)
  __pyx_v_count = __pyx_t_2;

  /* "asyncpg/protocol/codecs/base.pyx":130
 * 
 *         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":131
 *         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__31, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 131, __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, 131, __pyx_L1_error)

    /* "asyncpg/protocol/codecs/base.pyx":130
 * 
 *         count = len(obj)
 *         if count > _MAXINT32:             # <<<<<<<<<<<<<<
 *             raise ValueError('too many elements in composite type record')
 * 
 */
  }

  /* "asyncpg/protocol/codecs/base.pyx":133
 *             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(4, 133, __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":134
 * 
 *         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":135
 *         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(4, 135, __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(4, 135, __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(4, 135, __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(4, 135, __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(4, 135, __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(4, 135, __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(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(4, 135, __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":136
 *         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(4, 136, __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(4, 136, __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(4, 136, __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(4, 136, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "asyncpg/protocol/codecs/base.pyx":137
 *         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":138
 *             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(4, 138, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "asyncpg/protocol/codecs/base.pyx":137
 *         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":140
 *                 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(4, 140, __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(4, 140, __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(4, 140, __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":141
 *             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":135
 *         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":143
 *             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(4, 143, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/base.pyx":121
 *                      <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":145
 *         record_encode_frame(settings, buf, elem_data, <int32_t>count)
 * 
 *     cdef encode_in_python(self, ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
 *                           object obj):
 *         data = 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_data = 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;
  __Pyx_RefNannySetupContext("encode_in_python", 0);

  /* "asyncpg/protocol/codecs/base.pyx":147
 *     cdef encode_in_python(self, ConnectionSettings settings, WriteBuffer buf,
 *                           object obj):
 *         data = self.py_encoder(obj)             # <<<<<<<<<<<<<<
 *         if self.xformat == PG_XFORMAT_OBJECT:
 *             if self.format == PG_FORMAT_BINARY:
 */
  __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(4, 147, __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(4, 147, __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(4, 147, __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, 147, __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(4, 147, __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_data = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/base.pyx":148
 *                           object obj):
 *         data = self.py_encoder(obj)
 *         if self.xformat == PG_XFORMAT_OBJECT:             # <<<<<<<<<<<<<<
 *             if self.format == PG_FORMAT_BINARY:
 *                 bytea_encode(settings, buf, data)
 */
  switch (__pyx_v_self->xformat) {
    case __pyx_e_7asyncpg_8protocol_8protocol_PG_XFORMAT_OBJECT:

    /* "asyncpg/protocol/codecs/base.pyx":149
 *         data = self.py_encoder(obj)
 *         if self.xformat == PG_XFORMAT_OBJECT:
 *             if self.format == PG_FORMAT_BINARY:             # <<<<<<<<<<<<<<
 *                 bytea_encode(settings, buf, data)
 *             elif self.format == PG_FORMAT_TEXT:
 */
    __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":150
 *         if self.xformat == PG_XFORMAT_OBJECT:
 *             if self.format == PG_FORMAT_BINARY:
 *                 bytea_encode(settings, buf, data)             # <<<<<<<<<<<<<<
 *             elif self.format == PG_FORMAT_TEXT:
 *                 text_encode(settings, buf, data)
 */
      __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_bytea_encode(__pyx_v_settings, __pyx_v_buf, __pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 150, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "asyncpg/protocol/codecs/base.pyx":149
 *         data = self.py_encoder(obj)
 *         if self.xformat == PG_XFORMAT_OBJECT:
 *             if self.format == PG_FORMAT_BINARY:             # <<<<<<<<<<<<<<
 *                 bytea_encode(settings, buf, data)
 *             elif self.format == PG_FORMAT_TEXT:
 */
      goto __pyx_L3;
    }

    /* "asyncpg/protocol/codecs/base.pyx":151
 *             if self.format == PG_FORMAT_BINARY:
 *                 bytea_encode(settings, buf, data)
 *             elif self.format == PG_FORMAT_TEXT:             # <<<<<<<<<<<<<<
 *                 text_encode(settings, buf, data)
 *             else:
 */
    __pyx_t_5 = ((__pyx_v_self->format == __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT) != 0);
    if (__pyx_t_5) {

      /* "asyncpg/protocol/codecs/base.pyx":152
 *                 bytea_encode(settings, buf, data)
 *             elif self.format == PG_FORMAT_TEXT:
 *                 text_encode(settings, buf, data)             # <<<<<<<<<<<<<<
 *             else:
 *                 raise RuntimeError(
 */
      __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_text_encode(__pyx_v_settings, __pyx_v_buf, __pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 152, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "asyncpg/protocol/codecs/base.pyx":151
 *             if self.format == PG_FORMAT_BINARY:
 *                 bytea_encode(settings, buf, data)
 *             elif self.format == PG_FORMAT_TEXT:             # <<<<<<<<<<<<<<
 *                 text_encode(settings, buf, data)
 *             else:
 */
      goto __pyx_L3;
    }

    /* "asyncpg/protocol/codecs/base.pyx":154
 *                 text_encode(settings, buf, data)
 *             else:
 *                 raise RuntimeError(             # <<<<<<<<<<<<<<
 *                     'unexpected data format: {}'.format(self.format))
 *         elif self.xformat == PG_XFORMAT_TUPLE:
 */
    /*else*/ {

      /* "asyncpg/protocol/codecs/base.pyx":155
 *             else:
 *                 raise RuntimeError(
 *                     'unexpected data format: {}'.format(self.format))             # <<<<<<<<<<<<<<
 *         elif self.xformat == PG_XFORMAT_TUPLE:
 *             self.c_encoder(settings, buf, data)
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_unexpected_data_format, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 155, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(__pyx_v_self->format); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 155, __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(4, 155, __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, 155, __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, 155, __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_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 155, __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 = 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(4, 155, __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;

      /* "asyncpg/protocol/codecs/base.pyx":154
 *                 text_encode(settings, buf, data)
 *             else:
 *                 raise RuntimeError(             # <<<<<<<<<<<<<<
 *                     'unexpected data format: {}'.format(self.format))
 *         elif self.xformat == PG_XFORMAT_TUPLE:
 */
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 154, __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_RuntimeError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 154, __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(4, 154, __pyx_L1_error)
    }
    __pyx_L3:;

    /* "asyncpg/protocol/codecs/base.pyx":148
 *                           object obj):
 *         data = self.py_encoder(obj)
 *         if self.xformat == PG_XFORMAT_OBJECT:             # <<<<<<<<<<<<<<
 *             if self.format == PG_FORMAT_BINARY:
 *                 bytea_encode(settings, buf, data)
 */
    break;

    /* "asyncpg/protocol/codecs/base.pyx":156
 *                 raise RuntimeError(
 *                     'unexpected data format: {}'.format(self.format))
 *         elif self.xformat == PG_XFORMAT_TUPLE:             # <<<<<<<<<<<<<<
 *             self.c_encoder(settings, buf, data)
 *         else:
 */
    case __pyx_e_7asyncpg_8protocol_8protocol_PG_XFORMAT_TUPLE:

    /* "asyncpg/protocol/codecs/base.pyx":157
 *                     'unexpected data format: {}'.format(self.format))
 *         elif self.xformat == PG_XFORMAT_TUPLE:
 *             self.c_encoder(settings, buf, data)             # <<<<<<<<<<<<<<
 *         else:
 *             raise RuntimeError(
 */
    __pyx_t_1 = __pyx_v_self->c_encoder(__pyx_v_settings, __pyx_v_buf, __pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 157, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/codecs/base.pyx":156
 *                 raise RuntimeError(
 *                     'unexpected data format: {}'.format(self.format))
 *         elif self.xformat == PG_XFORMAT_TUPLE:             # <<<<<<<<<<<<<<
 *             self.c_encoder(settings, buf, data)
 *         else:
 */
    break;
    default:

    /* "asyncpg/protocol/codecs/base.pyx":160
 *         else:
 *             raise RuntimeError(
 *                 'unexpected exchange format: {}'.format(self.xformat))             # <<<<<<<<<<<<<<
 * 
 *     cdef encode(self, ConnectionSettings settings, WriteBuffer buf,
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_unexpected_exchange_format, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 160, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat(__pyx_v_self->xformat); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 160, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __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_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 160, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 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_6};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 160, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __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[2] = {__pyx_t_4, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 160, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 160, __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_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 160, __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;

    /* "asyncpg/protocol/codecs/base.pyx":159
 *             self.c_encoder(settings, buf, data)
 *         else:
 *             raise RuntimeError(             # <<<<<<<<<<<<<<
 *                 'unexpected exchange format: {}'.format(self.xformat))
 * 
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 159, __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_RuntimeError, __pyx_t_2, NULL); 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;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(4, 159, __pyx_L1_error)
    break;
  }

  /* "asyncpg/protocol/codecs/base.pyx":145
 *         record_encode_frame(settings, buf, elem_data, <int32_t>count)
 * 
 *     cdef encode_in_python(self, ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
 *                           object obj):
 *         data = 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_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.encode_in_python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/codecs/base.pyx":162
 *                 'unexpected exchange format: {}'.format(self.xformat))
 * 
 *     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":164
 *     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(4, 164, __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":162
 *                 'unexpected exchange format: {}'.format(self.xformat))
 * 
 *     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":166
 *         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":167
 * 
 *     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(4, 167, __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":166
 *         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":169
 *         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":170
 * 
 *     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":171
 *     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(4, 170, __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":169
 *         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":173
 *                             <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":175
 *     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":177
 *         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(4, 175, __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":173
 *                             <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":179
 *                                 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":180
 * 
 *     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":181
 *     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(4, 180, __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":179
 *                                 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":183
 *                             <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;
  Py_ssize_t __pyx_v_elem_count;
  Py_ssize_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;
  Py_ssize_t __pyx_t_3;
  int __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;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  Py_ssize_t __pyx_t_12;
  Py_ssize_t __pyx_t_13;
  uint32_t __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  __Pyx_RefNannySetupContext("decode_composite", 0);

  /* "asyncpg/protocol/codecs/base.pyx":193
 *             uint32_t received_elem_typ
 *             Codec elem_codec
 *             FastReadBuffer elem_buf = FastReadBuffer.new()             # <<<<<<<<<<<<<<
 * 
 *         elem_count = <ssize_t><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(4, 193, __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":195
 *             FastReadBuffer elem_buf = FastReadBuffer.new()
 * 
 *         elem_count = <ssize_t><uint32_t>hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
 *         if elem_count != len(self.element_type_oids):
 *             raise OutdatedSchemaCacheError(
 */
  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_2 == ((char const *)NULL))) __PYX_ERR(4, 195, __pyx_L1_error)
  __pyx_v_elem_count = ((Py_ssize_t)((uint32_t)unpack_int32(__pyx_t_2)));

  /* "asyncpg/protocol/codecs/base.pyx":196
 * 
 *         elem_count = <ssize_t><uint32_t>hton.unpack_int32(buf.read(4))
 *         if elem_count != len(self.element_type_oids):             # <<<<<<<<<<<<<<
 *             raise OutdatedSchemaCacheError(
 *                 'unexpected number of attributes of composite type: '
 */
  __pyx_t_1 = __pyx_v_self->element_type_oids;
  __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(4, 196, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(4, 196, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = ((__pyx_v_elem_count != __pyx_t_3) != 0);
  if (__pyx_t_4) {

    /* "asyncpg/protocol/codecs/base.pyx":197
 *         elem_count = <ssize_t><uint32_t>hton.unpack_int32(buf.read(4))
 *         if elem_count != len(self.element_type_oids):
 *             raise OutdatedSchemaCacheError(             # <<<<<<<<<<<<<<
 *                 'unexpected number of attributes of composite type: '
 *                 '{}, expected {}'
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_OutdatedSchemaCacheError); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 197, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);

    /* "asyncpg/protocol/codecs/base.pyx":200
 *                 'unexpected number of attributes of composite type: '
 *                 '{}, expected {}'
 *                     .format(             # <<<<<<<<<<<<<<
 *                         elem_count,
 *                         len(self.element_type_oids),
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_unexpected_number_of_attributes, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 200, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);

    /* "asyncpg/protocol/codecs/base.pyx":201
 *                 '{}, expected {}'
 *                     .format(
 *                         elem_count,             # <<<<<<<<<<<<<<
 *                         len(self.element_type_oids),
 *                     ),
 */
    __pyx_t_7 = PyInt_FromSsize_t(__pyx_v_elem_count); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 201, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);

    /* "asyncpg/protocol/codecs/base.pyx":202
 *                     .format(
 *                         elem_count,
 *                         len(self.element_type_oids),             # <<<<<<<<<<<<<<
 *                     ),
 *                 schema=self.schema,
 */
    __pyx_t_8 = __pyx_v_self->element_type_oids;
    __Pyx_INCREF(__pyx_t_8);
    if (unlikely(__pyx_t_8 == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      __PYX_ERR(4, 202, __pyx_L1_error)
    }
    __pyx_t_3 = PyTuple_GET_SIZE(__pyx_t_8); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(4, 202, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 202, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = NULL;
    __pyx_t_10 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_10 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_7, __pyx_t_8};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 200, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __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[3] = {__pyx_t_9, __pyx_t_7, __pyx_t_8};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 200, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(4, 200, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      if (__pyx_t_9) {
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_8);
      __pyx_t_7 = 0;
      __pyx_t_8 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 200, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "asyncpg/protocol/codecs/base.pyx":197
 *         elem_count = <ssize_t><uint32_t>hton.unpack_int32(buf.read(4))
 *         if elem_count != len(self.element_type_oids):
 *             raise OutdatedSchemaCacheError(             # <<<<<<<<<<<<<<
 *                 'unexpected number of attributes of composite type: '
 *                 '{}, expected {}'
 */
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 197, __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 = 0;

    /* "asyncpg/protocol/codecs/base.pyx":204
 *                         len(self.element_type_oids),
 *                     ),
 *                 schema=self.schema,             # <<<<<<<<<<<<<<
 *                 data_type=self.name,
 *             )
 */
    __pyx_t_5 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 204, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_schema, __pyx_v_self->schema) < 0) __PYX_ERR(4, 204, __pyx_L1_error)

    /* "asyncpg/protocol/codecs/base.pyx":205
 *                     ),
 *                 schema=self.schema,
 *                 data_type=self.name,             # <<<<<<<<<<<<<<
 *             )
 *         result = record.ApgRecord_New(self.element_names, elem_count)
 */
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_data_type, __pyx_v_self->name) < 0) __PYX_ERR(4, 204, __pyx_L1_error)

    /* "asyncpg/protocol/codecs/base.pyx":197
 *         elem_count = <ssize_t><uint32_t>hton.unpack_int32(buf.read(4))
 *         if elem_count != len(self.element_type_oids):
 *             raise OutdatedSchemaCacheError(             # <<<<<<<<<<<<<<
 *                 'unexpected number of attributes of composite type: '
 *                 '{}, expected {}'
 */
    __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(4, 197, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_11, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __PYX_ERR(4, 197, __pyx_L1_error)

    /* "asyncpg/protocol/codecs/base.pyx":196
 * 
 *         elem_count = <ssize_t><uint32_t>hton.unpack_int32(buf.read(4))
 *         if elem_count != len(self.element_type_oids):             # <<<<<<<<<<<<<<
 *             raise OutdatedSchemaCacheError(
 *                 'unexpected number of attributes of composite type: '
 */
  }

  /* "asyncpg/protocol/codecs/base.pyx":207
 *                 data_type=self.name,
 *             )
 *         result = record.ApgRecord_New(self.element_names, elem_count)             # <<<<<<<<<<<<<<
 *         for i in range(elem_count):
 *             elem_typ = self.element_type_oids[i]
 */
  __pyx_t_11 = __pyx_v_self->element_names;
  __Pyx_INCREF(__pyx_t_11);
  __pyx_t_5 = ApgRecord_New(__pyx_t_11, __pyx_v_elem_count); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 207, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_v_result = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "asyncpg/protocol/codecs/base.pyx":208
 *             )
 *         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_12 = __pyx_v_elem_count;
  for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) {
    __pyx_v_i = __pyx_t_13;

    /* "asyncpg/protocol/codecs/base.pyx":209
 *         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(4, 209, __pyx_L1_error)
    }
    __pyx_t_5 = __Pyx_GetItemInt_Tuple(__pyx_v_self->element_type_oids, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 209, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_14 = __Pyx_PyInt_As_uint32_t(__pyx_t_5); if (unlikely((__pyx_t_14 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(4, 209, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_elem_typ = __pyx_t_14;

    /* "asyncpg/protocol/codecs/base.pyx":210
 *         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 == ((char const *)NULL))) __PYX_ERR(4, 210, __pyx_L1_error)
    __pyx_v_received_elem_typ = ((uint32_t)unpack_int32(__pyx_t_2));

    /* "asyncpg/protocol/codecs/base.pyx":212
 *             received_elem_typ = <uint32_t>hton.unpack_int32(buf.read(4))
 * 
 *             if received_elem_typ != elem_typ:             # <<<<<<<<<<<<<<
 *                 raise OutdatedSchemaCacheError(
 *                     'unexpected data type of composite type attribute {}: '
 */
    __pyx_t_4 = ((__pyx_v_received_elem_typ != __pyx_v_elem_typ) != 0);
    if (__pyx_t_4) {

      /* "asyncpg/protocol/codecs/base.pyx":213
 * 
 *             if received_elem_typ != elem_typ:
 *                 raise OutdatedSchemaCacheError(             # <<<<<<<<<<<<<<
 *                     'unexpected data type of composite type attribute {}: '
 *                     '{!r}, expected {!r}'
 */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_OutdatedSchemaCacheError); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 213, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);

      /* "asyncpg/protocol/codecs/base.pyx":216
 *                     'unexpected data type of composite type attribute {}: '
 *                     '{!r}, expected {!r}'
 *                         .format(             # <<<<<<<<<<<<<<
 *                             i,
 *                             TYPEMAP.get(received_elem_typ, received_elem_typ),
 */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_unexpected_data_type_of_composit, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 216, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);

      /* "asyncpg/protocol/codecs/base.pyx":217
 *                     '{!r}, expected {!r}'
 *                         .format(
 *                             i,             # <<<<<<<<<<<<<<
 *                             TYPEMAP.get(received_elem_typ, received_elem_typ),
 *                             TYPEMAP.get(elem_typ, elem_typ)
 */
      __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 217, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);

      /* "asyncpg/protocol/codecs/base.pyx":218
 *                         .format(
 *                             i,
 *                             TYPEMAP.get(received_elem_typ, received_elem_typ),             # <<<<<<<<<<<<<<
 *                             TYPEMAP.get(elem_typ, elem_typ)
 *                         ),
 */
      __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_TYPEMAP); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 218, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_get); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 218, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_PyInt_From_uint32_t(__pyx_v_received_elem_typ); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 218, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_15 = __Pyx_PyInt_From_uint32_t(__pyx_v_received_elem_typ); if (unlikely(!__pyx_t_15)) __PYX_ERR(4, 218, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_16 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_16)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_16);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
          __pyx_t_10 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[3] = {__pyx_t_16, __pyx_t_7, __pyx_t_15};
        __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 218, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[3] = {__pyx_t_16, __pyx_t_7, __pyx_t_15};
        __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 218, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      } else
      #endif
      {
        __pyx_t_17 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_17)) __PYX_ERR(4, 218, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_17);
        if (__pyx_t_16) {
          __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_16); __pyx_t_16 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_17, 0+__pyx_t_10, __pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_15);
        PyTuple_SET_ITEM(__pyx_t_17, 1+__pyx_t_10, __pyx_t_15);
        __pyx_t_7 = 0;
        __pyx_t_15 = 0;
        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_17, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 218, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

      /* "asyncpg/protocol/codecs/base.pyx":219
 *                             i,
 *                             TYPEMAP.get(received_elem_typ, received_elem_typ),
 *                             TYPEMAP.get(elem_typ, elem_typ)             # <<<<<<<<<<<<<<
 *                         ),
 *                     schema=self.schema,
 */
      __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_TYPEMAP); if (unlikely(!__pyx_t_17)) __PYX_ERR(4, 219, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_n_s_get); if (unlikely(!__pyx_t_15)) __PYX_ERR(4, 219, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      __pyx_t_17 = __Pyx_PyInt_From_uint32_t(__pyx_v_elem_typ); if (unlikely(!__pyx_t_17)) __PYX_ERR(4, 219, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_7 = __Pyx_PyInt_From_uint32_t(__pyx_v_elem_typ); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 219, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_16 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
        __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_15);
        if (likely(__pyx_t_16)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
          __Pyx_INCREF(__pyx_t_16);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_15, function);
          __pyx_t_10 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_15)) {
        PyObject *__pyx_temp[3] = {__pyx_t_16, __pyx_t_17, __pyx_t_7};
        __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_15, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 219, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_15)) {
        PyObject *__pyx_temp[3] = {__pyx_t_16, __pyx_t_17, __pyx_t_7};
        __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_15, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 219, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      {
        __pyx_t_18 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_18)) __PYX_ERR(4, 219, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_18);
        if (__pyx_t_16) {
          __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_16); __pyx_t_16 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_17);
        PyTuple_SET_ITEM(__pyx_t_18, 0+__pyx_t_10, __pyx_t_17);
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_18, 1+__pyx_t_10, __pyx_t_7);
        __pyx_t_17 = 0;
        __pyx_t_7 = 0;
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_18, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 219, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      }
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __pyx_t_15 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_15)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_15);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
          __pyx_t_10 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[4] = {__pyx_t_15, __pyx_t_1, __pyx_t_8, __pyx_t_9};
        __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(4, 216, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __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[4] = {__pyx_t_15, __pyx_t_1, __pyx_t_8, __pyx_t_9};
        __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(4, 216, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      {
        __pyx_t_18 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_18)) __PYX_ERR(4, 216, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_18);
        if (__pyx_t_15) {
          __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_15); __pyx_t_15 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_18, 0+__pyx_t_10, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_18, 1+__pyx_t_10, __pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_18, 2+__pyx_t_10, __pyx_t_9);
        __pyx_t_1 = 0;
        __pyx_t_8 = 0;
        __pyx_t_9 = 0;
        __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_18, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(4, 216, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "asyncpg/protocol/codecs/base.pyx":213
 * 
 *             if received_elem_typ != elem_typ:
 *                 raise OutdatedSchemaCacheError(             # <<<<<<<<<<<<<<
 *                     'unexpected data type of composite type attribute {}: '
 *                     '{!r}, expected {!r}'
 */
      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 213, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_11);
      __pyx_t_11 = 0;

      /* "asyncpg/protocol/codecs/base.pyx":221
 *                             TYPEMAP.get(elem_typ, elem_typ)
 *                         ),
 *                     schema=self.schema,             # <<<<<<<<<<<<<<
 *                     data_type=self.name,
 *                     position=i,
 */
      __pyx_t_11 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_11)) __PYX_ERR(4, 221, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_schema, __pyx_v_self->schema) < 0) __PYX_ERR(4, 221, __pyx_L1_error)

      /* "asyncpg/protocol/codecs/base.pyx":222
 *                         ),
 *                     schema=self.schema,
 *                     data_type=self.name,             # <<<<<<<<<<<<<<
 *                     position=i,
 *                 )
 */
      if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_data_type, __pyx_v_self->name) < 0) __PYX_ERR(4, 221, __pyx_L1_error)

      /* "asyncpg/protocol/codecs/base.pyx":223
 *                     schema=self.schema,
 *                     data_type=self.name,
 *                     position=i,             # <<<<<<<<<<<<<<
 *                 )
 * 
 */
      __pyx_t_18 = PyInt_FromSsize_t(__pyx_v_i); if (unlikely(!__pyx_t_18)) __PYX_ERR(4, 223, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_18);
      if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_position, __pyx_t_18) < 0) __PYX_ERR(4, 221, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

      /* "asyncpg/protocol/codecs/base.pyx":213
 * 
 *             if received_elem_typ != elem_typ:
 *                 raise OutdatedSchemaCacheError(             # <<<<<<<<<<<<<<
 *                     'unexpected data type of composite type attribute {}: '
 *                     '{!r}, expected {!r}'
 */
      __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_11); if (unlikely(!__pyx_t_18)) __PYX_ERR(4, 213, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_18);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_Raise(__pyx_t_18, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      __PYX_ERR(4, 213, __pyx_L1_error)

      /* "asyncpg/protocol/codecs/base.pyx":212
 *             received_elem_typ = <uint32_t>hton.unpack_int32(buf.read(4))
 * 
 *             if received_elem_typ != elem_typ:             # <<<<<<<<<<<<<<
 *                 raise OutdatedSchemaCacheError(
 *                     'unexpected data type of composite type attribute {}: '
 */
    }

    /* "asyncpg/protocol/codecs/base.pyx":226
 *                 )
 * 
 *             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 == ((char const *)NULL))) __PYX_ERR(4, 226, __pyx_L1_error)
    __pyx_v_elem_len = unpack_int32(__pyx_t_2);

    /* "asyncpg/protocol/codecs/base.pyx":227
 * 
 *             elem_len = hton.unpack_int32(buf.read(4))
 *             if elem_len == -1:             # <<<<<<<<<<<<<<
 *                 elem = None
 *             else:
 */
    __pyx_t_4 = ((__pyx_v_elem_len == -1L) != 0);
    if (__pyx_t_4) {

      /* "asyncpg/protocol/codecs/base.pyx":228
 *             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":227
 * 
 *             elem_len = hton.unpack_int32(buf.read(4))
 *             if elem_len == -1:             # <<<<<<<<<<<<<<
 *                 elem = None
 *             else:
 */
      goto __pyx_L7;
    }

    /* "asyncpg/protocol/codecs/base.pyx":230
 *                 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(4, 230, __pyx_L1_error)
      }
      __pyx_t_18 = __Pyx_GetItemInt_List(__pyx_v_self->element_codecs, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_18)) __PYX_ERR(4, 230, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_18);
      if (!(likely(((__pyx_t_18) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_18, __pyx_ptype_7asyncpg_8protocol_8protocol_Codec))))) __PYX_ERR(4, 230, __pyx_L1_error)
      __Pyx_XDECREF_SET(__pyx_v_elem_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_18));
      __pyx_t_18 = 0;

      /* "asyncpg/protocol/codecs/base.pyx":232
 *                 elem_codec = self.element_codecs[i]
 *                 elem = elem_codec.decode(settings,
 *                                          elem_buf.slice_from(buf, elem_len))             # <<<<<<<<<<<<<<
 * 
 *             cpython.Py_INCREF(elem)
 */
      __pyx_t_18 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_slice_from(__pyx_v_elem_buf, __pyx_v_buf, __pyx_v_elem_len)); if (unlikely(!__pyx_t_18)) __PYX_ERR(4, 232, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_18);

      /* "asyncpg/protocol/codecs/base.pyx":231
 *             else:
 *                 elem_codec = self.element_codecs[i]
 *                 elem = elem_codec.decode(settings,             # <<<<<<<<<<<<<<
 *                                          elem_buf.slice_from(buf, elem_len))
 * 
 */
      __pyx_t_11 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_decode(__pyx_v_elem_codec, __pyx_v_settings, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *)__pyx_t_18)); if (unlikely(!__pyx_t_11)) __PYX_ERR(4, 231, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      __Pyx_XDECREF_SET(__pyx_v_elem, __pyx_t_11);
      __pyx_t_11 = 0;
    }
    __pyx_L7:;

    /* "asyncpg/protocol/codecs/base.pyx":234
 *                                          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":235
 * 
 *             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":237
 *             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":183
 *                             <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_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_11);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __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":239
 *         return result
 * 
 *     cdef decode_in_python(self, ConnectionSettings settings,             # <<<<<<<<<<<<<<
 *                           FastReadBuffer buf):
 *         if self.xformat == PG_XFORMAT_OBJECT:
 */

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_data = 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;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("decode_in_python", 0);

  /* "asyncpg/protocol/codecs/base.pyx":241
 *     cdef decode_in_python(self, ConnectionSettings settings,
 *                           FastReadBuffer buf):
 *         if self.xformat == PG_XFORMAT_OBJECT:             # <<<<<<<<<<<<<<
 *             if self.format == PG_FORMAT_BINARY:
 *                 data = bytea_decode(settings, buf)
 */
  switch (__pyx_v_self->xformat) {
    case __pyx_e_7asyncpg_8protocol_8protocol_PG_XFORMAT_OBJECT:

    /* "asyncpg/protocol/codecs/base.pyx":242
 *                           FastReadBuffer buf):
 *         if self.xformat == PG_XFORMAT_OBJECT:
 *             if self.format == PG_FORMAT_BINARY:             # <<<<<<<<<<<<<<
 *                 data = bytea_decode(settings, buf)
 *             elif self.format == PG_FORMAT_TEXT:
 */
    __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":243
 *         if self.xformat == PG_XFORMAT_OBJECT:
 *             if self.format == PG_FORMAT_BINARY:
 *                 data = bytea_decode(settings, buf)             # <<<<<<<<<<<<<<
 *             elif self.format == PG_FORMAT_TEXT:
 *                 data = 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(4, 243, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_v_data = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "asyncpg/protocol/codecs/base.pyx":242
 *                           FastReadBuffer buf):
 *         if self.xformat == PG_XFORMAT_OBJECT:
 *             if self.format == PG_FORMAT_BINARY:             # <<<<<<<<<<<<<<
 *                 data = bytea_decode(settings, buf)
 *             elif self.format == PG_FORMAT_TEXT:
 */
      goto __pyx_L3;
    }

    /* "asyncpg/protocol/codecs/base.pyx":244
 *             if self.format == PG_FORMAT_BINARY:
 *                 data = bytea_decode(settings, buf)
 *             elif self.format == PG_FORMAT_TEXT:             # <<<<<<<<<<<<<<
 *                 data = text_decode(settings, buf)
 *             else:
 */
    __pyx_t_1 = ((__pyx_v_self->format == __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT) != 0);
    if (__pyx_t_1) {

      /* "asyncpg/protocol/codecs/base.pyx":245
 *                 data = bytea_decode(settings, buf)
 *             elif self.format == PG_FORMAT_TEXT:
 *                 data = text_decode(settings, buf)             # <<<<<<<<<<<<<<
 *             else:
 *                 raise RuntimeError(
 */
      __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_text_decode(__pyx_v_settings, __pyx_v_buf); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 245, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_v_data = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "asyncpg/protocol/codecs/base.pyx":244
 *             if self.format == PG_FORMAT_BINARY:
 *                 data = bytea_decode(settings, buf)
 *             elif self.format == PG_FORMAT_TEXT:             # <<<<<<<<<<<<<<
 *                 data = text_decode(settings, buf)
 *             else:
 */
      goto __pyx_L3;
    }

    /* "asyncpg/protocol/codecs/base.pyx":247
 *                 data = text_decode(settings, buf)
 *             else:
 *                 raise RuntimeError(             # <<<<<<<<<<<<<<
 *                     'unexpected data format: {}'.format(self.format))
 *         elif self.xformat == PG_XFORMAT_TUPLE:
 */
    /*else*/ {

      /* "asyncpg/protocol/codecs/base.pyx":248
 *             else:
 *                 raise RuntimeError(
 *                     'unexpected data format: {}'.format(self.format))             # <<<<<<<<<<<<<<
 *         elif self.xformat == PG_XFORMAT_TUPLE:
 *             data = self.c_decoder(settings, buf)
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_unexpected_data_format, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 248, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(__pyx_v_self->format); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 248, __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, 248, __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, 248, __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, 248, __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, 248, __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, 248, __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/base.pyx":247
 *                 data = text_decode(settings, buf)
 *             else:
 *                 raise RuntimeError(             # <<<<<<<<<<<<<<
 *                     'unexpected data format: {}'.format(self.format))
 *         elif self.xformat == PG_XFORMAT_TUPLE:
 */
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 247, __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, 247, __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, 247, __pyx_L1_error)
    }
    __pyx_L3:;

    /* "asyncpg/protocol/codecs/base.pyx":241
 *     cdef decode_in_python(self, ConnectionSettings settings,
 *                           FastReadBuffer buf):
 *         if self.xformat == PG_XFORMAT_OBJECT:             # <<<<<<<<<<<<<<
 *             if self.format == PG_FORMAT_BINARY:
 *                 data = bytea_decode(settings, buf)
 */
    break;

    /* "asyncpg/protocol/codecs/base.pyx":249
 *                 raise RuntimeError(
 *                     'unexpected data format: {}'.format(self.format))
 *         elif self.xformat == PG_XFORMAT_TUPLE:             # <<<<<<<<<<<<<<
 *             data = self.c_decoder(settings, buf)
 *         else:
 */
    case __pyx_e_7asyncpg_8protocol_8protocol_PG_XFORMAT_TUPLE:

    /* "asyncpg/protocol/codecs/base.pyx":250
 *                     'unexpected data format: {}'.format(self.format))
 *         elif self.xformat == PG_XFORMAT_TUPLE:
 *             data = self.c_decoder(settings, buf)             # <<<<<<<<<<<<<<
 *         else:
 *             raise RuntimeError(
 */
    __pyx_t_2 = __pyx_v_self->c_decoder(__pyx_v_settings, __pyx_v_buf); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 250, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_data = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "asyncpg/protocol/codecs/base.pyx":249
 *                 raise RuntimeError(
 *                     'unexpected data format: {}'.format(self.format))
 *         elif self.xformat == PG_XFORMAT_TUPLE:             # <<<<<<<<<<<<<<
 *             data = self.c_decoder(settings, buf)
 *         else:
 */
    break;
    default:

    /* "asyncpg/protocol/codecs/base.pyx":253
 *         else:
 *             raise RuntimeError(
 *                 'unexpected exchange format: {}'.format(self.xformat))             # <<<<<<<<<<<<<<
 * 
 *         return self.py_decoder(data)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_unexpected_exchange_format, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 253, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat(__pyx_v_self->xformat); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 253, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __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_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 253, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 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_6};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 253, __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;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_6};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 253, __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;
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 253, __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_6);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 253, __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;

    /* "asyncpg/protocol/codecs/base.pyx":252
 *             data = self.c_decoder(settings, buf)
 *         else:
 *             raise RuntimeError(             # <<<<<<<<<<<<<<
 *                 'unexpected exchange format: {}'.format(self.xformat))
 * 
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 252, __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, 252, __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, 252, __pyx_L1_error)
    break;
  }

  /* "asyncpg/protocol/codecs/base.pyx":255
 *                 'unexpected exchange format: {}'.format(self.xformat))
 * 
 *         return self.py_decoder(data)             # <<<<<<<<<<<<<<
 * 
 *     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_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_v_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 255, __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_5, __pyx_v_data};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 255, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 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_5, __pyx_v_data};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 255, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 255, __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_data);
      __Pyx_GIVEREF(__pyx_v_data);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_data);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 255, __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_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "asyncpg/protocol/codecs/base.pyx":239
 *         return result
 * 
 *     cdef decode_in_python(self, ConnectionSettings settings,             # <<<<<<<<<<<<<<
 *                           FastReadBuffer buf):
 *         if self.xformat == PG_XFORMAT_OBJECT:
 */

  /* 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_AddTraceback("asyncpg.protocol.protocol.Codec.decode_in_python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/codecs/base.pyx":257
 *         return self.py_decoder(data)
 * 
 *     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":258
 * 
 *     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(4, 258, __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":257
 *         return self.py_decoder(data)
 * 
 *     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":260
 *         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":263
 *         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":264
 * 
 *         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":263
 *         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":266
 *             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":267
 * 
 *         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(4, 267, __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":266
 *             return True
 * 
 *         elif self.type == CODEC_ARRAY or self.type == CODEC_RANGE:             # <<<<<<<<<<<<<<
 *             return self.element_codec.has_encoder()
 * 
 */
  }

  /* "asyncpg/protocol/codecs/base.pyx":269
 *             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":270
 * 
 *         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(4, 270, __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(4, 270, __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(4, 270, __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(4, 270, __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":271
 *         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(4, 271, __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(4, 271, __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":272
 *             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":271
 *         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":270
 * 
 *         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":273
 *                 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":269
 *             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":276
 * 
 *         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":260
 *         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":278
 *             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":281
 *         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":282
 * 
 *         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":281
 *         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":284
 *             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":285
 * 
 *         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(4, 285, __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":284
 *             return True
 * 
 *         elif self.type == CODEC_ARRAY or self.type == CODEC_RANGE:             # <<<<<<<<<<<<<<
 *             return self.element_codec.has_decoder()
 * 
 */
  }

  /* "asyncpg/protocol/codecs/base.pyx":287
 *             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":288
 * 
 *         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(4, 288, __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(4, 288, __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(4, 288, __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(4, 288, __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":289
 *         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(4, 289, __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(4, 289, __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":290
 *             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":289
 *         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":288
 * 
 *         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":291
 *                 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":287
 *             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":294
 * 
 *         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":278
 *             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":296
 *             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":297
 * 
 *     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(4, 297, __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":296
 *             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":299
 *         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":300
 * 
 *     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(4, 300, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "asyncpg/protocol/codecs/base.pyx":301
 *     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(4, 301, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "asyncpg/protocol/codecs/base.pyx":302
 *         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(4, 302, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = __pyx_t_6;
    __pyx_t_6 = 0;
  }

  /* "asyncpg/protocol/codecs/base.pyx":303
 *             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(4, 303, __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(4, 300, __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(4, 300, __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(4, 300, __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(4, 300, __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":299
 *         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":306
 * 
 *     @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":312
 *                                Py_UCS4 element_delimiter):
 *         cdef Codec codec
 *         codec = Codec(oid)             # <<<<<<<<<<<<<<
 *         codec.init(name, schema, 'array', CODEC_ARRAY, element_codec.format,
 *                    PG_XFORMAT_OBJECT, NULL, NULL, None, None, element_codec,
 */
  __pyx_t_1 = __Pyx_PyInt_From_uint32_t(__pyx_v_oid); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 312, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 312, __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(4, 312, __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":313
 *         cdef Codec codec
 *         codec = Codec(oid)
 *         codec.init(name, schema, 'array', CODEC_ARRAY, element_codec.format,             # <<<<<<<<<<<<<<
 *                    PG_XFORMAT_OBJECT, 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, __pyx_e_7asyncpg_8protocol_8protocol_PG_XFORMAT_OBJECT, 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(4, 313, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/base.pyx":316
 *                    PG_XFORMAT_OBJECT, 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":306
 * 
 *     @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":319
 * 
 *     @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":324
 *                                Codec element_codec):
 *         cdef Codec codec
 *         codec = Codec(oid)             # <<<<<<<<<<<<<<
 *         codec.init(name, schema, 'range', CODEC_RANGE, element_codec.format,
 *                    PG_XFORMAT_OBJECT, NULL, NULL, None, None, element_codec,
 */
  __pyx_t_1 = __Pyx_PyInt_From_uint32_t(__pyx_v_oid); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 324, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 324, __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(4, 324, __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":325
 *         cdef Codec codec
 *         codec = Codec(oid)
 *         codec.init(name, schema, 'range', CODEC_RANGE, element_codec.format,             # <<<<<<<<<<<<<<
 *                    PG_XFORMAT_OBJECT, 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_v_element_codec->format, __pyx_e_7asyncpg_8protocol_8protocol_PG_XFORMAT_OBJECT, 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(4, 325, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/base.pyx":328
 *                    PG_XFORMAT_OBJECT, 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":319
 * 
 *     @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":331
 * 
 *     @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, enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat __pyx_v_format, 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":339
 *                                    object element_names):
 *         cdef Codec codec
 *         codec = Codec(oid)             # <<<<<<<<<<<<<<
 *         codec.init(name, schema, 'composite', CODEC_COMPOSITE,
 *                    format, PG_XFORMAT_OBJECT, NULL, NULL, None, None, None,
 */
  __pyx_t_1 = __Pyx_PyInt_From_uint32_t(__pyx_v_oid); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 339, __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(4, 339, __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":340
 *         cdef Codec codec
 *         codec = Codec(oid)
 *         codec.init(name, schema, 'composite', CODEC_COMPOSITE,             # <<<<<<<<<<<<<<
 *                    format, PG_XFORMAT_OBJECT, 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_v_format, __pyx_e_7asyncpg_8protocol_8protocol_PG_XFORMAT_OBJECT, 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(4, 340, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/base.pyx":343
 *                    format, PG_XFORMAT_OBJECT, 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":331
 * 
 *     @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":346
 * 
 *     @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, __pyx_t_7asyncpg_8protocol_8protocol_encode_func __pyx_v_c_encoder, __pyx_t_7asyncpg_8protocol_8protocol_decode_func __pyx_v_c_decoder, enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat __pyx_v_format, enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat __pyx_v_xformat) {
  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":357
 *                                 ClientExchangeFormat xformat):
 *         cdef Codec codec
 *         codec = Codec(oid)             # <<<<<<<<<<<<<<
 *         codec.init(name, schema, kind, CODEC_PY, format, xformat,
 *                    c_encoder, c_decoder, encoder, decoder,
 */
  __pyx_t_1 = __Pyx_PyInt_From_uint32_t(__pyx_v_oid); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 357, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 357, __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(4, 357, __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":358
 *         cdef Codec codec
 *         codec = Codec(oid)
 *         codec.init(name, schema, kind, CODEC_PY, format, xformat,             # <<<<<<<<<<<<<<
 *                    c_encoder, c_decoder, encoder, decoder,
 *                    None, None, None, None, 0)
 */
  __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, __pyx_v_xformat, __pyx_v_c_encoder, __pyx_v_c_decoder, __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(4, 358, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/base.pyx":361
 *                    c_encoder, c_decoder, 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":346
 * 
 *     @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;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_5Codec_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_5Codec_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_5Codec_4__reduce_cython__(((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_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __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, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_5Codec_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_5Codec_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_5Codec_6__setstate_cython__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_5Codec_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__33, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __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, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.Codec.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/codecs/base.pyx":365
 * 
 * # 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":367
 * 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(4, 367, __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":365
 * 
 * # 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":371
 * 
 * # 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":373
 * 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(4, 373, __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":371
 * 
 * # 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":377
 * 
 * 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);
        CYTHON_FALLTHROUGH;
        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(4, 377, __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(4, 377, __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":378
 * 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":379
 *     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(4, 379, __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(4, 379, __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(4, 379, __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":378
 * 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_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "asyncpg/protocol/codecs/base.pyx":380
 *         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(4, 380, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "asyncpg/protocol/codecs/base.pyx":381
 *             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 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 381, __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(4, 381, __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(4, 381, __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":378
 * cdef class DataCodecConfig:
 *     def __init__(self, cache_key):
 *         try:             # <<<<<<<<<<<<<<
 *             self._type_codecs_cache = TYPE_CODECS_CACHE[cache_key]
 *         except KeyError:
 */
    __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_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_L8_try_end:;
  }

  /* "asyncpg/protocol/codecs/base.pyx":383
 *             self._type_codecs_cache = TYPE_CODECS_CACHE[cache_key] = {}
 * 
 *         self._local_type_codecs = {}             # <<<<<<<<<<<<<<
 * 
 *     def add_types(self, types):
 */
  __pyx_t_7 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 383, __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":377
 * 
 * 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":385
 *         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_ServerDataFormat __pyx_v_format;
  enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat __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;
  int __pyx_t_11;
  Py_UCS4 __pyx_t_12;
  Py_ssize_t __pyx_t_13;
  PyObject *(*__pyx_t_14)(PyObject *);
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  __Pyx_RefNannySetupContext("add_types", 0);

  /* "asyncpg/protocol/codecs/base.pyx":394
 *             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(4, 394, __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(4, 394, __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(4, 394, __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(4, 394, __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(4, 394, __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(4, 394, __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(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(4, 394, __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":395
 * 
 *         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(4, 395, __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":397
 *             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(4, 397, __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(4, 397, __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":398
 * 
 *             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":397
 *             oid = ti['oid']
 * 
 *             if not ti['has_bin_io']:             # <<<<<<<<<<<<<<
 *                 format = PG_FORMAT_TEXT
 *             else:
 */
      goto __pyx_L5;
    }

    /* "asyncpg/protocol/codecs/base.pyx":400
 *                 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":402
 *                 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":404
 *             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(4, 404, __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(4, 404, __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":405
 * 
 *             if self.get_codec(oid, format) is not None:
 *                 continue             # <<<<<<<<<<<<<<
 * 
 *             name = ti['name']
 */
      goto __pyx_L3_continue;

      /* "asyncpg/protocol/codecs/base.pyx":404
 *             has_text_elements = False
 * 
 *             if self.get_codec(oid, format) is not None:             # <<<<<<<<<<<<<<
 *                 continue
 * 
 */
    }

    /* "asyncpg/protocol/codecs/base.pyx":407
 *                 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(4, 407, __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":408
 * 
 *             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(4, 408, __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":409
 *             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(4, 409, __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":410
 *             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(4, 410, __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":411
 *             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(4, 411, __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(4, 411, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_5) {

      /* "asyncpg/protocol/codecs/base.pyx":412
 *             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(4, 412, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = __Pyx_PySequence_Tuple(__pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 412, __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":411
 *             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":414
 *                 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":415
 *             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(4, 415, __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":417
 *             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(4, 417, __pyx_L1_error)
    if (__pyx_t_5) {

      /* "asyncpg/protocol/codecs/base.pyx":421
 * 
 *                 # 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(4, 421, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 421, __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(4, 421, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_5) {

        /* "asyncpg/protocol/codecs/base.pyx":422
 *                 # 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__35, 1, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 422, __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":421
 * 
 *                 # Canonicalize type name to "elemtype[]"
 *                 if name.startswith('_'):             # <<<<<<<<<<<<<<
 *                     name = name[1:]
 *                 name = '{}[]'.format(name)
 */
      }

      /* "asyncpg/protocol/codecs/base.pyx":423
 *                 if name.startswith('_'):
 *                     name = name[1:]
 *                 name = '{}[]'.format(name)             # <<<<<<<<<<<<<<
 * 
 *                 if ti['elem_has_bin_io']:
 */
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u__36, __pyx_n_s_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 423, __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(4, 423, __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(4, 423, __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(4, 423, __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(4, 423, __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(4, 423, __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":425
 *                 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(4, 425, __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(4, 425, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_5) {

        /* "asyncpg/protocol/codecs/base.pyx":426
 * 
 *                 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":425
 *                 name = '{}[]'.format(name)
 * 
 *                 if ti['elem_has_bin_io']:             # <<<<<<<<<<<<<<
 *                     elem_format = PG_FORMAT_BINARY
 *                 else:
 */
        goto __pyx_L10;
      }

      /* "asyncpg/protocol/codecs/base.pyx":428
 *                     elem_format = PG_FORMAT_BINARY
 *                 else:
 *                     elem_format = PG_FORMAT_TEXT             # <<<<<<<<<<<<<<
 * 
 *                 elem_codec = self.get_codec(array_element_oid, elem_format)
 */
      /*else*/ {
        __pyx_v_elem_format = __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT;
      }
      __pyx_L10:;

      /* "asyncpg/protocol/codecs/base.pyx":430
 *                     elem_format = PG_FORMAT_TEXT
 * 
 *                 elem_codec = self.get_codec(array_element_oid, elem_format)             # <<<<<<<<<<<<<<
 *                 if elem_codec is None:
 *                     elem_format = PG_FORMAT_TEXT
 */
      __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(4, 430, __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(4, 430, __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":431
 * 
 *                 elem_codec = self.get_codec(array_element_oid, elem_format)
 *                 if elem_codec is None:             # <<<<<<<<<<<<<<
 *                     elem_format = PG_FORMAT_TEXT
 *                     elem_codec = self.declare_fallback_codec(
 */
      __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":432
 *                 elem_codec = self.get_codec(array_element_oid, elem_format)
 *                 if elem_codec is None:
 *                     elem_format = PG_FORMAT_TEXT             # <<<<<<<<<<<<<<
 *                     elem_codec = self.declare_fallback_codec(
 *                         array_element_oid, name, schema)
 */
        __pyx_v_elem_format = __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT;

        /* "asyncpg/protocol/codecs/base.pyx":433
 *                 if elem_codec is None:
 *                     elem_format = PG_FORMAT_TEXT
 *                     elem_codec = self.declare_fallback_codec(             # <<<<<<<<<<<<<<
 *                         array_element_oid, name, schema)
 * 
 */
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_declare_fallback_codec); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 433, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);

        /* "asyncpg/protocol/codecs/base.pyx":434
 *                     elem_format = PG_FORMAT_TEXT
 *                     elem_codec = self.declare_fallback_codec(
 *                         array_element_oid, name, schema)             # <<<<<<<<<<<<<<
 * 
 *                 elem_delim = <Py_UCS4>ti['elemdelim'][0]
 */
        __pyx_t_10 = NULL;
        __pyx_t_11 = 0;
        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);
            __pyx_t_11 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_8)) {
          PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_v_array_element_oid, __pyx_v_name, __pyx_v_schema};
          __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 433, __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[4] = {__pyx_t_10, __pyx_v_array_element_oid, __pyx_v_name, __pyx_v_schema};
          __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 433, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_4);
        } else
        #endif
        {
          __pyx_t_9 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 433, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          if (__pyx_t_10) {
            __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+__pyx_t_11, __pyx_v_array_element_oid);
          __Pyx_INCREF(__pyx_v_name);
          __Pyx_GIVEREF(__pyx_v_name);
          PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_11, __pyx_v_name);
          __Pyx_INCREF(__pyx_v_schema);
          __Pyx_GIVEREF(__pyx_v_schema);
          PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_11, __pyx_v_schema);
          __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 433, __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":433
 *                 if elem_codec is None:
 *                     elem_format = PG_FORMAT_TEXT
 *                     elem_codec = self.declare_fallback_codec(             # <<<<<<<<<<<<<<
 *                         array_element_oid, name, schema)
 * 
 */
        if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_7asyncpg_8protocol_8protocol_Codec))))) __PYX_ERR(4, 433, __pyx_L1_error)
        __Pyx_DECREF_SET(__pyx_v_elem_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_4));
        __pyx_t_4 = 0;

        /* "asyncpg/protocol/codecs/base.pyx":431
 * 
 *                 elem_codec = self.get_codec(array_element_oid, elem_format)
 *                 if elem_codec is None:             # <<<<<<<<<<<<<<
 *                     elem_format = PG_FORMAT_TEXT
 *                     elem_codec = self.declare_fallback_codec(
 */
      }

      /* "asyncpg/protocol/codecs/base.pyx":436
 *                         array_element_oid, name, schema)
 * 
 *                 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(4, 436, __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(4, 436, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_12 = __Pyx_PyObject_AsPy_UCS4(__pyx_t_8); if (unlikely((__pyx_t_12 == (Py_UCS4)-1) && PyErr_Occurred())) __PYX_ERR(4, 436, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_v_elem_delim = ((Py_UCS4)__pyx_t_12);

      /* "asyncpg/protocol/codecs/base.pyx":440
 *                 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(4, 440, __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(4, 440, __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(4, 440, __pyx_L1_error)

      /* "asyncpg/protocol/codecs/base.pyx":439
 * 
 *                 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(4, 439, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);

      /* "asyncpg/protocol/codecs/base.pyx":438
 *                 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(4, 438, __pyx_L1_error)
      }
      __pyx_t_4 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(__pyx_v_elem_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 438, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 438, __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(4, 438, __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":417
 *             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":442
 *                         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(4, 442, __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(4, 442, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (__pyx_t_6) {

      /* "asyncpg/protocol/codecs/base.pyx":443
 * 
 *             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(4, 443, __pyx_L1_error)
      __pyx_t_5 = ((!__pyx_t_6) != 0);
      if (__pyx_t_5) {

        /* "asyncpg/protocol/codecs/base.pyx":446
 *                     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(4, 446, __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(4, 446, __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(4, 446, __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(4, 446, __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(4, 446, __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(4, 446, __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":444
 *             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(4, 444, __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(4, 444, __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(4, 444, __pyx_L1_error)

        /* "asyncpg/protocol/codecs/base.pyx":443
 * 
 *             elif ti['kind'] == b'c':
 *                 if not comp_type_attrs:             # <<<<<<<<<<<<<<
 *                     raise RuntimeError(
 *                         'type record missing field types for '
 */
      }

      /* "asyncpg/protocol/codecs/base.pyx":450
 *                 # Composite type
 * 
 *                 comp_elem_codecs = []             # <<<<<<<<<<<<<<
 * 
 *                 for typoid in comp_type_attrs:
 */
      __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 450, __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":452
 *                 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_13 = 0;
        __pyx_t_14 = NULL;
      } else {
        __pyx_t_13 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_v_comp_type_attrs); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 452, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_14 = Py_TYPE(__pyx_t_8)->tp_iternext; if (unlikely(!__pyx_t_14)) __PYX_ERR(4, 452, __pyx_L1_error)
      }
      for (;;) {
        if (likely(!__pyx_t_14)) {
          if (likely(PyList_CheckExact(__pyx_t_8))) {
            if (__pyx_t_13 >= 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_13); __Pyx_INCREF(__pyx_t_9); __pyx_t_13++; if (unlikely(0 < 0)) __PYX_ERR(4, 452, __pyx_L1_error)
            #else
            __pyx_t_9 = PySequence_ITEM(__pyx_t_8, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 452, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_9);
            #endif
          } else {
            if (__pyx_t_13 >= 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_13); __Pyx_INCREF(__pyx_t_9); __pyx_t_13++; if (unlikely(0 < 0)) __PYX_ERR(4, 452, __pyx_L1_error)
            #else
            __pyx_t_9 = PySequence_ITEM(__pyx_t_8, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 452, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_9);
            #endif
          }
        } else {
          __pyx_t_9 = __pyx_t_14(__pyx_t_8);
          if (unlikely(!__pyx_t_9)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(4, 452, __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":453
 * 
 *                 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(4, 453, __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(4, 453, __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":454
 *                 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":455
 *                     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(4, 455, __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(4, 455, __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":456
 *                     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":454
 *                 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":457
 *                         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":459
 *                     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(4, 459, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);

          /* "asyncpg/protocol/codecs/base.pyx":460
 *                         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(4, 459, __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(4, 459, __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(4, 459, __pyx_L1_error)
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_GOTREF(__pyx_t_9);
            } else
            #endif
            {
              __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(4, 459, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_15);
              __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_4); __pyx_t_4 = NULL;
              __Pyx_INCREF(__pyx_v_typoid);
              __Pyx_GIVEREF(__pyx_v_typoid);
              PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_v_typoid);
              __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_15, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 459, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_9);
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            }
          }
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

          /* "asyncpg/protocol/codecs/base.pyx":458
 *                         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(4, 458, __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(4, 458, __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(4, 458, __pyx_L1_error)

          /* "asyncpg/protocol/codecs/base.pyx":457
 *                         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":461
 *                             'no codec for composite attribute type {}'.format(
 *                                 typoid))
 *                     comp_elem_codecs.append(elem_codec)             # <<<<<<<<<<<<<<
 * 
 *                 element_names = collections.OrderedDict()
 */
        __pyx_t_16 = __Pyx_PyList_Append(__pyx_v_comp_elem_codecs, ((PyObject *)__pyx_v_elem_codec)); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(4, 461, __pyx_L1_error)

        /* "asyncpg/protocol/codecs/base.pyx":452
 *                 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":463
 *                     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(4, 463, __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(4, 463, __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(4, 463, __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(4, 463, __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":464
 * 
 *                 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(4, 464, __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_13 = 0;
        __pyx_t_14 = NULL;
      } else {
        __pyx_t_13 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 464, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_14 = Py_TYPE(__pyx_t_9)->tp_iternext; if (unlikely(!__pyx_t_14)) __PYX_ERR(4, 464, __pyx_L1_error)
      }
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      for (;;) {
        if (likely(!__pyx_t_14)) {
          if (likely(PyList_CheckExact(__pyx_t_9))) {
            if (__pyx_t_13 >= 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_13); __Pyx_INCREF(__pyx_t_10); __pyx_t_13++; if (unlikely(0 < 0)) __PYX_ERR(4, 464, __pyx_L1_error)
            #else
            __pyx_t_10 = PySequence_ITEM(__pyx_t_9, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_10)) __PYX_ERR(4, 464, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_10);
            #endif
          } else {
            if (__pyx_t_13 >= 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_13); __Pyx_INCREF(__pyx_t_10); __pyx_t_13++; if (unlikely(0 < 0)) __PYX_ERR(4, 464, __pyx_L1_error)
            #else
            __pyx_t_10 = PySequence_ITEM(__pyx_t_9, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_10)) __PYX_ERR(4, 464, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_10);
            #endif
          }
        } else {
          __pyx_t_10 = __pyx_t_14(__pyx_t_9);
          if (unlikely(!__pyx_t_10)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(4, 464, __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(4, 464, __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":465
 *                 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(4, 465, __pyx_L1_error)

        /* "asyncpg/protocol/codecs/base.pyx":464
 * 
 *                 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":467
 *                     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":468
 * 
 *                 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":467
 *                     element_names[attrname] = i
 * 
 *                 if has_text_elements:             # <<<<<<<<<<<<<<
 *                     format = PG_FORMAT_TEXT
 * 
 */
      }

      /* "asyncpg/protocol/codecs/base.pyx":472
 *                 self._type_codecs_cache[oid, format] = \
 *                     Codec.new_composite_codec(
 *                         oid, name, schema, format, 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(4, 472, __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(4, 472, __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(4, 472, __pyx_L1_error)

      /* "asyncpg/protocol/codecs/base.pyx":473
 *                     Codec.new_composite_codec(
 *                         oid, name, schema, format, comp_elem_codecs,
 *                         comp_type_attrs, element_names)             # <<<<<<<<<<<<<<
 * 
 *             elif ti['kind'] == b'd':
 */
      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(4, 473, __pyx_L1_error)

      /* "asyncpg/protocol/codecs/base.pyx":471
 * 
 *                 self._type_codecs_cache[oid, format] = \
 *                     Codec.new_composite_codec(             # <<<<<<<<<<<<<<
 *                         oid, name, schema, format, comp_elem_codecs,
 *                         comp_type_attrs, element_names)
 */
      __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_format, __pyx_v_comp_elem_codecs, ((PyObject*)__pyx_v_comp_type_attrs), __pyx_v_element_names)); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 471, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);

      /* "asyncpg/protocol/codecs/base.pyx":470
 *                     format = PG_FORMAT_TEXT
 * 
 *                 self._type_codecs_cache[oid, format] = \             # <<<<<<<<<<<<<<
 *                     Codec.new_composite_codec(
 *                         oid, name, schema, format, comp_elem_codecs,
 */
      if (unlikely(__pyx_v_self->_type_codecs_cache == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(4, 470, __pyx_L1_error)
      }
      __pyx_t_9 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(__pyx_v_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 470, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(4, 470, __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(4, 470, __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":442
 *                         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":475
 *                         comp_type_attrs, 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(4, 475, __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(4, 475, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (__pyx_t_5) {

      /* "asyncpg/protocol/codecs/base.pyx":478
 *                 # 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(4, 478, __pyx_L1_error)
      __pyx_t_6 = ((!__pyx_t_5) != 0);
      if (__pyx_t_6) {

        /* "asyncpg/protocol/codecs/base.pyx":480
 *                 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(4, 480, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);

        /* "asyncpg/protocol/codecs/base.pyx":481
 *                     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(4, 480, __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(4, 480, __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(4, 480, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
            __Pyx_GOTREF(__pyx_t_8);
          } else
          #endif
          {
            __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(4, 480, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_15);
            __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_9); __pyx_t_9 = NULL;
            __Pyx_INCREF(__pyx_v_oid);
            __Pyx_GIVEREF(__pyx_v_oid);
            PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_v_oid);
            __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_15, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 480, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

        /* "asyncpg/protocol/codecs/base.pyx":479
 * 
 *                 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(4, 479, __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(4, 479, __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(4, 479, __pyx_L1_error)

        /* "asyncpg/protocol/codecs/base.pyx":478
 *                 # Domain type
 * 
 *                 if not base_type:             # <<<<<<<<<<<<<<
 *                     raise RuntimeError(
 *                         'type record missing base type for domain {}'.format(
 */
      }

      /* "asyncpg/protocol/codecs/base.pyx":483
 *                             oid))
 * 
 *                 elem_codec = self.get_codec(base_type, format)             # <<<<<<<<<<<<<<
 *                 if elem_codec is None:
 *                     format = PG_FORMAT_TEXT
 */
      __pyx_t_7 = __Pyx_PyInt_As_uint32_t(__pyx_v_base_type); if (unlikely((__pyx_t_7 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(4, 483, __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(4, 483, __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":484
 * 
 *                 elem_codec = self.get_codec(base_type, format)
 *                 if elem_codec is None:             # <<<<<<<<<<<<<<
 *                     format = PG_FORMAT_TEXT
 *                     elem_codec = self.declare_fallback_codec(
 */
      __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":485
 *                 elem_codec = self.get_codec(base_type, format)
 *                 if elem_codec is None:
 *                     format = PG_FORMAT_TEXT             # <<<<<<<<<<<<<<
 *                     elem_codec = self.declare_fallback_codec(
 *                         base_type, name, schema)
 */
        __pyx_v_format = __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT;

        /* "asyncpg/protocol/codecs/base.pyx":486
 *                 if elem_codec is None:
 *                     format = PG_FORMAT_TEXT
 *                     elem_codec = self.declare_fallback_codec(             # <<<<<<<<<<<<<<
 *                         base_type, name, schema)
 * 
 */
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_declare_fallback_codec); if (unlikely(!__pyx_t_10)) __PYX_ERR(4, 486, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);

        /* "asyncpg/protocol/codecs/base.pyx":487
 *                     format = PG_FORMAT_TEXT
 *                     elem_codec = self.declare_fallback_codec(
 *                         base_type, name, schema)             # <<<<<<<<<<<<<<
 * 
 *                 self._type_codecs_cache[oid, format] = elem_codec
 */
        __pyx_t_15 = NULL;
        __pyx_t_11 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_10);
          if (likely(__pyx_t_15)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
            __Pyx_INCREF(__pyx_t_15);
            __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[4] = {__pyx_t_15, __pyx_v_base_type, __pyx_v_name, __pyx_v_schema};
          __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 486, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_GOTREF(__pyx_t_8);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
          PyObject *__pyx_temp[4] = {__pyx_t_15, __pyx_v_base_type, __pyx_v_name, __pyx_v_schema};
          __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 486, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_GOTREF(__pyx_t_8);
        } else
        #endif
        {
          __pyx_t_9 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 486, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          if (__pyx_t_15) {
            __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_15); __pyx_t_15 = NULL;
          }
          __Pyx_INCREF(__pyx_v_base_type);
          __Pyx_GIVEREF(__pyx_v_base_type);
          PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_11, __pyx_v_base_type);
          __Pyx_INCREF(__pyx_v_name);
          __Pyx_GIVEREF(__pyx_v_name);
          PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_11, __pyx_v_name);
          __Pyx_INCREF(__pyx_v_schema);
          __Pyx_GIVEREF(__pyx_v_schema);
          PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_11, __pyx_v_schema);
          __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_9, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 486, __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":486
 *                 if elem_codec is None:
 *                     format = PG_FORMAT_TEXT
 *                     elem_codec = self.declare_fallback_codec(             # <<<<<<<<<<<<<<
 *                         base_type, name, schema)
 * 
 */
        if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_7asyncpg_8protocol_8protocol_Codec))))) __PYX_ERR(4, 486, __pyx_L1_error)
        __Pyx_DECREF_SET(__pyx_v_elem_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_8));
        __pyx_t_8 = 0;

        /* "asyncpg/protocol/codecs/base.pyx":484
 * 
 *                 elem_codec = self.get_codec(base_type, format)
 *                 if elem_codec is None:             # <<<<<<<<<<<<<<
 *                     format = PG_FORMAT_TEXT
 *                     elem_codec = self.declare_fallback_codec(
 */
      }

      /* "asyncpg/protocol/codecs/base.pyx":489
 *                         base_type, name, schema)
 * 
 *                 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(4, 489, __pyx_L1_error)
      }
      __pyx_t_8 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(__pyx_v_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 489, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(4, 489, __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(4, 489, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

      /* "asyncpg/protocol/codecs/base.pyx":475
 *                         comp_type_attrs, element_names)
 * 
 *             elif ti['kind'] == b'd':             # <<<<<<<<<<<<<<
 *                 # Domain type
 * 
 */
      goto __pyx_L8;
    }

    /* "asyncpg/protocol/codecs/base.pyx":491
 *                 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(4, 491, __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(4, 491, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (__pyx_t_5) {

      /* "asyncpg/protocol/codecs/base.pyx":494
 *                 # 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(4, 494, __pyx_L1_error)
      __pyx_t_6 = ((!__pyx_t_5) != 0);
      if (__pyx_t_6) {

        /* "asyncpg/protocol/codecs/base.pyx":496
 *                 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(4, 496, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);

        /* "asyncpg/protocol/codecs/base.pyx":497
 *                     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(4, 496, __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(4, 496, __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(4, 496, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
            __Pyx_GOTREF(__pyx_t_10);
          } else
          #endif
          {
            __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(4, 496, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_15);
            __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_9); __pyx_t_9 = NULL;
            __Pyx_INCREF(__pyx_v_oid);
            __Pyx_GIVEREF(__pyx_v_oid);
            PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_v_oid);
            __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_15, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(4, 496, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

        /* "asyncpg/protocol/codecs/base.pyx":495
 * 
 *                 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(4, 495, __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(4, 495, __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(4, 495, __pyx_L1_error)

        /* "asyncpg/protocol/codecs/base.pyx":494
 *                 # Range type
 * 
 *                 if not range_subtype_oid:             # <<<<<<<<<<<<<<
 *                     raise RuntimeError(
 *                         'type record missing base type for range {}'.format(
 */
      }

      /* "asyncpg/protocol/codecs/base.pyx":499
 *                             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(4, 499, __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(4, 499, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (__pyx_t_6) {

        /* "asyncpg/protocol/codecs/base.pyx":500
 * 
 *                 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":499
 *                             oid))
 * 
 *                 if ti['elem_has_bin_io']:             # <<<<<<<<<<<<<<
 *                     elem_format = PG_FORMAT_BINARY
 *                 else:
 */
        goto __pyx_L23;
      }

      /* "asyncpg/protocol/codecs/base.pyx":502
 *                     elem_format = PG_FORMAT_BINARY
 *                 else:
 *                     elem_format = PG_FORMAT_TEXT             # <<<<<<<<<<<<<<
 * 
 *                 elem_codec = self.get_codec(range_subtype_oid, elem_format)
 */
      /*else*/ {
        __pyx_v_elem_format = __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT;
      }
      __pyx_L23:;

      /* "asyncpg/protocol/codecs/base.pyx":504
 *                     elem_format = PG_FORMAT_TEXT
 * 
 *                 elem_codec = self.get_codec(range_subtype_oid, elem_format)             # <<<<<<<<<<<<<<
 *                 if elem_codec is None:
 *                     elem_format = PG_FORMAT_TEXT
 */
      __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(4, 504, __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(4, 504, __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":505
 * 
 *                 elem_codec = self.get_codec(range_subtype_oid, elem_format)
 *                 if elem_codec is None:             # <<<<<<<<<<<<<<
 *                     elem_format = PG_FORMAT_TEXT
 *                     elem_codec = self.declare_fallback_codec(
 */
      __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":506
 *                 elem_codec = self.get_codec(range_subtype_oid, elem_format)
 *                 if elem_codec is None:
 *                     elem_format = PG_FORMAT_TEXT             # <<<<<<<<<<<<<<
 *                     elem_codec = self.declare_fallback_codec(
 *                         range_subtype_oid, name, schema)
 */
        __pyx_v_elem_format = __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT;

        /* "asyncpg/protocol/codecs/base.pyx":507
 *                 if elem_codec is None:
 *                     elem_format = PG_FORMAT_TEXT
 *                     elem_codec = self.declare_fallback_codec(             # <<<<<<<<<<<<<<
 *                         range_subtype_oid, name, schema)
 * 
 */
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_declare_fallback_codec); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 507, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);

        /* "asyncpg/protocol/codecs/base.pyx":508
 *                     elem_format = PG_FORMAT_TEXT
 *                     elem_codec = self.declare_fallback_codec(
 *                         range_subtype_oid, name, schema)             # <<<<<<<<<<<<<<
 * 
 *                 self._type_codecs_cache[oid, elem_format] = \
 */
        __pyx_t_15 = NULL;
        __pyx_t_11 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_8);
          if (likely(__pyx_t_15)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
            __Pyx_INCREF(__pyx_t_15);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_8, function);
            __pyx_t_11 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_8)) {
          PyObject *__pyx_temp[4] = {__pyx_t_15, __pyx_v_range_subtype_oid, __pyx_v_name, __pyx_v_schema};
          __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(4, 507, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_GOTREF(__pyx_t_10);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
          PyObject *__pyx_temp[4] = {__pyx_t_15, __pyx_v_range_subtype_oid, __pyx_v_name, __pyx_v_schema};
          __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(4, 507, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_GOTREF(__pyx_t_10);
        } else
        #endif
        {
          __pyx_t_9 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 507, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          if (__pyx_t_15) {
            __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_15); __pyx_t_15 = NULL;
          }
          __Pyx_INCREF(__pyx_v_range_subtype_oid);
          __Pyx_GIVEREF(__pyx_v_range_subtype_oid);
          PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_11, __pyx_v_range_subtype_oid);
          __Pyx_INCREF(__pyx_v_name);
          __Pyx_GIVEREF(__pyx_v_name);
          PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_11, __pyx_v_name);
          __Pyx_INCREF(__pyx_v_schema);
          __Pyx_GIVEREF(__pyx_v_schema);
          PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_11, __pyx_v_schema);
          __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_9, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(4, 507, __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":507
 *                 if elem_codec is None:
 *                     elem_format = PG_FORMAT_TEXT
 *                     elem_codec = self.declare_fallback_codec(             # <<<<<<<<<<<<<<
 *                         range_subtype_oid, name, schema)
 * 
 */
        if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_7asyncpg_8protocol_8protocol_Codec))))) __PYX_ERR(4, 507, __pyx_L1_error)
        __Pyx_DECREF_SET(__pyx_v_elem_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_10));
        __pyx_t_10 = 0;

        /* "asyncpg/protocol/codecs/base.pyx":505
 * 
 *                 elem_codec = self.get_codec(range_subtype_oid, elem_format)
 *                 if elem_codec is None:             # <<<<<<<<<<<<<<
 *                     elem_format = PG_FORMAT_TEXT
 *                     elem_codec = self.declare_fallback_codec(
 */
      }

      /* "asyncpg/protocol/codecs/base.pyx":511
 * 
 *                 self._type_codecs_cache[oid, elem_format] = \
 *                     Codec.new_range_codec(oid, name, schema, elem_codec)             # <<<<<<<<<<<<<<
 * 
 *             elif ti['kind'] == b'e':
 */
      __pyx_t_7 = __Pyx_PyInt_As_uint32_t(__pyx_v_oid); if (unlikely((__pyx_t_7 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(4, 511, __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(4, 511, __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(4, 511, __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(4, 511, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);

      /* "asyncpg/protocol/codecs/base.pyx":510
 *                         range_subtype_oid, name, schema)
 * 
 *                 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(4, 510, __pyx_L1_error)
      }
      __pyx_t_8 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(__pyx_v_elem_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 510, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 510, __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(4, 510, __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":491
 *                 self._type_codecs_cache[oid, format] = elem_codec
 * 
 *             elif ti['kind'] == b'r':             # <<<<<<<<<<<<<<
 *                 # Range type
 * 
 */
      goto __pyx_L8;
    }

    /* "asyncpg/protocol/codecs/base.pyx":513
 *                     Codec.new_range_codec(oid, name, schema, elem_codec)
 * 
 *             elif ti['kind'] == b'e':             # <<<<<<<<<<<<<<
 *                 # Enum types are essentially text
 *                 self._set_builtin_type_codec(oid, name, schema, 'scalar',
 */
    __pyx_t_10 = PyObject_GetItem(__pyx_v_ti, __pyx_n_u_kind); if (unlikely(!__pyx_t_10)) __PYX_ERR(4, 513, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_5 = (__Pyx_PyBytes_Equals(__pyx_t_10, __pyx_n_b_e, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(4, 513, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (__pyx_t_5) {

      /* "asyncpg/protocol/codecs/base.pyx":515
 *             elif ti['kind'] == b'e':
 *                 # Enum types are essentially text
 *                 self._set_builtin_type_codec(oid, name, schema, 'scalar',             # <<<<<<<<<<<<<<
 *                                              TEXTOID, PG_FORMAT_ANY)
 *             else:
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set_builtin_type_codec_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 515, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);

      /* "asyncpg/protocol/codecs/base.pyx":516
 *                 # Enum types are essentially text
 *                 self._set_builtin_type_codec(oid, name, schema, 'scalar',
 *                                              TEXTOID, PG_FORMAT_ANY)             # <<<<<<<<<<<<<<
 *             else:
 *                 self.declare_fallback_codec(oid, name, schema)
 */
      __pyx_t_8 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(__pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_ANY); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 516, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_15 = NULL;
      __pyx_t_11 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_15)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_15);
          __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[7] = {__pyx_t_15, __pyx_v_oid, __pyx_v_name, __pyx_v_schema, __pyx_n_u_scalar, __pyx_int_25, __pyx_t_8};
        __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 6+__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(4, 515, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[7] = {__pyx_t_15, __pyx_v_oid, __pyx_v_name, __pyx_v_schema, __pyx_n_u_scalar, __pyx_int_25, __pyx_t_8};
        __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 6+__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(4, 515, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      {
        __pyx_t_4 = PyTuple_New(6+__pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 515, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        if (__pyx_t_15) {
          __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_15); __pyx_t_15 = NULL;
        }
        __Pyx_INCREF(__pyx_v_oid);
        __Pyx_GIVEREF(__pyx_v_oid);
        PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_11, __pyx_v_oid);
        __Pyx_INCREF(__pyx_v_name);
        __Pyx_GIVEREF(__pyx_v_name);
        PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_11, __pyx_v_name);
        __Pyx_INCREF(__pyx_v_schema);
        __Pyx_GIVEREF(__pyx_v_schema);
        PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_11, __pyx_v_schema);
        __Pyx_INCREF(__pyx_n_u_scalar);
        __Pyx_GIVEREF(__pyx_n_u_scalar);
        PyTuple_SET_ITEM(__pyx_t_4, 3+__pyx_t_11, __pyx_n_u_scalar);
        __Pyx_INCREF(__pyx_int_25);
        __Pyx_GIVEREF(__pyx_int_25);
        PyTuple_SET_ITEM(__pyx_t_4, 4+__pyx_t_11, __pyx_int_25);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_4, 5+__pyx_t_11, __pyx_t_8);
        __pyx_t_8 = 0;
        __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_4, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(4, 515, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

      /* "asyncpg/protocol/codecs/base.pyx":513
 *                     Codec.new_range_codec(oid, name, schema, elem_codec)
 * 
 *             elif ti['kind'] == b'e':             # <<<<<<<<<<<<<<
 *                 # Enum types are essentially text
 *                 self._set_builtin_type_codec(oid, name, schema, 'scalar',
 */
      goto __pyx_L8;
    }

    /* "asyncpg/protocol/codecs/base.pyx":518
 *                                              TEXTOID, PG_FORMAT_ANY)
 *             else:
 *                 self.declare_fallback_codec(oid, name, schema)             # <<<<<<<<<<<<<<
 * 
 *     def add_python_codec(self, typeoid, typename, typeschema, typekind,
 */
    /*else*/ {
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_declare_fallback_codec); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 518, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_4 = NULL;
      __pyx_t_11 = 0;
      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);
          __pyx_t_11 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_oid, __pyx_v_name, __pyx_v_schema};
        __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(4, 518, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_10);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_oid, __pyx_v_name, __pyx_v_schema};
        __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(4, 518, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_10);
      } else
      #endif
      {
        __pyx_t_8 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 518, __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_INCREF(__pyx_v_oid);
        __Pyx_GIVEREF(__pyx_v_oid);
        PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_11, __pyx_v_oid);
        __Pyx_INCREF(__pyx_v_name);
        __Pyx_GIVEREF(__pyx_v_name);
        PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_11, __pyx_v_name);
        __Pyx_INCREF(__pyx_v_schema);
        __Pyx_GIVEREF(__pyx_v_schema);
        PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_11, __pyx_v_schema);
        __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_8, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(4, 518, __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":394
 *             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":385
 *         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_15);
  __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":520
 *                 self.declare_fallback_codec(oid, name, schema)
 * 
 *     def add_python_codec(self, typeoid, typename, typeschema, typekind,             # <<<<<<<<<<<<<<
 *                          encoder, decoder, format, xformat):
 *         cdef:
 */

/* 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_format = 0;
  PyObject *__pyx_v_xformat = 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_format,&__pyx_n_s_xformat,0};
    PyObject* values[8] = {0,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  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typename)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_python_codec", 1, 8, 8, 1); __PYX_ERR(4, 520, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typeschema)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_python_codec", 1, 8, 8, 2); __PYX_ERR(4, 520, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typekind)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_python_codec", 1, 8, 8, 3); __PYX_ERR(4, 520, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_encoder)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_python_codec", 1, 8, 8, 4); __PYX_ERR(4, 520, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_decoder)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_python_codec", 1, 8, 8, 5); __PYX_ERR(4, 520, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_format)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_python_codec", 1, 8, 8, 6); __PYX_ERR(4, 520, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_xformat)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_python_codec", 1, 8, 8, 7); __PYX_ERR(4, 520, __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(4, 520, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 8) {
      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);
      values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
    }
    __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_format = values[6];
    __pyx_v_xformat = values[7];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_python_codec", 1, 8, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(4, 520, __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_format, __pyx_v_xformat);

  /* 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_format, PyObject *__pyx_v_xformat) {
  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_core_codec = 0;
  __pyx_t_7asyncpg_8protocol_8protocol_encode_func __pyx_v_c_encoder;
  __pyx_t_7asyncpg_8protocol_8protocol_decode_func __pyx_v_c_decoder;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  uint32_t __pyx_t_4;
  enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat __pyx_t_5;
  enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat __pyx_t_6;
  struct __pyx_opt_args_7asyncpg_8protocol_8protocol_get_any_core_codec __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  __pyx_t_7asyncpg_8protocol_8protocol_encode_func __pyx_t_11;
  __pyx_t_7asyncpg_8protocol_8protocol_decode_func __pyx_t_12;
  int __pyx_t_13;
  __Pyx_RefNannySetupContext("add_python_codec", 0);
  __Pyx_INCREF(__pyx_v_format);

  /* "asyncpg/protocol/codecs/base.pyx":524
 *         cdef:
 *             Codec core_codec
 *             encode_func c_encoder = NULL             # <<<<<<<<<<<<<<
 *             decode_func c_decoder = NULL
 * 
 */
  __pyx_v_c_encoder = NULL;

  /* "asyncpg/protocol/codecs/base.pyx":525
 *             Codec core_codec
 *             encode_func c_encoder = NULL
 *             decode_func c_decoder = NULL             # <<<<<<<<<<<<<<
 * 
 *         if xformat == PG_XFORMAT_TUPLE:
 */
  __pyx_v_c_decoder = NULL;

  /* "asyncpg/protocol/codecs/base.pyx":527
 *             decode_func c_decoder = NULL
 * 
 *         if xformat == PG_XFORMAT_TUPLE:             # <<<<<<<<<<<<<<
 *             core_codec = get_any_core_codec(typeoid, format, xformat)
 *             if core_codec is None:
 */
  __pyx_t_1 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat(__pyx_e_7asyncpg_8protocol_8protocol_PG_XFORMAT_TUPLE); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_xformat, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 527, __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(4, 527, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "asyncpg/protocol/codecs/base.pyx":528
 * 
 *         if xformat == PG_XFORMAT_TUPLE:
 *             core_codec = get_any_core_codec(typeoid, format, xformat)             # <<<<<<<<<<<<<<
 *             if core_codec is None:
 *                 raise ValueError(
 */
    __pyx_t_4 = __Pyx_PyInt_As_uint32_t(__pyx_v_typeoid); if (unlikely((__pyx_t_4 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(4, 528, __pyx_L1_error)
    __pyx_t_5 = ((enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)__Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(__pyx_v_format)); if (unlikely(PyErr_Occurred())) __PYX_ERR(4, 528, __pyx_L1_error)
    __pyx_t_6 = ((enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)__Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat(__pyx_v_xformat)); if (unlikely(PyErr_Occurred())) __PYX_ERR(4, 528, __pyx_L1_error)
    __pyx_t_7.__pyx_n = 1;
    __pyx_t_7.xformat = __pyx_t_6;
    __pyx_t_2 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_get_any_core_codec(__pyx_t_4, __pyx_t_5, &__pyx_t_7)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 528, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_core_codec = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "asyncpg/protocol/codecs/base.pyx":529
 *         if xformat == PG_XFORMAT_TUPLE:
 *             core_codec = get_any_core_codec(typeoid, format, xformat)
 *             if core_codec is None:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     "{} type does not support 'tuple' exchange format".format(
 */
    __pyx_t_3 = (((PyObject *)__pyx_v_core_codec) == Py_None);
    __pyx_t_8 = (__pyx_t_3 != 0);
    if (__pyx_t_8) {

      /* "asyncpg/protocol/codecs/base.pyx":531
 *             if core_codec is None:
 *                 raise ValueError(
 *                     "{} type does not support 'tuple' exchange format".format(             # <<<<<<<<<<<<<<
 *                         typename))
 *             c_encoder = core_codec.c_encoder
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_type_does_not_support_tuple_exc, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 531, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);

      /* "asyncpg/protocol/codecs/base.pyx":532
 *                 raise ValueError(
 *                     "{} type does not support 'tuple' exchange format".format(
 *                         typename))             # <<<<<<<<<<<<<<
 *             c_encoder = core_codec.c_encoder
 *             c_decoder = core_codec.c_decoder
 */
      __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_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_typename); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 531, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_1)) {
          PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_typename};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 531, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
          PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_typename};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 531, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(4, 531, __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_typename);
          __Pyx_GIVEREF(__pyx_v_typename);
          PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_typename);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 531, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "asyncpg/protocol/codecs/base.pyx":530
 *             core_codec = get_any_core_codec(typeoid, format, xformat)
 *             if core_codec is None:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     "{} type does not support 'tuple' exchange format".format(
 *                         typename))
 */
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 530, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 530, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __PYX_ERR(4, 530, __pyx_L1_error)

      /* "asyncpg/protocol/codecs/base.pyx":529
 *         if xformat == PG_XFORMAT_TUPLE:
 *             core_codec = get_any_core_codec(typeoid, format, xformat)
 *             if core_codec is None:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     "{} type does not support 'tuple' exchange format".format(
 */
    }

    /* "asyncpg/protocol/codecs/base.pyx":533
 *                     "{} type does not support 'tuple' exchange format".format(
 *                         typename))
 *             c_encoder = core_codec.c_encoder             # <<<<<<<<<<<<<<
 *             c_decoder = core_codec.c_decoder
 *             format = core_codec.format
 */
    __pyx_t_11 = __pyx_v_core_codec->c_encoder;
    __pyx_v_c_encoder = __pyx_t_11;

    /* "asyncpg/protocol/codecs/base.pyx":534
 *                         typename))
 *             c_encoder = core_codec.c_encoder
 *             c_decoder = core_codec.c_decoder             # <<<<<<<<<<<<<<
 *             format = core_codec.format
 * 
 */
    __pyx_t_12 = __pyx_v_core_codec->c_decoder;
    __pyx_v_c_decoder = __pyx_t_12;

    /* "asyncpg/protocol/codecs/base.pyx":535
 *             c_encoder = core_codec.c_encoder
 *             c_decoder = core_codec.c_decoder
 *             format = core_codec.format             # <<<<<<<<<<<<<<
 * 
 *         # Clear all previous overrides (this also clears type cache).
 */
    __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(__pyx_v_core_codec->format); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 535, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF_SET(__pyx_v_format, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "asyncpg/protocol/codecs/base.pyx":527
 *             decode_func c_decoder = NULL
 * 
 *         if xformat == PG_XFORMAT_TUPLE:             # <<<<<<<<<<<<<<
 *             core_codec = get_any_core_codec(typeoid, format, xformat)
 *             if core_codec is None:
 */
  }

  /* "asyncpg/protocol/codecs/base.pyx":538
 * 
 *         # Clear all previous overrides (this also clears type cache).
 *         self.remove_python_codec(typeoid, typename, typeschema)             # <<<<<<<<<<<<<<
 * 
 *         self._local_type_codecs[typeoid] = \
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_remove_python_codec); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 538, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_10 = NULL;
  __pyx_t_13 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_13 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_v_typeoid, __pyx_v_typename, __pyx_v_typeschema};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_13, 3+__pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 538, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_v_typeoid, __pyx_v_typename, __pyx_v_typeschema};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_13, 3+__pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 538, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  {
    __pyx_t_9 = PyTuple_New(3+__pyx_t_13); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 538, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_10) {
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10); __pyx_t_10 = NULL;
    }
    __Pyx_INCREF(__pyx_v_typeoid);
    __Pyx_GIVEREF(__pyx_v_typeoid);
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_13, __pyx_v_typeoid);
    __Pyx_INCREF(__pyx_v_typename);
    __Pyx_GIVEREF(__pyx_v_typename);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_13, __pyx_v_typename);
    __Pyx_INCREF(__pyx_v_typeschema);
    __Pyx_GIVEREF(__pyx_v_typeschema);
    PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_13, __pyx_v_typeschema);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 538, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/codecs/base.pyx":541
 * 
 *         self._local_type_codecs[typeoid] = \
 *             Codec.new_python_codec(typeoid, typename, typeschema, typekind,             # <<<<<<<<<<<<<<
 *                                    encoder, decoder, c_encoder, c_decoder,
 *                                    format, xformat)
 */
  __pyx_t_4 = __Pyx_PyInt_As_uint32_t(__pyx_v_typeoid); if (unlikely((__pyx_t_4 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(4, 541, __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(4, 541, __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(4, 541, __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(4, 541, __pyx_L1_error)

  /* "asyncpg/protocol/codecs/base.pyx":543
 *             Codec.new_python_codec(typeoid, typename, typeschema, typekind,
 *                                    encoder, decoder, c_encoder, c_decoder,
 *                                    format, xformat)             # <<<<<<<<<<<<<<
 * 
 *     def remove_python_codec(self, typeoid, typename, typeschema):
 */
  __pyx_t_5 = ((enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)__Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(__pyx_v_format)); if (unlikely(PyErr_Occurred())) __PYX_ERR(4, 543, __pyx_L1_error)
  __pyx_t_6 = ((enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)__Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat(__pyx_v_xformat)); if (unlikely(PyErr_Occurred())) __PYX_ERR(4, 543, __pyx_L1_error)

  /* "asyncpg/protocol/codecs/base.pyx":541
 * 
 *         self._local_type_codecs[typeoid] = \
 *             Codec.new_python_codec(typeoid, typename, typeschema, typekind,             # <<<<<<<<<<<<<<
 *                                    encoder, decoder, c_encoder, c_decoder,
 *                                    format, xformat)
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_5Codec_new_python_codec(__pyx_t_4, ((PyObject*)__pyx_v_typename), ((PyObject*)__pyx_v_typeschema), ((PyObject*)__pyx_v_typekind), __pyx_v_encoder, __pyx_v_decoder, __pyx_v_c_encoder, __pyx_v_c_decoder, __pyx_t_5, __pyx_t_6)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 541, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "asyncpg/protocol/codecs/base.pyx":540
 *         self.remove_python_codec(typeoid, typename, typeschema)
 * 
 *         self._local_type_codecs[typeoid] = \             # <<<<<<<<<<<<<<
 *             Codec.new_python_codec(typeoid, typename, typeschema, typekind,
 *                                    encoder, decoder, c_encoder, c_decoder,
 */
  if (unlikely(__pyx_v_self->_local_type_codecs == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 540, __pyx_L1_error)
  }
  if (unlikely(PyDict_SetItem(__pyx_v_self->_local_type_codecs, __pyx_v_typeoid, __pyx_t_2) < 0)) __PYX_ERR(4, 540, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/codecs/base.pyx":520
 *                 self.declare_fallback_codec(oid, name, schema)
 * 
 *     def add_python_codec(self, typeoid, typename, typeschema, typekind,             # <<<<<<<<<<<<<<
 *                          encoder, decoder, format, xformat):
 *         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_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.DataCodecConfig.add_python_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_core_codec);
  __Pyx_XDECREF(__pyx_v_format);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/codecs/base.pyx":545
 *                                    format, xformat)
 * 
 *     def remove_python_codec(self, typeoid, typename, typeschema):             # <<<<<<<<<<<<<<
 *         self._local_type_codecs.pop(typeoid, None)
 *         self.clear_type_cache()
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_7remove_python_codec(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_7remove_python_codec(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_typeoid = 0;
  CYTHON_UNUSED PyObject *__pyx_v_typename = 0;
  CYTHON_UNUSED PyObject *__pyx_v_typeschema = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remove_python_codec (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_typeoid,&__pyx_n_s_typename,&__pyx_n_s_typeschema,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typename)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remove_python_codec", 1, 3, 3, 1); __PYX_ERR(4, 545, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typeschema)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("remove_python_codec", 1, 3, 3, 2); __PYX_ERR(4, 545, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "remove_python_codec") < 0)) __PYX_ERR(4, 545, __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_typeoid = values[0];
    __pyx_v_typename = values[1];
    __pyx_v_typeschema = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("remove_python_codec", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(4, 545, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("asyncpg.protocol.protocol.DataCodecConfig.remove_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_6remove_python_codec(((struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *)__pyx_v_self), __pyx_v_typeoid, __pyx_v_typename, __pyx_v_typeschema);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig_6remove_python_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *__pyx_v_self, PyObject *__pyx_v_typeoid, CYTHON_UNUSED PyObject *__pyx_v_typename, CYTHON_UNUSED PyObject *__pyx_v_typeschema) {
  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("remove_python_codec", 0);

  /* "asyncpg/protocol/codecs/base.pyx":546
 * 
 *     def remove_python_codec(self, typeoid, typename, typeschema):
 *         self._local_type_codecs.pop(typeoid, None)             # <<<<<<<<<<<<<<
 *         self.clear_type_cache()
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_local_type_codecs, __pyx_n_s_pop); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 546, __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, __pyx_v_typeoid, Py_None};
    __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(4, 546, __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, __pyx_v_typeoid, Py_None};
    __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(4, 546, __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(4, 546, __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(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, Py_None);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 546, __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/codecs/base.pyx":547
 *     def remove_python_codec(self, typeoid, typename, typeschema):
 *         self._local_type_codecs.pop(typeoid, None)
 *         self.clear_type_cache()             # <<<<<<<<<<<<<<
 * 
 *     def _set_builtin_type_codec(self, typeoid, typename, typeschema, typekind,
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_clear_type_cache); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 547, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __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_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 547, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 547, __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/base.pyx":545
 *                                    format, xformat)
 * 
 *     def remove_python_codec(self, typeoid, typename, typeschema):             # <<<<<<<<<<<<<<
 *         self._local_type_codecs.pop(typeoid, None)
 *         self.clear_type_cache()
 */

  /* 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.DataCodecConfig.remove_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":549
 *         self.clear_type_cache()
 * 
 *     def _set_builtin_type_codec(self, typeoid, typename, typeschema, typekind,             # <<<<<<<<<<<<<<
 *                                 alias_to, format=PG_FORMAT_ANY):
 *         cdef:
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_9_set_builtin_type_codec(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_9_set_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_v_format = 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,&__pyx_n_s_format,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    values[5] = __pyx_k__37;
    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);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typename)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_set_builtin_type_codec", 0, 5, 6, 1); __PYX_ERR(4, 549, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typeschema)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_set_builtin_type_codec", 0, 5, 6, 2); __PYX_ERR(4, 549, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typekind)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_set_builtin_type_codec", 0, 5, 6, 3); __PYX_ERR(4, 549, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        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", 0, 5, 6, 4); __PYX_ERR(4, 549, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_format);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_set_builtin_type_codec") < 0)) __PYX_ERR(4, 549, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __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];
    __pyx_v_format = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_set_builtin_type_codec", 0, 5, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(4, 549, __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_8_set_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, __pyx_v_format);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig_8_set_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, PyObject *__pyx_v_format) {
  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_formats = 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;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  uint32_t __pyx_t_7;
  enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat __pyx_t_8;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("_set_builtin_type_codec", 0);
  __Pyx_INCREF(__pyx_v_format);

  /* "asyncpg/protocol/codecs/base.pyx":555
 *             Codec target_codec
 * 
 *         if format == PG_FORMAT_ANY:             # <<<<<<<<<<<<<<
 *             formats = (PG_FORMAT_BINARY, PG_FORMAT_TEXT)
 *         else:
 */
  __pyx_t_1 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(__pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_ANY); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 555, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_format, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 555, __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(4, 555, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "asyncpg/protocol/codecs/base.pyx":556
 * 
 *         if format == PG_FORMAT_ANY:
 *             formats = (PG_FORMAT_BINARY, PG_FORMAT_TEXT)             # <<<<<<<<<<<<<<
 *         else:
 *             formats = (format,)
 */
    __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(__pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(__pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_2 = 0;
    __pyx_t_1 = 0;
    __pyx_v_formats = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "asyncpg/protocol/codecs/base.pyx":555
 *             Codec target_codec
 * 
 *         if format == PG_FORMAT_ANY:             # <<<<<<<<<<<<<<
 *             formats = (PG_FORMAT_BINARY, PG_FORMAT_TEXT)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "asyncpg/protocol/codecs/base.pyx":558
 *             formats = (PG_FORMAT_BINARY, PG_FORMAT_TEXT)
 *         else:
 *             formats = (format,)             # <<<<<<<<<<<<<<
 * 
 *         for format in formats:
 */
  /*else*/ {
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 558, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_format);
    __Pyx_GIVEREF(__pyx_v_format);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_format);
    __pyx_v_formats = __pyx_t_4;
    __pyx_t_4 = 0;
  }
  __pyx_L3:;

  /* "asyncpg/protocol/codecs/base.pyx":560
 *             formats = (format,)
 * 
 *         for format in formats:             # <<<<<<<<<<<<<<
 *             if self.get_codec(typeoid, format) is not None:
 *                 raise ValueError('cannot override codec for type {}'.format(
 */
  if (likely(PyList_CheckExact(__pyx_v_formats)) || PyTuple_CheckExact(__pyx_v_formats)) {
    __pyx_t_4 = __pyx_v_formats; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_formats); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 560, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 560, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(4, 560, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 560, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(4, 560, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 560, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_6(__pyx_t_4);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(4, 560, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_DECREF_SET(__pyx_v_format, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "asyncpg/protocol/codecs/base.pyx":561
 * 
 *         for format in formats:
 *             if self.get_codec(typeoid, format) is not None:             # <<<<<<<<<<<<<<
 *                 raise ValueError('cannot override codec for type {}'.format(
 *                     typeoid))
 */
    __pyx_t_7 = __Pyx_PyInt_As_uint32_t(__pyx_v_typeoid); if (unlikely((__pyx_t_7 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(4, 561, __pyx_L1_error)
    __pyx_t_8 = ((enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)__Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(__pyx_v_format)); if (unlikely(PyErr_Occurred())) __PYX_ERR(4, 561, __pyx_L1_error)
    __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_15DataCodecConfig_get_codec(__pyx_v_self, __pyx_t_7, __pyx_t_8)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 561, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = (__pyx_t_1 != Py_None);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_9 = (__pyx_t_3 != 0);
    if (__pyx_t_9) {

      /* "asyncpg/protocol/codecs/base.pyx":562
 *         for format in formats:
 *             if self.get_codec(typeoid, format) is not None:
 *                 raise ValueError('cannot override codec for type {}'.format(             # <<<<<<<<<<<<<<
 *                     typeoid))
 * 
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_cannot_override_codec_for_type, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 562, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);

      /* "asyncpg/protocol/codecs/base.pyx":563
 *             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_10 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      if (!__pyx_t_10) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_typeoid); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 562, __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_10, __pyx_v_typeoid};
          __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 562, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 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_10, __pyx_v_typeoid};
          __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 562, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_1);
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(4, 562, __pyx_L1_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_INCREF(__pyx_v_typeoid);
          __Pyx_GIVEREF(__pyx_v_typeoid);
          PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_typeoid);
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 562, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "asyncpg/protocol/codecs/base.pyx":562
 *         for format in formats:
 *             if self.get_codec(typeoid, format) is not None:
 *                 raise ValueError('cannot override codec for type {}'.format(             # <<<<<<<<<<<<<<
 *                     typeoid))
 * 
 */
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 562, __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(4, 562, __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(4, 562, __pyx_L1_error)

      /* "asyncpg/protocol/codecs/base.pyx":561
 * 
 *         for format in formats:
 *             if self.get_codec(typeoid, format) is not None:             # <<<<<<<<<<<<<<
 *                 raise ValueError('cannot override codec for type {}'.format(
 *                     typeoid))
 */
    }

    /* "asyncpg/protocol/codecs/base.pyx":565
 *                     typeoid))
 * 
 *             if isinstance(alias_to, int):             # <<<<<<<<<<<<<<
 *                 target_codec = self.get_codec(alias_to, format)
 *             else:
 */
    __pyx_t_9 = PyInt_Check(__pyx_v_alias_to); 
    __pyx_t_3 = (__pyx_t_9 != 0);
    if (__pyx_t_3) {

      /* "asyncpg/protocol/codecs/base.pyx":566
 * 
 *             if isinstance(alias_to, int):
 *                 target_codec = self.get_codec(alias_to, format)             # <<<<<<<<<<<<<<
 *             else:
 *                 target_codec = get_extra_codec(alias_to, format)
 */
      __pyx_t_7 = __Pyx_PyInt_As_uint32_t(__pyx_v_alias_to); if (unlikely((__pyx_t_7 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(4, 566, __pyx_L1_error)
      __pyx_t_8 = ((enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)__Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(__pyx_v_format)); if (unlikely(PyErr_Occurred())) __PYX_ERR(4, 566, __pyx_L1_error)
      __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_15DataCodecConfig_get_codec(__pyx_v_self, __pyx_t_7, __pyx_t_8)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 566, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_XDECREF_SET(__pyx_v_target_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_1));
      __pyx_t_1 = 0;

      /* "asyncpg/protocol/codecs/base.pyx":565
 *                     typeoid))
 * 
 *             if isinstance(alias_to, int):             # <<<<<<<<<<<<<<
 *                 target_codec = self.get_codec(alias_to, format)
 *             else:
 */
      goto __pyx_L7;
    }

    /* "asyncpg/protocol/codecs/base.pyx":568
 *                 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(4, 568, __pyx_L1_error)
      __pyx_t_8 = ((enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)__Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(__pyx_v_format)); if (unlikely(PyErr_Occurred())) __PYX_ERR(4, 568, __pyx_L1_error)
      __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_get_extra_codec(((PyObject*)__pyx_v_alias_to), __pyx_t_8)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 568, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_XDECREF_SET(__pyx_v_target_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_1));
      __pyx_t_1 = 0;
    }
    __pyx_L7:;

    /* "asyncpg/protocol/codecs/base.pyx":570
 *                 target_codec = get_extra_codec(alias_to, format)
 * 
 *             if target_codec is None:             # <<<<<<<<<<<<<<
 *                 continue
 * 
 */
    __pyx_t_3 = (((PyObject *)__pyx_v_target_codec) == Py_None);
    __pyx_t_9 = (__pyx_t_3 != 0);
    if (__pyx_t_9) {

      /* "asyncpg/protocol/codecs/base.pyx":571
 * 
 *             if target_codec is None:
 *                 continue             # <<<<<<<<<<<<<<
 * 
 *             codec = target_codec.copy()
 */
      goto __pyx_L4_continue;

      /* "asyncpg/protocol/codecs/base.pyx":570
 *                 target_codec = get_extra_codec(alias_to, format)
 * 
 *             if target_codec is None:             # <<<<<<<<<<<<<<
 *                 continue
 * 
 */
    }

    /* "asyncpg/protocol/codecs/base.pyx":573
 *                 continue
 * 
 *             codec = target_codec.copy()             # <<<<<<<<<<<<<<
 *             codec.oid = typeoid
 *             codec.name = typename
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_5Codec_copy(__pyx_v_target_codec)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 573, __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":574
 * 
 *             codec = target_codec.copy()
 *             codec.oid = typeoid             # <<<<<<<<<<<<<<
 *             codec.name = typename
 *             codec.schema = typeschema
 */
    __pyx_t_7 = __Pyx_PyInt_As_uint32_t(__pyx_v_typeoid); if (unlikely((__pyx_t_7 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(4, 574, __pyx_L1_error)
    __pyx_v_codec->oid = __pyx_t_7;

    /* "asyncpg/protocol/codecs/base.pyx":575
 *             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(4, 575, __pyx_L1_error)
    __pyx_t_1 = __pyx_v_typename;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_codec->name);
    __Pyx_DECREF(__pyx_v_codec->name);
    __pyx_v_codec->name = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "asyncpg/protocol/codecs/base.pyx":576
 *             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(4, 576, __pyx_L1_error)
    __pyx_t_1 = __pyx_v_typeschema;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_codec->schema);
    __Pyx_DECREF(__pyx_v_codec->schema);
    __pyx_v_codec->schema = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "asyncpg/protocol/codecs/base.pyx":577
 *             codec.name = typename
 *             codec.schema = typeschema
 *             codec.kind = typekind             # <<<<<<<<<<<<<<
 * 
 *             self._local_type_codecs[typeoid] = 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(4, 577, __pyx_L1_error)
    __pyx_t_1 = __pyx_v_typekind;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_codec->kind);
    __Pyx_DECREF(__pyx_v_codec->kind);
    __pyx_v_codec->kind = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "asyncpg/protocol/codecs/base.pyx":579
 *             codec.kind = typekind
 * 
 *             self._local_type_codecs[typeoid] = codec             # <<<<<<<<<<<<<<
 *             break
 *         else:
 */
    if (unlikely(__pyx_v_self->_local_type_codecs == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(4, 579, __pyx_L1_error)
    }
    if (unlikely(PyDict_SetItem(__pyx_v_self->_local_type_codecs, __pyx_v_typeoid, ((PyObject *)__pyx_v_codec)) < 0)) __PYX_ERR(4, 579, __pyx_L1_error)

    /* "asyncpg/protocol/codecs/base.pyx":580
 * 
 *             self._local_type_codecs[typeoid] = codec
 *             break             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError('unknown alias target: {}'.format(alias_to))
 */
    goto __pyx_L5_break;

    /* "asyncpg/protocol/codecs/base.pyx":560
 *             formats = (format,)
 * 
 *         for format in formats:             # <<<<<<<<<<<<<<
 *             if self.get_codec(typeoid, format) is not None:
 *                 raise ValueError('cannot override codec for type {}'.format(
 */
    __pyx_L4_continue:;
  }
  /*else*/ {

    /* "asyncpg/protocol/codecs/base.pyx":582
 *             break
 *         else:
 *             raise ValueError('unknown alias target: {}'.format(alias_to))             # <<<<<<<<<<<<<<
 * 
 *     def set_builtin_type_codec(self, typeoid, typename, typeschema, typekind,
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_unknown_alias_target, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 582, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_11 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_11) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_alias_to); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 582, __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_11, __pyx_v_alias_to};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 582, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 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_11, __pyx_v_alias_to};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 582, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(4, 582, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11); __pyx_t_11 = 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_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 582, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 582, __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(4, 582, __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(4, 582, __pyx_L1_error)
  }

  /* "asyncpg/protocol/codecs/base.pyx":560
 *             formats = (format,)
 * 
 *         for format in formats:             # <<<<<<<<<<<<<<
 *             if self.get_codec(typeoid, format) is not None:
 *                 raise ValueError('cannot override codec for type {}'.format(
 */
  __pyx_L5_break:;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "asyncpg/protocol/codecs/base.pyx":549
 *         self.clear_type_cache()
 * 
 *     def _set_builtin_type_codec(self, typeoid, typename, typeschema, typekind,             # <<<<<<<<<<<<<<
 *                                 alias_to, format=PG_FORMAT_ANY):
 *         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_4);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __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_formats);
  __Pyx_XDECREF(__pyx_v_format);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/codecs/base.pyx":584
 *             raise ValueError('unknown alias target: {}'.format(alias_to))
 * 
 *     def set_builtin_type_codec(self, typeoid, typename, typeschema, typekind,             # <<<<<<<<<<<<<<
 *                                alias_to, format=PG_FORMAT_ANY):
 *         self._set_builtin_type_codec(typeoid, typename, typeschema, typekind,
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_11set_builtin_type_codec(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_11set_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_v_format = 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,&__pyx_n_s_format,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    values[5] = __pyx_k__38;
    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);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typename)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("set_builtin_type_codec", 0, 5, 6, 1); __PYX_ERR(4, 584, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typeschema)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("set_builtin_type_codec", 0, 5, 6, 2); __PYX_ERR(4, 584, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_typekind)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("set_builtin_type_codec", 0, 5, 6, 3); __PYX_ERR(4, 584, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        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", 0, 5, 6, 4); __PYX_ERR(4, 584, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_format);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_builtin_type_codec") < 0)) __PYX_ERR(4, 584, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __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];
    __pyx_v_format = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("set_builtin_type_codec", 0, 5, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(4, 584, __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_10set_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, __pyx_v_format);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig_10set_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, PyObject *__pyx_v_format) {
  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/codecs/base.pyx":586
 *     def set_builtin_type_codec(self, typeoid, typename, typeschema, typekind,
 *                                alias_to, format=PG_FORMAT_ANY):
 *         self._set_builtin_type_codec(typeoid, typename, typeschema, typekind,             # <<<<<<<<<<<<<<
 *                                      alias_to, format)
 *         self.clear_type_cache()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set_builtin_type_codec_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 586, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "asyncpg/protocol/codecs/base.pyx":587
 *                                alias_to, format=PG_FORMAT_ANY):
 *         self._set_builtin_type_codec(typeoid, typename, typeschema, typekind,
 *                                      alias_to, format)             # <<<<<<<<<<<<<<
 *         self.clear_type_cache()
 * 
 */
  __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[7] = {__pyx_t_3, __pyx_v_typeoid, __pyx_v_typename, __pyx_v_typeschema, __pyx_v_typekind, __pyx_v_alias_to, __pyx_v_format};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 6+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 586, __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[7] = {__pyx_t_3, __pyx_v_typeoid, __pyx_v_typename, __pyx_v_typeschema, __pyx_v_typekind, __pyx_v_alias_to, __pyx_v_format};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 6+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 586, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(6+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 586, __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_INCREF(__pyx_v_format);
    __Pyx_GIVEREF(__pyx_v_format);
    PyTuple_SET_ITEM(__pyx_t_5, 5+__pyx_t_4, __pyx_v_format);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 586, __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/codecs/base.pyx":588
 *         self._set_builtin_type_codec(typeoid, typename, typeschema, typekind,
 *                                      alias_to, format)
 *         self.clear_type_cache()             # <<<<<<<<<<<<<<
 * 
 *     def clear_type_cache(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_clear_type_cache); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 588, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __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_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 588, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 588, __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/base.pyx":584
 *             raise ValueError('unknown alias target: {}'.format(alias_to))
 * 
 *     def set_builtin_type_codec(self, typeoid, typename, typeschema, typekind,             # <<<<<<<<<<<<<<
 *                                alias_to, format=PG_FORMAT_ANY):
 *         self._set_builtin_type_codec(typeoid, typename, typeschema, typekind,
 */

  /* 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.DataCodecConfig.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/codecs/base.pyx":590
 *         self.clear_type_cache()
 * 
 *     def clear_type_cache(self):             # <<<<<<<<<<<<<<
 *         self._type_codecs_cache.clear()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_13clear_type_cache(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_13clear_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_12clear_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_12clear_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":591
 * 
 *     def clear_type_cache(self):
 *         self._type_codecs_cache.clear()             # <<<<<<<<<<<<<<
 * 
 *     def declare_fallback_codec(self, uint32_t oid, str name, str schema):
 */
  if (unlikely(__pyx_v_self->_type_codecs_cache == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "clear");
    __PYX_ERR(4, 591, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_PyDict_Clear(__pyx_v_self->_type_codecs_cache); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(4, 591, __pyx_L1_error)

  /* "asyncpg/protocol/codecs/base.pyx":590
 *         self.clear_type_cache()
 * 
 *     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":593
 *         self._type_codecs_cache.clear()
 * 
 *     def declare_fallback_codec(self, uint32_t oid, str name, str schema):             # <<<<<<<<<<<<<<
 *         cdef Codec codec
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_15declare_fallback_codec(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_15declare_fallback_codec(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  uint32_t __pyx_v_oid;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_schema = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("declare_fallback_codec (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_oid,&__pyx_n_s_name,&__pyx_n_s_schema,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("declare_fallback_codec", 1, 3, 3, 1); __PYX_ERR(4, 593, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_schema)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("declare_fallback_codec", 1, 3, 3, 2); __PYX_ERR(4, 593, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "declare_fallback_codec") < 0)) __PYX_ERR(4, 593, __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_oid = __Pyx_PyInt_As_uint32_t(values[0]); if (unlikely((__pyx_v_oid == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(4, 593, __pyx_L3_error)
    __pyx_v_name = ((PyObject*)values[1]);
    __pyx_v_schema = ((PyObject*)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("declare_fallback_codec", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(4, 593, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("asyncpg.protocol.protocol.DataCodecConfig.declare_fallback_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_name), (&PyUnicode_Type), 1, "name", 1))) __PYX_ERR(4, 593, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_schema), (&PyUnicode_Type), 1, "schema", 1))) __PYX_ERR(4, 593, __pyx_L1_error)
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig_14declare_fallback_codec(((struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *)__pyx_v_self), __pyx_v_oid, __pyx_v_name, __pyx_v_schema);

  /* 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_15DataCodecConfig_14declare_fallback_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *__pyx_v_self, uint32_t __pyx_v_oid, PyObject *__pyx_v_name, PyObject *__pyx_v_schema) {
  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_codec = 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;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("declare_fallback_codec", 0);

  /* "asyncpg/protocol/codecs/base.pyx":596
 *         cdef Codec codec
 * 
 *         codec = self.get_codec(oid, PG_FORMAT_TEXT)             # <<<<<<<<<<<<<<
 *         if codec is not None:
 *             return codec
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_15DataCodecConfig_get_codec(__pyx_v_self, __pyx_v_oid, __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 596, __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":597
 * 
 *         codec = self.get_codec(oid, PG_FORMAT_TEXT)
 *         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":598
 *         codec = self.get_codec(oid, PG_FORMAT_TEXT)
 *         if codec is not None:
 *             return codec             # <<<<<<<<<<<<<<
 * 
 *         if oid <= MAXBUILTINOID:
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_codec));
    __pyx_r = ((PyObject *)__pyx_v_codec);
    goto __pyx_L0;

    /* "asyncpg/protocol/codecs/base.pyx":597
 * 
 *         codec = self.get_codec(oid, PG_FORMAT_TEXT)
 *         if codec is not None:             # <<<<<<<<<<<<<<
 *             return codec
 * 
 */
  }

  /* "asyncpg/protocol/codecs/base.pyx":600
 *             return codec
 * 
 *         if oid <= MAXBUILTINOID:             # <<<<<<<<<<<<<<
 *             # This is a BKI type, for which asyncpg has no
 *             # defined codec.  This should only happen for newly
 */
  __pyx_t_3 = ((__pyx_v_oid <= 0x270F) != 0);
  if (__pyx_t_3) {

    /* "asyncpg/protocol/codecs/base.pyx":607
 *             #
 *             raise NotImplementedError(
 *                 'unhandled standard data type {!r} (OID {})'.format(             # <<<<<<<<<<<<<<
 *                     name, oid))
 *         else:
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_unhandled_standard_data_type_r_O, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 607, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);

    /* "asyncpg/protocol/codecs/base.pyx":608
 *             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_5 = __Pyx_PyInt_From_uint32_t(__pyx_v_oid); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 608, __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_v_name, __pyx_t_5};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 607, __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[3] = {__pyx_t_6, __pyx_v_name, __pyx_t_5};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 607, __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_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 607, __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_name);
      __Pyx_GIVEREF(__pyx_v_name);
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_v_name);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 607, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "asyncpg/protocol/codecs/base.pyx":606
 *             # asyncpg is lacking support.
 *             #
 *             raise NotImplementedError(             # <<<<<<<<<<<<<<
 *                 'unhandled standard data type {!r} (OID {})'.format(
 *                     name, oid))
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 606, __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_NotImplementedError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 606, __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(4, 606, __pyx_L1_error)

    /* "asyncpg/protocol/codecs/base.pyx":600
 *             return codec
 * 
 *         if oid <= MAXBUILTINOID:             # <<<<<<<<<<<<<<
 *             # This is a BKI type, for which asyncpg has no
 *             # defined codec.  This should only happen for newly
 */
  }

  /* "asyncpg/protocol/codecs/base.pyx":616
 *             # using Connection.set_type_codec().
 *             #
 *             self._set_builtin_type_codec(oid, name, schema, 'scalar',             # <<<<<<<<<<<<<<
 *                                          TEXTOID, PG_FORMAT_TEXT)
 * 
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set_builtin_type_codec_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 616, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = __Pyx_PyInt_From_uint32_t(__pyx_v_oid); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 616, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);

    /* "asyncpg/protocol/codecs/base.pyx":617
 *             #
 *             self._set_builtin_type_codec(oid, name, schema, 'scalar',
 *                                          TEXTOID, PG_FORMAT_TEXT)             # <<<<<<<<<<<<<<
 * 
 *             codec = self.get_codec(oid, PG_FORMAT_TEXT)
 */
    __pyx_t_5 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(__pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 617, __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[7] = {__pyx_t_6, __pyx_t_8, __pyx_v_name, __pyx_v_schema, __pyx_n_u_scalar, __pyx_int_25, __pyx_t_5};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 6+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 616, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __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[7] = {__pyx_t_6, __pyx_t_8, __pyx_v_name, __pyx_v_schema, __pyx_n_u_scalar, __pyx_int_25, __pyx_t_5};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 6+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 616, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(6+__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 616, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_7, __pyx_t_8);
      __Pyx_INCREF(__pyx_v_name);
      __Pyx_GIVEREF(__pyx_v_name);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_7, __pyx_v_name);
      __Pyx_INCREF(__pyx_v_schema);
      __Pyx_GIVEREF(__pyx_v_schema);
      PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_7, __pyx_v_schema);
      __Pyx_INCREF(__pyx_n_u_scalar);
      __Pyx_GIVEREF(__pyx_n_u_scalar);
      PyTuple_SET_ITEM(__pyx_t_9, 3+__pyx_t_7, __pyx_n_u_scalar);
      __Pyx_INCREF(__pyx_int_25);
      __Pyx_GIVEREF(__pyx_int_25);
      PyTuple_SET_ITEM(__pyx_t_9, 4+__pyx_t_7, __pyx_int_25);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_9, 5+__pyx_t_7, __pyx_t_5);
      __pyx_t_8 = 0;
      __pyx_t_5 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 616, __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;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/codecs/base.pyx":619
 *                                          TEXTOID, PG_FORMAT_TEXT)
 * 
 *             codec = self.get_codec(oid, PG_FORMAT_TEXT)             # <<<<<<<<<<<<<<
 * 
 *         return codec
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_15DataCodecConfig_get_codec(__pyx_v_self, __pyx_v_oid, __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 619, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_1));
    __pyx_t_1 = 0;
  }

  /* "asyncpg/protocol/codecs/base.pyx":621
 *             codec = self.get_codec(oid, PG_FORMAT_TEXT)
 * 
 *         return codec             # <<<<<<<<<<<<<<
 * 
 *     cdef inline Codec get_codec(self, uint32_t oid, ServerDataFormat format):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_codec));
  __pyx_r = ((PyObject *)__pyx_v_codec);
  goto __pyx_L0;

  /* "asyncpg/protocol/codecs/base.pyx":593
 *         self._type_codecs_cache.clear()
 * 
 *     def declare_fallback_codec(self, uint32_t oid, str name, str schema):             # <<<<<<<<<<<<<<
 *         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_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.DataCodecConfig.declare_fallback_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/codecs/base.pyx":623
 *         return codec
 * 
 *     cdef inline Codec get_codec(self, uint32_t oid, ServerDataFormat 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_ServerDataFormat __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;
  __Pyx_RefNannySetupContext("get_codec", 0);

  /* "asyncpg/protocol/codecs/base.pyx":626
 *         cdef Codec codec
 * 
 *         codec = self.get_local_codec(oid)             # <<<<<<<<<<<<<<
 *         if codec is not None:
 *             if codec.format != format:
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_15DataCodecConfig_get_local_codec(__pyx_v_self, __pyx_v_oid)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 626, __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":627
 * 
 *         codec = self.get_local_codec(oid)
 *         if codec is not None:             # <<<<<<<<<<<<<<
 *             if codec.format != format:
 *                 # The codec for this OID has been overridden by
 */
  __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":628
 *         codec = self.get_local_codec(oid)
 *         if codec is not None:
 *             if codec.format != format:             # <<<<<<<<<<<<<<
 *                 # The codec for this OID has been overridden by
 *                 # set_{builtin}_type_codec with a different format.
 */
    __pyx_t_3 = ((__pyx_v_codec->format != __pyx_v_format) != 0);
    if (__pyx_t_3) {

      /* "asyncpg/protocol/codecs/base.pyx":632
 *                 # set_{builtin}_type_codec with a different format.
 *                 # We must respect that and not return a core codec.
 *                 return None             # <<<<<<<<<<<<<<
 *             else:
 *                 return codec
 */
      __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":628
 *         codec = self.get_local_codec(oid)
 *         if codec is not None:
 *             if codec.format != format:             # <<<<<<<<<<<<<<
 *                 # The codec for this OID has been overridden by
 *                 # set_{builtin}_type_codec with a different format.
 */
    }

    /* "asyncpg/protocol/codecs/base.pyx":634
 *                 return None
 *             else:
 *                 return codec             # <<<<<<<<<<<<<<
 * 
 *         codec = get_core_codec(oid, format)
 */
    /*else*/ {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(((PyObject *)__pyx_v_codec));
      __pyx_r = __pyx_v_codec;
      goto __pyx_L0;
    }

    /* "asyncpg/protocol/codecs/base.pyx":627
 * 
 *         codec = self.get_local_codec(oid)
 *         if codec is not None:             # <<<<<<<<<<<<<<
 *             if codec.format != format:
 *                 # The codec for this OID has been overridden by
 */
  }

  /* "asyncpg/protocol/codecs/base.pyx":636
 *                 return 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, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 636, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/base.pyx":637
 * 
 *         codec = get_core_codec(oid, format)
 *         if codec is not None:             # <<<<<<<<<<<<<<
 *             return codec
 *         else:
 */
  __pyx_t_3 = (((PyObject *)__pyx_v_codec) != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/codecs/base.pyx":638
 *         codec = get_core_codec(oid, format)
 *         if codec is not None:
 *             return codec             # <<<<<<<<<<<<<<
 *         else:
 *             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":637
 * 
 *         codec = get_core_codec(oid, format)
 *         if codec is not None:             # <<<<<<<<<<<<<<
 *             return codec
 *         else:
 */
  }

  /* "asyncpg/protocol/codecs/base.pyx":640
 *             return codec
 *         else:
 *             try:             # <<<<<<<<<<<<<<
 *                 return self._type_codecs_cache[oid, format]
 *             except KeyError:
 */
  /*else*/ {
    {
      __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":641
 *         else:
 *             try:
 *                 return self._type_codecs_cache[oid, format]             # <<<<<<<<<<<<<<
 *             except KeyError:
 *                 return None
 */
        __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(4, 641, __pyx_L6_error)
        }
        __pyx_t_1 = __Pyx_PyInt_From_uint32_t(__pyx_v_oid); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 641, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_7 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(__pyx_v_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 641, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 641, __pyx_L6_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(4, 641, __pyx_L6_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(4, 641, __pyx_L6_error)
        __pyx_r = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_7);
        __pyx_t_7 = 0;
        goto __pyx_L10_try_return;

        /* "asyncpg/protocol/codecs/base.pyx":640
 *             return codec
 *         else:
 *             try:             # <<<<<<<<<<<<<<
 *                 return self._type_codecs_cache[oid, format]
 *             except KeyError:
 */
      }
      __pyx_L6_error:;
      __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":642
 *             try:
 *                 return self._type_codecs_cache[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_7, &__pyx_t_8, &__pyx_t_1) < 0) __PYX_ERR(4, 642, __pyx_L8_except_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GOTREF(__pyx_t_1);

        /* "asyncpg/protocol/codecs/base.pyx":643
 *                 return self._type_codecs_cache[oid, format]
 *             except KeyError:
 *                 return None             # <<<<<<<<<<<<<<
 * 
 *     cdef inline Codec get_local_codec(self, uint32_t oid):
 */
        __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;
        goto __pyx_L9_except_return;
      }
      goto __pyx_L8_except_error;
      __pyx_L8_except_error:;

      /* "asyncpg/protocol/codecs/base.pyx":640
 *             return codec
 *         else:
 *             try:             # <<<<<<<<<<<<<<
 *                 return self._type_codecs_cache[oid, format]
 *             except KeyError:
 */
      __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_L10_try_return:;
      __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_L9_except_return:;
      __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":623
 *         return codec
 * 
 *     cdef inline Codec get_codec(self, uint32_t oid, ServerDataFormat 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_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":645
 *                 return None
 * 
 *     cdef inline Codec get_local_codec(self, uint32_t oid):             # <<<<<<<<<<<<<<
 *         return self._local_type_codecs.get(oid)
 * 
 */

static CYTHON_INLINE struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_15DataCodecConfig_get_local_codec(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *__pyx_v_self, uint32_t __pyx_v_oid) {
  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_local_codec", 0);

  /* "asyncpg/protocol/codecs/base.pyx":646
 * 
 *     cdef inline Codec get_local_codec(self, uint32_t oid):
 *         return self._local_type_codecs.get(oid)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  if (unlikely(__pyx_v_self->_local_type_codecs == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get");
    __PYX_ERR(4, 646, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_PyInt_From_uint32_t(__pyx_v_oid); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 646, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->_local_type_codecs, __pyx_t_1, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 646, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7asyncpg_8protocol_8protocol_Codec))))) __PYX_ERR(4, 646, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "asyncpg/protocol/codecs/base.pyx":645
 *                 return None
 * 
 *     cdef inline Codec get_local_codec(self, uint32_t oid):             # <<<<<<<<<<<<<<
 *         return self._local_type_codecs.get(oid)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.DataCodecConfig.get_local_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self._local_type_codecs, self._type_codecs_cache)
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_17__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_17__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig_16__reduce_cython__(((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_16__reduce_cython__(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *__pyx_v_self) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = 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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     cdef bint use_setstate
 *     state = (self._local_type_codecs, self._type_codecs_cache)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->_local_type_codecs);
  __Pyx_GIVEREF(__pyx_v_self->_local_type_codecs);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->_local_type_codecs);
  __Pyx_INCREF(__pyx_v_self->_type_codecs_cache);
  __Pyx_GIVEREF(__pyx_v_self->_type_codecs_cache);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_self->_type_codecs_cache);
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":4
 *     cdef bint use_setstate
 *     state = (self._local_type_codecs, self._type_codecs_cache)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":5
 *     state = (self._local_type_codecs, self._type_codecs_cache)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":6
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":7
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self._local_type_codecs is not None or self._type_codecs_cache is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":5
 *     state = (self._local_type_codecs, self._type_codecs_cache)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         use_setstate = True
 *     else:
 *         use_setstate = self._local_type_codecs is not None or self._type_codecs_cache is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_DataCodecConfig, (type(self), 0xb75bfc9, None), state
 */
  /*else*/ {
    __pyx_t_2 = (__pyx_v_self->_local_type_codecs != ((PyObject*)Py_None));
    __pyx_t_5 = (__pyx_t_2 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_3 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->_type_codecs_cache != ((PyObject*)Py_None));
    __pyx_t_2 = (__pyx_t_5 != 0);
    __pyx_t_3 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":10
 *     else:
 *         use_setstate = self._local_type_codecs is not None or self._type_codecs_cache is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_DataCodecConfig, (type(self), 0xb75bfc9, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":11
 *         use_setstate = self._local_type_codecs is not None or self._type_codecs_cache is not None
 *     if use_setstate:
 *         return __pyx_unpickle_DataCodecConfig, (type(self), 0xb75bfc9, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_DataCodecConfig, (type(self), 0xb75bfc9, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_DataCodecConfig); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_192266185);
    __Pyx_GIVEREF(__pyx_int_192266185);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_192266185);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 11, __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_1);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":10
 *     else:
 *         use_setstate = self._local_type_codecs is not None or self._type_codecs_cache is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_DataCodecConfig, (type(self), 0xb75bfc9, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         return __pyx_unpickle_DataCodecConfig, (type(self), 0xb75bfc9, None), state
 *     else:
 *         return __pyx_unpickle_DataCodecConfig, (type(self), 0xb75bfc9, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_DataCodecConfig__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_DataCodecConfig); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_192266185);
    __Pyx_GIVEREF(__pyx_int_192266185);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_192266185);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_6 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self._local_type_codecs, self._type_codecs_cache)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.DataCodecConfig.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_DataCodecConfig, (type(self), 0xb75bfc9, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_DataCodecConfig__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_19__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_19__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig_18__setstate_cython__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_15DataCodecConfig_18__setstate_cython__(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":15
 *         return __pyx_unpickle_DataCodecConfig, (type(self), 0xb75bfc9, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_DataCodecConfig__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol___pyx_unpickle_DataCodecConfig__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_DataCodecConfig, (type(self), 0xb75bfc9, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_DataCodecConfig__set_state(self, __pyx_state)
 */

  /* 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.DataCodecConfig.__setstate_cython__", __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":649
 * 
 * 
 * cdef inline Codec get_core_codec(             # <<<<<<<<<<<<<<
 *         uint32_t oid, ServerDataFormat format,
 *         ClientExchangeFormat xformat=PG_XFORMAT_OBJECT):
 */

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_ServerDataFormat __pyx_v_format, struct __pyx_opt_args_7asyncpg_8protocol_8protocol_get_core_codec *__pyx_optional_args) {
  enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat __pyx_v_xformat = __pyx_k__39;
  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);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_xformat = __pyx_optional_args->xformat;
    }
  }

  /* "asyncpg/protocol/codecs/base.pyx":653
 *         ClientExchangeFormat xformat=PG_XFORMAT_OBJECT):
 *     cdef:
 *         void *ptr = NULL             # <<<<<<<<<<<<<<
 * 
 *     if oid > MAXSUPPORTEDOID:
 */
  __pyx_v_ptr = NULL;

  /* "asyncpg/protocol/codecs/base.pyx":655
 *         void *ptr = NULL
 * 
 *     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":656
 * 
 *     if oid > MAXSUPPORTEDOID:
 *         return None             # <<<<<<<<<<<<<<
 *     if format == PG_FORMAT_BINARY:
 *         ptr = binary_codec_map[oid * xformat]
 */
    __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":655
 *         void *ptr = NULL
 * 
 *     if oid > MAXSUPPORTEDOID:             # <<<<<<<<<<<<<<
 *         return None
 *     if format == PG_FORMAT_BINARY:
 */
  }

  /* "asyncpg/protocol/codecs/base.pyx":657
 *     if oid > MAXSUPPORTEDOID:
 *         return None
 *     if format == PG_FORMAT_BINARY:             # <<<<<<<<<<<<<<
 *         ptr = binary_codec_map[oid * xformat]
 *     elif format == PG_FORMAT_TEXT:
 */
  switch (__pyx_v_format) {
    case __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY:

    /* "asyncpg/protocol/codecs/base.pyx":658
 *         return None
 *     if format == PG_FORMAT_BINARY:
 *         ptr = binary_codec_map[oid * xformat]             # <<<<<<<<<<<<<<
 *     elif format == PG_FORMAT_TEXT:
 *         ptr = text_codec_map[oid * xformat]
 */
    __pyx_v_ptr = (__pyx_v_7asyncpg_8protocol_8protocol_binary_codec_map[(__pyx_v_oid * __pyx_v_xformat)]);

    /* "asyncpg/protocol/codecs/base.pyx":657
 *     if oid > MAXSUPPORTEDOID:
 *         return None
 *     if format == PG_FORMAT_BINARY:             # <<<<<<<<<<<<<<
 *         ptr = binary_codec_map[oid * xformat]
 *     elif format == PG_FORMAT_TEXT:
 */
    break;

    /* "asyncpg/protocol/codecs/base.pyx":659
 *     if format == PG_FORMAT_BINARY:
 *         ptr = binary_codec_map[oid * xformat]
 *     elif format == PG_FORMAT_TEXT:             # <<<<<<<<<<<<<<
 *         ptr = text_codec_map[oid * xformat]
 * 
 */
    case __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT:

    /* "asyncpg/protocol/codecs/base.pyx":660
 *         ptr = binary_codec_map[oid * xformat]
 *     elif format == PG_FORMAT_TEXT:
 *         ptr = text_codec_map[oid * xformat]             # <<<<<<<<<<<<<<
 * 
 *     if ptr is NULL:
 */
    __pyx_v_ptr = (__pyx_v_7asyncpg_8protocol_8protocol_text_codec_map[(__pyx_v_oid * __pyx_v_xformat)]);

    /* "asyncpg/protocol/codecs/base.pyx":659
 *     if format == PG_FORMAT_BINARY:
 *         ptr = binary_codec_map[oid * xformat]
 *     elif format == PG_FORMAT_TEXT:             # <<<<<<<<<<<<<<
 *         ptr = text_codec_map[oid * xformat]
 * 
 */
    break;
    default: break;
  }

  /* "asyncpg/protocol/codecs/base.pyx":662
 *         ptr = text_codec_map[oid * xformat]
 * 
 *     if ptr is NULL:             # <<<<<<<<<<<<<<
 *         return None
 *     else:
 */
  __pyx_t_1 = ((__pyx_v_ptr == NULL) != 0);
  if (__pyx_t_1) {

    /* "asyncpg/protocol/codecs/base.pyx":663
 * 
 *     if ptr is NULL:
 *         return None             # <<<<<<<<<<<<<<
 *     else:
 *         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":662
 *         ptr = text_codec_map[oid * xformat]
 * 
 *     if ptr is NULL:             # <<<<<<<<<<<<<<
 *         return None
 *     else:
 */
  }

  /* "asyncpg/protocol/codecs/base.pyx":665
 *         return None
 *     else:
 *         return <Codec>ptr             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __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":649
 * 
 * 
 * cdef inline Codec get_core_codec(             # <<<<<<<<<<<<<<
 *         uint32_t oid, ServerDataFormat format,
 *         ClientExchangeFormat xformat=PG_XFORMAT_OBJECT):
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/codecs/base.pyx":668
 * 
 * 
 * cdef inline Codec get_any_core_codec(             # <<<<<<<<<<<<<<
 *         uint32_t oid, ServerDataFormat format,
 *         ClientExchangeFormat xformat=PG_XFORMAT_OBJECT):
 */

static CYTHON_INLINE struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_f_7asyncpg_8protocol_8protocol_get_any_core_codec(uint32_t __pyx_v_oid, enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat __pyx_v_format, struct __pyx_opt_args_7asyncpg_8protocol_8protocol_get_any_core_codec *__pyx_optional_args) {
  enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat __pyx_v_xformat = __pyx_k__40;
  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_v_codec = 0;
  struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  struct __pyx_opt_args_7asyncpg_8protocol_8protocol_get_core_codec __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("get_any_core_codec", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_xformat = __pyx_optional_args->xformat;
    }
  }

  /* "asyncpg/protocol/codecs/base.pyx":675
 *         Codec codec
 * 
 *     if format == PG_FORMAT_ANY:             # <<<<<<<<<<<<<<
 *         codec = get_core_codec(oid, PG_FORMAT_BINARY, xformat)
 *         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/codecs/base.pyx":676
 * 
 *     if format == PG_FORMAT_ANY:
 *         codec = get_core_codec(oid, PG_FORMAT_BINARY, xformat)             # <<<<<<<<<<<<<<
 *         if codec is None:
 *             codec = get_core_codec(oid, PG_FORMAT_TEXT, xformat)
 */
    __pyx_t_3.__pyx_n = 1;
    __pyx_t_3.xformat = __pyx_v_xformat;
    __pyx_t_2 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_get_core_codec(__pyx_v_oid, __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY, &__pyx_t_3)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 676, __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/codecs/base.pyx":677
 *     if format == PG_FORMAT_ANY:
 *         codec = get_core_codec(oid, PG_FORMAT_BINARY, xformat)
 *         if codec is None:             # <<<<<<<<<<<<<<
 *             codec = get_core_codec(oid, PG_FORMAT_TEXT, xformat)
 *     else:
 */
    __pyx_t_1 = (((PyObject *)__pyx_v_codec) == Py_None);
    __pyx_t_4 = (__pyx_t_1 != 0);
    if (__pyx_t_4) {

      /* "asyncpg/protocol/codecs/base.pyx":678
 *         codec = get_core_codec(oid, PG_FORMAT_BINARY, xformat)
 *         if codec is None:
 *             codec = get_core_codec(oid, PG_FORMAT_TEXT, xformat)             # <<<<<<<<<<<<<<
 *     else:
 *         codec = get_core_codec(oid, format, xformat)
 */
      __pyx_t_3.__pyx_n = 1;
      __pyx_t_3.xformat = __pyx_v_xformat;
      __pyx_t_2 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_get_core_codec(__pyx_v_oid, __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT, &__pyx_t_3)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 678, __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/codecs/base.pyx":677
 *     if format == PG_FORMAT_ANY:
 *         codec = get_core_codec(oid, PG_FORMAT_BINARY, xformat)
 *         if codec is None:             # <<<<<<<<<<<<<<
 *             codec = get_core_codec(oid, PG_FORMAT_TEXT, xformat)
 *     else:
 */
    }

    /* "asyncpg/protocol/codecs/base.pyx":675
 *         Codec codec
 * 
 *     if format == PG_FORMAT_ANY:             # <<<<<<<<<<<<<<
 *         codec = get_core_codec(oid, PG_FORMAT_BINARY, xformat)
 *         if codec is None:
 */
    goto __pyx_L3;
  }

  /* "asyncpg/protocol/codecs/base.pyx":680
 *             codec = get_core_codec(oid, PG_FORMAT_TEXT, xformat)
 *     else:
 *         codec = get_core_codec(oid, format, xformat)             # <<<<<<<<<<<<<<
 * 
 *     return codec
 */
  /*else*/ {
    __pyx_t_3.__pyx_n = 1;
    __pyx_t_3.xformat = __pyx_v_xformat;
    __pyx_t_2 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_get_core_codec(__pyx_v_oid, __pyx_v_format, &__pyx_t_3)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 680, __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;
  }
  __pyx_L3:;

  /* "asyncpg/protocol/codecs/base.pyx":682
 *         codec = get_core_codec(oid, format, xformat)
 * 
 *     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":668
 * 
 * 
 * cdef inline Codec get_any_core_codec(             # <<<<<<<<<<<<<<
 *         uint32_t oid, ServerDataFormat format,
 *         ClientExchangeFormat xformat=PG_XFORMAT_OBJECT):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.get_any_core_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":685
 * 
 * 
 * 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":686
 * 
 * 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":685
 * 
 * 
 * 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":689
 * 
 * 
 * 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_ServerDataFormat __pyx_v_format, struct __pyx_opt_args_7asyncpg_8protocol_8protocol_register_core_codec *__pyx_optional_args) {
  enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat __pyx_v_xformat = __pyx_k__41;
  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);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_xformat = __pyx_optional_args->xformat;
    }
  }

  /* "asyncpg/protocol/codecs/base.pyx":695
 *                          ClientExchangeFormat xformat=PG_XFORMAT_OBJECT):
 * 
 *     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":698
 *         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(4, 698, __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(4, 698, __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(4, 698, __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(4, 698, __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(4, 698, __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(4, 698, __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":696
 * 
 *     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(4, 696, __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, 696, __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, 696, __pyx_L1_error)

    /* "asyncpg/protocol/codecs/base.pyx":695
 *                          ClientExchangeFormat xformat=PG_XFORMAT_OBJECT):
 * 
 *     if oid > MAXSUPPORTEDOID:             # <<<<<<<<<<<<<<
 *         raise RuntimeError(
 *             'cannot register core codec for OID {}: it is greater '
 */
  }

  /* "asyncpg/protocol/codecs/base.pyx":705
 *         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(4, 705, __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(4, 705, __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(4, 705, __pyx_L1_error)
  __pyx_v_name = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "asyncpg/protocol/codecs/base.pyx":706
 * 
 *     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(4, 706, __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(4, 706, __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":708
 *     kind = 'array' if oid in ARRAY_TYPES else 'scalar'
 * 
 *     codec = Codec(oid)             # <<<<<<<<<<<<<<
 *     codec.init(name, 'pg_catalog', kind, CODEC_C, format, xformat,
 *                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(4, 708, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 708, __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(4, 708, __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":709
 * 
 *     codec = Codec(oid)
 *     codec.init(name, 'pg_catalog', kind, CODEC_C, format, xformat,             # <<<<<<<<<<<<<<
 *                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_xformat, __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(4, 709, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/codecs/base.pyx":711
 *     codec.init(name, 'pg_catalog', kind, CODEC_C, format, xformat,
 *                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":713
 *     cpython.Py_INCREF(codec)  # immortalize
 * 
 *     if format == PG_FORMAT_BINARY:             # <<<<<<<<<<<<<<
 *         binary_codec_map[oid * xformat] = <void*>codec
 *     elif format == PG_FORMAT_TEXT:
 */
  switch (__pyx_v_format) {
    case __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY:

    /* "asyncpg/protocol/codecs/base.pyx":714
 * 
 *     if format == PG_FORMAT_BINARY:
 *         binary_codec_map[oid * xformat] = <void*>codec             # <<<<<<<<<<<<<<
 *     elif format == PG_FORMAT_TEXT:
 *         text_codec_map[oid * xformat] = <void*>codec
 */
    (__pyx_v_7asyncpg_8protocol_8protocol_binary_codec_map[(__pyx_v_oid * __pyx_v_xformat)]) = ((void *)__pyx_v_codec);

    /* "asyncpg/protocol/codecs/base.pyx":713
 *     cpython.Py_INCREF(codec)  # immortalize
 * 
 *     if format == PG_FORMAT_BINARY:             # <<<<<<<<<<<<<<
 *         binary_codec_map[oid * xformat] = <void*>codec
 *     elif format == PG_FORMAT_TEXT:
 */
    break;

    /* "asyncpg/protocol/codecs/base.pyx":715
 *     if format == PG_FORMAT_BINARY:
 *         binary_codec_map[oid * xformat] = <void*>codec
 *     elif format == PG_FORMAT_TEXT:             # <<<<<<<<<<<<<<
 *         text_codec_map[oid * xformat] = <void*>codec
 *     else:
 */
    case __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT:

    /* "asyncpg/protocol/codecs/base.pyx":716
 *         binary_codec_map[oid * xformat] = <void*>codec
 *     elif format == PG_FORMAT_TEXT:
 *         text_codec_map[oid * xformat] = <void*>codec             # <<<<<<<<<<<<<<
 *     else:
 *         raise RuntimeError('invalid data format: {}'.format(format))
 */
    (__pyx_v_7asyncpg_8protocol_8protocol_text_codec_map[(__pyx_v_oid * __pyx_v_xformat)]) = ((void *)__pyx_v_codec);

    /* "asyncpg/protocol/codecs/base.pyx":715
 *     if format == PG_FORMAT_BINARY:
 *         binary_codec_map[oid * xformat] = <void*>codec
 *     elif format == PG_FORMAT_TEXT:             # <<<<<<<<<<<<<<
 *         text_codec_map[oid * xformat] = <void*>codec
 *     else:
 */
    break;
    default:

    /* "asyncpg/protocol/codecs/base.pyx":718
 *         text_codec_map[oid * xformat] = <void*>codec
 *     else:
 *         raise RuntimeError('invalid data format: {}'.format(format))             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_invalid_data_format, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 718, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(__pyx_v_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 718, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __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_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 718, __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_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_7};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 718, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 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_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_7};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 718, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 718, __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_7);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_7);
        __pyx_t_7 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 718, __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_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 718, __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_RuntimeError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 718, __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(4, 718, __pyx_L1_error)
    break;
  }

  /* "asyncpg/protocol/codecs/base.pyx":689
 * 
 * 
 * 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":721
 * 
 * 
 * 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_ServerDataFormat __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":729
 *         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":731
 *     kind = 'scalar'
 * 
 *     codec = Codec(INVALIDOID)             # <<<<<<<<<<<<<<
 *     codec.init(name, None, kind, CODEC_C, format, PG_XFORMAT_OBJECT,
 *                encode, decode, None, None, None, None, None, None, 0)
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_Codec), __pyx_tuple__42, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 731, __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":732
 * 
 *     codec = Codec(INVALIDOID)
 *     codec.init(name, None, kind, CODEC_C, format, PG_XFORMAT_OBJECT,             # <<<<<<<<<<<<<<
 *                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_e_7asyncpg_8protocol_8protocol_PG_XFORMAT_OBJECT, __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(4, 732, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/base.pyx":734
 *     codec.init(name, None, kind, CODEC_C, format, PG_XFORMAT_OBJECT,
 *                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(4, 734, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(__pyx_v_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 734, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 734, __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(4, 734, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/codecs/base.pyx":721
 * 
 * 
 * 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":737
 * 
 * 
 * cdef inline Codec get_extra_codec(str name, ServerDataFormat 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_ServerDataFormat __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":738
 * 
 * cdef inline Codec get_extra_codec(str name, ServerDataFormat 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 '%.30s'", "get");
    __PYX_ERR(4, 738, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(__pyx_v_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 738, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 738, __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(4, 738, __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(4, 738, __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":737
 * 
 * 
 * cdef inline Codec get_extra_codec(str name, ServerDataFormat 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":8
 * 
 * 
 * cdef inline uint32_t _apg_tolower(uint32_t c):             # <<<<<<<<<<<<<<
 *     if c >= <uint32_t><Py_UCS4>'A' and c <= <uint32_t><Py_UCS4>'Z':
 *         return c + <uint32_t><Py_UCS4>'a' - <uint32_t><Py_UCS4>'A'
 */

static CYTHON_INLINE uint32_t __pyx_f_7asyncpg_8protocol_8protocol__apg_tolower(uint32_t __pyx_v_c) {
  uint32_t __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("_apg_tolower", 0);

  /* "asyncpg/protocol/codecs/textutils.pyx":9
 * 
 * cdef inline uint32_t _apg_tolower(uint32_t c):
 *     if c >= <uint32_t><Py_UCS4>'A' and c <= <uint32_t><Py_UCS4>'Z':             # <<<<<<<<<<<<<<
 *         return c + <uint32_t><Py_UCS4>'a' - <uint32_t><Py_UCS4>'A'
 *     else:
 */
  __pyx_t_2 = ((__pyx_v_c >= ((uint32_t)((Py_UCS4)65))) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_c <= ((uint32_t)((Py_UCS4)90))) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "asyncpg/protocol/codecs/textutils.pyx":10
 * cdef inline uint32_t _apg_tolower(uint32_t c):
 *     if c >= <uint32_t><Py_UCS4>'A' and c <= <uint32_t><Py_UCS4>'Z':
 *         return c + <uint32_t><Py_UCS4>'a' - <uint32_t><Py_UCS4>'A'             # <<<<<<<<<<<<<<
 *     else:
 *         return c
 */
    __pyx_r = ((__pyx_v_c + ((uint32_t)((Py_UCS4)97))) - ((uint32_t)((Py_UCS4)65)));
    goto __pyx_L0;

    /* "asyncpg/protocol/codecs/textutils.pyx":9
 * 
 * cdef inline uint32_t _apg_tolower(uint32_t c):
 *     if c >= <uint32_t><Py_UCS4>'A' and c <= <uint32_t><Py_UCS4>'Z':             # <<<<<<<<<<<<<<
 *         return c + <uint32_t><Py_UCS4>'a' - <uint32_t><Py_UCS4>'A'
 *     else:
 */
  }

  /* "asyncpg/protocol/codecs/textutils.pyx":12
 *         return c + <uint32_t><Py_UCS4>'a' - <uint32_t><Py_UCS4>'A'
 *     else:
 *         return c             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __pyx_r = __pyx_v_c;
    goto __pyx_L0;
  }

  /* "asyncpg/protocol/codecs/textutils.pyx":8
 * 
 * 
 * cdef inline uint32_t _apg_tolower(uint32_t c):             # <<<<<<<<<<<<<<
 *     if c >= <uint32_t><Py_UCS4>'A' and c <= <uint32_t><Py_UCS4>'Z':
 *         return c + <uint32_t><Py_UCS4>'a' - <uint32_t><Py_UCS4>'A'
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/codecs/textutils.pyx":15
 * 
 * 
 * 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":19
 *         uint32_t c1
 *         uint32_t c2
 *         int i = 0             # <<<<<<<<<<<<<<
 * 
 *     while True:
 */
  __pyx_v_i = 0;

  /* "asyncpg/protocol/codecs/textutils.pyx":21
 *         int i = 0
 * 
 *     while True:             # <<<<<<<<<<<<<<
 *         c1 = s1[i]
 *         c2 = s2[i]
 */
  while (1) {

    /* "asyncpg/protocol/codecs/textutils.pyx":22
 * 
 *     while True:
 *         c1 = s1[i]             # <<<<<<<<<<<<<<
 *         c2 = s2[i]
 * 
 */
    __pyx_v_c1 = (__pyx_v_s1[__pyx_v_i]);

    /* "asyncpg/protocol/codecs/textutils.pyx":23
 *     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":25
 *         c2 = s2[i]
 * 
 *         if c1 != c2:             # <<<<<<<<<<<<<<
 *             c1 = _apg_tolower(c1)
 *             c2 = _apg_tolower(c2)
 */
    __pyx_t_1 = ((__pyx_v_c1 != __pyx_v_c2) != 0);
    if (__pyx_t_1) {

      /* "asyncpg/protocol/codecs/textutils.pyx":26
 * 
 *         if c1 != c2:
 *             c1 = _apg_tolower(c1)             # <<<<<<<<<<<<<<
 *             c2 = _apg_tolower(c2)
 *             if c1 != c2:
 */
      __pyx_v_c1 = __pyx_f_7asyncpg_8protocol_8protocol__apg_tolower(__pyx_v_c1);

      /* "asyncpg/protocol/codecs/textutils.pyx":27
 *         if c1 != c2:
 *             c1 = _apg_tolower(c1)
 *             c2 = _apg_tolower(c2)             # <<<<<<<<<<<<<<
 *             if c1 != c2:
 *                 return <int32_t>c1 - <int32_t>c2
 */
      __pyx_v_c2 = __pyx_f_7asyncpg_8protocol_8protocol__apg_tolower(__pyx_v_c2);

      /* "asyncpg/protocol/codecs/textutils.pyx":28
 *             c1 = _apg_tolower(c1)
 *             c2 = _apg_tolower(c2)
 *             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":29
 *             c2 = _apg_tolower(c2)
 *             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":28
 *             c1 = _apg_tolower(c1)
 *             c2 = _apg_tolower(c2)
 *             if c1 != c2:             # <<<<<<<<<<<<<<
 *                 return <int32_t>c1 - <int32_t>c2
 * 
 */
      }

      /* "asyncpg/protocol/codecs/textutils.pyx":25
 *         c2 = s2[i]
 * 
 *         if c1 != c2:             # <<<<<<<<<<<<<<
 *             c1 = _apg_tolower(c1)
 *             c2 = _apg_tolower(c2)
 */
    }

    /* "asyncpg/protocol/codecs/textutils.pyx":31
 *                 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_L8_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_v_c2 == 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L8_bool_binop_done:;
    if (__pyx_t_1) {

      /* "asyncpg/protocol/codecs/textutils.pyx":32
 * 
 *         if c1 == 0 or c2 == 0:
 *             break             # <<<<<<<<<<<<<<
 * 
 *         i += 1
 */
      goto __pyx_L4_break;

      /* "asyncpg/protocol/codecs/textutils.pyx":31
 *                 return <int32_t>c1 - <int32_t>c2
 * 
 *         if c1 == 0 or c2 == 0:             # <<<<<<<<<<<<<<
 *             break
 * 
 */
    }

    /* "asyncpg/protocol/codecs/textutils.pyx":34
 *             break
 * 
 *         i += 1             # <<<<<<<<<<<<<<
 * 
 *     return 0
 */
    __pyx_v_i = (__pyx_v_i + 1);
  }
  __pyx_L4_break:;

  /* "asyncpg/protocol/codecs/textutils.pyx":36
 *         i += 1
 * 
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "asyncpg/protocol/codecs/textutils.pyx":15
 * 
 * 
 * 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":39
 * 
 * 
 * cdef int apg_strcasecmp_char(const char *s1, const char *s2):             # <<<<<<<<<<<<<<
 *     cdef:
 *         uint8_t c1
 */

static int __pyx_f_7asyncpg_8protocol_8protocol_apg_strcasecmp_char(char const *__pyx_v_s1, char const *__pyx_v_s2) {
  uint8_t __pyx_v_c1;
  uint8_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_char", 0);

  /* "asyncpg/protocol/codecs/textutils.pyx":43
 *         uint8_t c1
 *         uint8_t c2
 *         int i = 0             # <<<<<<<<<<<<<<
 * 
 *     while True:
 */
  __pyx_v_i = 0;

  /* "asyncpg/protocol/codecs/textutils.pyx":45
 *         int i = 0
 * 
 *     while True:             # <<<<<<<<<<<<<<
 *         c1 = <uint8_t>s1[i]
 *         c2 = <uint8_t>s2[i]
 */
  while (1) {

    /* "asyncpg/protocol/codecs/textutils.pyx":46
 * 
 *     while True:
 *         c1 = <uint8_t>s1[i]             # <<<<<<<<<<<<<<
 *         c2 = <uint8_t>s2[i]
 * 
 */
    __pyx_v_c1 = ((uint8_t)(__pyx_v_s1[__pyx_v_i]));

    /* "asyncpg/protocol/codecs/textutils.pyx":47
 *     while True:
 *         c1 = <uint8_t>s1[i]
 *         c2 = <uint8_t>s2[i]             # <<<<<<<<<<<<<<
 * 
 *         if c1 != c2:
 */
    __pyx_v_c2 = ((uint8_t)(__pyx_v_s2[__pyx_v_i]));

    /* "asyncpg/protocol/codecs/textutils.pyx":49
 *         c2 = <uint8_t>s2[i]
 * 
 *         if c1 != c2:             # <<<<<<<<<<<<<<
 *             c1 = <uint8_t>_apg_tolower(c1)
 *             c2 = <uint8_t>_apg_tolower(c2)
 */
    __pyx_t_1 = ((__pyx_v_c1 != __pyx_v_c2) != 0);
    if (__pyx_t_1) {

      /* "asyncpg/protocol/codecs/textutils.pyx":50
 * 
 *         if c1 != c2:
 *             c1 = <uint8_t>_apg_tolower(c1)             # <<<<<<<<<<<<<<
 *             c2 = <uint8_t>_apg_tolower(c2)
 *             if c1 != c2:
 */
      __pyx_v_c1 = ((uint8_t)__pyx_f_7asyncpg_8protocol_8protocol__apg_tolower(__pyx_v_c1));

      /* "asyncpg/protocol/codecs/textutils.pyx":51
 *         if c1 != c2:
 *             c1 = <uint8_t>_apg_tolower(c1)
 *             c2 = <uint8_t>_apg_tolower(c2)             # <<<<<<<<<<<<<<
 *             if c1 != c2:
 *                 return <int8_t>c1 - <int8_t>c2
 */
      __pyx_v_c2 = ((uint8_t)__pyx_f_7asyncpg_8protocol_8protocol__apg_tolower(__pyx_v_c2));

      /* "asyncpg/protocol/codecs/textutils.pyx":52
 *             c1 = <uint8_t>_apg_tolower(c1)
 *             c2 = <uint8_t>_apg_tolower(c2)
 *             if c1 != c2:             # <<<<<<<<<<<<<<
 *                 return <int8_t>c1 - <int8_t>c2
 * 
 */
      __pyx_t_1 = ((__pyx_v_c1 != __pyx_v_c2) != 0);
      if (__pyx_t_1) {

        /* "asyncpg/protocol/codecs/textutils.pyx":53
 *             c2 = <uint8_t>_apg_tolower(c2)
 *             if c1 != c2:
 *                 return <int8_t>c1 - <int8_t>c2             # <<<<<<<<<<<<<<
 * 
 *         if c1 == 0 or c2 == 0:
 */
        __pyx_r = (((int8_t)__pyx_v_c1) - ((int8_t)__pyx_v_c2));
        goto __pyx_L0;

        /* "asyncpg/protocol/codecs/textutils.pyx":52
 *             c1 = <uint8_t>_apg_tolower(c1)
 *             c2 = <uint8_t>_apg_tolower(c2)
 *             if c1 != c2:             # <<<<<<<<<<<<<<
 *                 return <int8_t>c1 - <int8_t>c2
 * 
 */
      }

      /* "asyncpg/protocol/codecs/textutils.pyx":49
 *         c2 = <uint8_t>s2[i]
 * 
 *         if c1 != c2:             # <<<<<<<<<<<<<<
 *             c1 = <uint8_t>_apg_tolower(c1)
 *             c2 = <uint8_t>_apg_tolower(c2)
 */
    }

    /* "asyncpg/protocol/codecs/textutils.pyx":55
 *                 return <int8_t>c1 - <int8_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_L8_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_v_c2 == 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L8_bool_binop_done:;
    if (__pyx_t_1) {

      /* "asyncpg/protocol/codecs/textutils.pyx":56
 * 
 *         if c1 == 0 or c2 == 0:
 *             break             # <<<<<<<<<<<<<<
 * 
 *         i += 1
 */
      goto __pyx_L4_break;

      /* "asyncpg/protocol/codecs/textutils.pyx":55
 *                 return <int8_t>c1 - <int8_t>c2
 * 
 *         if c1 == 0 or c2 == 0:             # <<<<<<<<<<<<<<
 *             break
 * 
 */
    }

    /* "asyncpg/protocol/codecs/textutils.pyx":58
 *             break
 * 
 *         i += 1             # <<<<<<<<<<<<<<
 * 
 *     return 0
 */
    __pyx_v_i = (__pyx_v_i + 1);
  }
  __pyx_L4_break:;

  /* "asyncpg/protocol/codecs/textutils.pyx":60
 *         i += 1
 * 
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "asyncpg/protocol/codecs/textutils.pyx":39
 * 
 * 
 * cdef int apg_strcasecmp_char(const char *s1, const char *s2):             # <<<<<<<<<<<<<<
 *     cdef:
 *         uint8_t c1
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/codecs/textutils.pyx":63
 * 
 * 
 * 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":65
 * 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":66
 *     return (
 *         ch == ' ' or
 *         ch == '\n' or             # <<<<<<<<<<<<<<
 *         ch == '\r' or
 *         ch == '\t' or
 */
    case 10:

    /* "asyncpg/protocol/codecs/textutils.pyx":67
 *         ch == ' ' or
 *         ch == '\n' or
 *         ch == '\r' or             # <<<<<<<<<<<<<<
 *         ch == '\t' or
 *         ch == '\v' or
 */
    case 13:

    /* "asyncpg/protocol/codecs/textutils.pyx":68
 *         ch == '\n' or
 *         ch == '\r' or
 *         ch == '\t' or             # <<<<<<<<<<<<<<
 *         ch == '\v' or
 *         ch == '\f'
 */
    case 9:

    /* "asyncpg/protocol/codecs/textutils.pyx":69
 *         ch == '\r' or
 *         ch == '\t' or
 *         ch == '\v' or             # <<<<<<<<<<<<<<
 *         ch == '\f'
 *     )
 */
    case 11:

    /* "asyncpg/protocol/codecs/textutils.pyx":70
 *         ch == '\t' or
 *         ch == '\v' or
 *         ch == '\f'             # <<<<<<<<<<<<<<
 *     )
 * 
 */
    case 12:

    /* "asyncpg/protocol/codecs/textutils.pyx":65
 * 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":63
 * 
 * 
 * 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":74
 * 
 * 
 * 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":77
 *     cdef:
 *         Py_UCS4 *p
 *         int32_t n = 0             # <<<<<<<<<<<<<<
 *         int32_t neg = 0
 * 
 */
  __pyx_v_n = 0;

  /* "asyncpg/protocol/codecs/textutils.pyx":78
 *         Py_UCS4 *p
 *         int32_t n = 0
 *         int32_t neg = 0             # <<<<<<<<<<<<<<
 * 
 *     if buf[0] == '-':
 */
  __pyx_v_neg = 0;

  /* "asyncpg/protocol/codecs/textutils.pyx":80
 *         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":81
 * 
 *     if buf[0] == '-':
 *         neg = 1             # <<<<<<<<<<<<<<
 *         buf += 1
 *     elif buf[0] == '+':
 */
    __pyx_v_neg = 1;

    /* "asyncpg/protocol/codecs/textutils.pyx":82
 *     if buf[0] == '-':
 *         neg = 1
 *         buf += 1             # <<<<<<<<<<<<<<
 *     elif buf[0] == '+':
 *         buf += 1
 */
    __pyx_v_buf = (__pyx_v_buf + 1);

    /* "asyncpg/protocol/codecs/textutils.pyx":80
 *         int32_t neg = 0
 * 
 *     if buf[0] == '-':             # <<<<<<<<<<<<<<
 *         neg = 1
 *         buf += 1
 */
    goto __pyx_L3;
  }

  /* "asyncpg/protocol/codecs/textutils.pyx":83
 *         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":84
 *         buf += 1
 *     elif buf[0] == '+':
 *         buf += 1             # <<<<<<<<<<<<<<
 * 
 *     p = buf
 */
    __pyx_v_buf = (__pyx_v_buf + 1);

    /* "asyncpg/protocol/codecs/textutils.pyx":83
 *         neg = 1
 *         buf += 1
 *     elif buf[0] == '+':             # <<<<<<<<<<<<<<
 *         buf += 1
 * 
 */
  }
  __pyx_L3:;

  /* "asyncpg/protocol/codecs/textutils.pyx":86
 *         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":87
 * 
 *     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":88
 *     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":89
 *     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":91
 *         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":92
 * 
 *     if p == buf:
 *         return NULL             # <<<<<<<<<<<<<<
 * 
 *     if not neg:
 */
    __pyx_r = NULL;
    goto __pyx_L0;

    /* "asyncpg/protocol/codecs/textutils.pyx":91
 *         p += 1
 * 
 *     if p == buf:             # <<<<<<<<<<<<<<
 *         return NULL
 * 
 */
  }

  /* "asyncpg/protocol/codecs/textutils.pyx":94
 *         return NULL
 * 
 *     if not neg:             # <<<<<<<<<<<<<<
 *         n = -n
 * 
 */
  __pyx_t_1 = ((!(__pyx_v_neg != 0)) != 0);
  if (__pyx_t_1) {

    /* "asyncpg/protocol/codecs/textutils.pyx":95
 * 
 *     if not neg:
 *         n = -n             # <<<<<<<<<<<<<<
 * 
 *     num[0] = n
 */
    __pyx_v_n = (-__pyx_v_n);

    /* "asyncpg/protocol/codecs/textutils.pyx":94
 *         return NULL
 * 
 *     if not neg:             # <<<<<<<<<<<<<<
 *         n = -n
 * 
 */
  }

  /* "asyncpg/protocol/codecs/textutils.pyx":97
 *         n = -n
 * 
 *     num[0] = n             # <<<<<<<<<<<<<<
 * 
 *     return p
 */
  (__pyx_v_num[0]) = __pyx_v_n;

  /* "asyncpg/protocol/codecs/textutils.pyx":99
 *     num[0] = n
 * 
 *     return p             # <<<<<<<<<<<<<<
 */
  __pyx_r = __pyx_v_p;
  goto __pyx_L0;

  /* "asyncpg/protocol/codecs/textutils.pyx":74
 * 
 * 
 * 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 == ((int)-1))) __PYX_ERR(9, 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(9, 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(9, 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;
    }
    __pyx_L5_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __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_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)
 * 
 */
        }
      }
      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(9, 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 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;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  char *__pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("as_pg_string_and_size", 0);

  /* "asyncpg/protocol/codecs/text.pyx":11
 *         ConnectionSettings settings, obj, char **cstr, ssize_t *size):
 * 
 *     if not cpython.PyUnicode_Check(obj):             # <<<<<<<<<<<<<<
 *         raise TypeError('expected str, got {}'.format(type(obj).__name__))
 * 
 */
  __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):
 *         raise TypeError('expected str, got {}'.format(type(obj).__name__))             # <<<<<<<<<<<<<<
 * 
 *     if settings.is_encoding_utf8():
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_expected_str_got, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(10, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_obj)), __pyx_n_s_name_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(10, 12, __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(10, 12, __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(10, 12, __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(10, 12, __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(10, 12, __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(10, 12, __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_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(10, 12, __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(10, 12, __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(10, 12, __pyx_L1_error)

    /* "asyncpg/protocol/codecs/text.pyx":11
 *         ConnectionSettings settings, obj, char **cstr, ssize_t *size):
 * 
 *     if not cpython.PyUnicode_Check(obj):             # <<<<<<<<<<<<<<
 *         raise TypeError('expected str, got {}'.format(type(obj).__name__))
 * 
 */
  }

  /* "asyncpg/protocol/codecs/text.pyx":14
 *         raise TypeError('expected str, got {}'.format(type(obj).__name__))
 * 
 *     if settings.is_encoding_utf8():             # <<<<<<<<<<<<<<
 *         cstr[0] = PyUnicode_AsUTF8AndSize(obj, size)
 *     else:
 */
  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_is_encoding_utf8(__pyx_v_settings); if (unlikely(!__pyx_t_2)) __PYX_ERR(10, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(10, 14, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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_7 = PyUnicode_AsUTF8AndSize(__pyx_v_obj, __pyx_v_size); if (unlikely(__pyx_t_7 == ((char *)NULL))) __PYX_ERR(10, 15, __pyx_L1_error)
    (__pyx_v_cstr[0]) = __pyx_t_7;

    /* "asyncpg/protocol/codecs/text.pyx":14
 *         raise TypeError('expected str, got {}'.format(type(obj).__name__))
 * 
 *     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_3 = __pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_text_codec(__pyx_v_settings, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(10, 17, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_encode); if (unlikely(!__pyx_t_6)) __PYX_ERR(10, 17, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_obj); if (unlikely(!__pyx_t_2)) __PYX_ERR(10, 17, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_obj};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(10, 17, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_obj};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(10, 17, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(10, 17, __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_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(10, 17, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_v_encoded = __pyx_t_2;
    __pyx_t_2 = 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_8 = PyBytes_AsStringAndSize(__pyx_v_encoded, __pyx_v_cstr, ((Py_ssize_t *)__pyx_v_size)); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(10, 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_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(10, 21, __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(10, 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_4);
  __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_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(10, 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(10, 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(10, 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(10, 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(10, 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(10, 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(10, 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(10, 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(10, 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(10, 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(10, 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(10, 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(10, 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(10, 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(10, 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(10, 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(10, 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(10, 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(10, 61, __pyx_L1_error)

    /* "asyncpg/protocol/codecs/text.pyx":64
 *                             <encode_func>&text_encode,
 *                             <decode_func>&text_decode,
 *                             PG_FORMAT_BINARY)             # <<<<<<<<<<<<<<
 * 
 *         register_core_codec(oid,
 */
    __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, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(10, 61, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "asyncpg/protocol/codecs/text.pyx":66
 *                             PG_FORMAT_BINARY)
 * 
 *         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(10, 66, __pyx_L1_error)

    /* "asyncpg/protocol/codecs/text.pyx":69
 *                             <encode_func>&text_encode,
 *                             <decode_func>&text_decode,
 *                             PG_FORMAT_TEXT)             # <<<<<<<<<<<<<<
 * 
 * init_text_codecs()
 */
    __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, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(10, 66, __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(11, 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 == ((int)-1))) __PYX_ERR(11, 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(11, 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 == ((int)-1))) __PYX_ERR(11, 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(11, 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(11, 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(11, 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(11, 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 == ((int)-1))) __PYX_ERR(11, 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__44, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 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(11, 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(11, 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(11, 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(11, 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;
    }
    __pyx_L5_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __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_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)
 * 
 */
        }
      }
      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 == ((char const *)NULL))) __PYX_ERR(11, 46, __pyx_L1_error)
  __pyx_v_bitlen = 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(11, 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(11, 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(11, 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(11, 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(11, 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(11, 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(11, 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(11, 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, NULL); 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/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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 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(12, 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(12, 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(12, 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 == ((char const *)NULL))) __PYX_ERR(12, 77, __pyx_L1_error)
  __pyx_v_ts = 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, 1, 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(12, 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(12, 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(12, 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 == ((long)-1L) && PyErr_Occurred())) __PYX_ERR(12, 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(12, 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(12, 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_encode_tuple(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int32_t pg_ordinal
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_date_encode_tuple(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_pg_ordinal;
  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;
  PyObject *__pyx_t_7 = NULL;
  int32_t __pyx_t_8;
  __Pyx_RefNannySetupContext("date_encode_tuple", 0);

  /* "asyncpg/protocol/codecs/datetime.pyx":110
 *         int32_t pg_ordinal
 * 
 *     if len(obj) != 1:             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             'date tuple encoder: expecting 1 element '
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(12, 110, __pyx_L1_error)
  __pyx_t_2 = ((__pyx_t_1 != 1) != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/codecs/datetime.pyx":113
 *         raise ValueError(
 *             'date tuple encoder: expecting 1 element '
 *             'in tuple, got {}'.format(len(obj)))             # <<<<<<<<<<<<<<
 * 
 *     pg_ordinal = obj[0]
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_date_tuple_encoder_expecting_1_e, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(12, 113, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyObject_Length(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(12, 113, __pyx_L1_error)
    __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(12, 113, __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, 113, __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, 113, __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, 113, __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, 113, __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, 113, __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/datetime.pyx":111
 * 
 *     if len(obj) != 1:
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             'date tuple encoder: expecting 1 element '
 *             'in tuple, got {}'.format(len(obj)))
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(12, 111, __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, 111, __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, 111, __pyx_L1_error)

    /* "asyncpg/protocol/codecs/datetime.pyx":110
 *         int32_t pg_ordinal
 * 
 *     if len(obj) != 1:             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             'date tuple encoder: expecting 1 element '
 */
  }

  /* "asyncpg/protocol/codecs/datetime.pyx":115
 *             'in tuple, got {}'.format(len(obj)))
 * 
 *     pg_ordinal = obj[0]             # <<<<<<<<<<<<<<
 *     buf.write_int32(4)
 *     buf.write_int32(pg_ordinal)
 */
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_obj, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 115, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = __Pyx_PyInt_As_int32_t(__pyx_t_3); if (unlikely((__pyx_t_8 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(12, 115, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_pg_ordinal = __pyx_t_8;

  /* "asyncpg/protocol/codecs/datetime.pyx":116
 * 
 *     pg_ordinal = obj[0]
 *     buf.write_int32(4)             # <<<<<<<<<<<<<<
 *     buf.write_int32(pg_ordinal)
 * 
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, 4); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":117
 *     pg_ordinal = obj[0]
 *     buf.write_int32(4)
 *     buf.write_int32(pg_ordinal)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, __pyx_v_pg_ordinal); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":106
 * 
 * 
 * cdef date_encode_tuple(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int32_t pg_ordinal
 */

  /* 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.date_encode_tuple", __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":120
 * 
 * 
 * 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":121
 * 
 * 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 == ((char const *)NULL))) __PYX_ERR(12, 121, __pyx_L1_error)
  __pyx_v_pg_ordinal = unpack_int32(__pyx_t_1);

  /* "asyncpg/protocol/codecs/datetime.pyx":123
 *     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":124
 * 
 *     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(12, 124, __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":123
 *     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":125
 *     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":126
 *         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(12, 126, __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":125
 *     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":128
 *         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(12, 128, __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(12, 128, __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(12, 128, __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, 128, __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, 128, __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, 128, __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, 128, __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":120
 * 
 * 
 * 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":131
 * 
 * 
 * cdef date_decode_tuple(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
 *     cdef int32_t pg_ordinal = hton.unpack_int32(buf.read(4))
 * 
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_date_decode_tuple(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;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("date_decode_tuple", 0);

  /* "asyncpg/protocol/codecs/datetime.pyx":132
 * 
 * cdef date_decode_tuple(ConnectionSettings settings, FastReadBuffer buf):
 *     cdef int32_t pg_ordinal = hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
 * 
 *     return (pg_ordinal,)
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(12, 132, __pyx_L1_error)
  __pyx_v_pg_ordinal = unpack_int32(__pyx_t_1);

  /* "asyncpg/protocol/codecs/datetime.pyx":134
 *     cdef int32_t pg_ordinal = hton.unpack_int32(buf.read(4))
 * 
 *     return (pg_ordinal,)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_From_int32_t(__pyx_v_pg_ordinal); if (unlikely(!__pyx_t_2)) __PYX_ERR(12, 134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 134, __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_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "asyncpg/protocol/codecs/datetime.pyx":131
 * 
 * 
 * cdef date_decode_tuple(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_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.date_decode_tuple", __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":137
 * 
 * 
 * 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":138
 * 
 * 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(12, 138, __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(12, 138, __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":140
 *     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(12, 140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyLong_AsLongLong(__pyx_t_2); if (unlikely(__pyx_t_3 == ((PY_LONG_LONG)-1LL) && PyErr_Occurred())) __PYX_ERR(12, 140, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":141
 *     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(12, 141, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyLong_AsLong(__pyx_t_2); if (unlikely(__pyx_t_4 == ((long)-1L) && PyErr_Occurred())) __PYX_ERR(12, 141, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":140
 *     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":143
 *                                 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(12, 143, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "asyncpg/protocol/codecs/datetime.pyx":142
 *         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 == ((long)-1L) && PyErr_Occurred())) __PYX_ERR(12, 142, __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":145
 *                                     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(12, 145, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":146
 * 
 *     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(12, 146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":137
 * 
 * 
 * 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":149
 * 
 * 
 * cdef timestamp_encode_tuple(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int64_t microseconds
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_timestamp_encode_tuple(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_microseconds;
  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;
  PyObject *__pyx_t_7 = NULL;
  int64_t __pyx_t_8;
  __Pyx_RefNannySetupContext("timestamp_encode_tuple", 0);

  /* "asyncpg/protocol/codecs/datetime.pyx":153
 *         int64_t microseconds
 * 
 *     if len(obj) != 1:             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             'timestamp tuple encoder: expecting 1 element '
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(12, 153, __pyx_L1_error)
  __pyx_t_2 = ((__pyx_t_1 != 1) != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/codecs/datetime.pyx":156
 *         raise ValueError(
 *             'timestamp tuple encoder: expecting 1 element '
 *             'in tuple, got {}'.format(len(obj)))             # <<<<<<<<<<<<<<
 * 
 *     microseconds = obj[0]
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_timestamp_tuple_encoder_expectin, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(12, 156, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyObject_Length(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(12, 156, __pyx_L1_error)
    __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(12, 156, __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, 156, __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, 156, __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, 156, __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, 156, __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, 156, __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/datetime.pyx":154
 * 
 *     if len(obj) != 1:
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             'timestamp tuple encoder: expecting 1 element '
 *             'in tuple, got {}'.format(len(obj)))
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(12, 154, __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, 154, __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, 154, __pyx_L1_error)

    /* "asyncpg/protocol/codecs/datetime.pyx":153
 *         int64_t microseconds
 * 
 *     if len(obj) != 1:             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             'timestamp tuple encoder: expecting 1 element '
 */
  }

  /* "asyncpg/protocol/codecs/datetime.pyx":158
 *             'in tuple, got {}'.format(len(obj)))
 * 
 *     microseconds = obj[0]             # <<<<<<<<<<<<<<
 * 
 *     buf.write_int32(8)
 */
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_obj, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 158, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = __Pyx_PyInt_As_int64_t(__pyx_t_3); if (unlikely((__pyx_t_8 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(12, 158, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_microseconds = __pyx_t_8;

  /* "asyncpg/protocol/codecs/datetime.pyx":160
 *     microseconds = obj[0]
 * 
 *     buf.write_int32(8)             # <<<<<<<<<<<<<<
 *     buf.write_int64(microseconds)
 * 
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, 8); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":161
 * 
 *     buf.write_int32(8)
 *     buf.write_int64(microseconds)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int64(__pyx_v_buf, __pyx_v_microseconds); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":149
 * 
 * 
 * cdef timestamp_encode_tuple(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int64_t microseconds
 */

  /* 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.timestamp_encode_tuple", __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":164
 * 
 * 
 * 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":166
 * 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":167
 *     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":168
 *         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":170
 *         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":172
 *     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(12, 172, __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":170
 *         int32_t inf = _decode_time(buf, &seconds, &microseconds)
 * 
 *     if inf > 0:             # <<<<<<<<<<<<<<
 *         # positive infinity
 *         return infinity_datetime
 */
  }

  /* "asyncpg/protocol/codecs/datetime.pyx":173
 *         # 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":175
 *     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(12, 175, __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":173
 *         # positive infinity
 *         return infinity_datetime
 *     elif inf < 0:             # <<<<<<<<<<<<<<
 *         # negative infinity
 *         return negative_infinity_datetime
 */
  }

  /* "asyncpg/protocol/codecs/datetime.pyx":177
 *         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(12, 177, __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(12, 177, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "asyncpg/protocol/codecs/datetime.pyx":178
 *     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(12, 178, __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(12, 178, __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(12, 178, __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(12, 178, __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(12, 178, __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(12, 178, __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(12, 178, __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(12, 177, __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(12, 177, __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(12, 177, __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(12, 177, __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(12, 177, __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":164
 * 
 * 
 * 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":181
 * 
 * 
 * cdef timestamp_decode_tuple(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int64_t ts = hton.unpack_int64(buf.read(8))
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_timestamp_decode_tuple(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_ts;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  char const *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("timestamp_decode_tuple", 0);

  /* "asyncpg/protocol/codecs/datetime.pyx":183
 * cdef timestamp_decode_tuple(ConnectionSettings settings, FastReadBuffer buf):
 *     cdef:
 *         int64_t ts = hton.unpack_int64(buf.read(8))             # <<<<<<<<<<<<<<
 * 
 *     return (ts,)
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(12, 183, __pyx_L1_error)
  __pyx_v_ts = unpack_int64(__pyx_t_1);

  /* "asyncpg/protocol/codecs/datetime.pyx":185
 *         int64_t ts = hton.unpack_int64(buf.read(8))
 * 
 *     return (ts,)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_From_int64_t(__pyx_v_ts); if (unlikely(!__pyx_t_2)) __PYX_ERR(12, 185, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 185, __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_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "asyncpg/protocol/codecs/datetime.pyx":181
 * 
 * 
 * cdef timestamp_decode_tuple(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int64_t ts = hton.unpack_int64(buf.read(8))
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.timestamp_decode_tuple", __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":188
 * 
 * 
 * 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":189
 * 
 * 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(12, 189, __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)
 * 
 *     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(12, 191, __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(12, 191, __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(12, 191, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "asyncpg/protocol/codecs/datetime.pyx":192
 * 
 *     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(12, 192, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "asyncpg/protocol/codecs/datetime.pyx":193
 *     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":191
 *     buf.write_int32(8)
 * 
 *     if obj == infinity_datetime:             # <<<<<<<<<<<<<<
 *         buf.write_int64(pg_time64_infinity)
 *         return
 */
  }

  /* "asyncpg/protocol/codecs/datetime.pyx":194
 *         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(12, 194, __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(12, 194, __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(12, 194, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_3) {

    /* "asyncpg/protocol/codecs/datetime.pyx":195
 *         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(12, 195, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/codecs/datetime.pyx":196
 *     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":194
 *         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":198
 *         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(12, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_utc); if (unlikely(!__pyx_t_4)) __PYX_ERR(12, 198, __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(12, 198, __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(12, 198, __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(12, 198, __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(12, 198, __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(12, 198, __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(12, 198, __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(12, 198, __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":200
 *     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(12, 200, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyLong_AsLongLong(__pyx_t_6); if (unlikely(__pyx_t_7 == ((PY_LONG_LONG)-1LL) && PyErr_Occurred())) __PYX_ERR(12, 200, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":201
 *     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(12, 201, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = PyLong_AsLong(__pyx_t_6); if (unlikely(__pyx_t_8 == ((long)-1L) && PyErr_Occurred())) __PYX_ERR(12, 201, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":200
 *     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":203
 *                                 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(12, 203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);

  /* "asyncpg/protocol/codecs/datetime.pyx":202
 *         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 == ((long)-1L) && PyErr_Occurred())) __PYX_ERR(12, 202, __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":205
 *                                     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(12, 205, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":188
 * 
 * 
 * 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":208
 * 
 * 
 * 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":210
 * 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":211
 *     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":212
 *         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":214
 *         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":216
 *     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(12, 216, __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":214
 *         int32_t inf = _decode_time(buf, &seconds, &microseconds)
 * 
 *     if inf > 0:             # <<<<<<<<<<<<<<
 *         # positive infinity
 *         return infinity_datetime
 */
  }

  /* "asyncpg/protocol/codecs/datetime.pyx":217
 *         # 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":219
 *     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(12, 219, __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":217
 *         # positive infinity
 *         return infinity_datetime
 *     elif inf < 0:             # <<<<<<<<<<<<<<
 *         # negative infinity
 *         return negative_infinity_datetime
 */
  }

  /* "asyncpg/protocol/codecs/datetime.pyx":221
 *         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(12, 221, __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(12, 221, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "asyncpg/protocol/codecs/datetime.pyx":222
 *     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(12, 222, __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(12, 222, __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(12, 222, __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(12, 222, __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(12, 222, __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(12, 222, __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(12, 222, __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(12, 221, __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(12, 221, __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(12, 221, __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(12, 221, __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(12, 221, __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":208
 * 
 * 
 * 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":225
 * 
 * 
 * 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":227
 * 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(12, 227, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_2 == ((long)-1L) && PyErr_Occurred())) __PYX_ERR(12, 227, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":228
 *     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(12, 228, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_3 == ((long)-1L) && PyErr_Occurred())) __PYX_ERR(12, 228, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":229
 *         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(12, 229, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_4 == ((long)-1L) && PyErr_Occurred())) __PYX_ERR(12, 229, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":228
 *     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":230
 *                             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(12, 230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_4 == ((long)-1L) && PyErr_Occurred())) __PYX_ERR(12, 230, __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":232
 *         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(12, 232, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":233
 * 
 *     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(12, 233, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":225
 * 
 * 
 * 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":236
 * 
 * 
 * cdef time_encode_tuple(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int64_t microseconds
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_time_encode_tuple(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_microseconds;
  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;
  PyObject *__pyx_t_7 = NULL;
  int64_t __pyx_t_8;
  __Pyx_RefNannySetupContext("time_encode_tuple", 0);

  /* "asyncpg/protocol/codecs/datetime.pyx":240
 *         int64_t microseconds
 * 
 *     if len(obj) != 1:             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             'time tuple encoder: expecting 1 element '
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(12, 240, __pyx_L1_error)
  __pyx_t_2 = ((__pyx_t_1 != 1) != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/codecs/datetime.pyx":243
 *         raise ValueError(
 *             'time tuple encoder: expecting 1 element '
 *             'in tuple, got {}'.format(len(obj)))             # <<<<<<<<<<<<<<
 * 
 *     microseconds = obj[0]
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_time_tuple_encoder_expecting_1_e, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(12, 243, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyObject_Length(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(12, 243, __pyx_L1_error)
    __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(12, 243, __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, 243, __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, 243, __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, 243, __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, 243, __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, 243, __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/datetime.pyx":241
 * 
 *     if len(obj) != 1:
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             'time tuple encoder: expecting 1 element '
 *             'in tuple, got {}'.format(len(obj)))
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(12, 241, __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, 241, __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, 241, __pyx_L1_error)

    /* "asyncpg/protocol/codecs/datetime.pyx":240
 *         int64_t microseconds
 * 
 *     if len(obj) != 1:             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             'time tuple encoder: expecting 1 element '
 */
  }

  /* "asyncpg/protocol/codecs/datetime.pyx":245
 *             'in tuple, got {}'.format(len(obj)))
 * 
 *     microseconds = obj[0]             # <<<<<<<<<<<<<<
 * 
 *     buf.write_int32(8)
 */
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_obj, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 245, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = __Pyx_PyInt_As_int64_t(__pyx_t_3); if (unlikely((__pyx_t_8 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(12, 245, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_microseconds = __pyx_t_8;

  /* "asyncpg/protocol/codecs/datetime.pyx":247
 *     microseconds = obj[0]
 * 
 *     buf.write_int32(8)             # <<<<<<<<<<<<<<
 *     buf.write_int64(microseconds)
 * 
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, 8); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 247, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":248
 * 
 *     buf.write_int32(8)
 *     buf.write_int64(microseconds)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int64(__pyx_v_buf, __pyx_v_microseconds); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 248, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":236
 * 
 * 
 * cdef time_encode_tuple(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int64_t microseconds
 */

  /* 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.time_encode_tuple", __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":251
 * 
 * 
 * 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":253
 * 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":254
 *     cdef:
 *         int64_t seconds = 0
 *         uint32_t microseconds = 0             # <<<<<<<<<<<<<<
 * 
 *     _decode_time(buf, &seconds, &microseconds)
 */
  __pyx_v_microseconds = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":256
 *         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":259
 * 
 *     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":260
 *     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":261
 *         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":262
 *         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":264
 *         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(12, 264, __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(12, 264, __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(12, 264, __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(12, 264, __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(12, 264, __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(12, 264, __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(12, 264, __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(12, 264, __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(12, 264, __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(12, 264, __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":251
 * 
 * 
 * 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":267
 * 
 * 
 * cdef time_decode_tuple(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int64_t ts = hton.unpack_int64(buf.read(8))
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_time_decode_tuple(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_ts;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  char const *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("time_decode_tuple", 0);

  /* "asyncpg/protocol/codecs/datetime.pyx":269
 * cdef time_decode_tuple(ConnectionSettings settings, FastReadBuffer buf):
 *     cdef:
 *         int64_t ts = hton.unpack_int64(buf.read(8))             # <<<<<<<<<<<<<<
 * 
 *     return (ts,)
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(12, 269, __pyx_L1_error)
  __pyx_v_ts = unpack_int64(__pyx_t_1);

  /* "asyncpg/protocol/codecs/datetime.pyx":271
 *         int64_t ts = hton.unpack_int64(buf.read(8))
 * 
 *     return (ts,)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_From_int64_t(__pyx_v_ts); if (unlikely(!__pyx_t_2)) __PYX_ERR(12, 271, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 271, __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_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "asyncpg/protocol/codecs/datetime.pyx":267
 * 
 * 
 * cdef time_decode_tuple(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int64_t ts = hton.unpack_int64(buf.read(8))
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.time_decode_tuple", __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":274
 * 
 * 
 * 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":275
 * 
 * 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(12, 275, __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(12, 275, __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__45, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 275, __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":279
 *     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(12, 279, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_3 == ((long)-1L) && PyErr_Occurred())) __PYX_ERR(12, 279, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":280
 *         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(12, 280, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_4 == ((long)-1L) && PyErr_Occurred())) __PYX_ERR(12, 280, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":279
 *     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":282
 *             <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(12, 282, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_4 == ((long)-1L) && PyErr_Occurred())) __PYX_ERR(12, 282, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":283
 * 
 *         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(12, 283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_3 == ((long)-1L) && PyErr_Occurred())) __PYX_ERR(12, 283, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":284
 *         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(12, 284, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_5 == ((long)-1L) && PyErr_Occurred())) __PYX_ERR(12, 284, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":283
 * 
 *         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":286
 *                             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(12, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_5 == ((long)-1L) && PyErr_Occurred())) __PYX_ERR(12, 286, __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":288
 *         int32_t microseconds = <int32_t>cpython.PyLong_AsLong(obj.microsecond)
 * 
 *     buf.write_int32(12)             # <<<<<<<<<<<<<<
 *     _encode_time(buf, seconds, microseconds)
 *     # In Python utcoffset() is the difference between the local time
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, 12); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 288, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":289
 * 
 *     buf.write_int32(12)
 *     _encode_time(buf, seconds, microseconds)             # <<<<<<<<<<<<<<
 *     # In Python utcoffset() is the difference between the local time
 *     # and the UTC, whereas in PostgreSQL it's the opposite,
 */
  __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(12, 289, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":293
 *     # and the UTC, whereas in PostgreSQL it's the opposite,
 *     # so we need to flip the sign.
 *     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(12, 293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":274
 * 
 * 
 * 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":296
 * 
 * 
 * cdef timetz_encode_tuple(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int64_t microseconds
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_timetz_encode_tuple(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_microseconds;
  int32_t __pyx_v_offset_sec;
  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;
  PyObject *__pyx_t_7 = NULL;
  int64_t __pyx_t_8;
  int32_t __pyx_t_9;
  __Pyx_RefNannySetupContext("timetz_encode_tuple", 0);

  /* "asyncpg/protocol/codecs/datetime.pyx":301
 *         int32_t offset_sec
 * 
 *     if len(obj) != 2:             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             'time tuple encoder: expecting 2 elements2 '
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(12, 301, __pyx_L1_error)
  __pyx_t_2 = ((__pyx_t_1 != 2) != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/codecs/datetime.pyx":304
 *         raise ValueError(
 *             'time tuple encoder: expecting 2 elements2 '
 *             'in tuple, got {}'.format(len(obj)))             # <<<<<<<<<<<<<<
 * 
 *     microseconds = obj[0]
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_time_tuple_encoder_expecting_2_e, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(12, 304, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyObject_Length(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(12, 304, __pyx_L1_error)
    __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(12, 304, __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, 304, __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, 304, __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, 304, __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, 304, __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, 304, __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/datetime.pyx":302
 * 
 *     if len(obj) != 2:
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             'time tuple encoder: expecting 2 elements2 '
 *             'in tuple, got {}'.format(len(obj)))
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(12, 302, __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, 302, __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, 302, __pyx_L1_error)

    /* "asyncpg/protocol/codecs/datetime.pyx":301
 *         int32_t offset_sec
 * 
 *     if len(obj) != 2:             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             'time tuple encoder: expecting 2 elements2 '
 */
  }

  /* "asyncpg/protocol/codecs/datetime.pyx":306
 *             'in tuple, got {}'.format(len(obj)))
 * 
 *     microseconds = obj[0]             # <<<<<<<<<<<<<<
 *     offset_sec = obj[1]
 * 
 */
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_obj, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = __Pyx_PyInt_As_int64_t(__pyx_t_3); if (unlikely((__pyx_t_8 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(12, 306, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_microseconds = __pyx_t_8;

  /* "asyncpg/protocol/codecs/datetime.pyx":307
 * 
 *     microseconds = obj[0]
 *     offset_sec = obj[1]             # <<<<<<<<<<<<<<
 * 
 *     buf.write_int32(12)
 */
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_obj, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_9 = __Pyx_PyInt_As_int32_t(__pyx_t_3); if (unlikely((__pyx_t_9 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(12, 307, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_offset_sec = __pyx_t_9;

  /* "asyncpg/protocol/codecs/datetime.pyx":309
 *     offset_sec = obj[1]
 * 
 *     buf.write_int32(12)             # <<<<<<<<<<<<<<
 *     buf.write_int64(microseconds)
 *     buf.write_int32(offset_sec)
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, 12); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 309, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":310
 * 
 *     buf.write_int32(12)
 *     buf.write_int64(microseconds)             # <<<<<<<<<<<<<<
 *     buf.write_int32(offset_sec)
 * 
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int64(__pyx_v_buf, __pyx_v_microseconds); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":311
 *     buf.write_int32(12)
 *     buf.write_int64(microseconds)
 *     buf.write_int32(offset_sec)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, __pyx_v_offset_sec); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 311, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":296
 * 
 * 
 * cdef timetz_encode_tuple(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int64_t microseconds
 */

  /* 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.timetz_encode_tuple", __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":314
 * 
 * 
 * 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":315
 * 
 * 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)
 *     # See the comment in the `timetz_encode` method.
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_time_decode(__pyx_v_settings, __pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 315, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_time = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":316
 * 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)             # <<<<<<<<<<<<<<
 *     # See the comment in the `timetz_encode` method.
 *     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 == ((char const *)NULL))) __PYX_ERR(12, 316, __pyx_L1_error)
  __pyx_v_offset = ((int32_t)(((double)unpack_int32(__pyx_t_2)) / 60.0));

  /* "asyncpg/protocol/codecs/datetime.pyx":318
 *     cdef int32_t offset = <int32_t>(hton.unpack_int32(buf.read(4)) / 60)
 *     # See the comment in the `timetz_encode` method.
 *     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(12, 318, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 318, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_datetime); if (unlikely(!__pyx_t_5)) __PYX_ERR(12, 318, __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(12, 318, __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(12, 318, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(12, 318, __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(12, 318, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_minutes, __pyx_t_8) < 0) __PYX_ERR(12, 318, __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(12, 318, __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(12, 318, __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(12, 318, __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(12, 318, __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(12, 318, __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(12, 318, __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(12, 318, __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(12, 318, __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":314
 * 
 * 
 * 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":321
 * 
 * 
 * cdef timetz_decode_tuple(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int64_t microseconds = hton.unpack_int64(buf.read(8))
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_timetz_decode_tuple(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_microseconds;
  int32_t __pyx_v_offset_sec;
  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("timetz_decode_tuple", 0);

  /* "asyncpg/protocol/codecs/datetime.pyx":323
 * cdef timetz_decode_tuple(ConnectionSettings settings, FastReadBuffer buf):
 *     cdef:
 *         int64_t microseconds = hton.unpack_int64(buf.read(8))             # <<<<<<<<<<<<<<
 *         int32_t offset_sec = hton.unpack_int32(buf.read(4))
 * 
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(12, 323, __pyx_L1_error)
  __pyx_v_microseconds = unpack_int64(__pyx_t_1);

  /* "asyncpg/protocol/codecs/datetime.pyx":324
 *     cdef:
 *         int64_t microseconds = hton.unpack_int64(buf.read(8))
 *         int32_t offset_sec = hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
 * 
 *     return (microseconds, offset_sec)
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(12, 324, __pyx_L1_error)
  __pyx_v_offset_sec = unpack_int32(__pyx_t_1);

  /* "asyncpg/protocol/codecs/datetime.pyx":326
 *         int32_t offset_sec = hton.unpack_int32(buf.read(4))
 * 
 *     return (microseconds, offset_sec)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_From_int64_t(__pyx_v_microseconds); if (unlikely(!__pyx_t_2)) __PYX_ERR(12, 326, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_int32_t(__pyx_v_offset_sec); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 326, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(12, 326, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "asyncpg/protocol/codecs/datetime.pyx":321
 * 
 * 
 * cdef timetz_decode_tuple(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int64_t microseconds = hton.unpack_int64(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_AddTraceback("asyncpg.protocol.protocol.timetz_decode_tuple", __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":329
 * 
 * 
 * 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":331
 * 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(12, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_2 == ((long)-1L) && PyErr_Occurred())) __PYX_ERR(12, 331, __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":332
 *     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(12, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyLong_AsLongLong(__pyx_t_1); if (unlikely(__pyx_t_3 == ((PY_LONG_LONG)-1LL) && PyErr_Occurred())) __PYX_ERR(12, 332, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_seconds = __pyx_t_3;

  /* "asyncpg/protocol/codecs/datetime.pyx":333
 *         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(12, 333, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyLong_AsLong(__pyx_t_1); if (unlikely(__pyx_t_2 == ((long)-1L) && PyErr_Occurred())) __PYX_ERR(12, 333, __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":335
 *         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(12, 335, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":336
 * 
 *     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(12, 336, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":337
 *     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(12, 337, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":338
 *     _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(12, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":329
 * 
 * 
 * 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":341
 * 
 * 
 * cdef interval_encode_tuple(ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
 *                            tuple obj):
 *     cdef:
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_interval_encode_tuple(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_months;
  int32_t __pyx_v_days;
  int64_t __pyx_v_microseconds;
  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;
  PyObject *__pyx_t_7 = NULL;
  int32_t __pyx_t_8;
  int64_t __pyx_t_9;
  __Pyx_RefNannySetupContext("interval_encode_tuple", 0);

  /* "asyncpg/protocol/codecs/datetime.pyx":348
 *         int64_t microseconds
 * 
 *     if len(obj) != 3:             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             'interval tuple encoder: expecting 3 elements '
 */
  if (unlikely(__pyx_v_obj == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(12, 348, __pyx_L1_error)
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(12, 348, __pyx_L1_error)
  __pyx_t_2 = ((__pyx_t_1 != 3) != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/codecs/datetime.pyx":351
 *         raise ValueError(
 *             'interval tuple encoder: expecting 3 elements '
 *             'in tuple, got {}'.format(len(obj)))             # <<<<<<<<<<<<<<
 * 
 *     months = obj[0]
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_interval_tuple_encoder_expecting, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(12, 351, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(__pyx_v_obj == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      __PYX_ERR(12, 351, __pyx_L1_error)
    }
    __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(12, 351, __pyx_L1_error)
    __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(12, 351, __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, 351, __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, 351, __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, 351, __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, 351, __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, 351, __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/datetime.pyx":349
 * 
 *     if len(obj) != 3:
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             'interval tuple encoder: expecting 3 elements '
 *             'in tuple, got {}'.format(len(obj)))
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(12, 349, __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, 349, __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, 349, __pyx_L1_error)

    /* "asyncpg/protocol/codecs/datetime.pyx":348
 *         int64_t microseconds
 * 
 *     if len(obj) != 3:             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             'interval tuple encoder: expecting 3 elements '
 */
  }

  /* "asyncpg/protocol/codecs/datetime.pyx":353
 *             'in tuple, got {}'.format(len(obj)))
 * 
 *     months = obj[0]             # <<<<<<<<<<<<<<
 *     days = obj[1]
 *     microseconds = obj[2]
 */
  if (unlikely(__pyx_v_obj == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(12, 353, __pyx_L1_error)
  }
  __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_obj, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 353, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = __Pyx_PyInt_As_int32_t(__pyx_t_3); if (unlikely((__pyx_t_8 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(12, 353, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_months = __pyx_t_8;

  /* "asyncpg/protocol/codecs/datetime.pyx":354
 * 
 *     months = obj[0]
 *     days = obj[1]             # <<<<<<<<<<<<<<
 *     microseconds = obj[2]
 * 
 */
  if (unlikely(__pyx_v_obj == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(12, 354, __pyx_L1_error)
  }
  __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_obj, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 354, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = __Pyx_PyInt_As_int32_t(__pyx_t_3); if (unlikely((__pyx_t_8 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(12, 354, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_days = __pyx_t_8;

  /* "asyncpg/protocol/codecs/datetime.pyx":355
 *     months = obj[0]
 *     days = obj[1]
 *     microseconds = obj[2]             # <<<<<<<<<<<<<<
 * 
 *     buf.write_int32(16)
 */
  if (unlikely(__pyx_v_obj == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(12, 355, __pyx_L1_error)
  }
  __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_obj, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 355, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_9 = __Pyx_PyInt_As_int64_t(__pyx_t_3); if (unlikely((__pyx_t_9 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(12, 355, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_microseconds = __pyx_t_9;

  /* "asyncpg/protocol/codecs/datetime.pyx":357
 *     microseconds = obj[2]
 * 
 *     buf.write_int32(16)             # <<<<<<<<<<<<<<
 *     buf.write_int64(microseconds)
 *     buf.write_int32(days)
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, 16); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 357, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":358
 * 
 *     buf.write_int32(16)
 *     buf.write_int64(microseconds)             # <<<<<<<<<<<<<<
 *     buf.write_int32(days)
 *     buf.write_int32(months)
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int64(__pyx_v_buf, __pyx_v_microseconds); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 358, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":359
 *     buf.write_int32(16)
 *     buf.write_int64(microseconds)
 *     buf.write_int32(days)             # <<<<<<<<<<<<<<
 *     buf.write_int32(months)
 * 
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, __pyx_v_days); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 359, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":360
 *     buf.write_int64(microseconds)
 *     buf.write_int32(days)
 *     buf.write_int32(months)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, __pyx_v_months); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 360, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":341
 * 
 * 
 * cdef interval_encode_tuple(ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
 *                            tuple obj):
 *     cdef:
 */

  /* 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.interval_encode_tuple", __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":363
 * 
 * 
 * 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;
  int32_t __pyx_v_years;
  int64_t __pyx_v_seconds;
  uint32_t __pyx_v_microseconds;
  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;
  __Pyx_RefNannySetupContext("interval_decode", 0);

  /* "asyncpg/protocol/codecs/datetime.pyx":368
 *         int32_t months
 *         int32_t years
 *         int64_t seconds = 0             # <<<<<<<<<<<<<<
 *         uint32_t microseconds = 0
 * 
 */
  __pyx_v_seconds = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":369
 *         int32_t years
 *         int64_t seconds = 0
 *         uint32_t microseconds = 0             # <<<<<<<<<<<<<<
 * 
 *     _decode_time(buf, &seconds, &microseconds)
 */
  __pyx_v_microseconds = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":371
 *         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":372
 * 
 *     _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 == ((char const *)NULL))) __PYX_ERR(12, 372, __pyx_L1_error)
  __pyx_v_days = unpack_int32(__pyx_t_1);

  /* "asyncpg/protocol/codecs/datetime.pyx":373
 *     _decode_time(buf, &seconds, &microseconds)
 *     days = hton.unpack_int32(buf.read(4))
 *     months = hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
 * 
 *     if months < 0:
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(12, 373, __pyx_L1_error)
  __pyx_v_months = unpack_int32(__pyx_t_1);

  /* "asyncpg/protocol/codecs/datetime.pyx":375
 *     months = hton.unpack_int32(buf.read(4))
 * 
 *     if months < 0:             # <<<<<<<<<<<<<<
 *         years = -<int32_t>(-months // 12)
 *         months = -<int32_t>(-months % 12)
 */
  __pyx_t_2 = ((__pyx_v_months < 0) != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/codecs/datetime.pyx":376
 * 
 *     if months < 0:
 *         years = -<int32_t>(-months // 12)             # <<<<<<<<<<<<<<
 *         months = -<int32_t>(-months % 12)
 *     else:
 */
    __pyx_v_years = (-((int32_t)__Pyx_div_long((-__pyx_v_months), 12)));

    /* "asyncpg/protocol/codecs/datetime.pyx":377
 *     if months < 0:
 *         years = -<int32_t>(-months // 12)
 *         months = -<int32_t>(-months % 12)             # <<<<<<<<<<<<<<
 *     else:
 *         years = <int32_t>(months // 12)
 */
    __pyx_v_months = (-((int32_t)__Pyx_mod_long((-__pyx_v_months), 12)));

    /* "asyncpg/protocol/codecs/datetime.pyx":375
 *     months = hton.unpack_int32(buf.read(4))
 * 
 *     if months < 0:             # <<<<<<<<<<<<<<
 *         years = -<int32_t>(-months // 12)
 *         months = -<int32_t>(-months % 12)
 */
    goto __pyx_L3;
  }

  /* "asyncpg/protocol/codecs/datetime.pyx":379
 *         months = -<int32_t>(-months % 12)
 *     else:
 *         years = <int32_t>(months // 12)             # <<<<<<<<<<<<<<
 *         months = <int32_t>(months % 12)
 * 
 */
  /*else*/ {
    __pyx_v_years = ((int32_t)__Pyx_div_long(__pyx_v_months, 12));

    /* "asyncpg/protocol/codecs/datetime.pyx":380
 *     else:
 *         years = <int32_t>(months // 12)
 *         months = <int32_t>(months % 12)             # <<<<<<<<<<<<<<
 * 
 *     return datetime.timedelta(days=days + months * 30 + years * 365,
 */
    __pyx_v_months = ((int32_t)__Pyx_mod_long(__pyx_v_months, 12));
  }
  __pyx_L3:;

  /* "asyncpg/protocol/codecs/datetime.pyx":382
 *         months = <int32_t>(months % 12)
 * 
 *     return datetime.timedelta(days=days + months * 30 + years * 365,             # <<<<<<<<<<<<<<
 *                               seconds=seconds, microseconds=microseconds)
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_timedelta); if (unlikely(!__pyx_t_4)) __PYX_ERR(12, 382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyInt_From_long(((__pyx_v_days + (__pyx_v_months * 30)) + (__pyx_v_years * 0x16D))); if (unlikely(!__pyx_t_5)) __PYX_ERR(12, 382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_days, __pyx_t_5) < 0) __PYX_ERR(12, 382, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":383
 * 
 *     return datetime.timedelta(days=days + months * 30 + years * 365,
 *                               seconds=seconds, microseconds=microseconds)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5 = __Pyx_PyInt_From_int64_t(__pyx_v_seconds); if (unlikely(!__pyx_t_5)) __PYX_ERR(12, 383, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_seconds, __pyx_t_5) < 0) __PYX_ERR(12, 382, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyInt_From_uint32_t(__pyx_v_microseconds); if (unlikely(!__pyx_t_5)) __PYX_ERR(12, 383, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_microseconds, __pyx_t_5) < 0) __PYX_ERR(12, 382, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":382
 *         months = <int32_t>(months % 12)
 * 
 *     return datetime.timedelta(days=days + months * 30 + years * 365,             # <<<<<<<<<<<<<<
 *                               seconds=seconds, microseconds=microseconds)
 * 
 */
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(12, 382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __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/datetime.pyx":363
 * 
 * 
 * cdef interval_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int32_t days
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __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":386
 * 
 * 
 * cdef interval_decode_tuple(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int32_t days
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_interval_decode_tuple(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_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;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("interval_decode_tuple", 0);

  /* "asyncpg/protocol/codecs/datetime.pyx":392
 *         int64_t microseconds
 * 
 *     microseconds = hton.unpack_int64(buf.read(8))             # <<<<<<<<<<<<<<
 *     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, 8); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(12, 392, __pyx_L1_error)
  __pyx_v_microseconds = unpack_int64(__pyx_t_1);

  /* "asyncpg/protocol/codecs/datetime.pyx":393
 * 
 *     microseconds = hton.unpack_int64(buf.read(8))
 *     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 == ((char const *)NULL))) __PYX_ERR(12, 393, __pyx_L1_error)
  __pyx_v_days = unpack_int32(__pyx_t_1);

  /* "asyncpg/protocol/codecs/datetime.pyx":394
 *     microseconds = hton.unpack_int64(buf.read(8))
 *     days = hton.unpack_int32(buf.read(4))
 *     months = hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
 * 
 *     return (months, days, microseconds)
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(12, 394, __pyx_L1_error)
  __pyx_v_months = unpack_int32(__pyx_t_1);

  /* "asyncpg/protocol/codecs/datetime.pyx":396
 *     months = hton.unpack_int32(buf.read(4))
 * 
 *     return (months, days, microseconds)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_From_int32_t(__pyx_v_months); if (unlikely(!__pyx_t_2)) __PYX_ERR(12, 396, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_int32_t(__pyx_v_days); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 396, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_From_int64_t(__pyx_v_microseconds); if (unlikely(!__pyx_t_4)) __PYX_ERR(12, 396, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(12, 396, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "asyncpg/protocol/codecs/datetime.pyx":386
 * 
 * 
 * cdef interval_decode_tuple(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_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.interval_decode_tuple", __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":399
 * 
 * 
 * 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;
  struct __pyx_opt_args_7asyncpg_8protocol_8protocol_register_core_codec __pyx_t_2;
  __Pyx_RefNannySetupContext("init_datetime_codecs", 0);

  /* "asyncpg/protocol/codecs/datetime.pyx":400
 * 
 * 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 400, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":405
 *                         PG_FORMAT_BINARY)
 * 
 *     register_core_codec(DATEOID,             # <<<<<<<<<<<<<<
 *                         <encode_func>&date_encode_tuple,
 *                         <decode_func>&date_decode_tuple,
 */
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.xformat = __pyx_e_7asyncpg_8protocol_8protocol_PG_XFORMAT_TUPLE;
  __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_tuple)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_date_decode_tuple)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 405, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":411
 *                         PG_XFORMAT_TUPLE)
 * 
 *     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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 411, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":416
 *                         PG_FORMAT_BINARY)
 * 
 *     register_core_codec(TIMEOID,             # <<<<<<<<<<<<<<
 *                         <encode_func>&time_encode_tuple,
 *                         <decode_func>&time_decode_tuple,
 */
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.xformat = __pyx_e_7asyncpg_8protocol_8protocol_PG_XFORMAT_TUPLE;
  __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_tuple)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_time_decode_tuple)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":422
 *                         PG_XFORMAT_TUPLE)
 * 
 *     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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":427
 *                         PG_FORMAT_BINARY)
 * 
 *     register_core_codec(TIMETZOID,             # <<<<<<<<<<<<<<
 *                         <encode_func>&timetz_encode_tuple,
 *                         <decode_func>&timetz_decode_tuple,
 */
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.xformat = __pyx_e_7asyncpg_8protocol_8protocol_PG_XFORMAT_TUPLE;
  __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_tuple)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_timetz_decode_tuple)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 427, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":433
 *                         PG_XFORMAT_TUPLE)
 * 
 *     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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":438
 *                         PG_FORMAT_BINARY)
 * 
 *     register_core_codec(TIMESTAMPOID,             # <<<<<<<<<<<<<<
 *                         <encode_func>&timestamp_encode_tuple,
 *                         <decode_func>&timestamp_decode_tuple,
 */
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.xformat = __pyx_e_7asyncpg_8protocol_8protocol_PG_XFORMAT_TUPLE;
  __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_tuple)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_timestamp_decode_tuple)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":444
 *                         PG_XFORMAT_TUPLE)
 * 
 *     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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 444, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":449
 *                         PG_FORMAT_BINARY)
 * 
 *     register_core_codec(TIMESTAMPTZOID,             # <<<<<<<<<<<<<<
 *                         <encode_func>&timestamp_encode_tuple,
 *                         <decode_func>&timestamp_decode_tuple,
 */
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.xformat = __pyx_e_7asyncpg_8protocol_8protocol_PG_XFORMAT_TUPLE;
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x4A0, ((__pyx_t_7asyncpg_8protocol_8protocol_encode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_timestamp_encode_tuple)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_timestamp_decode_tuple)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 449, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":455
 *                         PG_XFORMAT_TUPLE)
 * 
 *     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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 455, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":460
 *                         PG_FORMAT_BINARY)
 * 
 *     register_core_codec(INTERVALOID,             # <<<<<<<<<<<<<<
 *                         <encode_func>&interval_encode_tuple,
 *                         <decode_func>&interval_decode_tuple,
 */
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.xformat = __pyx_e_7asyncpg_8protocol_8protocol_PG_XFORMAT_TUPLE;
  __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_tuple)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_interval_decode_tuple)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 460, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":469
 *     # 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 469, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":474
 *                         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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 474, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":479
 *                         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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 479, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/datetime.pyx":399
 * 
 * 
 * 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 == ((double)-1.0) && PyErr_Occurred())) __PYX_ERR(13, 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__46, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(13, 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(13, 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(13, 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(13, 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 == ((char const *)NULL))) __PYX_ERR(13, 22, __pyx_L1_error)
  __pyx_v_f = 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(13, 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 == ((double)-1.0) && PyErr_Occurred())) __PYX_ERR(13, 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(13, 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(13, 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 == ((char const *)NULL))) __PYX_ERR(13, 33, __pyx_L1_error)
  __pyx_v_f = 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(13, 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(13, 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(13, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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 == ((char const *)NULL))) __PYX_ERR(14, 21, __pyx_L1_error)
  __pyx_v_npts = 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(14, 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 == ((char const *)NULL))) __PYX_ERR(14, 29, __pyx_L1_error)
    __pyx_v_x = 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 == ((char const *)NULL))) __PYX_ERR(14, 30, __pyx_L1_error)
    __pyx_v_y = 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(14, 31, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyFloat_FromDouble(__pyx_v_x); if (unlikely(!__pyx_t_6)) __PYX_ERR(14, 31, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyFloat_FromDouble(__pyx_v_y); if (unlikely(!__pyx_t_7)) __PYX_ERR(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 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(14, 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 == ((char const *)NULL))) __PYX_ERR(14, 45, __pyx_L1_error)
  __pyx_v_high_x = 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 == ((char const *)NULL))) __PYX_ERR(14, 46, __pyx_L1_error)
  __pyx_v_high_y = 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 == ((char const *)NULL))) __PYX_ERR(14, 47, __pyx_L1_error)
  __pyx_v_low_x = 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 == ((char const *)NULL))) __PYX_ERR(14, 48, __pyx_L1_error)
  __pyx_v_low_y = 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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 == ((char const *)NULL))) __PYX_ERR(14, 62, __pyx_L1_error)
  __pyx_v_A = 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 == ((char const *)NULL))) __PYX_ERR(14, 63, __pyx_L1_error)
  __pyx_v_B = 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 == ((char const *)NULL))) __PYX_ERR(14, 64, __pyx_L1_error)
  __pyx_v_C = 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(14, 66, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_A); if (unlikely(!__pyx_t_4)) __PYX_ERR(14, 66, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_B); if (unlikely(!__pyx_t_5)) __PYX_ERR(14, 66, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_C); if (unlikely(!__pyx_t_6)) __PYX_ERR(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 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(14, 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 == ((char const *)NULL))) __PYX_ERR(14, 76, __pyx_L1_error)
  __pyx_v_p1_x = 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 == ((char const *)NULL))) __PYX_ERR(14, 77, __pyx_L1_error)
  __pyx_v_p1_y = 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 == ((char const *)NULL))) __PYX_ERR(14, 78, __pyx_L1_error)
  __pyx_v_p2_x = 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 == ((char const *)NULL))) __PYX_ERR(14, 79, __pyx_L1_error)
  __pyx_v_p2_y = 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(14, 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(14, 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(14, 81, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(14, 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(14, 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(14, 81, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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 == ((char const *)NULL))) __PYX_ERR(14, 92, __pyx_L1_error)
  __pyx_v_x = 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 == ((char const *)NULL))) __PYX_ERR(14, 93, __pyx_L1_error)
  __pyx_v_y = 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(14, 95, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_x); if (unlikely(!__pyx_t_4)) __PYX_ERR(14, 95, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_y); if (unlikely(!__pyx_t_5)) __PYX_ERR(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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 == ((int)-1))) __PYX_ERR(14, 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(14, 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(14, 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 == ((Py_ssize_t)-1))) __PYX_ERR(14, 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__47, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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 == ((char const *)NULL))) __PYX_ERR(14, 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(14, 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(14, 128, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(14, 128, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 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(14, 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(14, 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(14, 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 == ((Py_ssize_t)-1))) __PYX_ERR(14, 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__48, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 149, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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 == ((char const *)NULL))) __PYX_ERR(14, 161, __pyx_L1_error)
  __pyx_v_center_x = 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 == ((char const *)NULL))) __PYX_ERR(14, 162, __pyx_L1_error)
  __pyx_v_center_y = 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 == ((char const *)NULL))) __PYX_ERR(14, 163, __pyx_L1_error)
  __pyx_v_radius = 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(14, 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(14, 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(14, 165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(14, 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(14, 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(14, 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(14, 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(14, 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(14, 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(14, 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(14, 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(14, 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(14, 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(14, 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(14, 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(14, 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(5, 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(5, 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(5, 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(5, 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(5, 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(5, 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(5, 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(5, 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(5, 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(5, 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(5, 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(5, 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 == ((char const *)NULL))) __PYX_ERR(5, 18, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyBool_FromLong(((__pyx_t_1[0]) == '\x01')); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 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 int overflow = 0
 *     cdef long val
 */

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) {
  int __pyx_v_overflow;
  long __pyx_v_val;
  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;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("int2_encode", 0);

  /* "asyncpg/protocol/codecs/int.pyx":22
 * 
 * cdef int2_encode(ConnectionSettings settings, WriteBuffer buf, obj):
 *     cdef int overflow = 0             # <<<<<<<<<<<<<<
 *     cdef long val
 * 
 */
  __pyx_v_overflow = 0;

  /* "asyncpg/protocol/codecs/int.pyx":25
 *     cdef long val
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         val = cpython.PyLong_AsLong(obj)
 *     except OverflowError:
 */
  {
    __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/int.pyx":26
 * 
 *     try:
 *         val = cpython.PyLong_AsLong(obj)             # <<<<<<<<<<<<<<
 *     except OverflowError:
 *         overflow = 1
 */
      __pyx_t_4 = PyLong_AsLong(__pyx_v_obj); if (unlikely(__pyx_t_4 == ((long)-1L) && PyErr_Occurred())) __PYX_ERR(5, 26, __pyx_L3_error)
      __pyx_v_val = __pyx_t_4;

      /* "asyncpg/protocol/codecs/int.pyx":25
 *     cdef long val
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         val = cpython.PyLong_AsLong(obj)
 *     except OverflowError:
 */
    }
    __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_L8_try_end;
    __pyx_L3_error:;

    /* "asyncpg/protocol/codecs/int.pyx":27
 *     try:
 *         val = cpython.PyLong_AsLong(obj)
 *     except OverflowError:             # <<<<<<<<<<<<<<
 *         overflow = 1
 * 
 */
    __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_OverflowError);
    if (__pyx_t_5) {
      __Pyx_AddTraceback("asyncpg.protocol.protocol.int2_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8) < 0) __PYX_ERR(5, 27, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_8);

      /* "asyncpg/protocol/codecs/int.pyx":28
 *         val = cpython.PyLong_AsLong(obj)
 *     except OverflowError:
 *         overflow = 1             # <<<<<<<<<<<<<<
 * 
 *     if overflow or val < -32768 or val > 32767:
 */
      __pyx_v_overflow = 1;
      __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;
      goto __pyx_L4_exception_handled;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "asyncpg/protocol/codecs/int.pyx":25
 *     cdef long val
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         val = cpython.PyLong_AsLong(obj)
 *     except OverflowError:
 */
    __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_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_L8_try_end:;
  }

  /* "asyncpg/protocol/codecs/int.pyx":30
 *         overflow = 1
 * 
 *     if overflow or val < -32768 or val > 32767:             # <<<<<<<<<<<<<<
 *         raise OverflowError(
 *             'int too big to be encoded as INT2: {!r}'.format(obj))
 */
  __pyx_t_10 = (__pyx_v_overflow != 0);
  if (!__pyx_t_10) {
  } else {
    __pyx_t_9 = __pyx_t_10;
    goto __pyx_L12_bool_binop_done;
  }
  __pyx_t_10 = ((__pyx_v_val < -32768L) != 0);
  if (!__pyx_t_10) {
  } else {
    __pyx_t_9 = __pyx_t_10;
    goto __pyx_L12_bool_binop_done;
  }
  __pyx_t_10 = ((__pyx_v_val > 0x7FFF) != 0);
  __pyx_t_9 = __pyx_t_10;
  __pyx_L12_bool_binop_done:;
  if (__pyx_t_9) {

    /* "asyncpg/protocol/codecs/int.pyx":32
 *     if overflow or val < -32768 or val > 32767:
 *         raise OverflowError(
 *             'int too big to be encoded as INT2: {!r}'.format(obj))             # <<<<<<<<<<<<<<
 * 
 *     buf.write_int32(2)
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_int_too_big_to_be_encoded_as_INT, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 32, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __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_8 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_obj); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 32, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_obj};
        __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 32, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 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_6, __pyx_v_obj};
        __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 32, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_8);
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 32, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_6); __pyx_t_6 = NULL;
        __Pyx_INCREF(__pyx_v_obj);
        __Pyx_GIVEREF(__pyx_v_obj);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_obj);
        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_11, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 32, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "asyncpg/protocol/codecs/int.pyx":31
 * 
 *     if overflow or val < -32768 or val > 32767:
 *         raise OverflowError(             # <<<<<<<<<<<<<<
 *             'int too big to be encoded as INT2: {!r}'.format(obj))
 * 
 */
    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 31, __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 = 0;
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_OverflowError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 31, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_Raise(__pyx_t_8, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __PYX_ERR(5, 31, __pyx_L1_error)

    /* "asyncpg/protocol/codecs/int.pyx":30
 *         overflow = 1
 * 
 *     if overflow or val < -32768 or val > 32767:             # <<<<<<<<<<<<<<
 *         raise OverflowError(
 *             'int too big to be encoded as INT2: {!r}'.format(obj))
 */
  }

  /* "asyncpg/protocol/codecs/int.pyx":34
 *             'int too big to be encoded as INT2: {!r}'.format(obj))
 * 
 *     buf.write_int32(2)             # <<<<<<<<<<<<<<
 *     buf.write_int16(<int16_t>val)
 * 
 */
  __pyx_t_8 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, 2); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 34, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "asyncpg/protocol/codecs/int.pyx":35
 * 
 *     buf.write_int32(2)
 *     buf.write_int16(<int16_t>val)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_8 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int16(__pyx_v_buf, ((int16_t)__pyx_v_val)); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 35, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "asyncpg/protocol/codecs/int.pyx":21
 * 
 * 
 * cdef int2_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     cdef int overflow = 0
 *     cdef long val
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_11);
  __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":38
 * 
 * 
 * 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":39
 * 
 * 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 == ((char const *)NULL))) __PYX_ERR(5, 39, __pyx_L1_error)
  __pyx_t_2 = PyLong_FromLong(unpack_int16(__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 39, __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":38
 * 
 * 
 * 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":42
 * 
 * 
 * cdef int4_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     cdef int overflow = 0
 *     cdef long val = 0
 */

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) {
  int __pyx_v_overflow;
  long __pyx_v_val;
  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;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("int4_encode", 0);

  /* "asyncpg/protocol/codecs/int.pyx":43
 * 
 * cdef int4_encode(ConnectionSettings settings, WriteBuffer buf, obj):
 *     cdef int overflow = 0             # <<<<<<<<<<<<<<
 *     cdef long val = 0
 * 
 */
  __pyx_v_overflow = 0;

  /* "asyncpg/protocol/codecs/int.pyx":44
 * cdef int4_encode(ConnectionSettings settings, WriteBuffer buf, obj):
 *     cdef int overflow = 0
 *     cdef long val = 0             # <<<<<<<<<<<<<<
 * 
 *     try:
 */
  __pyx_v_val = 0;

  /* "asyncpg/protocol/codecs/int.pyx":46
 *     cdef long val = 0
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         val = cpython.PyLong_AsLong(obj)
 *     except OverflowError:
 */
  {
    __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/int.pyx":47
 * 
 *     try:
 *         val = cpython.PyLong_AsLong(obj)             # <<<<<<<<<<<<<<
 *     except OverflowError:
 *         overflow = 1
 */
      __pyx_t_4 = PyLong_AsLong(__pyx_v_obj); if (unlikely(__pyx_t_4 == ((long)-1L) && PyErr_Occurred())) __PYX_ERR(5, 47, __pyx_L3_error)
      __pyx_v_val = __pyx_t_4;

      /* "asyncpg/protocol/codecs/int.pyx":46
 *     cdef long val = 0
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         val = cpython.PyLong_AsLong(obj)
 *     except OverflowError:
 */
    }
    __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_L8_try_end;
    __pyx_L3_error:;

    /* "asyncpg/protocol/codecs/int.pyx":48
 *     try:
 *         val = cpython.PyLong_AsLong(obj)
 *     except OverflowError:             # <<<<<<<<<<<<<<
 *         overflow = 1
 * 
 */
    __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_OverflowError);
    if (__pyx_t_5) {
      __Pyx_AddTraceback("asyncpg.protocol.protocol.int4_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8) < 0) __PYX_ERR(5, 48, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_8);

      /* "asyncpg/protocol/codecs/int.pyx":49
 *         val = cpython.PyLong_AsLong(obj)
 *     except OverflowError:
 *         overflow = 1             # <<<<<<<<<<<<<<
 * 
 *     # "long" and "long long" have the same size for x86_64, need an extra check
 */
      __pyx_v_overflow = 1;
      __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;
      goto __pyx_L4_exception_handled;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "asyncpg/protocol/codecs/int.pyx":46
 *     cdef long val = 0
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         val = cpython.PyLong_AsLong(obj)
 *     except OverflowError:
 */
    __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_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_L8_try_end:;
  }

  /* "asyncpg/protocol/codecs/int.pyx":52
 * 
 *     # "long" and "long long" have the same size for x86_64, need an extra check
 *     if overflow or (sizeof(val) > 4 and (val < -2147483648 or             # <<<<<<<<<<<<<<
 *                                          val > 2147483647)):
 *         raise OverflowError(
 */
  __pyx_t_10 = (__pyx_v_overflow != 0);
  if (!__pyx_t_10) {
  } else {
    __pyx_t_9 = __pyx_t_10;
    goto __pyx_L12_bool_binop_done;
  }
  __pyx_t_10 = (((sizeof(__pyx_v_val)) > 4) != 0);
  if (__pyx_t_10) {
  } else {
    __pyx_t_9 = __pyx_t_10;
    goto __pyx_L12_bool_binop_done;
  }
  __pyx_t_10 = ((__pyx_v_val < -2147483648L) != 0);
  if (!__pyx_t_10) {
  } else {
    __pyx_t_9 = __pyx_t_10;
    goto __pyx_L12_bool_binop_done;
  }

  /* "asyncpg/protocol/codecs/int.pyx":53
 *     # "long" and "long long" have the same size for x86_64, need an extra check
 *     if overflow or (sizeof(val) > 4 and (val < -2147483648 or
 *                                          val > 2147483647)):             # <<<<<<<<<<<<<<
 *         raise OverflowError(
 *             'int too big to be encoded as INT4: {!r}'.format(obj))
 */
  __pyx_t_10 = ((__pyx_v_val > 0x7FFFFFFF) != 0);
  __pyx_t_9 = __pyx_t_10;
  __pyx_L12_bool_binop_done:;

  /* "asyncpg/protocol/codecs/int.pyx":52
 * 
 *     # "long" and "long long" have the same size for x86_64, need an extra check
 *     if overflow or (sizeof(val) > 4 and (val < -2147483648 or             # <<<<<<<<<<<<<<
 *                                          val > 2147483647)):
 *         raise OverflowError(
 */
  if (__pyx_t_9) {

    /* "asyncpg/protocol/codecs/int.pyx":55
 *                                          val > 2147483647)):
 *         raise OverflowError(
 *             'int too big to be encoded as INT4: {!r}'.format(obj))             # <<<<<<<<<<<<<<
 * 
 *     buf.write_int32(4)
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_int_too_big_to_be_encoded_as_INT_2, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 55, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __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_8 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_obj); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 55, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_obj};
        __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 55, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 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_6, __pyx_v_obj};
        __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 55, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_8);
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 55, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_6); __pyx_t_6 = NULL;
        __Pyx_INCREF(__pyx_v_obj);
        __Pyx_GIVEREF(__pyx_v_obj);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_obj);
        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_11, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 55, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "asyncpg/protocol/codecs/int.pyx":54
 *     if overflow or (sizeof(val) > 4 and (val < -2147483648 or
 *                                          val > 2147483647)):
 *         raise OverflowError(             # <<<<<<<<<<<<<<
 *             'int too big to be encoded as INT4: {!r}'.format(obj))
 * 
 */
    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 54, __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 = 0;
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_OverflowError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 54, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_Raise(__pyx_t_8, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __PYX_ERR(5, 54, __pyx_L1_error)

    /* "asyncpg/protocol/codecs/int.pyx":52
 * 
 *     # "long" and "long long" have the same size for x86_64, need an extra check
 *     if overflow or (sizeof(val) > 4 and (val < -2147483648 or             # <<<<<<<<<<<<<<
 *                                          val > 2147483647)):
 *         raise OverflowError(
 */
  }

  /* "asyncpg/protocol/codecs/int.pyx":57
 *             'int too big to be encoded as INT4: {!r}'.format(obj))
 * 
 *     buf.write_int32(4)             # <<<<<<<<<<<<<<
 *     buf.write_int32(<int32_t>val)
 * 
 */
  __pyx_t_8 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, 4); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 57, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "asyncpg/protocol/codecs/int.pyx":58
 * 
 *     buf.write_int32(4)
 *     buf.write_int32(<int32_t>val)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_8 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, ((int32_t)__pyx_v_val)); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 58, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "asyncpg/protocol/codecs/int.pyx":42
 * 
 * 
 * cdef int4_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     cdef int overflow = 0
 *     cdef long val = 0
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_11);
  __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":61
 * 
 * 
 * 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":62
 * 
 * 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 == ((char const *)NULL))) __PYX_ERR(5, 62, __pyx_L1_error)
  __pyx_t_2 = PyLong_FromLong(unpack_int32(__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 62, __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":61
 * 
 * 
 * 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":65
 * 
 * 
 * cdef int8_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     cdef int overflow = 0
 *     cdef long long val
 */

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) {
  int __pyx_v_overflow;
  PY_LONG_LONG __pyx_v_val;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PY_LONG_LONG __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;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("int8_encode", 0);

  /* "asyncpg/protocol/codecs/int.pyx":66
 * 
 * cdef int8_encode(ConnectionSettings settings, WriteBuffer buf, obj):
 *     cdef int overflow = 0             # <<<<<<<<<<<<<<
 *     cdef long long val
 * 
 */
  __pyx_v_overflow = 0;

  /* "asyncpg/protocol/codecs/int.pyx":69
 *     cdef long long val
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         val = cpython.PyLong_AsLongLong(obj)
 *     except OverflowError:
 */
  {
    __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/int.pyx":70
 * 
 *     try:
 *         val = cpython.PyLong_AsLongLong(obj)             # <<<<<<<<<<<<<<
 *     except OverflowError:
 *         overflow = 1
 */
      __pyx_t_4 = PyLong_AsLongLong(__pyx_v_obj); if (unlikely(__pyx_t_4 == ((PY_LONG_LONG)-1LL) && PyErr_Occurred())) __PYX_ERR(5, 70, __pyx_L3_error)
      __pyx_v_val = __pyx_t_4;

      /* "asyncpg/protocol/codecs/int.pyx":69
 *     cdef long long val
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         val = cpython.PyLong_AsLongLong(obj)
 *     except OverflowError:
 */
    }
    __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_L8_try_end;
    __pyx_L3_error:;

    /* "asyncpg/protocol/codecs/int.pyx":71
 *     try:
 *         val = cpython.PyLong_AsLongLong(obj)
 *     except OverflowError:             # <<<<<<<<<<<<<<
 *         overflow = 1
 * 
 */
    __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_OverflowError);
    if (__pyx_t_5) {
      __Pyx_AddTraceback("asyncpg.protocol.protocol.int8_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8) < 0) __PYX_ERR(5, 71, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_8);

      /* "asyncpg/protocol/codecs/int.pyx":72
 *         val = cpython.PyLong_AsLongLong(obj)
 *     except OverflowError:
 *         overflow = 1             # <<<<<<<<<<<<<<
 * 
 *     # Just in case for systems with "long long" bigger than 8 bytes
 */
      __pyx_v_overflow = 1;
      __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;
      goto __pyx_L4_exception_handled;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "asyncpg/protocol/codecs/int.pyx":69
 *     cdef long long val
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         val = cpython.PyLong_AsLongLong(obj)
 *     except OverflowError:
 */
    __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_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_L8_try_end:;
  }

  /* "asyncpg/protocol/codecs/int.pyx":75
 * 
 *     # Just in case for systems with "long long" bigger than 8 bytes
 *     if overflow or (sizeof(val) > 8 and (val < -9223372036854775808 or             # <<<<<<<<<<<<<<
 *                                          val > 9223372036854775807)):
 *         raise OverflowError(
 */
  __pyx_t_10 = (__pyx_v_overflow != 0);
  if (!__pyx_t_10) {
  } else {
    __pyx_t_9 = __pyx_t_10;
    goto __pyx_L12_bool_binop_done;
  }
  __pyx_t_10 = (((sizeof(__pyx_v_val)) > 8) != 0);
  if (__pyx_t_10) {
  } else {
    __pyx_t_9 = __pyx_t_10;
    goto __pyx_L12_bool_binop_done;
  }
  __pyx_t_8 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_v_val); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_7 = PyObject_RichCompare(__pyx_t_8, __pyx_int_neg_9223372036854775808, Py_LT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 75, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(5, 75, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (!__pyx_t_10) {
  } else {
    __pyx_t_9 = __pyx_t_10;
    goto __pyx_L12_bool_binop_done;
  }

  /* "asyncpg/protocol/codecs/int.pyx":76
 *     # Just in case for systems with "long long" bigger than 8 bytes
 *     if overflow or (sizeof(val) > 8 and (val < -9223372036854775808 or
 *                                          val > 9223372036854775807)):             # <<<<<<<<<<<<<<
 *         raise OverflowError(
 *             'int too big to be encoded as INT8: {!r}'.format(obj))
 */
  __pyx_t_7 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_v_val); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = PyObject_RichCompare(__pyx_t_7, __pyx_int_9223372036854775807, Py_GT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 76, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(5, 76, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_9 = __pyx_t_10;
  __pyx_L12_bool_binop_done:;

  /* "asyncpg/protocol/codecs/int.pyx":75
 * 
 *     # Just in case for systems with "long long" bigger than 8 bytes
 *     if overflow or (sizeof(val) > 8 and (val < -9223372036854775808 or             # <<<<<<<<<<<<<<
 *                                          val > 9223372036854775807)):
 *         raise OverflowError(
 */
  if (__pyx_t_9) {

    /* "asyncpg/protocol/codecs/int.pyx":78
 *                                          val > 9223372036854775807)):
 *         raise OverflowError(
 *             'int too big to be encoded as INT8: {!r}'.format(obj))             # <<<<<<<<<<<<<<
 * 
 *     buf.write_int32(8)
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_int_too_big_to_be_encoded_as_INT_3, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 78, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __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_8 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_obj); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 78, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_obj};
        __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 78, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 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_6, __pyx_v_obj};
        __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 78, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_8);
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 78, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_6); __pyx_t_6 = NULL;
        __Pyx_INCREF(__pyx_v_obj);
        __Pyx_GIVEREF(__pyx_v_obj);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_obj);
        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_11, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 78, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "asyncpg/protocol/codecs/int.pyx":77
 *     if overflow or (sizeof(val) > 8 and (val < -9223372036854775808 or
 *                                          val > 9223372036854775807)):
 *         raise OverflowError(             # <<<<<<<<<<<<<<
 *             'int too big to be encoded as INT8: {!r}'.format(obj))
 * 
 */
    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 77, __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 = 0;
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_OverflowError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 77, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_Raise(__pyx_t_8, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __PYX_ERR(5, 77, __pyx_L1_error)

    /* "asyncpg/protocol/codecs/int.pyx":75
 * 
 *     # Just in case for systems with "long long" bigger than 8 bytes
 *     if overflow or (sizeof(val) > 8 and (val < -9223372036854775808 or             # <<<<<<<<<<<<<<
 *                                          val > 9223372036854775807)):
 *         raise OverflowError(
 */
  }

  /* "asyncpg/protocol/codecs/int.pyx":80
 *             'int too big to be encoded as INT8: {!r}'.format(obj))
 * 
 *     buf.write_int32(8)             # <<<<<<<<<<<<<<
 *     buf.write_int64(<int64_t>val)
 * 
 */
  __pyx_t_8 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, 8); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 80, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "asyncpg/protocol/codecs/int.pyx":81
 * 
 *     buf.write_int32(8)
 *     buf.write_int64(<int64_t>val)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_8 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int64(__pyx_v_buf, ((int64_t)__pyx_v_val)); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 81, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "asyncpg/protocol/codecs/int.pyx":65
 * 
 * 
 * cdef int8_encode(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     cdef int overflow = 0
 *     cdef long long val
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_11);
  __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":84
 * 
 * 
 * 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":85
 * 
 * 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 == ((char const *)NULL))) __PYX_ERR(5, 85, __pyx_L1_error)
  __pyx_t_2 = PyLong_FromLongLong(unpack_int64(__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 85, __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":84
 * 
 * 
 * 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":88
 * 
 * 
 * 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":90
 * 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 90, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/int.pyx":95
 *                         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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 95, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/int.pyx":100
 *                         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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 100, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/int.pyx":105
 *                         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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 105, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/int.pyx":88
 * 
 * 
 * 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(15, 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__49, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(15, 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(15, 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(15, 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(15, 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(15, 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 == ((char const *)NULL))) __PYX_ERR(15, 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(15, 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(15, 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(15, 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(15, 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(15, 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(15, 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(15, 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(15, 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(15, 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(15, 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(15, 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(15, 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(15, 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(16, 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(16, 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(16, 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(16, 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, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(16, 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 uint8_t _ip_max_prefix_len(int32_t family):             # <<<<<<<<<<<<<<
 *     # Maximum number of bits in the network prefix of the specified
 *     # IP protocol version.
 */

static CYTHON_INLINE uint8_t __pyx_f_7asyncpg_8protocol_8protocol__ip_max_prefix_len(int32_t __pyx_v_family) {
  uint8_t __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("_ip_max_prefix_len", 0);

  /* "asyncpg/protocol/codecs/network.pyx":24
 *     # Maximum number of bits in the network prefix of the specified
 *     # IP protocol version.
 *     if family == PGSQL_AF_INET:             # <<<<<<<<<<<<<<
 *         return 32
 *     else:
 */
  __pyx_t_1 = ((__pyx_v_family == 2) != 0);
  if (__pyx_t_1) {

    /* "asyncpg/protocol/codecs/network.pyx":25
 *     # IP protocol version.
 *     if family == PGSQL_AF_INET:
 *         return 32             # <<<<<<<<<<<<<<
 *     else:
 *         return 128
 */
    __pyx_r = 32;
    goto __pyx_L0;

    /* "asyncpg/protocol/codecs/network.pyx":24
 *     # Maximum number of bits in the network prefix of the specified
 *     # IP protocol version.
 *     if family == PGSQL_AF_INET:             # <<<<<<<<<<<<<<
 *         return 32
 *     else:
 */
  }

  /* "asyncpg/protocol/codecs/network.pyx":27
 *         return 32
 *     else:
 *         return 128             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __pyx_r = 0x80;
    goto __pyx_L0;
  }

  /* "asyncpg/protocol/codecs/network.pyx":21
 * 
 * 
 * cdef inline uint8_t _ip_max_prefix_len(int32_t family):             # <<<<<<<<<<<<<<
 *     # Maximum number of bits in the network prefix of the specified
 *     # IP protocol version.
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/codecs/network.pyx":30
 * 
 * 
 * cdef inline int32_t _ip_addr_len(int32_t family):             # <<<<<<<<<<<<<<
 *     # Length of address in bytes for the specified IP protocol version.
 *     if family == PGSQL_AF_INET:
 */

static CYTHON_INLINE int32_t __pyx_f_7asyncpg_8protocol_8protocol__ip_addr_len(int32_t __pyx_v_family) {
  int32_t __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("_ip_addr_len", 0);

  /* "asyncpg/protocol/codecs/network.pyx":32
 * cdef inline int32_t _ip_addr_len(int32_t family):
 *     # Length of address in bytes for the specified IP protocol version.
 *     if family == PGSQL_AF_INET:             # <<<<<<<<<<<<<<
 *         return 4
 *     else:
 */
  __pyx_t_1 = ((__pyx_v_family == 2) != 0);
  if (__pyx_t_1) {

    /* "asyncpg/protocol/codecs/network.pyx":33
 *     # Length of address in bytes for the specified IP protocol version.
 *     if family == PGSQL_AF_INET:
 *         return 4             # <<<<<<<<<<<<<<
 *     else:
 *         return 16
 */
    __pyx_r = 4;
    goto __pyx_L0;

    /* "asyncpg/protocol/codecs/network.pyx":32
 * cdef inline int32_t _ip_addr_len(int32_t family):
 *     # Length of address in bytes for the specified IP protocol version.
 *     if family == PGSQL_AF_INET:             # <<<<<<<<<<<<<<
 *         return 4
 *     else:
 */
  }

  /* "asyncpg/protocol/codecs/network.pyx":35
 *         return 4
 *     else:
 *         return 16             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __pyx_r = 16;
    goto __pyx_L0;
  }

  /* "asyncpg/protocol/codecs/network.pyx":30
 * 
 * 
 * cdef inline int32_t _ip_addr_len(int32_t family):             # <<<<<<<<<<<<<<
 *     # Length of address in bytes for the specified IP protocol version.
 *     if family == PGSQL_AF_INET:
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/codecs/network.pyx":38
 * 
 * 
 * cdef inline int8_t _ver_to_family(int32_t version):             # <<<<<<<<<<<<<<
 *     if version == 4:
 *         return PGSQL_AF_INET
 */

static CYTHON_INLINE int8_t __pyx_f_7asyncpg_8protocol_8protocol__ver_to_family(int32_t __pyx_v_version) {
  int8_t __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("_ver_to_family", 0);

  /* "asyncpg/protocol/codecs/network.pyx":39
 * 
 * cdef inline int8_t _ver_to_family(int32_t version):
 *     if version == 4:             # <<<<<<<<<<<<<<
 *         return PGSQL_AF_INET
 *     else:
 */
  __pyx_t_1 = ((__pyx_v_version == 4) != 0);
  if (__pyx_t_1) {

    /* "asyncpg/protocol/codecs/network.pyx":40
 * cdef inline int8_t _ver_to_family(int32_t version):
 *     if version == 4:
 *         return PGSQL_AF_INET             # <<<<<<<<<<<<<<
 *     else:
 *         return PGSQL_AF_INET6
 */
    __pyx_r = 2;
    goto __pyx_L0;

    /* "asyncpg/protocol/codecs/network.pyx":39
 * 
 * cdef inline int8_t _ver_to_family(int32_t version):
 *     if version == 4:             # <<<<<<<<<<<<<<
 *         return PGSQL_AF_INET
 *     else:
 */
  }

  /* "asyncpg/protocol/codecs/network.pyx":42
 *         return PGSQL_AF_INET
 *     else:
 *         return PGSQL_AF_INET6             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __pyx_r = 3;
    goto __pyx_L0;
  }

  /* "asyncpg/protocol/codecs/network.pyx":38
 * 
 * 
 * cdef inline int8_t _ver_to_family(int32_t version):             # <<<<<<<<<<<<<<
 *     if version == 4:
 *         return PGSQL_AF_INET
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/codecs/network.pyx":45
 * 
 * 
 * cdef inline _net_encode(WriteBuffer buf, int8_t family, uint32_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, int8_t __pyx_v_family, uint32_t __pyx_v_bits, int8_t __pyx_v_is_cidr, PyObject *__pyx_v_addr) {
  char *__pyx_v_addrbytes;
  Py_ssize_t __pyx_v_addrlen;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("_net_encode", 0);

  /* "asyncpg/protocol/codecs/network.pyx":52
 *         ssize_t addrlen
 * 
 *     cpython.PyBytes_AsStringAndSize(addr, &addrbytes, &addrlen)             # <<<<<<<<<<<<<<
 * 
 *     buf.write_int32(4 + <int32_t>addrlen)
 */
  __pyx_t_1 = PyBytes_AsStringAndSize(__pyx_v_addr, (&__pyx_v_addrbytes), ((Py_ssize_t *)(&__pyx_v_addrlen))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(17, 52, __pyx_L1_error)

  /* "asyncpg/protocol/codecs/network.pyx":54
 *     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_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, (4 + ((int32_t)__pyx_v_addrlen))); if (unlikely(!__pyx_t_2)) __PYX_ERR(17, 54, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/codecs/network.pyx":55
 * 
 *     buf.write_int32(4 + <int32_t>addrlen)
 *     buf.write_byte(family)             # <<<<<<<<<<<<<<
 *     buf.write_byte(<int8_t>bits)
 *     buf.write_byte(is_cidr)
 */
  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(__pyx_v_buf, __pyx_v_family); if (unlikely(!__pyx_t_2)) __PYX_ERR(17, 55, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/codecs/network.pyx":56
 *     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_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(__pyx_v_buf, ((int8_t)__pyx_v_bits)); if (unlikely(!__pyx_t_2)) __PYX_ERR(17, 56, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/codecs/network.pyx":57
 *     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_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(__pyx_v_buf, __pyx_v_is_cidr); if (unlikely(!__pyx_t_2)) __PYX_ERR(17, 57, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/codecs/network.pyx":58
 *     buf.write_byte(<int8_t>bits)
 *     buf.write_byte(is_cidr)
 *     buf.write_byte(<int8_t>addrlen)             # <<<<<<<<<<<<<<
 *     buf.write_cstr(addrbytes, addrlen)
 * 
 */
  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(__pyx_v_buf, ((int8_t)__pyx_v_addrlen)); if (unlikely(!__pyx_t_2)) __PYX_ERR(17, 58, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/codecs/network.pyx":59
 *     buf.write_byte(is_cidr)
 *     buf.write_byte(<int8_t>addrlen)
 *     buf.write_cstr(addrbytes, addrlen)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_cstr(__pyx_v_buf, __pyx_v_addrbytes, __pyx_v_addrlen); if (unlikely(!__pyx_t_2)) __PYX_ERR(17, 59, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/codecs/network.pyx":45
 * 
 * 
 * cdef inline _net_encode(WriteBuffer buf, int8_t family, uint32_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_2);
  __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":62
 * 
 * 
 * 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;
  int32_t __pyx_v_is_cidr;
  int32_t __pyx_v_addrlen;
  PyObject *__pyx_v_addr = 0;
  uint8_t __pyx_v_max_prefix_len;
  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;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("net_decode", 0);

  /* "asyncpg/protocol/codecs/network.pyx":64
 * 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]
 *         int32_t is_cidr = <int32_t>buf.read(1)[0]
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 1); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(17, 64, __pyx_L1_error)
  __pyx_v_family = ((int32_t)(__pyx_t_1[0]));

  /* "asyncpg/protocol/codecs/network.pyx":65
 *     cdef:
 *         int32_t family = <int32_t>buf.read(1)[0]
 *         uint8_t bits = <uint8_t>buf.read(1)[0]             # <<<<<<<<<<<<<<
 *         int32_t is_cidr = <int32_t>buf.read(1)[0]
 *         int32_t addrlen = <int32_t>buf.read(1)[0]
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 1); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(17, 65, __pyx_L1_error)
  __pyx_v_bits = ((uint8_t)(__pyx_t_1[0]));

  /* "asyncpg/protocol/codecs/network.pyx":66
 *         int32_t family = <int32_t>buf.read(1)[0]
 *         uint8_t bits = <uint8_t>buf.read(1)[0]
 *         int32_t is_cidr = <int32_t>buf.read(1)[0]             # <<<<<<<<<<<<<<
 *         int32_t addrlen = <int32_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 == ((char const *)NULL))) __PYX_ERR(17, 66, __pyx_L1_error)
  __pyx_v_is_cidr = ((int32_t)(__pyx_t_1[0]));

  /* "asyncpg/protocol/codecs/network.pyx":67
 *         uint8_t bits = <uint8_t>buf.read(1)[0]
 *         int32_t is_cidr = <int32_t>buf.read(1)[0]
 *         int32_t addrlen = <int32_t>buf.read(1)[0]             # <<<<<<<<<<<<<<
 *         bytes addr
 *         uint8_t max_prefix_len = _ip_max_prefix_len(family)
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 1); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(17, 67, __pyx_L1_error)
  __pyx_v_addrlen = ((int32_t)(__pyx_t_1[0]));

  /* "asyncpg/protocol/codecs/network.pyx":69
 *         int32_t addrlen = <int32_t>buf.read(1)[0]
 *         bytes addr
 *         uint8_t max_prefix_len = _ip_max_prefix_len(family)             # <<<<<<<<<<<<<<
 * 
 *     if family != PGSQL_AF_INET and family != PGSQL_AF_INET6:
 */
  __pyx_v_max_prefix_len = __pyx_f_7asyncpg_8protocol_8protocol__ip_max_prefix_len(__pyx_v_family);

  /* "asyncpg/protocol/codecs/network.pyx":71
 *         uint8_t max_prefix_len = _ip_max_prefix_len(family)
 * 
 *     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":72
 * 
 *     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(17, 72, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);

    /* "asyncpg/protocol/codecs/network.pyx":73
 *     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(17, 72, __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(17, 72, __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(17, 72, __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(17, 72, __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(17, 72, __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":72
 * 
 *     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(17, 72, __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(17, 72, __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(17, 72, __pyx_L1_error)

    /* "asyncpg/protocol/codecs/network.pyx":71
 *         uint8_t max_prefix_len = _ip_max_prefix_len(family)
 * 
 *     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":76
 *         ))
 * 
 *     max_prefix_len = _ip_max_prefix_len(family)             # <<<<<<<<<<<<<<
 * 
 *     if bits > max_prefix_len:
 */
  __pyx_v_max_prefix_len = __pyx_f_7asyncpg_8protocol_8protocol__ip_max_prefix_len(__pyx_v_family);

  /* "asyncpg/protocol/codecs/network.pyx":78
 *     max_prefix_len = _ip_max_prefix_len(family)
 * 
 *     if bits > max_prefix_len:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid network prefix length in "{}" value'.format(
 *             'cidr' if is_cidr else 'inet'
 */
  __pyx_t_2 = ((__pyx_v_bits > __pyx_v_max_prefix_len) != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/codecs/network.pyx":79
 * 
 *     if bits > max_prefix_len:
 *         raise ValueError('invalid network prefix length in "{}" value'.format(             # <<<<<<<<<<<<<<
 *             'cidr' if is_cidr else 'inet'
 *         ))
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_invalid_network_prefix_length_in, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(17, 79, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);

    /* "asyncpg/protocol/codecs/network.pyx":80
 *     if bits > max_prefix_len:
 *         raise ValueError('invalid network prefix length 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(17, 79, __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(17, 79, __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(17, 79, __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(17, 79, __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(17, 79, __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":79
 * 
 *     if bits > max_prefix_len:
 *         raise ValueError('invalid network prefix length in "{}" value'.format(             # <<<<<<<<<<<<<<
 *             'cidr' if is_cidr else 'inet'
 *         ))
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(17, 79, __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(17, 79, __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(17, 79, __pyx_L1_error)

    /* "asyncpg/protocol/codecs/network.pyx":78
 *     max_prefix_len = _ip_max_prefix_len(family)
 * 
 *     if bits > max_prefix_len:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid network prefix length in "{}" value'.format(
 *             'cidr' if is_cidr else 'inet'
 */
  }

  /* "asyncpg/protocol/codecs/network.pyx":83
 *         ))
 * 
 *     if addrlen != _ip_addr_len(family):             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid address length in "{}" value'.format(
 *             'cidr' if is_cidr else 'inet'
 */
  __pyx_t_2 = ((__pyx_v_addrlen != __pyx_f_7asyncpg_8protocol_8protocol__ip_addr_len(__pyx_v_family)) != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/codecs/network.pyx":84
 * 
 *     if addrlen != _ip_addr_len(family):
 *         raise ValueError('invalid address length in "{}" value'.format(             # <<<<<<<<<<<<<<
 *             'cidr' if is_cidr else 'inet'
 *         ))
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_invalid_address_length_in_value, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(17, 84, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);

    /* "asyncpg/protocol/codecs/network.pyx":85
 *     if addrlen != _ip_addr_len(family):
 *         raise ValueError('invalid address 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(17, 84, __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(17, 84, __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(17, 84, __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(17, 84, __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(17, 84, __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":84
 * 
 *     if addrlen != _ip_addr_len(family):
 *         raise ValueError('invalid address length in "{}" value'.format(             # <<<<<<<<<<<<<<
 *             'cidr' if is_cidr else 'inet'
 *         ))
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(17, 84, __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(17, 84, __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(17, 84, __pyx_L1_error)

    /* "asyncpg/protocol/codecs/network.pyx":83
 *         ))
 * 
 *     if addrlen != _ip_addr_len(family):             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid address length in "{}" value'.format(
 *             'cidr' if is_cidr else 'inet'
 */
  }

  /* "asyncpg/protocol/codecs/network.pyx":88
 *         ))
 * 
 *     addr = cpython.PyBytes_FromStringAndSize(buf.read(addrlen), addrlen)             # <<<<<<<<<<<<<<
 * 
 *     if is_cidr or bits != max_prefix_len:
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, __pyx_v_addrlen); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(17, 88, __pyx_L1_error)
  __pyx_t_3 = PyBytes_FromStringAndSize(__pyx_t_1, __pyx_v_addrlen); if (unlikely(!__pyx_t_3)) __PYX_ERR(17, 88, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_addr = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "asyncpg/protocol/codecs/network.pyx":90
 *     addr = cpython.PyBytes_FromStringAndSize(buf.read(addrlen), addrlen)
 * 
 *     if is_cidr or bits != max_prefix_len:             # <<<<<<<<<<<<<<
 *         return _ipnet(addr).supernet(new_prefix=cpython.PyLong_FromLong(bits))
 *     else:
 */
  __pyx_t_8 = (__pyx_v_is_cidr != 0);
  if (!__pyx_t_8) {
  } else {
    __pyx_t_2 = __pyx_t_8;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_8 = ((__pyx_v_bits != __pyx_v_max_prefix_len) != 0);
  __pyx_t_2 = __pyx_t_8;
  __pyx_L7_bool_binop_done:;
  if (__pyx_t_2) {

    /* "asyncpg/protocol/codecs/network.pyx":91
 * 
 *     if is_cidr or bits != max_prefix_len:
 *         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(17, 91, __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(17, 91, __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(17, 91, __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(17, 91, __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(17, 91, __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(17, 91, __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(17, 91, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(17, 91, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = PyLong_FromLong(__pyx_v_bits); if (unlikely(!__pyx_t_6)) __PYX_ERR(17, 91, __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(17, 91, __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(17, 91, __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":90
 *     addr = cpython.PyBytes_FromStringAndSize(buf.read(addrlen), addrlen)
 * 
 *     if is_cidr or bits != max_prefix_len:             # <<<<<<<<<<<<<<
 *         return _ipnet(addr).supernet(new_prefix=cpython.PyLong_FromLong(bits))
 *     else:
 */
  }

  /* "asyncpg/protocol/codecs/network.pyx":93
 *         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(17, 93, __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(17, 93, __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(17, 93, __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(17, 93, __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(17, 93, __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(17, 93, __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":62
 * 
 * 
 * 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":96
 * 
 * 
 * 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;
  int8_t __pyx_v_family;
  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;
  uint32_t __pyx_t_6;
  __Pyx_RefNannySetupContext("cidr_encode", 0);

  /* "asyncpg/protocol/codecs/network.pyx":101
 *         int8_t family
 * 
 *     ipnet = _ipnet(obj)             # <<<<<<<<<<<<<<
 *     family = _ver_to_family(ipnet.version)
 *     _net_encode(buf, family, ipnet.prefixlen, 1, ipnet.network_address.packed)
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_ipnet); if (unlikely(!__pyx_t_2)) __PYX_ERR(17, 101, __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(17, 101, __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(17, 101, __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(17, 101, __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(17, 101, __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(17, 101, __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":102
 * 
 *     ipnet = _ipnet(obj)
 *     family = _ver_to_family(ipnet.version)             # <<<<<<<<<<<<<<
 *     _net_encode(buf, family, 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(17, 102, __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(17, 102, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_family = __pyx_f_7asyncpg_8protocol_8protocol__ver_to_family(__pyx_t_5);

  /* "asyncpg/protocol/codecs/network.pyx":103
 *     ipnet = _ipnet(obj)
 *     family = _ver_to_family(ipnet.version)
 *     _net_encode(buf, family, ipnet.prefixlen, 1, ipnet.network_address.packed)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_ipnet, __pyx_n_s_prefixlen); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 103, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyInt_As_uint32_t(__pyx_t_1); if (unlikely((__pyx_t_6 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(17, 103, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_ipnet, __pyx_n_s_network_address); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 103, __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(17, 103, __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(17, 103, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol__net_encode(__pyx_v_buf, __pyx_v_family, __pyx_t_6, 1, ((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 103, __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":96
 * 
 * 
 * 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":106
 * 
 * 
 * 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;
  int8_t __pyx_v_family;
  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":111
 *         int8_t family
 * 
 *     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":112
 * 
 *     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(17, 112, __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(17, 112, __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(17, 112, __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(17, 112, __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(17, 112, __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(17, 112, __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":111
 *         int8_t family
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         ipaddr = _ipaddr(obj)
 *     except ValueError:
 */
    }

    /* "asyncpg/protocol/codecs/network.pyx":118
 *         cidr_encode(settings, buf, obj)
 *     else:
 *         family = _ver_to_family(ipaddr.version)             # <<<<<<<<<<<<<<
 *         _net_encode(buf, family, _ip_max_prefix_len(family), 0, ipaddr.packed)
 * 
 */
    /*else:*/ {
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_ipaddr, __pyx_n_s_version); if (unlikely(!__pyx_t_4)) __PYX_ERR(17, 118, __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(17, 118, __pyx_L5_except_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_family = __pyx_f_7asyncpg_8protocol_8protocol__ver_to_family(__pyx_t_8);

      /* "asyncpg/protocol/codecs/network.pyx":119
 *     else:
 *         family = _ver_to_family(ipaddr.version)
 *         _net_encode(buf, family, _ip_max_prefix_len(family), 0, ipaddr.packed)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_ipaddr, __pyx_n_s_packed); if (unlikely(!__pyx_t_4)) __PYX_ERR(17, 119, __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(17, 119, __pyx_L5_except_error)
      __pyx_t_5 = __pyx_f_7asyncpg_8protocol_8protocol__net_encode(__pyx_v_buf, __pyx_v_family, __pyx_f_7asyncpg_8protocol_8protocol__ip_max_prefix_len(__pyx_v_family), 0, ((PyObject*)__pyx_t_4)); if (unlikely(!__pyx_t_5)) __PYX_ERR(17, 119, __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_L8_try_end;
    __pyx_L3_error:;
    __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":113
 *     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(17, 113, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_7);

      /* "asyncpg/protocol/codecs/network.pyx":116
 *         # PostgreSQL accepts *both* CIDR and host values
 *         # for the host datatype.
 *         cidr_encode(settings, buf, obj)             # <<<<<<<<<<<<<<
 *     else:
 *         family = _ver_to_family(ipaddr.version)
 */
      __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(17, 116, __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":111
 *         int8_t family
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         ipaddr = _ipaddr(obj)
 *     except ValueError:
 */
    __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_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_L8_try_end:;
  }

  /* "asyncpg/protocol/codecs/network.pyx":106
 * 
 * 
 * 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":122
 * 
 * 
 * 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":123
 * 
 * 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 123, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/network.pyx":128
 *                         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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 128, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/network.pyx":133
 *                         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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 133, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/network.pyx":138
 *                         PG_FORMAT_TEXT)
 * 
 *     register_core_codec(MACADDR8OID,             # <<<<<<<<<<<<<<
 *                         <encode_func>&text_encode,
 *                         <decode_func>&text_decode,
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0x306, ((__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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/network.pyx":122
 * 
 * 
 * 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":25
 * 
 * 
 * cdef numeric_encode_text(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     text_encode(settings, buf, str(obj))
 * 
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_numeric_encode_text(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_text", 0);

  /* "asyncpg/protocol/codecs/numeric.pyx":26
 * 
 * cdef numeric_encode_text(ConnectionSettings settings, WriteBuffer buf, obj):
 *     text_encode(settings, buf, str(obj))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 26, __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(18, 26, __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(18, 26, __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":25
 * 
 * 
 * cdef numeric_encode_text(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_text", __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":29
 * 
 * 
 * cdef numeric_decode_text(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
 *     return _Dec(text_decode(settings, buf))
 * 
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_numeric_decode_text(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_text", 0);

  /* "asyncpg/protocol/codecs/numeric.pyx":30
 * 
 * cdef numeric_decode_text(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(18, 30, __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(18, 30, __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(18, 30, __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(18, 30, __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(18, 30, __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(18, 30, __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(18, 30, __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":29
 * 
 * 
 * cdef numeric_decode_text(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_text", __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":33
 * 
 * 
 * cdef numeric_encode_binary(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     cdef:
 *         object dec
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_numeric_encode_binary(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_dec = 0;
  PyObject *__pyx_v_dt = 0;
  int64_t __pyx_v_exponent;
  CYTHON_UNUSED int64_t __pyx_v_i;
  int64_t __pyx_v_j;
  PyObject *__pyx_v_pydigits = 0;
  int64_t __pyx_v_num_pydigits;
  int16_t __pyx_v_pgdigit;
  int64_t __pyx_v_num_pgdigits;
  int16_t __pyx_v_dscale;
  int64_t __pyx_v_dweight;
  int64_t __pyx_v_weight;
  uint16_t __pyx_v_sign;
  int64_t __pyx_v_padding_size;
  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;
  int64_t __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  int64_t __pyx_t_9;
  int64_t __pyx_t_10;
  int16_t __pyx_t_11;
  __Pyx_RefNannySetupContext("numeric_encode_binary", 0);

  /* "asyncpg/protocol/codecs/numeric.pyx":48
 *         int64_t weight
 *         uint16_t sign
 *         int64_t padding_size = 0             # <<<<<<<<<<<<<<
 * 
 *     if isinstance(obj, _Dec):
 */
  __pyx_v_padding_size = 0;

  /* "asyncpg/protocol/codecs/numeric.pyx":50
 *         int64_t padding_size = 0
 * 
 *     if isinstance(obj, _Dec):             # <<<<<<<<<<<<<<
 *         dec = obj
 *     else:
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Dec); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_obj, __pyx_t_1); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(18, 50, __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/numeric.pyx":51
 * 
 *     if isinstance(obj, _Dec):
 *         dec = obj             # <<<<<<<<<<<<<<
 *     else:
 *         dec = _Dec(obj)
 */
    __Pyx_INCREF(__pyx_v_obj);
    __pyx_v_dec = __pyx_v_obj;

    /* "asyncpg/protocol/codecs/numeric.pyx":50
 *         int64_t padding_size = 0
 * 
 *     if isinstance(obj, _Dec):             # <<<<<<<<<<<<<<
 *         dec = obj
 *     else:
 */
    goto __pyx_L3;
  }

  /* "asyncpg/protocol/codecs/numeric.pyx":53
 *         dec = obj
 *     else:
 *         dec = _Dec(obj)             # <<<<<<<<<<<<<<
 * 
 *     dt = dec.as_tuple()
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_Dec); if (unlikely(!__pyx_t_4)) __PYX_ERR(18, 53, __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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 53, __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, __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(18, 53, __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, __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(18, 53, __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(18, 53, __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_obj);
        __Pyx_GIVEREF(__pyx_v_obj);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_obj);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 53, __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;
    __pyx_v_dec = __pyx_t_1;
    __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "asyncpg/protocol/codecs/numeric.pyx":55
 *         dec = _Dec(obj)
 * 
 *     dt = dec.as_tuple()             # <<<<<<<<<<<<<<
 *     if dt.exponent == 'F':
 *         raise ValueError('numeric type does not support infinite values')
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_dec, __pyx_n_s_as_tuple); if (unlikely(!__pyx_t_4)) __PYX_ERR(18, 55, __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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 55, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 55, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_dt = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/numeric.pyx":56
 * 
 *     dt = dec.as_tuple()
 *     if dt.exponent == 'F':             # <<<<<<<<<<<<<<
 *         raise ValueError('numeric type does not support infinite values')
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_dt, __pyx_n_s_exponent); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 56, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_F, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(18, 56, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_3) {

    /* "asyncpg/protocol/codecs/numeric.pyx":57
 *     dt = dec.as_tuple()
 *     if dt.exponent == 'F':
 *         raise ValueError('numeric type does not support infinite values')             # <<<<<<<<<<<<<<
 * 
 *     if dt.exponent == 'n' or dt.exponent == 'N':
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__50, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 57, __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(18, 57, __pyx_L1_error)

    /* "asyncpg/protocol/codecs/numeric.pyx":56
 * 
 *     dt = dec.as_tuple()
 *     if dt.exponent == 'F':             # <<<<<<<<<<<<<<
 *         raise ValueError('numeric type does not support infinite values')
 * 
 */
  }

  /* "asyncpg/protocol/codecs/numeric.pyx":59
 *         raise ValueError('numeric type does not support infinite values')
 * 
 *     if dt.exponent == 'n' or dt.exponent == 'N':             # <<<<<<<<<<<<<<
 *         # NaN
 *         sign = NUMERIC_NAN
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_dt, __pyx_n_s_exponent); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 59, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_n, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(18, 59, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!__pyx_t_2) {
  } else {
    __pyx_t_3 = __pyx_t_2;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_dt, __pyx_n_s_exponent); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 59, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_N, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(18, 59, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __pyx_t_2;
  __pyx_L6_bool_binop_done:;
  if (__pyx_t_3) {

    /* "asyncpg/protocol/codecs/numeric.pyx":61
 *     if dt.exponent == 'n' or dt.exponent == 'N':
 *         # NaN
 *         sign = NUMERIC_NAN             # <<<<<<<<<<<<<<
 *         num_pgdigits = 0
 *         weight = 0
 */
    __pyx_v_sign = 0xC000;

    /* "asyncpg/protocol/codecs/numeric.pyx":62
 *         # NaN
 *         sign = NUMERIC_NAN
 *         num_pgdigits = 0             # <<<<<<<<<<<<<<
 *         weight = 0
 *         dscale = 0
 */
    __pyx_v_num_pgdigits = 0;

    /* "asyncpg/protocol/codecs/numeric.pyx":63
 *         sign = NUMERIC_NAN
 *         num_pgdigits = 0
 *         weight = 0             # <<<<<<<<<<<<<<
 *         dscale = 0
 *     else:
 */
    __pyx_v_weight = 0;

    /* "asyncpg/protocol/codecs/numeric.pyx":64
 *         num_pgdigits = 0
 *         weight = 0
 *         dscale = 0             # <<<<<<<<<<<<<<
 *     else:
 *         exponent = dt.exponent
 */
    __pyx_v_dscale = 0;

    /* "asyncpg/protocol/codecs/numeric.pyx":59
 *         raise ValueError('numeric type does not support infinite values')
 * 
 *     if dt.exponent == 'n' or dt.exponent == 'N':             # <<<<<<<<<<<<<<
 *         # NaN
 *         sign = NUMERIC_NAN
 */
    goto __pyx_L5;
  }

  /* "asyncpg/protocol/codecs/numeric.pyx":66
 *         dscale = 0
 *     else:
 *         exponent = dt.exponent             # <<<<<<<<<<<<<<
 *         if exponent < 0 and -exponent > MAX_DSCALE:
 *             raise ValueError(
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_dt, __pyx_n_s_exponent); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 66, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = __Pyx_PyInt_As_int64_t(__pyx_t_1); if (unlikely((__pyx_t_7 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(18, 66, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_exponent = __pyx_t_7;

    /* "asyncpg/protocol/codecs/numeric.pyx":67
 *     else:
 *         exponent = dt.exponent
 *         if exponent < 0 and -exponent > MAX_DSCALE:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'cannot encode Decimal value into numeric: '
 */
    __pyx_t_2 = ((__pyx_v_exponent < 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_3 = __pyx_t_2;
      goto __pyx_L9_bool_binop_done;
    }
    __pyx_t_2 = (((-__pyx_v_exponent) > 0x3FFF) != 0);
    __pyx_t_3 = __pyx_t_2;
    __pyx_L9_bool_binop_done:;
    if (__pyx_t_3) {

      /* "asyncpg/protocol/codecs/numeric.pyx":68
 *         exponent = dt.exponent
 *         if exponent < 0 and -exponent > MAX_DSCALE:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 'cannot encode Decimal value into numeric: '
 *                 'exponent is too small')
 */
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__51, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 68, __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(18, 68, __pyx_L1_error)

      /* "asyncpg/protocol/codecs/numeric.pyx":67
 *     else:
 *         exponent = dt.exponent
 *         if exponent < 0 and -exponent > MAX_DSCALE:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'cannot encode Decimal value into numeric: '
 */
    }

    /* "asyncpg/protocol/codecs/numeric.pyx":72
 *                 'exponent is too small')
 * 
 *         if dt.sign:             # <<<<<<<<<<<<<<
 *             sign = NUMERIC_NEG
 *         else:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_dt, __pyx_n_s_sign); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 72, __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(18, 72, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_3) {

      /* "asyncpg/protocol/codecs/numeric.pyx":73
 * 
 *         if dt.sign:
 *             sign = NUMERIC_NEG             # <<<<<<<<<<<<<<
 *         else:
 *             sign = NUMERIC_POS
 */
      __pyx_v_sign = 0x4000;

      /* "asyncpg/protocol/codecs/numeric.pyx":72
 *                 'exponent is too small')
 * 
 *         if dt.sign:             # <<<<<<<<<<<<<<
 *             sign = NUMERIC_NEG
 *         else:
 */
      goto __pyx_L11;
    }

    /* "asyncpg/protocol/codecs/numeric.pyx":75
 *             sign = NUMERIC_NEG
 *         else:
 *             sign = NUMERIC_POS             # <<<<<<<<<<<<<<
 * 
 *         pydigits = dt.digits
 */
    /*else*/ {
      __pyx_v_sign = 0;
    }
    __pyx_L11:;

    /* "asyncpg/protocol/codecs/numeric.pyx":77
 *             sign = NUMERIC_POS
 * 
 *         pydigits = dt.digits             # <<<<<<<<<<<<<<
 *         num_pydigits = len(pydigits)
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_dt, __pyx_n_s_digits); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 77, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(18, 77, __pyx_L1_error)
    __pyx_v_pydigits = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "asyncpg/protocol/codecs/numeric.pyx":78
 * 
 *         pydigits = dt.digits
 *         num_pydigits = len(pydigits)             # <<<<<<<<<<<<<<
 * 
 *         dweight = num_pydigits + exponent - 1
 */
    if (unlikely(__pyx_v_pydigits == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      __PYX_ERR(18, 78, __pyx_L1_error)
    }
    __pyx_t_8 = PyTuple_GET_SIZE(__pyx_v_pydigits); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(18, 78, __pyx_L1_error)
    __pyx_v_num_pydigits = __pyx_t_8;

    /* "asyncpg/protocol/codecs/numeric.pyx":80
 *         num_pydigits = len(pydigits)
 * 
 *         dweight = num_pydigits + exponent - 1             # <<<<<<<<<<<<<<
 *         if dweight >= 0:
 *             weight = (dweight + DEC_DIGITS) // DEC_DIGITS - 1
 */
    __pyx_v_dweight = ((__pyx_v_num_pydigits + __pyx_v_exponent) - 1);

    /* "asyncpg/protocol/codecs/numeric.pyx":81
 * 
 *         dweight = num_pydigits + exponent - 1
 *         if dweight >= 0:             # <<<<<<<<<<<<<<
 *             weight = (dweight + DEC_DIGITS) // DEC_DIGITS - 1
 *         else:
 */
    __pyx_t_3 = ((__pyx_v_dweight >= 0) != 0);
    if (__pyx_t_3) {

      /* "asyncpg/protocol/codecs/numeric.pyx":82
 *         dweight = num_pydigits + exponent - 1
 *         if dweight >= 0:
 *             weight = (dweight + DEC_DIGITS) // DEC_DIGITS - 1             # <<<<<<<<<<<<<<
 *         else:
 *             weight = -((-dweight - 1) // DEC_DIGITS + 1)
 */
      __pyx_v_weight = (__Pyx_div_int64_t((__pyx_v_dweight + 4), 4) - 1);

      /* "asyncpg/protocol/codecs/numeric.pyx":81
 * 
 *         dweight = num_pydigits + exponent - 1
 *         if dweight >= 0:             # <<<<<<<<<<<<<<
 *             weight = (dweight + DEC_DIGITS) // DEC_DIGITS - 1
 *         else:
 */
      goto __pyx_L12;
    }

    /* "asyncpg/protocol/codecs/numeric.pyx":84
 *             weight = (dweight + DEC_DIGITS) // DEC_DIGITS - 1
 *         else:
 *             weight = -((-dweight - 1) // DEC_DIGITS + 1)             # <<<<<<<<<<<<<<
 * 
 *         if weight > 2 ** 16 - 1:
 */
    /*else*/ {
      __pyx_v_weight = (-(__Pyx_div_int64_t(((-__pyx_v_dweight) - 1), 4) + 1));
    }
    __pyx_L12:;

    /* "asyncpg/protocol/codecs/numeric.pyx":86
 *             weight = -((-dweight - 1) // DEC_DIGITS + 1)
 * 
 *         if weight > 2 ** 16 - 1:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                     'cannot encode Decimal value into numeric: '
 */
    __pyx_t_3 = ((__pyx_v_weight > 0xFFFF) != 0);
    if (__pyx_t_3) {

      /* "asyncpg/protocol/codecs/numeric.pyx":87
 * 
 *         if weight > 2 ** 16 - 1:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                     'cannot encode Decimal value into numeric: '
 *                     'exponent is too large')
 */
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__52, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 87, __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(18, 87, __pyx_L1_error)

      /* "asyncpg/protocol/codecs/numeric.pyx":86
 *             weight = -((-dweight - 1) // DEC_DIGITS + 1)
 * 
 *         if weight > 2 ** 16 - 1:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                     'cannot encode Decimal value into numeric: '
 */
    }

    /* "asyncpg/protocol/codecs/numeric.pyx":92
 * 
 *         padding_size = \
 *             (weight + 1) * DEC_DIGITS - (dweight + 1)             # <<<<<<<<<<<<<<
 *         num_pgdigits = \
 *             (num_pydigits + padding_size + DEC_DIGITS - 1) // DEC_DIGITS
 */
    __pyx_v_padding_size = (((__pyx_v_weight + 1) * 4) - (__pyx_v_dweight + 1));

    /* "asyncpg/protocol/codecs/numeric.pyx":94
 *             (weight + 1) * DEC_DIGITS - (dweight + 1)
 *         num_pgdigits = \
 *             (num_pydigits + padding_size + DEC_DIGITS - 1) // DEC_DIGITS             # <<<<<<<<<<<<<<
 * 
 *         if num_pgdigits > 2 ** 16 - 1:
 */
    __pyx_v_num_pgdigits = __Pyx_div_int64_t((((__pyx_v_num_pydigits + __pyx_v_padding_size) + 4) - 1), 4);

    /* "asyncpg/protocol/codecs/numeric.pyx":96
 *             (num_pydigits + padding_size + DEC_DIGITS - 1) // DEC_DIGITS
 * 
 *         if num_pgdigits > 2 ** 16 - 1:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                     'cannot encode Decimal value into numeric: '
 */
    __pyx_t_3 = ((__pyx_v_num_pgdigits > 0xFFFF) != 0);
    if (__pyx_t_3) {

      /* "asyncpg/protocol/codecs/numeric.pyx":97
 * 
 *         if num_pgdigits > 2 ** 16 - 1:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                     'cannot encode Decimal value into numeric: '
 *                     'number of digits is too large')
 */
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__53, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 97, __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(18, 97, __pyx_L1_error)

      /* "asyncpg/protocol/codecs/numeric.pyx":96
 *             (num_pydigits + padding_size + DEC_DIGITS - 1) // DEC_DIGITS
 * 
 *         if num_pgdigits > 2 ** 16 - 1:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                     'cannot encode Decimal value into numeric: '
 */
    }

    /* "asyncpg/protocol/codecs/numeric.pyx":103
 *         # Pad decimal digits to provide room for correct Postgres
 *         # digit alignment in the digit computation loop.
 *         pydigits = (0,) * DEC_DIGITS + pydigits + (0,) * DEC_DIGITS             # <<<<<<<<<<<<<<
 * 
 *         if exponent < 0:
 */
    __pyx_t_1 = PyNumber_Add(__pyx_tuple__54, __pyx_v_pydigits); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 103, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_tuple__55); if (unlikely(!__pyx_t_4)) __PYX_ERR(18, 103, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_pydigits, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "asyncpg/protocol/codecs/numeric.pyx":105
 *         pydigits = (0,) * DEC_DIGITS + pydigits + (0,) * DEC_DIGITS
 * 
 *         if exponent < 0:             # <<<<<<<<<<<<<<
 *             if -exponent > MAX_DSCALE:
 *                 raise ValueError(
 */
    __pyx_t_3 = ((__pyx_v_exponent < 0) != 0);
    if (__pyx_t_3) {

      /* "asyncpg/protocol/codecs/numeric.pyx":106
 * 
 *         if exponent < 0:
 *             if -exponent > MAX_DSCALE:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     'cannot encode Decimal value into numeric: '
 */
      __pyx_t_3 = (((-__pyx_v_exponent) > 0x3FFF) != 0);
      if (__pyx_t_3) {

        /* "asyncpg/protocol/codecs/numeric.pyx":107
 *         if exponent < 0:
 *             if -exponent > MAX_DSCALE:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     'cannot encode Decimal value into numeric: '
 *                     'exponent is too small')
 */
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__56, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(18, 107, __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(18, 107, __pyx_L1_error)

        /* "asyncpg/protocol/codecs/numeric.pyx":106
 * 
 *         if exponent < 0:
 *             if -exponent > MAX_DSCALE:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     'cannot encode Decimal value into numeric: '
 */
      }

      /* "asyncpg/protocol/codecs/numeric.pyx":110
 *                     'cannot encode Decimal value into numeric: '
 *                     'exponent is too small')
 *             dscale = <int16_t>-exponent             # <<<<<<<<<<<<<<
 *         else:
 *             dscale = 0
 */
      __pyx_v_dscale = ((int16_t)(-__pyx_v_exponent));

      /* "asyncpg/protocol/codecs/numeric.pyx":105
 *         pydigits = (0,) * DEC_DIGITS + pydigits + (0,) * DEC_DIGITS
 * 
 *         if exponent < 0:             # <<<<<<<<<<<<<<
 *             if -exponent > MAX_DSCALE:
 *                 raise ValueError(
 */
      goto __pyx_L15;
    }

    /* "asyncpg/protocol/codecs/numeric.pyx":112
 *             dscale = <int16_t>-exponent
 *         else:
 *             dscale = 0             # <<<<<<<<<<<<<<
 * 
 *     buf.write_int32(2 + 2 + 2 + 2 + 2 * <uint16_t>num_pgdigits)
 */
    /*else*/ {
      __pyx_v_dscale = 0;
    }
    __pyx_L15:;
  }
  __pyx_L5:;

  /* "asyncpg/protocol/codecs/numeric.pyx":114
 *             dscale = 0
 * 
 *     buf.write_int32(2 + 2 + 2 + 2 + 2 * <uint16_t>num_pgdigits)             # <<<<<<<<<<<<<<
 *     buf.write_int16(<int16_t>num_pgdigits)
 *     buf.write_int16(<int16_t>weight)
 */
  __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_buf, (8 + (2 * ((uint16_t)__pyx_v_num_pgdigits)))); if (unlikely(!__pyx_t_4)) __PYX_ERR(18, 114, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "asyncpg/protocol/codecs/numeric.pyx":115
 * 
 *     buf.write_int32(2 + 2 + 2 + 2 + 2 * <uint16_t>num_pgdigits)
 *     buf.write_int16(<int16_t>num_pgdigits)             # <<<<<<<<<<<<<<
 *     buf.write_int16(<int16_t>weight)
 *     buf.write_int16(<int16_t>sign)
 */
  __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int16(__pyx_v_buf, ((int16_t)__pyx_v_num_pgdigits)); if (unlikely(!__pyx_t_4)) __PYX_ERR(18, 115, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "asyncpg/protocol/codecs/numeric.pyx":116
 *     buf.write_int32(2 + 2 + 2 + 2 + 2 * <uint16_t>num_pgdigits)
 *     buf.write_int16(<int16_t>num_pgdigits)
 *     buf.write_int16(<int16_t>weight)             # <<<<<<<<<<<<<<
 *     buf.write_int16(<int16_t>sign)
 *     buf.write_int16(dscale)
 */
  __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int16(__pyx_v_buf, ((int16_t)__pyx_v_weight)); if (unlikely(!__pyx_t_4)) __PYX_ERR(18, 116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "asyncpg/protocol/codecs/numeric.pyx":117
 *     buf.write_int16(<int16_t>num_pgdigits)
 *     buf.write_int16(<int16_t>weight)
 *     buf.write_int16(<int16_t>sign)             # <<<<<<<<<<<<<<
 *     buf.write_int16(dscale)
 * 
 */
  __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int16(__pyx_v_buf, ((int16_t)__pyx_v_sign)); if (unlikely(!__pyx_t_4)) __PYX_ERR(18, 117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "asyncpg/protocol/codecs/numeric.pyx":118
 *     buf.write_int16(<int16_t>weight)
 *     buf.write_int16(<int16_t>sign)
 *     buf.write_int16(dscale)             # <<<<<<<<<<<<<<
 * 
 *     j = DEC_DIGITS - padding_size
 */
  __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int16(__pyx_v_buf, __pyx_v_dscale); if (unlikely(!__pyx_t_4)) __PYX_ERR(18, 118, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "asyncpg/protocol/codecs/numeric.pyx":120
 *     buf.write_int16(dscale)
 * 
 *     j = DEC_DIGITS - padding_size             # <<<<<<<<<<<<<<
 * 
 *     for i in range(num_pgdigits):
 */
  __pyx_v_j = (4 - __pyx_v_padding_size);

  /* "asyncpg/protocol/codecs/numeric.pyx":122
 *     j = DEC_DIGITS - padding_size
 * 
 *     for i in range(num_pgdigits):             # <<<<<<<<<<<<<<
 *         pgdigit = (pydigits[j] * 1000 + pydigits[j + 1] * 100 +
 *                    pydigits[j + 2] * 10 + pydigits[j + 3])
 */
  __pyx_t_7 = __pyx_v_num_pgdigits;
  for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_7; __pyx_t_9+=1) {
    __pyx_v_i = __pyx_t_9;

    /* "asyncpg/protocol/codecs/numeric.pyx":123
 * 
 *     for i in range(num_pgdigits):
 *         pgdigit = (pydigits[j] * 1000 + pydigits[j + 1] * 100 +             # <<<<<<<<<<<<<<
 *                    pydigits[j + 2] * 10 + pydigits[j + 3])
 *         j += DEC_DIGITS
 */
    if (unlikely(!__pyx_v_pydigits)) { __Pyx_RaiseUnboundLocalError("pydigits"); __PYX_ERR(18, 123, __pyx_L1_error) }
    __pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_v_pydigits, __pyx_v_j, int64_t, 1, __Pyx_PyInt_From_int64_t, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(18, 123, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyNumber_Multiply(__pyx_t_4, __pyx_int_1000); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 123, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_v_pydigits)) { __Pyx_RaiseUnboundLocalError("pydigits"); __PYX_ERR(18, 123, __pyx_L1_error) }
    __pyx_t_10 = (__pyx_v_j + 1);
    __pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_v_pydigits, __pyx_t_10, int64_t, 1, __Pyx_PyInt_From_int64_t, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(18, 123, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = PyNumber_Multiply(__pyx_t_4, __pyx_int_100); if (unlikely(!__pyx_t_6)) __PYX_ERR(18, 123, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(18, 123, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "asyncpg/protocol/codecs/numeric.pyx":124
 *     for i in range(num_pgdigits):
 *         pgdigit = (pydigits[j] * 1000 + pydigits[j + 1] * 100 +
 *                    pydigits[j + 2] * 10 + pydigits[j + 3])             # <<<<<<<<<<<<<<
 *         j += DEC_DIGITS
 *         buf.write_int16(pgdigit)
 */
    if (unlikely(!__pyx_v_pydigits)) { __Pyx_RaiseUnboundLocalError("pydigits"); __PYX_ERR(18, 124, __pyx_L1_error) }
    __pyx_t_10 = (__pyx_v_j + 2);
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v_pydigits, __pyx_t_10, int64_t, 1, __Pyx_PyInt_From_int64_t, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(18, 124, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyNumber_Multiply(__pyx_t_6, __pyx_int_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 124, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "asyncpg/protocol/codecs/numeric.pyx":123
 * 
 *     for i in range(num_pgdigits):
 *         pgdigit = (pydigits[j] * 1000 + pydigits[j + 1] * 100 +             # <<<<<<<<<<<<<<
 *                    pydigits[j + 2] * 10 + pydigits[j + 3])
 *         j += DEC_DIGITS
 */
    __pyx_t_6 = PyNumber_Add(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(18, 123, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/codecs/numeric.pyx":124
 *     for i in range(num_pgdigits):
 *         pgdigit = (pydigits[j] * 1000 + pydigits[j + 1] * 100 +
 *                    pydigits[j + 2] * 10 + pydigits[j + 3])             # <<<<<<<<<<<<<<
 *         j += DEC_DIGITS
 *         buf.write_int16(pgdigit)
 */
    if (unlikely(!__pyx_v_pydigits)) { __Pyx_RaiseUnboundLocalError("pydigits"); __PYX_ERR(18, 124, __pyx_L1_error) }
    __pyx_t_10 = (__pyx_v_j + 3);
    __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_pydigits, __pyx_t_10, int64_t, 1, __Pyx_PyInt_From_int64_t, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 124, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyNumber_Add(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(18, 124, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_11 = __Pyx_PyInt_As_int16_t(__pyx_t_4); if (unlikely((__pyx_t_11 == ((int16_t)-1)) && PyErr_Occurred())) __PYX_ERR(18, 124, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_pgdigit = __pyx_t_11;

    /* "asyncpg/protocol/codecs/numeric.pyx":125
 *         pgdigit = (pydigits[j] * 1000 + pydigits[j + 1] * 100 +
 *                    pydigits[j + 2] * 10 + pydigits[j + 3])
 *         j += DEC_DIGITS             # <<<<<<<<<<<<<<
 *         buf.write_int16(pgdigit)
 * 
 */
    __pyx_v_j = (__pyx_v_j + 4);

    /* "asyncpg/protocol/codecs/numeric.pyx":126
 *                    pydigits[j + 2] * 10 + pydigits[j + 3])
 *         j += DEC_DIGITS
 *         buf.write_int16(pgdigit)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int16(__pyx_v_buf, __pyx_v_pgdigit); if (unlikely(!__pyx_t_4)) __PYX_ERR(18, 126, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }

  /* "asyncpg/protocol/codecs/numeric.pyx":33
 * 
 * 
 * cdef numeric_encode_binary(ConnectionSettings settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     cdef:
 *         object dec
 */

  /* 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.numeric_encode_binary", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_dec);
  __Pyx_XDECREF(__pyx_v_dt);
  __Pyx_XDECREF(__pyx_v_pydigits);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/codecs/numeric.pyx":134
 * # than the simple text decoder above.  That said, we need the binary
 * # decoder to support binary COPY with numeric values.
 * cdef numeric_decode_binary(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
 *     cdef:
 *         uint16_t num_pgdigits = <uint16_t>hton.unpack_int16(buf.read(2))
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_numeric_decode_binary(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *__pyx_v_settings, struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v_buf) {
  uint16_t __pyx_v_num_pgdigits;
  int16_t __pyx_v_weight;
  uint16_t __pyx_v_sign;
  uint16_t __pyx_v_dscale;
  int16_t __pyx_v_pgdigit0;
  Py_ssize_t __pyx_v_i;
  int16_t __pyx_v_pgdigit;
  PyObject *__pyx_v_pydigits = 0;
  Py_ssize_t __pyx_v_num_pydigits;
  Py_ssize_t __pyx_v_buf_size;
  int64_t __pyx_v_exponent;
  int64_t __pyx_v_abs_exponent;
  Py_ssize_t __pyx_v_exponent_chars;
  Py_ssize_t __pyx_v_front_padding;
  CYTHON_UNUSED Py_ssize_t __pyx_v_trailing_padding;
  Py_ssize_t __pyx_v_num_fract_digits;
  Py_ssize_t __pyx_v_dscale_left;
  char __pyx_v_smallbuf[0x100];
  char *__pyx_v_charbuf;
  char *__pyx_v_bufptr;
  int __pyx_v_buf_allocated;
  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;
  int64_t __pyx_t_6;
  uint16_t __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  int __pyx_t_12;
  char const *__pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  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;
  __Pyx_RefNannySetupContext("numeric_decode_binary", 0);

  /* "asyncpg/protocol/codecs/numeric.pyx":136
 * cdef numeric_decode_binary(ConnectionSettings settings, FastReadBuffer buf):
 *     cdef:
 *         uint16_t num_pgdigits = <uint16_t>hton.unpack_int16(buf.read(2))             # <<<<<<<<<<<<<<
 *         int16_t weight = hton.unpack_int16(buf.read(2))
 *         uint16_t sign = <uint16_t>hton.unpack_int16(buf.read(2))
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(18, 136, __pyx_L1_error)
  __pyx_v_num_pgdigits = ((uint16_t)unpack_int16(__pyx_t_1));

  /* "asyncpg/protocol/codecs/numeric.pyx":137
 *     cdef:
 *         uint16_t num_pgdigits = <uint16_t>hton.unpack_int16(buf.read(2))
 *         int16_t weight = hton.unpack_int16(buf.read(2))             # <<<<<<<<<<<<<<
 *         uint16_t sign = <uint16_t>hton.unpack_int16(buf.read(2))
 *         uint16_t dscale = <uint16_t>hton.unpack_int16(buf.read(2))
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(18, 137, __pyx_L1_error)
  __pyx_v_weight = unpack_int16(__pyx_t_1);

  /* "asyncpg/protocol/codecs/numeric.pyx":138
 *         uint16_t num_pgdigits = <uint16_t>hton.unpack_int16(buf.read(2))
 *         int16_t weight = hton.unpack_int16(buf.read(2))
 *         uint16_t sign = <uint16_t>hton.unpack_int16(buf.read(2))             # <<<<<<<<<<<<<<
 *         uint16_t dscale = <uint16_t>hton.unpack_int16(buf.read(2))
 *         int16_t pgdigit0
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(18, 138, __pyx_L1_error)
  __pyx_v_sign = ((uint16_t)unpack_int16(__pyx_t_1));

  /* "asyncpg/protocol/codecs/numeric.pyx":139
 *         int16_t weight = hton.unpack_int16(buf.read(2))
 *         uint16_t sign = <uint16_t>hton.unpack_int16(buf.read(2))
 *         uint16_t dscale = <uint16_t>hton.unpack_int16(buf.read(2))             # <<<<<<<<<<<<<<
 *         int16_t pgdigit0
 *         ssize_t i
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(18, 139, __pyx_L1_error)
  __pyx_v_dscale = ((uint16_t)unpack_int16(__pyx_t_1));

  /* "asyncpg/protocol/codecs/numeric.pyx":149
 *         int64_t abs_exponent
 *         ssize_t exponent_chars
 *         ssize_t front_padding = 0             # <<<<<<<<<<<<<<
 *         ssize_t trailing_padding = 0
 *         ssize_t num_fract_digits
 */
  __pyx_v_front_padding = 0;

  /* "asyncpg/protocol/codecs/numeric.pyx":150
 *         ssize_t exponent_chars
 *         ssize_t front_padding = 0
 *         ssize_t trailing_padding = 0             # <<<<<<<<<<<<<<
 *         ssize_t num_fract_digits
 *         ssize_t dscale_left
 */
  __pyx_v_trailing_padding = 0;

  /* "asyncpg/protocol/codecs/numeric.pyx":156
 *         char *charbuf
 *         char *bufptr
 *         bint buf_allocated = False             # <<<<<<<<<<<<<<
 * 
 *     if sign == NUMERIC_NAN:
 */
  __pyx_v_buf_allocated = 0;

  /* "asyncpg/protocol/codecs/numeric.pyx":158
 *         bint buf_allocated = False
 * 
 *     if sign == NUMERIC_NAN:             # <<<<<<<<<<<<<<
 *         # Not-a-number
 *         return _Dec('NaN')
 */
  __pyx_t_2 = ((__pyx_v_sign == 0xC000) != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/codecs/numeric.pyx":160
 *     if sign == NUMERIC_NAN:
 *         # Not-a-number
 *         return _Dec('NaN')             # <<<<<<<<<<<<<<
 * 
 *     if num_pgdigits == 0:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_Dec); if (unlikely(!__pyx_t_3)) __PYX_ERR(18, 160, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__57, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(18, 160, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "asyncpg/protocol/codecs/numeric.pyx":158
 *         bint buf_allocated = False
 * 
 *     if sign == NUMERIC_NAN:             # <<<<<<<<<<<<<<
 *         # Not-a-number
 *         return _Dec('NaN')
 */
  }

  /* "asyncpg/protocol/codecs/numeric.pyx":162
 *         return _Dec('NaN')
 * 
 *     if num_pgdigits == 0:             # <<<<<<<<<<<<<<
 *         # Zero
 *         return _Dec()
 */
  __pyx_t_2 = ((__pyx_v_num_pgdigits == 0) != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/codecs/numeric.pyx":164
 *     if num_pgdigits == 0:
 *         # Zero
 *         return _Dec()             # <<<<<<<<<<<<<<
 * 
 *     pgdigit0 = hton.unpack_int16(buf.read(2))
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_Dec); if (unlikely(!__pyx_t_3)) __PYX_ERR(18, 164, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(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_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(18, 164, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(18, 164, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "asyncpg/protocol/codecs/numeric.pyx":162
 *         return _Dec('NaN')
 * 
 *     if num_pgdigits == 0:             # <<<<<<<<<<<<<<
 *         # Zero
 *         return _Dec()
 */
  }

  /* "asyncpg/protocol/codecs/numeric.pyx":166
 *         return _Dec()
 * 
 *     pgdigit0 = hton.unpack_int16(buf.read(2))             # <<<<<<<<<<<<<<
 *     if weight >= 0:
 *         if pgdigit0 < 10:
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(18, 166, __pyx_L1_error)
  __pyx_v_pgdigit0 = unpack_int16(__pyx_t_1);

  /* "asyncpg/protocol/codecs/numeric.pyx":167
 * 
 *     pgdigit0 = hton.unpack_int16(buf.read(2))
 *     if weight >= 0:             # <<<<<<<<<<<<<<
 *         if pgdigit0 < 10:
 *             front_padding = 3
 */
  __pyx_t_2 = ((__pyx_v_weight >= 0) != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/codecs/numeric.pyx":168
 *     pgdigit0 = hton.unpack_int16(buf.read(2))
 *     if weight >= 0:
 *         if pgdigit0 < 10:             # <<<<<<<<<<<<<<
 *             front_padding = 3
 *         elif pgdigit0 < 100:
 */
    __pyx_t_2 = ((__pyx_v_pgdigit0 < 10) != 0);
    if (__pyx_t_2) {

      /* "asyncpg/protocol/codecs/numeric.pyx":169
 *     if weight >= 0:
 *         if pgdigit0 < 10:
 *             front_padding = 3             # <<<<<<<<<<<<<<
 *         elif pgdigit0 < 100:
 *             front_padding = 2
 */
      __pyx_v_front_padding = 3;

      /* "asyncpg/protocol/codecs/numeric.pyx":168
 *     pgdigit0 = hton.unpack_int16(buf.read(2))
 *     if weight >= 0:
 *         if pgdigit0 < 10:             # <<<<<<<<<<<<<<
 *             front_padding = 3
 *         elif pgdigit0 < 100:
 */
      goto __pyx_L6;
    }

    /* "asyncpg/protocol/codecs/numeric.pyx":170
 *         if pgdigit0 < 10:
 *             front_padding = 3
 *         elif pgdigit0 < 100:             # <<<<<<<<<<<<<<
 *             front_padding = 2
 *         elif pgdigit0 < 1000:
 */
    __pyx_t_2 = ((__pyx_v_pgdigit0 < 0x64) != 0);
    if (__pyx_t_2) {

      /* "asyncpg/protocol/codecs/numeric.pyx":171
 *             front_padding = 3
 *         elif pgdigit0 < 100:
 *             front_padding = 2             # <<<<<<<<<<<<<<
 *         elif pgdigit0 < 1000:
 *             front_padding = 1
 */
      __pyx_v_front_padding = 2;

      /* "asyncpg/protocol/codecs/numeric.pyx":170
 *         if pgdigit0 < 10:
 *             front_padding = 3
 *         elif pgdigit0 < 100:             # <<<<<<<<<<<<<<
 *             front_padding = 2
 *         elif pgdigit0 < 1000:
 */
      goto __pyx_L6;
    }

    /* "asyncpg/protocol/codecs/numeric.pyx":172
 *         elif pgdigit0 < 100:
 *             front_padding = 2
 *         elif pgdigit0 < 1000:             # <<<<<<<<<<<<<<
 *             front_padding = 1
 * 
 */
    __pyx_t_2 = ((__pyx_v_pgdigit0 < 0x3E8) != 0);
    if (__pyx_t_2) {

      /* "asyncpg/protocol/codecs/numeric.pyx":173
 *             front_padding = 2
 *         elif pgdigit0 < 1000:
 *             front_padding = 1             # <<<<<<<<<<<<<<
 * 
 *     # Maximum possible number of decimal digits in base 10.
 */
      __pyx_v_front_padding = 1;

      /* "asyncpg/protocol/codecs/numeric.pyx":172
 *         elif pgdigit0 < 100:
 *             front_padding = 2
 *         elif pgdigit0 < 1000:             # <<<<<<<<<<<<<<
 *             front_padding = 1
 * 
 */
    }
    __pyx_L6:;

    /* "asyncpg/protocol/codecs/numeric.pyx":167
 * 
 *     pgdigit0 = hton.unpack_int16(buf.read(2))
 *     if weight >= 0:             # <<<<<<<<<<<<<<
 *         if pgdigit0 < 10:
 *             front_padding = 3
 */
  }

  /* "asyncpg/protocol/codecs/numeric.pyx":176
 * 
 *     # Maximum possible number of decimal digits in base 10.
 *     num_pydigits = num_pgdigits * DEC_DIGITS + dscale             # <<<<<<<<<<<<<<
 *     # Exponent.
 *     exponent = (weight + 1) * DEC_DIGITS - front_padding
 */
  __pyx_v_num_pydigits = ((__pyx_v_num_pgdigits * 4) + __pyx_v_dscale);

  /* "asyncpg/protocol/codecs/numeric.pyx":178
 *     num_pydigits = num_pgdigits * DEC_DIGITS + dscale
 *     # Exponent.
 *     exponent = (weight + 1) * DEC_DIGITS - front_padding             # <<<<<<<<<<<<<<
 *     abs_exponent = abs(exponent)
 *     # Number of characters required to render absolute exponent value.
 */
  __pyx_v_exponent = (((__pyx_v_weight + 1) * 4) - __pyx_v_front_padding);

  /* "asyncpg/protocol/codecs/numeric.pyx":179
 *     # Exponent.
 *     exponent = (weight + 1) * DEC_DIGITS - front_padding
 *     abs_exponent = abs(exponent)             # <<<<<<<<<<<<<<
 *     # Number of characters required to render absolute exponent value.
 *     exponent_chars = <ssize_t>log10(<double>abs_exponent) + 1
 */
  __pyx_t_4 = __Pyx_PyInt_From_int64_t(__pyx_v_exponent); if (unlikely(!__pyx_t_4)) __PYX_ERR(18, 179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyNumber_Absolute(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(18, 179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_6 = __Pyx_PyInt_As_int64_t(__pyx_t_3); if (unlikely((__pyx_t_6 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(18, 179, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_abs_exponent = __pyx_t_6;

  /* "asyncpg/protocol/codecs/numeric.pyx":181
 *     abs_exponent = abs(exponent)
 *     # Number of characters required to render absolute exponent value.
 *     exponent_chars = <ssize_t>log10(<double>abs_exponent) + 1             # <<<<<<<<<<<<<<
 * 
 *     buf_size = (
 */
  __pyx_v_exponent_chars = (((Py_ssize_t)log10(((double)__pyx_v_abs_exponent))) + 1);

  /* "asyncpg/protocol/codecs/numeric.pyx":189
 *         num_pydigits +      # digits
 *         2 +                 # exponent indicator (E-,E+)
 *         exponent_chars +    # exponent             # <<<<<<<<<<<<<<
 *         1                   # null terminator char
 *     )
 */
  __pyx_v_buf_size = ((((3 + __pyx_v_num_pydigits) + 2) + __pyx_v_exponent_chars) + 1);

  /* "asyncpg/protocol/codecs/numeric.pyx":193
 *     )
 * 
 *     if buf_size > _NUMERIC_DECODER_SMALLBUF_SIZE:             # <<<<<<<<<<<<<<
 *         charbuf = <char *>PyMem_Malloc(<size_t>buf_size)
 *         buf_allocated = True
 */
  __pyx_t_2 = ((__pyx_v_buf_size > 0x100) != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/codecs/numeric.pyx":194
 * 
 *     if buf_size > _NUMERIC_DECODER_SMALLBUF_SIZE:
 *         charbuf = <char *>PyMem_Malloc(<size_t>buf_size)             # <<<<<<<<<<<<<<
 *         buf_allocated = True
 *     else:
 */
    __pyx_v_charbuf = ((char *)PyMem_Malloc(((size_t)__pyx_v_buf_size)));

    /* "asyncpg/protocol/codecs/numeric.pyx":195
 *     if buf_size > _NUMERIC_DECODER_SMALLBUF_SIZE:
 *         charbuf = <char *>PyMem_Malloc(<size_t>buf_size)
 *         buf_allocated = True             # <<<<<<<<<<<<<<
 *     else:
 *         charbuf = smallbuf
 */
    __pyx_v_buf_allocated = 1;

    /* "asyncpg/protocol/codecs/numeric.pyx":193
 *     )
 * 
 *     if buf_size > _NUMERIC_DECODER_SMALLBUF_SIZE:             # <<<<<<<<<<<<<<
 *         charbuf = <char *>PyMem_Malloc(<size_t>buf_size)
 *         buf_allocated = True
 */
    goto __pyx_L7;
  }

  /* "asyncpg/protocol/codecs/numeric.pyx":197
 *         buf_allocated = True
 *     else:
 *         charbuf = smallbuf             # <<<<<<<<<<<<<<
 * 
 *     try:
 */
  /*else*/ {
    __pyx_v_charbuf = __pyx_v_smallbuf;
  }
  __pyx_L7:;

  /* "asyncpg/protocol/codecs/numeric.pyx":199
 *         charbuf = smallbuf
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         bufptr = charbuf
 * 
 */
  /*try:*/ {

    /* "asyncpg/protocol/codecs/numeric.pyx":200
 * 
 *     try:
 *         bufptr = charbuf             # <<<<<<<<<<<<<<
 * 
 *         if sign == NUMERIC_NEG:
 */
    __pyx_v_bufptr = __pyx_v_charbuf;

    /* "asyncpg/protocol/codecs/numeric.pyx":202
 *         bufptr = charbuf
 * 
 *         if sign == NUMERIC_NEG:             # <<<<<<<<<<<<<<
 *             bufptr[0] = b'-'
 *             bufptr += 1
 */
    __pyx_t_2 = ((__pyx_v_sign == 0x4000) != 0);
    if (__pyx_t_2) {

      /* "asyncpg/protocol/codecs/numeric.pyx":203
 * 
 *         if sign == NUMERIC_NEG:
 *             bufptr[0] = b'-'             # <<<<<<<<<<<<<<
 *             bufptr += 1
 * 
 */
      (__pyx_v_bufptr[0]) = '-';

      /* "asyncpg/protocol/codecs/numeric.pyx":204
 *         if sign == NUMERIC_NEG:
 *             bufptr[0] = b'-'
 *             bufptr += 1             # <<<<<<<<<<<<<<
 * 
 *         bufptr[0] = b'0'
 */
      __pyx_v_bufptr = (__pyx_v_bufptr + 1);

      /* "asyncpg/protocol/codecs/numeric.pyx":202
 *         bufptr = charbuf
 * 
 *         if sign == NUMERIC_NEG:             # <<<<<<<<<<<<<<
 *             bufptr[0] = b'-'
 *             bufptr += 1
 */
    }

    /* "asyncpg/protocol/codecs/numeric.pyx":206
 *             bufptr += 1
 * 
 *         bufptr[0] = b'0'             # <<<<<<<<<<<<<<
 *         bufptr[1] = b'.'
 *         bufptr += 2
 */
    (__pyx_v_bufptr[0]) = '0';

    /* "asyncpg/protocol/codecs/numeric.pyx":207
 * 
 *         bufptr[0] = b'0'
 *         bufptr[1] = b'.'             # <<<<<<<<<<<<<<
 *         bufptr += 2
 * 
 */
    (__pyx_v_bufptr[1]) = '.';

    /* "asyncpg/protocol/codecs/numeric.pyx":208
 *         bufptr[0] = b'0'
 *         bufptr[1] = b'.'
 *         bufptr += 2             # <<<<<<<<<<<<<<
 * 
 *         if weight >= 0:
 */
    __pyx_v_bufptr = (__pyx_v_bufptr + 2);

    /* "asyncpg/protocol/codecs/numeric.pyx":210
 *         bufptr += 2
 * 
 *         if weight >= 0:             # <<<<<<<<<<<<<<
 *             bufptr = _unpack_digit_stripping_lzeros(bufptr, pgdigit0)
 *         else:
 */
    __pyx_t_2 = ((__pyx_v_weight >= 0) != 0);
    if (__pyx_t_2) {

      /* "asyncpg/protocol/codecs/numeric.pyx":211
 * 
 *         if weight >= 0:
 *             bufptr = _unpack_digit_stripping_lzeros(bufptr, pgdigit0)             # <<<<<<<<<<<<<<
 *         else:
 *             bufptr = _unpack_digit(bufptr, pgdigit0)
 */
      __pyx_v_bufptr = __pyx_f_7asyncpg_8protocol_8protocol__unpack_digit_stripping_lzeros(__pyx_v_bufptr, __pyx_v_pgdigit0);

      /* "asyncpg/protocol/codecs/numeric.pyx":210
 *         bufptr += 2
 * 
 *         if weight >= 0:             # <<<<<<<<<<<<<<
 *             bufptr = _unpack_digit_stripping_lzeros(bufptr, pgdigit0)
 *         else:
 */
      goto __pyx_L12;
    }

    /* "asyncpg/protocol/codecs/numeric.pyx":213
 *             bufptr = _unpack_digit_stripping_lzeros(bufptr, pgdigit0)
 *         else:
 *             bufptr = _unpack_digit(bufptr, pgdigit0)             # <<<<<<<<<<<<<<
 * 
 *         for i in range(1, num_pgdigits):
 */
    /*else*/ {
      __pyx_v_bufptr = __pyx_f_7asyncpg_8protocol_8protocol__unpack_digit(__pyx_v_bufptr, __pyx_v_pgdigit0);
    }
    __pyx_L12:;

    /* "asyncpg/protocol/codecs/numeric.pyx":215
 *             bufptr = _unpack_digit(bufptr, pgdigit0)
 * 
 *         for i in range(1, num_pgdigits):             # <<<<<<<<<<<<<<
 *             pgdigit = hton.unpack_int16(buf.read(2))
 *             bufptr = _unpack_digit(bufptr, pgdigit)
 */
    __pyx_t_7 = __pyx_v_num_pgdigits;
    for (__pyx_t_8 = 1; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
      __pyx_v_i = __pyx_t_8;

      /* "asyncpg/protocol/codecs/numeric.pyx":216
 * 
 *         for i in range(1, num_pgdigits):
 *             pgdigit = hton.unpack_int16(buf.read(2))             # <<<<<<<<<<<<<<
 *             bufptr = _unpack_digit(bufptr, pgdigit)
 * 
 */
      __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(18, 216, __pyx_L9_error)
      __pyx_v_pgdigit = unpack_int16(__pyx_t_1);

      /* "asyncpg/protocol/codecs/numeric.pyx":217
 *         for i in range(1, num_pgdigits):
 *             pgdigit = hton.unpack_int16(buf.read(2))
 *             bufptr = _unpack_digit(bufptr, pgdigit)             # <<<<<<<<<<<<<<
 * 
 *         if dscale:
 */
      __pyx_v_bufptr = __pyx_f_7asyncpg_8protocol_8protocol__unpack_digit(__pyx_v_bufptr, __pyx_v_pgdigit);
    }

    /* "asyncpg/protocol/codecs/numeric.pyx":219
 *             bufptr = _unpack_digit(bufptr, pgdigit)
 * 
 *         if dscale:             # <<<<<<<<<<<<<<
 *             if weight >= 0:
 *                 num_fract_digits = num_pgdigits - weight - 1
 */
    __pyx_t_2 = (__pyx_v_dscale != 0);
    if (__pyx_t_2) {

      /* "asyncpg/protocol/codecs/numeric.pyx":220
 * 
 *         if dscale:
 *             if weight >= 0:             # <<<<<<<<<<<<<<
 *                 num_fract_digits = num_pgdigits - weight - 1
 *             else:
 */
      __pyx_t_2 = ((__pyx_v_weight >= 0) != 0);
      if (__pyx_t_2) {

        /* "asyncpg/protocol/codecs/numeric.pyx":221
 *         if dscale:
 *             if weight >= 0:
 *                 num_fract_digits = num_pgdigits - weight - 1             # <<<<<<<<<<<<<<
 *             else:
 *                 num_fract_digits = num_pgdigits
 */
        __pyx_v_num_fract_digits = ((__pyx_v_num_pgdigits - __pyx_v_weight) - 1);

        /* "asyncpg/protocol/codecs/numeric.pyx":220
 * 
 *         if dscale:
 *             if weight >= 0:             # <<<<<<<<<<<<<<
 *                 num_fract_digits = num_pgdigits - weight - 1
 *             else:
 */
        goto __pyx_L16;
      }

      /* "asyncpg/protocol/codecs/numeric.pyx":223
 *                 num_fract_digits = num_pgdigits - weight - 1
 *             else:
 *                 num_fract_digits = num_pgdigits             # <<<<<<<<<<<<<<
 * 
 *             # Check how much dscale is left to render (trailing zeros).
 */
      /*else*/ {
        __pyx_v_num_fract_digits = __pyx_v_num_pgdigits;
      }
      __pyx_L16:;

      /* "asyncpg/protocol/codecs/numeric.pyx":226
 * 
 *             # Check how much dscale is left to render (trailing zeros).
 *             dscale_left = dscale - num_fract_digits * DEC_DIGITS             # <<<<<<<<<<<<<<
 *             if dscale_left > 0:
 *                 for i in range(dscale_left):
 */
      __pyx_v_dscale_left = (__pyx_v_dscale - (__pyx_v_num_fract_digits * 4));

      /* "asyncpg/protocol/codecs/numeric.pyx":227
 *             # Check how much dscale is left to render (trailing zeros).
 *             dscale_left = dscale - num_fract_digits * DEC_DIGITS
 *             if dscale_left > 0:             # <<<<<<<<<<<<<<
 *                 for i in range(dscale_left):
 *                     bufptr[i] = <char>b'0'
 */
      __pyx_t_2 = ((__pyx_v_dscale_left > 0) != 0);
      if (__pyx_t_2) {

        /* "asyncpg/protocol/codecs/numeric.pyx":228
 *             dscale_left = dscale - num_fract_digits * DEC_DIGITS
 *             if dscale_left > 0:
 *                 for i in range(dscale_left):             # <<<<<<<<<<<<<<
 *                     bufptr[i] = <char>b'0'
 * 
 */
        __pyx_t_8 = __pyx_v_dscale_left;
        for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
          __pyx_v_i = __pyx_t_9;

          /* "asyncpg/protocol/codecs/numeric.pyx":229
 *             if dscale_left > 0:
 *                 for i in range(dscale_left):
 *                     bufptr[i] = <char>b'0'             # <<<<<<<<<<<<<<
 * 
 *             # If display scale is _less_ than the number of rendered digits,
 */
          (__pyx_v_bufptr[__pyx_v_i]) = ((char)'0');
        }

        /* "asyncpg/protocol/codecs/numeric.pyx":227
 *             # Check how much dscale is left to render (trailing zeros).
 *             dscale_left = dscale - num_fract_digits * DEC_DIGITS
 *             if dscale_left > 0:             # <<<<<<<<<<<<<<
 *                 for i in range(dscale_left):
 *                     bufptr[i] = <char>b'0'
 */
      }

      /* "asyncpg/protocol/codecs/numeric.pyx":234
 *             # dscale_left will be negative and this will strip the excess
 *             # trailing zeros.
 *             bufptr += dscale_left             # <<<<<<<<<<<<<<
 * 
 *         if exponent != 0:
 */
      __pyx_v_bufptr = (__pyx_v_bufptr + __pyx_v_dscale_left);

      /* "asyncpg/protocol/codecs/numeric.pyx":219
 *             bufptr = _unpack_digit(bufptr, pgdigit)
 * 
 *         if dscale:             # <<<<<<<<<<<<<<
 *             if weight >= 0:
 *                 num_fract_digits = num_pgdigits - weight - 1
 */
    }

    /* "asyncpg/protocol/codecs/numeric.pyx":236
 *             bufptr += dscale_left
 * 
 *         if exponent != 0:             # <<<<<<<<<<<<<<
 *             bufptr[0] = b'E'
 *             if exponent < 0:
 */
    __pyx_t_2 = ((__pyx_v_exponent != 0) != 0);
    if (__pyx_t_2) {

      /* "asyncpg/protocol/codecs/numeric.pyx":237
 * 
 *         if exponent != 0:
 *             bufptr[0] = b'E'             # <<<<<<<<<<<<<<
 *             if exponent < 0:
 *                 bufptr[1] = b'-'
 */
      (__pyx_v_bufptr[0]) = 'E';

      /* "asyncpg/protocol/codecs/numeric.pyx":238
 *         if exponent != 0:
 *             bufptr[0] = b'E'
 *             if exponent < 0:             # <<<<<<<<<<<<<<
 *                 bufptr[1] = b'-'
 *             else:
 */
      __pyx_t_2 = ((__pyx_v_exponent < 0) != 0);
      if (__pyx_t_2) {

        /* "asyncpg/protocol/codecs/numeric.pyx":239
 *             bufptr[0] = b'E'
 *             if exponent < 0:
 *                 bufptr[1] = b'-'             # <<<<<<<<<<<<<<
 *             else:
 *                 bufptr[1] = b'+'
 */
        (__pyx_v_bufptr[1]) = '-';

        /* "asyncpg/protocol/codecs/numeric.pyx":238
 *         if exponent != 0:
 *             bufptr[0] = b'E'
 *             if exponent < 0:             # <<<<<<<<<<<<<<
 *                 bufptr[1] = b'-'
 *             else:
 */
        goto __pyx_L21;
      }

      /* "asyncpg/protocol/codecs/numeric.pyx":241
 *                 bufptr[1] = b'-'
 *             else:
 *                 bufptr[1] = b'+'             # <<<<<<<<<<<<<<
 *             bufptr += 2
 *             snprintf(bufptr, <size_t>exponent_chars + 1, '%d',
 */
      /*else*/ {
        (__pyx_v_bufptr[1]) = '+';
      }
      __pyx_L21:;

      /* "asyncpg/protocol/codecs/numeric.pyx":242
 *             else:
 *                 bufptr[1] = b'+'
 *             bufptr += 2             # <<<<<<<<<<<<<<
 *             snprintf(bufptr, <size_t>exponent_chars + 1, '%d',
 *                      <int>abs_exponent)
 */
      __pyx_v_bufptr = (__pyx_v_bufptr + 2);

      /* "asyncpg/protocol/codecs/numeric.pyx":243
 *                 bufptr[1] = b'+'
 *             bufptr += 2
 *             snprintf(bufptr, <size_t>exponent_chars + 1, '%d',             # <<<<<<<<<<<<<<
 *                      <int>abs_exponent)
 *             bufptr += exponent_chars
 */
      snprintf(__pyx_v_bufptr, (((size_t)__pyx_v_exponent_chars) + 1), ((char const *)"%d"), ((int)__pyx_v_abs_exponent));

      /* "asyncpg/protocol/codecs/numeric.pyx":245
 *             snprintf(bufptr, <size_t>exponent_chars + 1, '%d',
 *                      <int>abs_exponent)
 *             bufptr += exponent_chars             # <<<<<<<<<<<<<<
 * 
 *         bufptr[0] = 0
 */
      __pyx_v_bufptr = (__pyx_v_bufptr + __pyx_v_exponent_chars);

      /* "asyncpg/protocol/codecs/numeric.pyx":236
 *             bufptr += dscale_left
 * 
 *         if exponent != 0:             # <<<<<<<<<<<<<<
 *             bufptr[0] = b'E'
 *             if exponent < 0:
 */
    }

    /* "asyncpg/protocol/codecs/numeric.pyx":247
 *             bufptr += exponent_chars
 * 
 *         bufptr[0] = 0             # <<<<<<<<<<<<<<
 * 
 *         pydigits = python.PyUnicode_FromString(charbuf)
 */
    (__pyx_v_bufptr[0]) = 0;

    /* "asyncpg/protocol/codecs/numeric.pyx":249
 *         bufptr[0] = 0
 * 
 *         pydigits = python.PyUnicode_FromString(charbuf)             # <<<<<<<<<<<<<<
 * 
 *         return _Dec(pydigits)
 */
    __pyx_t_3 = PyUnicode_FromString(__pyx_v_charbuf); if (unlikely(!__pyx_t_3)) __PYX_ERR(18, 249, __pyx_L9_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_pydigits = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "asyncpg/protocol/codecs/numeric.pyx":251
 *         pydigits = python.PyUnicode_FromString(charbuf)
 * 
 *         return _Dec(pydigits)             # <<<<<<<<<<<<<<
 * 
 *     finally:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_Dec); if (unlikely(!__pyx_t_4)) __PYX_ERR(18, 251, __pyx_L9_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_pydigits); if (unlikely(!__pyx_t_3)) __PYX_ERR(18, 251, __pyx_L9_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_pydigits};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(18, 251, __pyx_L9_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_pydigits};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(18, 251, __pyx_L9_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(18, 251, __pyx_L9_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_INCREF(__pyx_v_pydigits);
        __Pyx_GIVEREF(__pyx_v_pydigits);
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_pydigits);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(18, 251, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L8_return;
  }

  /* "asyncpg/protocol/codecs/numeric.pyx":254
 * 
 *     finally:
 *         if buf_allocated:             # <<<<<<<<<<<<<<
 *             PyMem_Free(charbuf)
 * 
 */
  /*finally:*/ {
    __pyx_L9_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16) < 0)) __Pyx_ErrFetch(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
      __Pyx_XGOTREF(__pyx_t_14);
      __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_t_11 = __pyx_lineno; __pyx_t_12 = __pyx_clineno; __pyx_t_13 = __pyx_filename;
      {
        __pyx_t_2 = (__pyx_v_buf_allocated != 0);
        if (__pyx_t_2) {

          /* "asyncpg/protocol/codecs/numeric.pyx":255
 *     finally:
 *         if buf_allocated:
 *             PyMem_Free(charbuf)             # <<<<<<<<<<<<<<
 * 
 * 
 */
          PyMem_Free(__pyx_v_charbuf);

          /* "asyncpg/protocol/codecs/numeric.pyx":254
 * 
 *     finally:
 *         if buf_allocated:             # <<<<<<<<<<<<<<
 *             PyMem_Free(charbuf)
 * 
 */
        }
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_17);
        __Pyx_XGIVEREF(__pyx_t_18);
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19);
      }
      __Pyx_XGIVEREF(__pyx_t_14);
      __Pyx_XGIVEREF(__pyx_t_15);
      __Pyx_XGIVEREF(__pyx_t_16);
      __Pyx_ErrRestore(__pyx_t_14, __pyx_t_15, __pyx_t_16);
      __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0;
      __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_12; __pyx_filename = __pyx_t_13;
      goto __pyx_L1_error;
    }
    __pyx_L8_return: {
      __pyx_t_19 = __pyx_r;
      __pyx_r = 0;
      __pyx_t_2 = (__pyx_v_buf_allocated != 0);
      if (__pyx_t_2) {

        /* "asyncpg/protocol/codecs/numeric.pyx":255
 *     finally:
 *         if buf_allocated:
 *             PyMem_Free(charbuf)             # <<<<<<<<<<<<<<
 * 
 * 
 */
        PyMem_Free(__pyx_v_charbuf);

        /* "asyncpg/protocol/codecs/numeric.pyx":254
 * 
 *     finally:
 *         if buf_allocated:             # <<<<<<<<<<<<<<
 *             PyMem_Free(charbuf)
 * 
 */
      }
      __pyx_r = __pyx_t_19;
      __pyx_t_19 = 0;
      goto __pyx_L0;
    }
  }

  /* "asyncpg/protocol/codecs/numeric.pyx":134
 * # than the simple text decoder above.  That said, we need the binary
 * # decoder to support binary COPY with numeric values.
 * cdef numeric_decode_binary(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
 *     cdef:
 *         uint16_t num_pgdigits = <uint16_t>hton.unpack_int16(buf.read(2))
 */

  /* 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_10);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.numeric_decode_binary", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_pydigits);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/codecs/numeric.pyx":258
 * 
 * 
 * cdef inline char *_unpack_digit_stripping_lzeros(char *buf, int64_t pgdigit):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int64_t d
 */

static CYTHON_INLINE char *__pyx_f_7asyncpg_8protocol_8protocol__unpack_digit_stripping_lzeros(char *__pyx_v_buf, int64_t __pyx_v_pgdigit) {
  int64_t __pyx_v_d;
  int __pyx_v_significant;
  char *__pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("_unpack_digit_stripping_lzeros", 0);

  /* "asyncpg/protocol/codecs/numeric.pyx":263
 *         bint significant
 * 
 *     d = pgdigit // 1000             # <<<<<<<<<<<<<<
 *     significant = (d > 0)
 *     if significant:
 */
  __pyx_v_d = __Pyx_div_int64_t(__pyx_v_pgdigit, 0x3E8);

  /* "asyncpg/protocol/codecs/numeric.pyx":264
 * 
 *     d = pgdigit // 1000
 *     significant = (d > 0)             # <<<<<<<<<<<<<<
 *     if significant:
 *         pgdigit -= d * 1000
 */
  __pyx_v_significant = (__pyx_v_d > 0);

  /* "asyncpg/protocol/codecs/numeric.pyx":265
 *     d = pgdigit // 1000
 *     significant = (d > 0)
 *     if significant:             # <<<<<<<<<<<<<<
 *         pgdigit -= d * 1000
 *         buf[0] = <char>(d + <int32_t>b'0')
 */
  __pyx_t_1 = (__pyx_v_significant != 0);
  if (__pyx_t_1) {

    /* "asyncpg/protocol/codecs/numeric.pyx":266
 *     significant = (d > 0)
 *     if significant:
 *         pgdigit -= d * 1000             # <<<<<<<<<<<<<<
 *         buf[0] = <char>(d + <int32_t>b'0')
 *         buf += 1
 */
    __pyx_v_pgdigit = (__pyx_v_pgdigit - (__pyx_v_d * 0x3E8));

    /* "asyncpg/protocol/codecs/numeric.pyx":267
 *     if significant:
 *         pgdigit -= d * 1000
 *         buf[0] = <char>(d + <int32_t>b'0')             # <<<<<<<<<<<<<<
 *         buf += 1
 * 
 */
    (__pyx_v_buf[0]) = ((char)(__pyx_v_d + ((int32_t)'0')));

    /* "asyncpg/protocol/codecs/numeric.pyx":268
 *         pgdigit -= d * 1000
 *         buf[0] = <char>(d + <int32_t>b'0')
 *         buf += 1             # <<<<<<<<<<<<<<
 * 
 *     d = pgdigit // 100
 */
    __pyx_v_buf = (__pyx_v_buf + 1);

    /* "asyncpg/protocol/codecs/numeric.pyx":265
 *     d = pgdigit // 1000
 *     significant = (d > 0)
 *     if significant:             # <<<<<<<<<<<<<<
 *         pgdigit -= d * 1000
 *         buf[0] = <char>(d + <int32_t>b'0')
 */
  }

  /* "asyncpg/protocol/codecs/numeric.pyx":270
 *         buf += 1
 * 
 *     d = pgdigit // 100             # <<<<<<<<<<<<<<
 *     significant |= (d > 0)
 *     if significant:
 */
  __pyx_v_d = __Pyx_div_int64_t(__pyx_v_pgdigit, 0x64);

  /* "asyncpg/protocol/codecs/numeric.pyx":271
 * 
 *     d = pgdigit // 100
 *     significant |= (d > 0)             # <<<<<<<<<<<<<<
 *     if significant:
 *         pgdigit -= d * 100
 */
  __pyx_v_significant = (__pyx_v_significant | (__pyx_v_d > 0));

  /* "asyncpg/protocol/codecs/numeric.pyx":272
 *     d = pgdigit // 100
 *     significant |= (d > 0)
 *     if significant:             # <<<<<<<<<<<<<<
 *         pgdigit -= d * 100
 *         buf[0] = <char>(d + <int32_t>b'0')
 */
  __pyx_t_1 = (__pyx_v_significant != 0);
  if (__pyx_t_1) {

    /* "asyncpg/protocol/codecs/numeric.pyx":273
 *     significant |= (d > 0)
 *     if significant:
 *         pgdigit -= d * 100             # <<<<<<<<<<<<<<
 *         buf[0] = <char>(d + <int32_t>b'0')
 *         buf += 1
 */
    __pyx_v_pgdigit = (__pyx_v_pgdigit - (__pyx_v_d * 0x64));

    /* "asyncpg/protocol/codecs/numeric.pyx":274
 *     if significant:
 *         pgdigit -= d * 100
 *         buf[0] = <char>(d + <int32_t>b'0')             # <<<<<<<<<<<<<<
 *         buf += 1
 * 
 */
    (__pyx_v_buf[0]) = ((char)(__pyx_v_d + ((int32_t)'0')));

    /* "asyncpg/protocol/codecs/numeric.pyx":275
 *         pgdigit -= d * 100
 *         buf[0] = <char>(d + <int32_t>b'0')
 *         buf += 1             # <<<<<<<<<<<<<<
 * 
 *     d = pgdigit // 10
 */
    __pyx_v_buf = (__pyx_v_buf + 1);

    /* "asyncpg/protocol/codecs/numeric.pyx":272
 *     d = pgdigit // 100
 *     significant |= (d > 0)
 *     if significant:             # <<<<<<<<<<<<<<
 *         pgdigit -= d * 100
 *         buf[0] = <char>(d + <int32_t>b'0')
 */
  }

  /* "asyncpg/protocol/codecs/numeric.pyx":277
 *         buf += 1
 * 
 *     d = pgdigit // 10             # <<<<<<<<<<<<<<
 *     significant |= (d > 0)
 *     if significant:
 */
  __pyx_v_d = __Pyx_div_int64_t(__pyx_v_pgdigit, 10);

  /* "asyncpg/protocol/codecs/numeric.pyx":278
 * 
 *     d = pgdigit // 10
 *     significant |= (d > 0)             # <<<<<<<<<<<<<<
 *     if significant:
 *         pgdigit -= d * 10
 */
  __pyx_v_significant = (__pyx_v_significant | (__pyx_v_d > 0));

  /* "asyncpg/protocol/codecs/numeric.pyx":279
 *     d = pgdigit // 10
 *     significant |= (d > 0)
 *     if significant:             # <<<<<<<<<<<<<<
 *         pgdigit -= d * 10
 *         buf[0] = <char>(d + <int32_t>b'0')
 */
  __pyx_t_1 = (__pyx_v_significant != 0);
  if (__pyx_t_1) {

    /* "asyncpg/protocol/codecs/numeric.pyx":280
 *     significant |= (d > 0)
 *     if significant:
 *         pgdigit -= d * 10             # <<<<<<<<<<<<<<
 *         buf[0] = <char>(d + <int32_t>b'0')
 *         buf += 1
 */
    __pyx_v_pgdigit = (__pyx_v_pgdigit - (__pyx_v_d * 10));

    /* "asyncpg/protocol/codecs/numeric.pyx":281
 *     if significant:
 *         pgdigit -= d * 10
 *         buf[0] = <char>(d + <int32_t>b'0')             # <<<<<<<<<<<<<<
 *         buf += 1
 * 
 */
    (__pyx_v_buf[0]) = ((char)(__pyx_v_d + ((int32_t)'0')));

    /* "asyncpg/protocol/codecs/numeric.pyx":282
 *         pgdigit -= d * 10
 *         buf[0] = <char>(d + <int32_t>b'0')
 *         buf += 1             # <<<<<<<<<<<<<<
 * 
 *     buf[0] = <char>(pgdigit + <int32_t>b'0')
 */
    __pyx_v_buf = (__pyx_v_buf + 1);

    /* "asyncpg/protocol/codecs/numeric.pyx":279
 *     d = pgdigit // 10
 *     significant |= (d > 0)
 *     if significant:             # <<<<<<<<<<<<<<
 *         pgdigit -= d * 10
 *         buf[0] = <char>(d + <int32_t>b'0')
 */
  }

  /* "asyncpg/protocol/codecs/numeric.pyx":284
 *         buf += 1
 * 
 *     buf[0] = <char>(pgdigit + <int32_t>b'0')             # <<<<<<<<<<<<<<
 *     buf += 1
 * 
 */
  (__pyx_v_buf[0]) = ((char)(__pyx_v_pgdigit + ((int32_t)'0')));

  /* "asyncpg/protocol/codecs/numeric.pyx":285
 * 
 *     buf[0] = <char>(pgdigit + <int32_t>b'0')
 *     buf += 1             # <<<<<<<<<<<<<<
 * 
 *     return buf
 */
  __pyx_v_buf = (__pyx_v_buf + 1);

  /* "asyncpg/protocol/codecs/numeric.pyx":287
 *     buf += 1
 * 
 *     return buf             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_buf;
  goto __pyx_L0;

  /* "asyncpg/protocol/codecs/numeric.pyx":258
 * 
 * 
 * cdef inline char *_unpack_digit_stripping_lzeros(char *buf, int64_t pgdigit):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int64_t d
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/codecs/numeric.pyx":290
 * 
 * 
 * cdef inline char *_unpack_digit(char *buf, int64_t pgdigit):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int64_t d
 */

static CYTHON_INLINE char *__pyx_f_7asyncpg_8protocol_8protocol__unpack_digit(char *__pyx_v_buf, int64_t __pyx_v_pgdigit) {
  int64_t __pyx_v_d;
  char *__pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_unpack_digit", 0);

  /* "asyncpg/protocol/codecs/numeric.pyx":294
 *         int64_t d
 * 
 *     d = pgdigit // 1000             # <<<<<<<<<<<<<<
 *     pgdigit -= d * 1000
 *     buf[0] = <char>(d + <int32_t>b'0')
 */
  __pyx_v_d = __Pyx_div_int64_t(__pyx_v_pgdigit, 0x3E8);

  /* "asyncpg/protocol/codecs/numeric.pyx":295
 * 
 *     d = pgdigit // 1000
 *     pgdigit -= d * 1000             # <<<<<<<<<<<<<<
 *     buf[0] = <char>(d + <int32_t>b'0')
 * 
 */
  __pyx_v_pgdigit = (__pyx_v_pgdigit - (__pyx_v_d * 0x3E8));

  /* "asyncpg/protocol/codecs/numeric.pyx":296
 *     d = pgdigit // 1000
 *     pgdigit -= d * 1000
 *     buf[0] = <char>(d + <int32_t>b'0')             # <<<<<<<<<<<<<<
 * 
 *     d = pgdigit // 100
 */
  (__pyx_v_buf[0]) = ((char)(__pyx_v_d + ((int32_t)'0')));

  /* "asyncpg/protocol/codecs/numeric.pyx":298
 *     buf[0] = <char>(d + <int32_t>b'0')
 * 
 *     d = pgdigit // 100             # <<<<<<<<<<<<<<
 *     pgdigit -= d * 100
 *     buf[1] = <char>(d + <int32_t>b'0')
 */
  __pyx_v_d = __Pyx_div_int64_t(__pyx_v_pgdigit, 0x64);

  /* "asyncpg/protocol/codecs/numeric.pyx":299
 * 
 *     d = pgdigit // 100
 *     pgdigit -= d * 100             # <<<<<<<<<<<<<<
 *     buf[1] = <char>(d + <int32_t>b'0')
 * 
 */
  __pyx_v_pgdigit = (__pyx_v_pgdigit - (__pyx_v_d * 0x64));

  /* "asyncpg/protocol/codecs/numeric.pyx":300
 *     d = pgdigit // 100
 *     pgdigit -= d * 100
 *     buf[1] = <char>(d + <int32_t>b'0')             # <<<<<<<<<<<<<<
 * 
 *     d = pgdigit // 10
 */
  (__pyx_v_buf[1]) = ((char)(__pyx_v_d + ((int32_t)'0')));

  /* "asyncpg/protocol/codecs/numeric.pyx":302
 *     buf[1] = <char>(d + <int32_t>b'0')
 * 
 *     d = pgdigit // 10             # <<<<<<<<<<<<<<
 *     pgdigit -= d * 10
 *     buf[2] = <char>(d + <int32_t>b'0')
 */
  __pyx_v_d = __Pyx_div_int64_t(__pyx_v_pgdigit, 10);

  /* "asyncpg/protocol/codecs/numeric.pyx":303
 * 
 *     d = pgdigit // 10
 *     pgdigit -= d * 10             # <<<<<<<<<<<<<<
 *     buf[2] = <char>(d + <int32_t>b'0')
 * 
 */
  __pyx_v_pgdigit = (__pyx_v_pgdigit - (__pyx_v_d * 10));

  /* "asyncpg/protocol/codecs/numeric.pyx":304
 *     d = pgdigit // 10
 *     pgdigit -= d * 10
 *     buf[2] = <char>(d + <int32_t>b'0')             # <<<<<<<<<<<<<<
 * 
 *     buf[3] = <char>(pgdigit + <int32_t>b'0')
 */
  (__pyx_v_buf[2]) = ((char)(__pyx_v_d + ((int32_t)'0')));

  /* "asyncpg/protocol/codecs/numeric.pyx":306
 *     buf[2] = <char>(d + <int32_t>b'0')
 * 
 *     buf[3] = <char>(pgdigit + <int32_t>b'0')             # <<<<<<<<<<<<<<
 *     buf += 4
 * 
 */
  (__pyx_v_buf[3]) = ((char)(__pyx_v_pgdigit + ((int32_t)'0')));

  /* "asyncpg/protocol/codecs/numeric.pyx":307
 * 
 *     buf[3] = <char>(pgdigit + <int32_t>b'0')
 *     buf += 4             # <<<<<<<<<<<<<<
 * 
 *     return buf
 */
  __pyx_v_buf = (__pyx_v_buf + 4);

  /* "asyncpg/protocol/codecs/numeric.pyx":309
 *     buf += 4
 * 
 *     return buf             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_buf;
  goto __pyx_L0;

  /* "asyncpg/protocol/codecs/numeric.pyx":290
 * 
 * 
 * cdef inline char *_unpack_digit(char *buf, int64_t pgdigit):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int64_t d
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/codecs/numeric.pyx":312
 * 
 * 
 * cdef init_numeric_codecs():             # <<<<<<<<<<<<<<
 *     register_core_codec(NUMERICOID,
 *                         <encode_func>&numeric_encode_text,
 */

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":313
 * 
 * cdef init_numeric_codecs():
 *     register_core_codec(NUMERICOID,             # <<<<<<<<<<<<<<
 *                         <encode_func>&numeric_encode_text,
 *                         <decode_func>&numeric_decode_text,
 */
  __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_text)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_numeric_decode_text)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_TEXT, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 313, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/numeric.pyx":318
 *                         PG_FORMAT_TEXT)
 * 
 *     register_core_codec(NUMERICOID,             # <<<<<<<<<<<<<<
 *                         <encode_func>&numeric_encode_binary,
 *                         <decode_func>&numeric_decode_binary,
 */
  __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_binary)), ((__pyx_t_7asyncpg_8protocol_8protocol_decode_func)(&__pyx_f_7asyncpg_8protocol_8protocol_numeric_decode_binary)), __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 318, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/numeric.pyx":312
 * 
 * 
 * cdef init_numeric_codecs():             # <<<<<<<<<<<<<<
 *     register_core_codec(NUMERICOID,
 *                         <encode_func>&numeric_encode_text,
 */

  /* 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(19, 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(19, 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(19, 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(19, 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, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(19, 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(19, 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(20, 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(20, 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(20, 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(20, 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(20, 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(20, 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(20, 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(20, 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(20, 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(20, 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 == ((Py_ssize_t)-1))) __PYX_ERR(20, 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__58, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 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(20, 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(20, 24, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(20, 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__59, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 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(20, 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(20, 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(20, 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(20, 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(20, 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(20, 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(20, 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(20, 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(20, 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(20, 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(20, 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(20, 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(20, 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(20, 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(20, 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(20, 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(20, 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(20, 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(20, 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(20, 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(20, 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 == ((char const *)NULL))) __PYX_ERR(20, 51, __pyx_L1_error)
  __pyx_v_nxip = 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 == ((char const *)NULL))) __PYX_ERR(20, 52, __pyx_L1_error)
  __pyx_v_xmin = 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 == ((char const *)NULL))) __PYX_ERR(20, 53, __pyx_L1_error)
  __pyx_v_xmax = 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(20, 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 == ((char const *)NULL))) __PYX_ERR(20, 57, __pyx_L1_error)
    __pyx_t_2 = PyLong_FromLongLong(unpack_int64(__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(20, 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(20, 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(20, 61, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(20, 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(20, 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(21, 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(21, 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(21, 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(21, 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(21, 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(21, 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(21, 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(21, 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(21, 22, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(21, 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(21, 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(21, 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(21, 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(21, 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(22, 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(22, 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(22, 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(22, 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(22, 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(22, 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(22, 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, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 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(22, 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(22, 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(22, 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(22, 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, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(22, 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(12); if (unlikely(!__pyx_t_1)) __PYX_ERR(22, 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_INCREF(__pyx_int_325);
  __Pyx_GIVEREF(__pyx_int_325);
  PyList_SET_ITEM(__pyx_t_1, 11, __pyx_int_325);
  __pyx_v_no_io_types = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/misc.pyx":74
 *     ]
 * 
 *     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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(22, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/misc.pyx":79
 *                         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(22, 79, __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(22, 79, __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":80
 * 
 *     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(22, 80, __pyx_L1_error)

    /* "asyncpg/protocol/codecs/misc.pyx":83
 *                             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, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 80, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "asyncpg/protocol/codecs/misc.pyx":79
 *                         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":86
 * 
 *     # 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(22, 86, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/misc.pyx":92
 * 
 *     # 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(22, 92, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/misc.pyx":98
 * 
 *     # 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(22, 98, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/misc.pyx":103
 *                         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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(22, 103, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/misc.pyx":110
 *     # pg_dependencies and pg_ndistinct are special types
 *     # used in pg_statistic_ext columns.
 *     register_core_codec(PG_DEPENDENCIESOID,             # <<<<<<<<<<<<<<
 *                         <encode_func>&text_encode,
 *                         <decode_func>&text_decode,
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0xD4A, ((__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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(22, 110, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/misc.pyx":115
 *                         PG_FORMAT_TEXT)
 * 
 *     register_core_codec(PG_NDISTINCTOID,             # <<<<<<<<<<<<<<
 *                         <encode_func>&text_encode,
 *                         <decode_func>&text_decode,
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_register_core_codec(0xD21, ((__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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(22, 115, __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(6, 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(6, 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 == ((int)-1))) __PYX_ERR(6, 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(6, 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(6, 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(6, 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 == ((int)-1))) __PYX_ERR(6, 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(6, 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(6, 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 == ((Py_ssize_t)-1))) __PYX_ERR(6, 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__60, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(6, 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(6, 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(6, 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 == ((Py_ssize_t)-1))) __PYX_ERR(6, 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__61, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(6, 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(6, 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(6, 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 == ((Py_ssize_t)-1))) __PYX_ERR(6, 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__62, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(6, 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(6, 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__63, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(6, 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(6, 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(6, 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_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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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:*/ {
              __pyx_L22_error:;
              /*exception exit:*/{
                __Pyx_PyThreadState_declare
                __Pyx_PyThreadState_assign
                __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_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;
                }
                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_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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(6, 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(6, 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(6, 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_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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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:*/ {
              __pyx_L21_error:;
              /*exception exit:*/{
                __Pyx_PyThreadState_declare
                __Pyx_PyThreadState_assign
                __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_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;
                }
                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_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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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(6, 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 _write_textarray_data(ConnectionSettings settings, object obj,             # <<<<<<<<<<<<<<
 *                            int32_t ndims, int32_t dim, WriteBuffer array_data,
 *                            encode_func_ex encoder, const void *encoder_arg,
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol__write_textarray_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_array_data, __pyx_t_7asyncpg_8protocol_8protocol_encode_func_ex __pyx_v_encoder, void const *__pyx_v_encoder_arg, Py_UCS4 __pyx_v_typdelim) {
  Py_ssize_t __pyx_v_i;
  int8_t __pyx_v_delim;
  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_elem_data = 0;
  Py_buffer __pyx_v_pybuf;
  char const *__pyx_v_elem_str;
  char __pyx_v_ch;
  Py_ssize_t __pyx_v_elem_len;
  Py_ssize_t __pyx_v_quoted_elem_len;
  int __pyx_v_need_quoting;
  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;
  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;
  Py_ssize_t __pyx_t_26;
  Py_ssize_t __pyx_t_27;
  char const *__pyx_t_28;
  __Pyx_RefNannySetupContext("_write_textarray_data", 0);

  /* "asyncpg/protocol/codecs/array.pyx":148
 *                            Py_UCS4 typdelim):
 *     cdef:
 *         ssize_t i = 0             # <<<<<<<<<<<<<<
 *         int8_t delim = <int8_t>typdelim
 *         WriteBuffer elem_data
 */
  __pyx_v_i = 0;

  /* "asyncpg/protocol/codecs/array.pyx":149
 *     cdef:
 *         ssize_t i = 0
 *         int8_t delim = <int8_t>typdelim             # <<<<<<<<<<<<<<
 *         WriteBuffer elem_data
 *         Py_buffer pybuf
 */
  __pyx_v_delim = ((int8_t)__pyx_v_typdelim);

  /* "asyncpg/protocol/codecs/array.pyx":158
 *         bint need_quoting
 * 
 *     array_data.write_byte(b'{')             # <<<<<<<<<<<<<<
 * 
 *     if dim < ndims - 1:
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(__pyx_v_array_data, '{'); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 158, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/codecs/array.pyx":160
 *     array_data.write_byte(b'{')
 * 
 *     if dim < ndims - 1:             # <<<<<<<<<<<<<<
 *         for item in obj:
 *             if i > 0:
 */
    __pyx_t_2 = ((__pyx_v_dim < (__pyx_v_ndims - 1)) != 0);
    if (__pyx_t_2) {

      /* "asyncpg/protocol/codecs/array.pyx":161
 * 
 *     if dim < ndims - 1:
 *         for item in obj:             # <<<<<<<<<<<<<<
 *             if i > 0:
 *                 array_data.write_byte(delim)
 */
      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_3 = 0;
        __pyx_t_4 = NULL;
      } else {
        __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 161, __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(6, 161, __pyx_L1_error)
      }
      for (;;) {
        if (likely(!__pyx_t_4)) {
          if (likely(PyList_CheckExact(__pyx_t_1))) {
            if (__pyx_t_3 >= 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_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(6, 161, __pyx_L1_error)
            #else
            __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(6, 161, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_5);
            #endif
          } else {
            if (__pyx_t_3 >= 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_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(6, 161, __pyx_L1_error)
            #else
            __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(6, 161, __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(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(6, 161, __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":162
 *     if dim < ndims - 1:
 *         for item in obj:
 *             if i > 0:             # <<<<<<<<<<<<<<
 *                 array_data.write_byte(delim)
 *                 array_data.write_byte(b' ')
 */
        __pyx_t_2 = ((__pyx_v_i > 0) != 0);
        if (__pyx_t_2) {

          /* "asyncpg/protocol/codecs/array.pyx":163
 *         for item in obj:
 *             if i > 0:
 *                 array_data.write_byte(delim)             # <<<<<<<<<<<<<<
 *                 array_data.write_byte(b' ')
 *             _write_textarray_data(settings, item, ndims, dim + 1, array_data,
 */
          __pyx_t_5 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(__pyx_v_array_data, __pyx_v_delim); if (unlikely(!__pyx_t_5)) __PYX_ERR(6, 163, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "asyncpg/protocol/codecs/array.pyx":164
 *             if i > 0:
 *                 array_data.write_byte(delim)
 *                 array_data.write_byte(b' ')             # <<<<<<<<<<<<<<
 *             _write_textarray_data(settings, item, ndims, dim + 1, array_data,
 *                                   encoder, encoder_arg, typdelim)
 */
          __pyx_t_5 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(__pyx_v_array_data, ' '); if (unlikely(!__pyx_t_5)) __PYX_ERR(6, 164, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "asyncpg/protocol/codecs/array.pyx":162
 *     if dim < ndims - 1:
 *         for item in obj:
 *             if i > 0:             # <<<<<<<<<<<<<<
 *                 array_data.write_byte(delim)
 *                 array_data.write_byte(b' ')
 */
        }

        /* "asyncpg/protocol/codecs/array.pyx":165
 *                 array_data.write_byte(delim)
 *                 array_data.write_byte(b' ')
 *             _write_textarray_data(settings, item, ndims, dim + 1, array_data,             # <<<<<<<<<<<<<<
 *                                   encoder, encoder_arg, typdelim)
 *             i += 1
 */
        __pyx_t_5 = __pyx_f_7asyncpg_8protocol_8protocol__write_textarray_data(__pyx_v_settings, __pyx_v_item, __pyx_v_ndims, (__pyx_v_dim + 1), __pyx_v_array_data, __pyx_v_encoder, __pyx_v_encoder_arg, __pyx_v_typdelim); if (unlikely(!__pyx_t_5)) __PYX_ERR(6, 165, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "asyncpg/protocol/codecs/array.pyx":167
 *             _write_textarray_data(settings, item, ndims, dim + 1, array_data,
 *                                   encoder, encoder_arg, typdelim)
 *             i += 1             # <<<<<<<<<<<<<<
 *     else:
 *         for item in obj:
 */
        __pyx_v_i = (__pyx_v_i + 1);

        /* "asyncpg/protocol/codecs/array.pyx":161
 * 
 *     if dim < ndims - 1:
 *         for item in obj:             # <<<<<<<<<<<<<<
 *             if i > 0:
 *                 array_data.write_byte(delim)
 */
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "asyncpg/protocol/codecs/array.pyx":160
 *     array_data.write_byte(b'{')
 * 
 *     if dim < ndims - 1:             # <<<<<<<<<<<<<<
 *         for item in obj:
 *             if i > 0:
 */
      goto __pyx_L3;
    }

    /* "asyncpg/protocol/codecs/array.pyx":169
 *             i += 1
 *     else:
 *         for item in obj:             # <<<<<<<<<<<<<<
 *             elem_data = WriteBuffer.new()
 * 
 */
    /*else*/ {
      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_3 = 0;
        __pyx_t_4 = NULL;
      } else {
        __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 169, __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(6, 169, __pyx_L1_error)
      }
      for (;;) {
        if (likely(!__pyx_t_4)) {
          if (likely(PyList_CheckExact(__pyx_t_1))) {
            if (__pyx_t_3 >= 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_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(6, 169, __pyx_L1_error)
            #else
            __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(6, 169, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_5);
            #endif
          } else {
            if (__pyx_t_3 >= 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_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(6, 169, __pyx_L1_error)
            #else
            __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(6, 169, __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(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(6, 169, __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":170
 *     else:
 *         for item in obj:
 *             elem_data = WriteBuffer.new()             # <<<<<<<<<<<<<<
 * 
 *             if i > 0:
 */
        __pyx_t_5 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new()); if (unlikely(!__pyx_t_5)) __PYX_ERR(6, 170, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_XDECREF_SET(__pyx_v_elem_data, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_5));
        __pyx_t_5 = 0;

        /* "asyncpg/protocol/codecs/array.pyx":172
 *             elem_data = WriteBuffer.new()
 * 
 *             if i > 0:             # <<<<<<<<<<<<<<
 *                 array_data.write_byte(delim)
 *                 array_data.write_byte(b' ')
 */
        __pyx_t_2 = ((__pyx_v_i > 0) != 0);
        if (__pyx_t_2) {

          /* "asyncpg/protocol/codecs/array.pyx":173
 * 
 *             if i > 0:
 *                 array_data.write_byte(delim)             # <<<<<<<<<<<<<<
 *                 array_data.write_byte(b' ')
 * 
 */
          __pyx_t_5 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(__pyx_v_array_data, __pyx_v_delim); if (unlikely(!__pyx_t_5)) __PYX_ERR(6, 173, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "asyncpg/protocol/codecs/array.pyx":174
 *             if i > 0:
 *                 array_data.write_byte(delim)
 *                 array_data.write_byte(b' ')             # <<<<<<<<<<<<<<
 * 
 *             if item is None:
 */
          __pyx_t_5 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(__pyx_v_array_data, ' '); if (unlikely(!__pyx_t_5)) __PYX_ERR(6, 174, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "asyncpg/protocol/codecs/array.pyx":172
 *             elem_data = WriteBuffer.new()
 * 
 *             if i > 0:             # <<<<<<<<<<<<<<
 *                 array_data.write_byte(delim)
 *                 array_data.write_byte(b' ')
 */
        }

        /* "asyncpg/protocol/codecs/array.pyx":176
 *                 array_data.write_byte(b' ')
 * 
 *             if item is None:             # <<<<<<<<<<<<<<
 *                 array_data.write_bytes(b'NULL')
 *                 i += 1
 */
        __pyx_t_2 = (__pyx_v_item == Py_None);
        __pyx_t_6 = (__pyx_t_2 != 0);
        if (__pyx_t_6) {

          /* "asyncpg/protocol/codecs/array.pyx":177
 * 
 *             if item is None:
 *                 array_data.write_bytes(b'NULL')             # <<<<<<<<<<<<<<
 *                 i += 1
 *                 continue
 */
          __pyx_t_5 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_bytes(__pyx_v_array_data, __pyx_n_b_NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(6, 177, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "asyncpg/protocol/codecs/array.pyx":178
 *             if item is None:
 *                 array_data.write_bytes(b'NULL')
 *                 i += 1             # <<<<<<<<<<<<<<
 *                 continue
 *             else:
 */
          __pyx_v_i = (__pyx_v_i + 1);

          /* "asyncpg/protocol/codecs/array.pyx":179
 *                 array_data.write_bytes(b'NULL')
 *                 i += 1
 *                 continue             # <<<<<<<<<<<<<<
 *             else:
 *                 try:
 */
          goto __pyx_L7_continue;

          /* "asyncpg/protocol/codecs/array.pyx":176
 *                 array_data.write_byte(b' ')
 * 
 *             if item is None:             # <<<<<<<<<<<<<<
 *                 array_data.write_bytes(b'NULL')
 *                 i += 1
 */
        }

        /* "asyncpg/protocol/codecs/array.pyx":181
 *                 continue
 *             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":182
 *             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(6, 182, __pyx_L11_error)
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

              /* "asyncpg/protocol/codecs/array.pyx":181
 *                 continue
 *             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_L18_try_end;
            __pyx_L11_error:;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

            /* "asyncpg/protocol/codecs/array.pyx":183
 *                 try:
 *                     encoder(settings, elem_data, item, encoder_arg)
 *                 except TypeError as e:             # <<<<<<<<<<<<<<
 *                     raise ValueError(
 *                         'invalid array element: {}'.format(
 */
            __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError);
            if (__pyx_t_10) {
              __Pyx_AddTraceback("asyncpg.protocol.protocol._write_textarray_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_11, &__pyx_t_12) < 0) __PYX_ERR(6, 183, __pyx_L13_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":185
 *                 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(6, 185, __pyx_L24_error)
                __Pyx_GOTREF(__pyx_t_14);

                /* "asyncpg/protocol/codecs/array.pyx":186
 *                     raise ValueError(
 *                         'invalid array element: {}'.format(
 *                             e.args[0])) from None             # <<<<<<<<<<<<<<
 * 
 *             # element string length (first four bytes are the encoded length.)
 */
                __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_e, __pyx_n_s_args); if (unlikely(!__pyx_t_15)) __PYX_ERR(6, 186, __pyx_L24_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(6, 186, __pyx_L24_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(6, 185, __pyx_L24_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(6, 185, __pyx_L24_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(6, 185, __pyx_L24_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(6, 185, __pyx_L24_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(6, 185, __pyx_L24_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":184
 *                     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(6, 184, __pyx_L24_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(6, 184, __pyx_L24_error)
                __Pyx_GOTREF(__pyx_t_13);
                __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

                /* "asyncpg/protocol/codecs/array.pyx":186
 *                     raise ValueError(
 *                         'invalid array element: {}'.format(
 *                             e.args[0])) from None             # <<<<<<<<<<<<<<
 * 
 *             # element string length (first four bytes are the encoded length.)
 */
                __Pyx_Raise(__pyx_t_13, 0, 0, Py_None);
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                __PYX_ERR(6, 184, __pyx_L24_error)
              }

              /* "asyncpg/protocol/codecs/array.pyx":183
 *                 try:
 *                     encoder(settings, elem_data, item, encoder_arg)
 *                 except TypeError as e:             # <<<<<<<<<<<<<<
 *                     raise ValueError(
 *                         'invalid array element: {}'.format(
 */
              /*finally:*/ {
                __pyx_L24_error:;
                /*exception exit:*/{
                  __Pyx_PyThreadState_declare
                  __Pyx_PyThreadState_assign
                  __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_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;
                  }
                  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_L13_except_error;
                }
              }
            }
            goto __pyx_L13_except_error;
            __pyx_L13_except_error:;

            /* "asyncpg/protocol/codecs/array.pyx":181
 *                 continue
 *             else:
 *                 try:             # <<<<<<<<<<<<<<
 *                     encoder(settings, elem_data, item, encoder_arg)
 *                 except TypeError as e:
 */
            __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_L18_try_end:;
          }
        }

        /* "asyncpg/protocol/codecs/array.pyx":189
 * 
 *             # element string length (first four bytes are the encoded length.)
 *             elem_len = elem_data.len() - 4             # <<<<<<<<<<<<<<
 * 
 *             if elem_len == 0:
 */
        __pyx_t_12 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_len(__pyx_v_elem_data); if (unlikely(!__pyx_t_12)) __PYX_ERR(6, 189, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_11 = __Pyx_PyInt_SubtractObjC(__pyx_t_12, __pyx_int_4, 4, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(6, 189, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_26 = PyInt_AsSsize_t(__pyx_t_11); if (unlikely((__pyx_t_26 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(6, 189, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_v_elem_len = __pyx_t_26;

        /* "asyncpg/protocol/codecs/array.pyx":191
 *             elem_len = elem_data.len() - 4
 * 
 *             if elem_len == 0:             # <<<<<<<<<<<<<<
 *                 # Empty string
 *                 array_data.write_bytes(b'""')
 */
        __pyx_t_6 = ((__pyx_v_elem_len == 0) != 0);
        if (__pyx_t_6) {

          /* "asyncpg/protocol/codecs/array.pyx":193
 *             if elem_len == 0:
 *                 # Empty string
 *                 array_data.write_bytes(b'""')             # <<<<<<<<<<<<<<
 *             else:
 *                 cpython.PyObject_GetBuffer(
 */
          __pyx_t_11 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_bytes(__pyx_v_array_data, __pyx_kp_b__64); if (unlikely(!__pyx_t_11)) __PYX_ERR(6, 193, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

          /* "asyncpg/protocol/codecs/array.pyx":191
 *             elem_len = elem_data.len() - 4
 * 
 *             if elem_len == 0:             # <<<<<<<<<<<<<<
 *                 # Empty string
 *                 array_data.write_bytes(b'""')
 */
          goto __pyx_L30;
        }

        /* "asyncpg/protocol/codecs/array.pyx":195
 *                 array_data.write_bytes(b'""')
 *             else:
 *                 cpython.PyObject_GetBuffer(             # <<<<<<<<<<<<<<
 *                     elem_data, &pybuf, cpython.PyBUF_SIMPLE)
 * 
 */
        /*else*/ {

          /* "asyncpg/protocol/codecs/array.pyx":196
 *             else:
 *                 cpython.PyObject_GetBuffer(
 *                     elem_data, &pybuf, cpython.PyBUF_SIMPLE)             # <<<<<<<<<<<<<<
 * 
 *                 elem_str = <const char*>(pybuf.buf) + 4
 */
          __pyx_t_18 = PyObject_GetBuffer(((PyObject *)__pyx_v_elem_data), (&__pyx_v_pybuf), PyBUF_SIMPLE); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(6, 195, __pyx_L1_error)

          /* "asyncpg/protocol/codecs/array.pyx":198
 *                     elem_data, &pybuf, cpython.PyBUF_SIMPLE)
 * 
 *                 elem_str = <const char*>(pybuf.buf) + 4             # <<<<<<<<<<<<<<
 * 
 *                 try:
 */
          __pyx_v_elem_str = (((char const *)__pyx_v_pybuf.buf) + 4);

          /* "asyncpg/protocol/codecs/array.pyx":200
 *                 elem_str = <const char*>(pybuf.buf) + 4
 * 
 *                 try:             # <<<<<<<<<<<<<<
 *                     if not apg_strcasecmp_char(elem_str, b'NULL'):
 *                         array_data.write_bytes(b'"NULL"')
 */
          /*try:*/ {

            /* "asyncpg/protocol/codecs/array.pyx":201
 * 
 *                 try:
 *                     if not apg_strcasecmp_char(elem_str, b'NULL'):             # <<<<<<<<<<<<<<
 *                         array_data.write_bytes(b'"NULL"')
 *                     else:
 */
            __pyx_t_6 = ((!(__pyx_f_7asyncpg_8protocol_8protocol_apg_strcasecmp_char(__pyx_v_elem_str, ((char const *)"NULL")) != 0)) != 0);
            if (__pyx_t_6) {

              /* "asyncpg/protocol/codecs/array.pyx":202
 *                 try:
 *                     if not apg_strcasecmp_char(elem_str, b'NULL'):
 *                         array_data.write_bytes(b'"NULL"')             # <<<<<<<<<<<<<<
 *                     else:
 *                         quoted_elem_len = elem_len
 */
              __pyx_t_11 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_bytes(__pyx_v_array_data, __pyx_kp_b_NULL_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(6, 202, __pyx_L34_error)
              __Pyx_GOTREF(__pyx_t_11);
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

              /* "asyncpg/protocol/codecs/array.pyx":201
 * 
 *                 try:
 *                     if not apg_strcasecmp_char(elem_str, b'NULL'):             # <<<<<<<<<<<<<<
 *                         array_data.write_bytes(b'"NULL"')
 *                     else:
 */
              goto __pyx_L36;
            }

            /* "asyncpg/protocol/codecs/array.pyx":204
 *                         array_data.write_bytes(b'"NULL"')
 *                     else:
 *                         quoted_elem_len = elem_len             # <<<<<<<<<<<<<<
 *                         need_quoting = False
 * 
 */
            /*else*/ {
              __pyx_v_quoted_elem_len = __pyx_v_elem_len;

              /* "asyncpg/protocol/codecs/array.pyx":205
 *                     else:
 *                         quoted_elem_len = elem_len
 *                         need_quoting = False             # <<<<<<<<<<<<<<
 * 
 *                         for i in range(elem_len):
 */
              __pyx_v_need_quoting = 0;

              /* "asyncpg/protocol/codecs/array.pyx":207
 *                         need_quoting = False
 * 
 *                         for i in range(elem_len):             # <<<<<<<<<<<<<<
 *                             ch = elem_str[i]
 *                             if ch == b'"' or ch == b'\\':
 */
              __pyx_t_26 = __pyx_v_elem_len;
              for (__pyx_t_27 = 0; __pyx_t_27 < __pyx_t_26; __pyx_t_27+=1) {
                __pyx_v_i = __pyx_t_27;

                /* "asyncpg/protocol/codecs/array.pyx":208
 * 
 *                         for i in range(elem_len):
 *                             ch = elem_str[i]             # <<<<<<<<<<<<<<
 *                             if ch == b'"' or ch == b'\\':
 *                                 # Quotes and backslashes need escaping.
 */
                __pyx_v_ch = (__pyx_v_elem_str[__pyx_v_i]);

                /* "asyncpg/protocol/codecs/array.pyx":209
 *                         for i in range(elem_len):
 *                             ch = elem_str[i]
 *                             if ch == b'"' or ch == b'\\':             # <<<<<<<<<<<<<<
 *                                 # Quotes and backslashes need escaping.
 *                                 quoted_elem_len += 1
 */
                switch (__pyx_v_ch) {
                  case '"':
                  case '\\':
                  __pyx_t_6 = 1;
                  break;
                  default:
                  __pyx_t_6 = 0;
                  break;
                }
                if (__pyx_t_6) {

                  /* "asyncpg/protocol/codecs/array.pyx":211
 *                             if ch == b'"' or ch == b'\\':
 *                                 # Quotes and backslashes need escaping.
 *                                 quoted_elem_len += 1             # <<<<<<<<<<<<<<
 *                                 need_quoting = True
 *                             elif (ch == b'{' or ch == b'}' or ch == delim or
 */
                  __pyx_v_quoted_elem_len = (__pyx_v_quoted_elem_len + 1);

                  /* "asyncpg/protocol/codecs/array.pyx":212
 *                                 # Quotes and backslashes need escaping.
 *                                 quoted_elem_len += 1
 *                                 need_quoting = True             # <<<<<<<<<<<<<<
 *                             elif (ch == b'{' or ch == b'}' or ch == delim or
 *                                     apg_ascii_isspace(<uint32_t>ch)):
 */
                  __pyx_v_need_quoting = 1;

                  /* "asyncpg/protocol/codecs/array.pyx":209
 *                         for i in range(elem_len):
 *                             ch = elem_str[i]
 *                             if ch == b'"' or ch == b'\\':             # <<<<<<<<<<<<<<
 *                                 # Quotes and backslashes need escaping.
 *                                 quoted_elem_len += 1
 */
                  goto __pyx_L39;
                }

                /* "asyncpg/protocol/codecs/array.pyx":213
 *                                 quoted_elem_len += 1
 *                                 need_quoting = True
 *                             elif (ch == b'{' or ch == b'}' or ch == delim or             # <<<<<<<<<<<<<<
 *                                     apg_ascii_isspace(<uint32_t>ch)):
 *                                 need_quoting = True
 */
                __pyx_t_2 = ((__pyx_v_ch == '{') != 0);
                  if (!__pyx_t_2) {
                  } else {
                    __pyx_t_6 = __pyx_t_2;
                    goto __pyx_L40_bool_binop_done;
                  }
                __pyx_t_2 = ((__pyx_v_ch == '}') != 0);
                if (!__pyx_t_2) {
                } else {
                  __pyx_t_6 = __pyx_t_2;
                  goto __pyx_L40_bool_binop_done;
                }
                __pyx_t_2 = ((__pyx_v_ch == __pyx_v_delim) != 0);
                if (!__pyx_t_2) {
                } else {
                  __pyx_t_6 = __pyx_t_2;
                  goto __pyx_L40_bool_binop_done;
                }

                /* "asyncpg/protocol/codecs/array.pyx":214
 *                                 need_quoting = True
 *                             elif (ch == b'{' or ch == b'}' or ch == delim or
 *                                     apg_ascii_isspace(<uint32_t>ch)):             # <<<<<<<<<<<<<<
 *                                 need_quoting = True
 * 
 */
                __pyx_t_2 = (__pyx_f_7asyncpg_8protocol_8protocol_apg_ascii_isspace(((uint32_t)__pyx_v_ch)) != 0);
                __pyx_t_6 = __pyx_t_2;
                __pyx_L40_bool_binop_done:;

                /* "asyncpg/protocol/codecs/array.pyx":213
 *                                 quoted_elem_len += 1
 *                                 need_quoting = True
 *                             elif (ch == b'{' or ch == b'}' or ch == delim or             # <<<<<<<<<<<<<<
 *                                     apg_ascii_isspace(<uint32_t>ch)):
 *                                 need_quoting = True
 */
                if (__pyx_t_6) {

                  /* "asyncpg/protocol/codecs/array.pyx":215
 *                             elif (ch == b'{' or ch == b'}' or ch == delim or
 *                                     apg_ascii_isspace(<uint32_t>ch)):
 *                                 need_quoting = True             # <<<<<<<<<<<<<<
 * 
 *                         if need_quoting:
 */
                  __pyx_v_need_quoting = 1;

                  /* "asyncpg/protocol/codecs/array.pyx":213
 *                                 quoted_elem_len += 1
 *                                 need_quoting = True
 *                             elif (ch == b'{' or ch == b'}' or ch == delim or             # <<<<<<<<<<<<<<
 *                                     apg_ascii_isspace(<uint32_t>ch)):
 *                                 need_quoting = True
 */
                }
                __pyx_L39:;
              }

              /* "asyncpg/protocol/codecs/array.pyx":217
 *                                 need_quoting = True
 * 
 *                         if need_quoting:             # <<<<<<<<<<<<<<
 *                             array_data.write_byte(b'"')
 * 
 */
              __pyx_t_6 = (__pyx_v_need_quoting != 0);
              if (__pyx_t_6) {

                /* "asyncpg/protocol/codecs/array.pyx":218
 * 
 *                         if need_quoting:
 *                             array_data.write_byte(b'"')             # <<<<<<<<<<<<<<
 * 
 *                             if quoted_elem_len == elem_len:
 */
                __pyx_t_11 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(__pyx_v_array_data, '"'); if (unlikely(!__pyx_t_11)) __PYX_ERR(6, 218, __pyx_L34_error)
                __Pyx_GOTREF(__pyx_t_11);
                __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

                /* "asyncpg/protocol/codecs/array.pyx":220
 *                             array_data.write_byte(b'"')
 * 
 *                             if quoted_elem_len == elem_len:             # <<<<<<<<<<<<<<
 *                                 array_data.write_cstr(elem_str, elem_len)
 *                             else:
 */
                __pyx_t_6 = ((__pyx_v_quoted_elem_len == __pyx_v_elem_len) != 0);
                if (__pyx_t_6) {

                  /* "asyncpg/protocol/codecs/array.pyx":221
 * 
 *                             if quoted_elem_len == elem_len:
 *                                 array_data.write_cstr(elem_str, elem_len)             # <<<<<<<<<<<<<<
 *                             else:
 *                                 # Escaping required.
 */
                  __pyx_t_11 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_cstr(__pyx_v_array_data, __pyx_v_elem_str, __pyx_v_elem_len); if (unlikely(!__pyx_t_11)) __PYX_ERR(6, 221, __pyx_L34_error)
                  __Pyx_GOTREF(__pyx_t_11);
                  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

                  /* "asyncpg/protocol/codecs/array.pyx":220
 *                             array_data.write_byte(b'"')
 * 
 *                             if quoted_elem_len == elem_len:             # <<<<<<<<<<<<<<
 *                                 array_data.write_cstr(elem_str, elem_len)
 *                             else:
 */
                  goto __pyx_L45;
                }

                /* "asyncpg/protocol/codecs/array.pyx":224
 *                             else:
 *                                 # Escaping required.
 *                                 for i in range(elem_len):             # <<<<<<<<<<<<<<
 *                                     ch = elem_str[i]
 *                                     if ch == b'"' or ch == b'\\':
 */
                /*else*/ {
                  __pyx_t_26 = __pyx_v_elem_len;
                  for (__pyx_t_27 = 0; __pyx_t_27 < __pyx_t_26; __pyx_t_27+=1) {
                    __pyx_v_i = __pyx_t_27;

                    /* "asyncpg/protocol/codecs/array.pyx":225
 *                                 # Escaping required.
 *                                 for i in range(elem_len):
 *                                     ch = elem_str[i]             # <<<<<<<<<<<<<<
 *                                     if ch == b'"' or ch == b'\\':
 *                                         array_data.write_byte(b'\\')
 */
                    __pyx_v_ch = (__pyx_v_elem_str[__pyx_v_i]);

                    /* "asyncpg/protocol/codecs/array.pyx":226
 *                                 for i in range(elem_len):
 *                                     ch = elem_str[i]
 *                                     if ch == b'"' or ch == b'\\':             # <<<<<<<<<<<<<<
 *                                         array_data.write_byte(b'\\')
 *                                     array_data.write_byte(ch)
 */
                    switch (__pyx_v_ch) {
                      case '"':
                      case '\\':

                      /* "asyncpg/protocol/codecs/array.pyx":227
 *                                     ch = elem_str[i]
 *                                     if ch == b'"' or ch == b'\\':
 *                                         array_data.write_byte(b'\\')             # <<<<<<<<<<<<<<
 *                                     array_data.write_byte(ch)
 * 
 */
                      __pyx_t_11 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(__pyx_v_array_data, '\\'); if (unlikely(!__pyx_t_11)) __PYX_ERR(6, 227, __pyx_L34_error)
                      __Pyx_GOTREF(__pyx_t_11);
                      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

                      /* "asyncpg/protocol/codecs/array.pyx":226
 *                                 for i in range(elem_len):
 *                                     ch = elem_str[i]
 *                                     if ch == b'"' or ch == b'\\':             # <<<<<<<<<<<<<<
 *                                         array_data.write_byte(b'\\')
 *                                     array_data.write_byte(ch)
 */
                      break;
                      default: break;
                    }

                    /* "asyncpg/protocol/codecs/array.pyx":228
 *                                     if ch == b'"' or ch == b'\\':
 *                                         array_data.write_byte(b'\\')
 *                                     array_data.write_byte(ch)             # <<<<<<<<<<<<<<
 * 
 *                             array_data.write_byte(b'"')
 */
                    __pyx_t_11 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(__pyx_v_array_data, __pyx_v_ch); if (unlikely(!__pyx_t_11)) __PYX_ERR(6, 228, __pyx_L34_error)
                    __Pyx_GOTREF(__pyx_t_11);
                    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
                  }
                }
                __pyx_L45:;

                /* "asyncpg/protocol/codecs/array.pyx":230
 *                                     array_data.write_byte(ch)
 * 
 *                             array_data.write_byte(b'"')             # <<<<<<<<<<<<<<
 *                         else:
 *                             array_data.write_cstr(elem_str, elem_len)
 */
                __pyx_t_11 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(__pyx_v_array_data, '"'); if (unlikely(!__pyx_t_11)) __PYX_ERR(6, 230, __pyx_L34_error)
                __Pyx_GOTREF(__pyx_t_11);
                __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

                /* "asyncpg/protocol/codecs/array.pyx":217
 *                                 need_quoting = True
 * 
 *                         if need_quoting:             # <<<<<<<<<<<<<<
 *                             array_data.write_byte(b'"')
 * 
 */
                goto __pyx_L44;
              }

              /* "asyncpg/protocol/codecs/array.pyx":232
 *                             array_data.write_byte(b'"')
 *                         else:
 *                             array_data.write_cstr(elem_str, elem_len)             # <<<<<<<<<<<<<<
 *                 finally:
 *                     cpython.PyBuffer_Release(&pybuf)
 */
              /*else*/ {
                __pyx_t_11 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_cstr(__pyx_v_array_data, __pyx_v_elem_str, __pyx_v_elem_len); if (unlikely(!__pyx_t_11)) __PYX_ERR(6, 232, __pyx_L34_error)
                __Pyx_GOTREF(__pyx_t_11);
                __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
              }
              __pyx_L44:;
            }
            __pyx_L36:;
          }

          /* "asyncpg/protocol/codecs/array.pyx":234
 *                             array_data.write_cstr(elem_str, elem_len)
 *                 finally:
 *                     cpython.PyBuffer_Release(&pybuf)             # <<<<<<<<<<<<<<
 * 
 *             i += 1
 */
          /*finally:*/ {
            /*normal exit:*/{
              PyBuffer_Release((&__pyx_v_pybuf));
              goto __pyx_L35;
            }
            __pyx_L34_error:;
            /*exception exit:*/{
              __Pyx_PyThreadState_declare
              __Pyx_PyThreadState_assign
              __pyx_t_9 = 0; __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0;
              __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;
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
              if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_25, &__pyx_t_24, &__pyx_t_23);
              if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7);
              __Pyx_XGOTREF(__pyx_t_9);
              __Pyx_XGOTREF(__pyx_t_8);
              __Pyx_XGOTREF(__pyx_t_7);
              __Pyx_XGOTREF(__pyx_t_25);
              __Pyx_XGOTREF(__pyx_t_24);
              __Pyx_XGOTREF(__pyx_t_23);
              __pyx_t_18 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_28 = __pyx_filename;
              {
                PyBuffer_Release((&__pyx_v_pybuf));
              }
              if (PY_MAJOR_VERSION >= 3) {
                __Pyx_XGIVEREF(__pyx_t_25);
                __Pyx_XGIVEREF(__pyx_t_24);
                __Pyx_XGIVEREF(__pyx_t_23);
                __Pyx_ExceptionReset(__pyx_t_25, __pyx_t_24, __pyx_t_23);
              }
              __Pyx_XGIVEREF(__pyx_t_9);
              __Pyx_XGIVEREF(__pyx_t_8);
              __Pyx_XGIVEREF(__pyx_t_7);
              __Pyx_ErrRestore(__pyx_t_9, __pyx_t_8, __pyx_t_7);
              __pyx_t_9 = 0; __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0;
              __pyx_lineno = __pyx_t_18; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_28;
              goto __pyx_L1_error;
            }
            __pyx_L35:;
          }
        }
        __pyx_L30:;

        /* "asyncpg/protocol/codecs/array.pyx":236
 *                     cpython.PyBuffer_Release(&pybuf)
 * 
 *             i += 1             # <<<<<<<<<<<<<<
 * 
 *     array_data.write_byte(b'}')
 */
        __pyx_v_i = (__pyx_v_i + 1);

        /* "asyncpg/protocol/codecs/array.pyx":169
 *             i += 1
 *     else:
 *         for item in obj:             # <<<<<<<<<<<<<<
 *             elem_data = WriteBuffer.new()
 * 
 */
        __pyx_L7_continue:;
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __pyx_L3:;

    /* "asyncpg/protocol/codecs/array.pyx":238
 *             i += 1
 * 
 *     array_data.write_byte(b'}')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_byte(__pyx_v_array_data, '}'); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 238, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/array.pyx":143
 * 
 * 
 * cdef _write_textarray_data(ConnectionSettings settings, object obj,             # <<<<<<<<<<<<<<
 *                            int32_t ndims, int32_t dim, WriteBuffer array_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_1);
  __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_textarray_data", __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":241
 * 
 * 
 * cdef inline textarray_encode(ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
 *                              object obj, encode_func_ex encoder,
 *                              const void *encoder_arg, Py_UCS4 typdelim):
 */

static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_textarray_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, __pyx_t_7asyncpg_8protocol_8protocol_encode_func_ex __pyx_v_encoder, void const *__pyx_v_encoder_arg, Py_UCS4 __pyx_v_typdelim) {
  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_array_data = 0;
  int32_t __pyx_v_dims[6];
  int32_t __pyx_v_ndims;
  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;
  __Pyx_RefNannySetupContext("textarray_encode", 0);

  /* "asyncpg/protocol/codecs/array.pyx":247
 *         WriteBuffer array_data
 *         int32_t dims[ARRAY_MAXDIM]
 *         int32_t ndims = 1             # <<<<<<<<<<<<<<
 *         int32_t i
 * 
 */
  __pyx_v_ndims = 1;

  /* "asyncpg/protocol/codecs/array.pyx":250
 *         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(6, 250, __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(6, 250, __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":252
 *     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(6, 252, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);

    /* "asyncpg/protocol/codecs/array.pyx":253
 *         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(6, 253, __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(6, 252, __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(6, 252, __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(6, 252, __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(6, 252, __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(6, 252, __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":251
 * 
 *     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(6, 251, __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(6, 251, __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(6, 251, __pyx_L1_error)

    /* "asyncpg/protocol/codecs/array.pyx":250
 *         int32_t i
 * 
 *     if not _is_container(obj):             # <<<<<<<<<<<<<<
 *         raise TypeError(
 *             'a non-trivial iterable expected (got type {!r})'.format(
 */
  }

  /* "asyncpg/protocol/codecs/array.pyx":255
 *                 type(obj).__name__))
 * 
 *     _get_array_shape(obj, dims, &ndims)             # <<<<<<<<<<<<<<
 * 
 *     array_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(6, 255, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/array.pyx":257
 *     _get_array_shape(obj, dims, &ndims)
 * 
 *     array_data = WriteBuffer.new()             # <<<<<<<<<<<<<<
 *     _write_textarray_data(settings, obj, ndims, 0, array_data,
 *                           encoder, encoder_arg, typdelim)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new()); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 257, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_array_data = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/array.pyx":258
 * 
 *     array_data = WriteBuffer.new()
 *     _write_textarray_data(settings, obj, ndims, 0, array_data,             # <<<<<<<<<<<<<<
 *                           encoder, encoder_arg, typdelim)
 *     buf.write_int32(array_data.len())
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol__write_textarray_data(__pyx_v_settings, __pyx_v_obj, __pyx_v_ndims, 0, __pyx_v_array_data, __pyx_v_encoder, __pyx_v_encoder_arg, __pyx_v_typdelim); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 258, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/array.pyx":260
 *     _write_textarray_data(settings, obj, ndims, 0, array_data,
 *                           encoder, encoder_arg, typdelim)
 *     buf.write_int32(array_data.len())             # <<<<<<<<<<<<<<
 *     buf.write_buffer(array_data)
 * 
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_len(__pyx_v_array_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 260, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = __Pyx_PyInt_As_int32_t(__pyx_t_1); if (unlikely((__pyx_t_8 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(6, 260, __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_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 260, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/array.pyx":261
 *                           encoder, encoder_arg, typdelim)
 *     buf.write_int32(array_data.len())
 *     buf.write_buffer(array_data)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_buffer(__pyx_v_buf, __pyx_v_array_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 261, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/array.pyx":241
 * 
 * 
 * cdef inline textarray_encode(ConnectionSettings settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
 *                              object obj, encode_func_ex encoder,
 *                              const void *encoder_arg, Py_UCS4 typdelim):
 */

  /* 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_AddTraceback("asyncpg.protocol.protocol.textarray_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_array_data);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/codecs/array.pyx":264
 * 
 * 
 * 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;
  CYTHON_UNUSED 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];
  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;
  int32_t __pyx_t_9;
  __Pyx_RefNannySetupContext("array_decode", 0);

  /* "asyncpg/protocol/codecs/array.pyx":267
 *                          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 == ((char const *)NULL))) __PYX_ERR(6, 267, __pyx_L1_error)
  __pyx_v_ndims = unpack_int32(__pyx_t_1);

  /* "asyncpg/protocol/codecs/array.pyx":268
 *     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 == ((char const *)NULL))) __PYX_ERR(6, 268, __pyx_L1_error)
  __pyx_v_flags = unpack_int32(__pyx_t_1);

  /* "asyncpg/protocol/codecs/array.pyx":269
 *         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 == ((char const *)NULL))) __PYX_ERR(6, 269, __pyx_L1_error)
  __pyx_v_elem_oid = ((uint32_t)unpack_int32(__pyx_t_1));

  /* "asyncpg/protocol/codecs/array.pyx":273
 *         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":274
 *         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(6, 274, __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":278
 *         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":279
 * 
 *     if ndims == 0:
 *         result = cpython.PyList_New(0)             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(6, 279, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_result = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "asyncpg/protocol/codecs/array.pyx":280
 *     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":278
 *         Codec elem_codec
 * 
 *     if ndims == 0:             # <<<<<<<<<<<<<<
 *         result = cpython.PyList_New(0)
 *         return result
 */
  }

  /* "asyncpg/protocol/codecs/array.pyx":282
 *         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":284
 *     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(6, 284, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);

    /* "asyncpg/protocol/codecs/array.pyx":285
 *         raise RuntimeError(
 *             'number of array dimensions ({}) exceed the maximum expected ({})'.
 *             format(ndims, ARRAY_MAXDIM))             # <<<<<<<<<<<<<<
 * 
 *     for i in range(ndims):
 */
    __pyx_t_5 = __Pyx_PyInt_From_int32_t(__pyx_v_ndims); if (unlikely(!__pyx_t_5)) __PYX_ERR(6, 285, __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(6, 285, __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(6, 285, __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(6, 285, __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(6, 285, __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":283
 * 
 *     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(6, 283, __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(6, 283, __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(6, 283, __pyx_L1_error)

    /* "asyncpg/protocol/codecs/array.pyx":282
 *         return result
 * 
 *     if ndims > ARRAY_MAXDIM:             # <<<<<<<<<<<<<<
 *         raise RuntimeError(
 *             'number of array dimensions ({}) exceed the maximum expected ({})'.
 */
  }

  /* "asyncpg/protocol/codecs/array.pyx":287
 *             format(ndims, ARRAY_MAXDIM))
 * 
 *     for i in range(ndims):             # <<<<<<<<<<<<<<
 *         dims[i] = hton.unpack_int32(buf.read(4))
 *         # Ignore the lower bound information
 */
  __pyx_t_9 = __pyx_v_ndims;
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_9; __pyx_t_7+=1) {
    __pyx_v_i = __pyx_t_7;

    /* "asyncpg/protocol/codecs/array.pyx":288
 * 
 *     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 == ((char const *)NULL))) __PYX_ERR(6, 288, __pyx_L1_error)
    (__pyx_v_dims[__pyx_v_i]) = unpack_int32(__pyx_t_1);

    /* "asyncpg/protocol/codecs/array.pyx":290
 *         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 == ((char const *)NULL))) __PYX_ERR(6, 290, __pyx_L1_error)
  }

  /* "asyncpg/protocol/codecs/array.pyx":292
 *         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":294
 *     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":295
 *         # 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(6, 295, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_result = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "asyncpg/protocol/codecs/array.pyx":297
 *         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_9 = __pyx_v_elem_count;
    for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_9; __pyx_t_7+=1) {
      __pyx_v_i = __pyx_t_7;

      /* "asyncpg/protocol/codecs/array.pyx":298
 * 
 *         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 == ((char const *)NULL))) __PYX_ERR(6, 298, __pyx_L1_error)
      __pyx_v_elem_len = unpack_int32(__pyx_t_1);

      /* "asyncpg/protocol/codecs/array.pyx":299
 *         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":300
 *             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":299
 *         for i in range(elem_count):
 *             elem_len = hton.unpack_int32(buf.read(4))
 *             if elem_len == -1:             # <<<<<<<<<<<<<<
 *                 elem = None
 *             else:
 */
        goto __pyx_L10;
      }

      /* "asyncpg/protocol/codecs/array.pyx":302
 *                 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(6, 302, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "asyncpg/protocol/codecs/array.pyx":303
 *             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(6, 303, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_XDECREF_SET(__pyx_v_elem, __pyx_t_2);
        __pyx_t_2 = 0;
      }
      __pyx_L10:;

      /* "asyncpg/protocol/codecs/array.pyx":305
 *                 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":306
 * 
 *             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":292
 *         buf.read(4)
 * 
 *     if ndims == 1:             # <<<<<<<<<<<<<<
 *         # Fast path for flat arrays
 *         elem_count = dims[0]
 */
    goto __pyx_L7;
  }

  /* "asyncpg/protocol/codecs/array.pyx":309
 * 
 *     else:
 *         result = _nested_array_decode(settings, buf,             # <<<<<<<<<<<<<<
 *                                       decoder, decoder_arg, ndims, dims,
 *                                       elem_buf)
 */
  /*else*/ {

    /* "asyncpg/protocol/codecs/array.pyx":311
 *         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(6, 309, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);

    /* "asyncpg/protocol/codecs/array.pyx":309
 * 
 *     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(6, 309, __pyx_L1_error)
    __pyx_v_result = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;
  }
  __pyx_L7:;

  /* "asyncpg/protocol/codecs/array.pyx":313
 *                                       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":264
 * 
 * 
 * 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(__pyx_v_elem);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/codecs/array.pyx":316
 * 
 * 
 * cdef _nested_array_decode(ConnectionSettings settings,             # <<<<<<<<<<<<<<
 *                           FastReadBuffer buf,
 *                           decode_func_ex decoder,
 */

static 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;
  int64_t __pyx_v_i;
  int64_t __pyx_v_j;
  int64_t __pyx_v_array_len;
  PyObject *__pyx_v_elem = 0;
  PyObject *__pyx_v_stride = 0;
  void *__pyx_v_strides[6];
  int32_t __pyx_v_indexes[6];
  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;
  int32_t __pyx_t_7;
  int64_t __pyx_t_8;
  int64_t __pyx_t_9;
  char const *__pyx_t_10;
  int64_t __pyx_t_11;
  int64_t __pyx_t_12;
  int __pyx_t_13;
  __Pyx_RefNannySetupContext("_nested_array_decode", 0);

  /* "asyncpg/protocol/codecs/array.pyx":326
 *         int32_t elem_len
 *         int64_t i, j
 *         int64_t array_len = 1             # <<<<<<<<<<<<<<
 *         object elem, stride
 *         # An array of pointers to lists for each current array level.
 */
  __pyx_v_array_len = 1;

  /* "asyncpg/protocol/codecs/array.pyx":333
 *         int32_t indexes[ARRAY_MAXDIM]
 * 
 *     if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
 *         if ndims <= 0:
 *             raise RuntimeError('unexpected ndims value: {}'.format(ndims))
 */
  __pyx_t_1 = (ASYNCPG_DEBUG != 0);
  if (__pyx_t_1) {

    /* "asyncpg/protocol/codecs/array.pyx":334
 * 
 *     if ASYNCPG_DEBUG:
 *         if ndims <= 0:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('unexpected ndims value: {}'.format(ndims))
 * 
 */
    __pyx_t_1 = ((__pyx_v_ndims <= 0) != 0);
    if (__pyx_t_1) {

      /* "asyncpg/protocol/codecs/array.pyx":335
 *     if ASYNCPG_DEBUG:
 *         if ndims <= 0:
 *             raise RuntimeError('unexpected ndims value: {}'.format(ndims))             # <<<<<<<<<<<<<<
 * 
 *     for i in range(ndims):
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_unexpected_ndims_value, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(6, 335, __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(6, 335, __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(6, 335, __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(6, 335, __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(6, 335, __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(6, 335, __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(6, 335, __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_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(6, 335, __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(6, 335, __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(6, 335, __pyx_L1_error)

      /* "asyncpg/protocol/codecs/array.pyx":334
 * 
 *     if ASYNCPG_DEBUG:
 *         if ndims <= 0:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('unexpected ndims value: {}'.format(ndims))
 * 
 */
    }

    /* "asyncpg/protocol/codecs/array.pyx":333
 *         int32_t indexes[ARRAY_MAXDIM]
 * 
 *     if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
 *         if ndims <= 0:
 *             raise RuntimeError('unexpected ndims value: {}'.format(ndims))
 */
  }

  /* "asyncpg/protocol/codecs/array.pyx":337
 *             raise RuntimeError('unexpected ndims value: {}'.format(ndims))
 * 
 *     for i in range(ndims):             # <<<<<<<<<<<<<<
 *         array_len *= dims[i]
 *         indexes[i] = 0
 */
  __pyx_t_7 = __pyx_v_ndims;
  for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
    __pyx_v_i = __pyx_t_8;

    /* "asyncpg/protocol/codecs/array.pyx":338
 * 
 *     for i in range(ndims):
 *         array_len *= dims[i]             # <<<<<<<<<<<<<<
 *         indexes[i] = 0
 * 
 */
    __pyx_v_array_len = (__pyx_v_array_len * (__pyx_v_dims[__pyx_v_i]));

    /* "asyncpg/protocol/codecs/array.pyx":339
 *     for i in range(ndims):
 *         array_len *= dims[i]
 *         indexes[i] = 0             # <<<<<<<<<<<<<<
 * 
 *     for i in range(array_len):
 */
    (__pyx_v_indexes[__pyx_v_i]) = 0;
  }

  /* "asyncpg/protocol/codecs/array.pyx":341
 *         indexes[i] = 0
 * 
 *     for i in range(array_len):             # <<<<<<<<<<<<<<
 *         # Decode the element.
 *         elem_len = hton.unpack_int32(buf.read(4))
 */
  __pyx_t_8 = __pyx_v_array_len;
  for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
    __pyx_v_i = __pyx_t_9;

    /* "asyncpg/protocol/codecs/array.pyx":343
 *     for i in range(array_len):
 *         # Decode the element.
 *         elem_len = hton.unpack_int32(buf.read(4))             # <<<<<<<<<<<<<<
 *         if elem_len == -1:
 *             elem = None
 */
    __pyx_t_10 = __pyx_f_7asyncpg_8protocol_8protocol_14FastReadBuffer_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_10 == ((char const *)NULL))) __PYX_ERR(6, 343, __pyx_L1_error)
    __pyx_v_elem_len = unpack_int32(__pyx_t_10);

    /* "asyncpg/protocol/codecs/array.pyx":344
 *         # Decode the element.
 *         elem_len = hton.unpack_int32(buf.read(4))
 *         if elem_len == -1:             # <<<<<<<<<<<<<<
 *             elem = None
 *         else:
 */
    __pyx_t_1 = ((__pyx_v_elem_len == -1L) != 0);
    if (__pyx_t_1) {

      /* "asyncpg/protocol/codecs/array.pyx":345
 *         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":344
 *         # Decode the element.
 *         elem_len = hton.unpack_int32(buf.read(4))
 *         if elem_len == -1:             # <<<<<<<<<<<<<<
 *             elem = None
 *         else:
 */
      goto __pyx_L9;
    }

    /* "asyncpg/protocol/codecs/array.pyx":347
 *             elem = None
 *         else:
 *             elem = decoder(settings,             # <<<<<<<<<<<<<<
 *                            elem_buf.slice_from(buf, elem_len),
 *                            decoder_arg)
 */
    /*else*/ {

      /* "asyncpg/protocol/codecs/array.pyx":348
 *         else:
 *             elem = decoder(settings,
 *                            elem_buf.slice_from(buf, elem_len),             # <<<<<<<<<<<<<<
 *                            decoder_arg)
 * 
 */
      __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(6, 348, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);

      /* "asyncpg/protocol/codecs/array.pyx":347
 *             elem = None
 *         else:
 *             elem = decoder(settings,             # <<<<<<<<<<<<<<
 *                            elem_buf.slice_from(buf, elem_len),
 *                            decoder_arg)
 */
      __pyx_t_3 = __pyx_v_decoder(__pyx_v_settings, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *)__pyx_t_2), __pyx_v_decoder_arg); if (unlikely(!__pyx_t_3)) __PYX_ERR(6, 347, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF_SET(__pyx_v_elem, __pyx_t_3);
      __pyx_t_3 = 0;
    }
    __pyx_L9:;

    /* "asyncpg/protocol/codecs/array.pyx":353
 *         # Take an explicit reference for PyList_SET_ITEM in the below
 *         # loop expects this.
 *         cpython.Py_INCREF(elem)             # <<<<<<<<<<<<<<
 * 
 *         # Iterate over array dimentions and put the element in
 */
    Py_INCREF(__pyx_v_elem);

    /* "asyncpg/protocol/codecs/array.pyx":357
 *         # Iterate over array dimentions and put the element in
 *         # the correctly nested sublist.
 *         for j in reversed(range(ndims)):             # <<<<<<<<<<<<<<
 *             if indexes[j] == 0:
 *                 # Allocate the list for this array level.
 */
    for (__pyx_t_11 = __pyx_v_ndims-1; __pyx_t_11 >= 0; __pyx_t_11-=1) {
      __pyx_v_j = __pyx_t_11;

      /* "asyncpg/protocol/codecs/array.pyx":358
 *         # the correctly nested sublist.
 *         for j in reversed(range(ndims)):
 *             if indexes[j] == 0:             # <<<<<<<<<<<<<<
 *                 # Allocate the list for this array level.
 *                 stride = cpython.PyList_New(dims[j])
 */
      __pyx_t_1 = (((__pyx_v_indexes[__pyx_v_j]) == 0) != 0);
      if (__pyx_t_1) {

        /* "asyncpg/protocol/codecs/array.pyx":360
 *             if indexes[j] == 0:
 *                 # Allocate the list for this array level.
 *                 stride = cpython.PyList_New(dims[j])             # <<<<<<<<<<<<<<
 * 
 *                 strides[j] = <void*><cpython.PyObject>stride
 */
        __pyx_t_3 = PyList_New((__pyx_v_dims[__pyx_v_j])); if (unlikely(!__pyx_t_3)) __PYX_ERR(6, 360, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_XDECREF_SET(__pyx_v_stride, __pyx_t_3);
        __pyx_t_3 = 0;

        /* "asyncpg/protocol/codecs/array.pyx":362
 *                 stride = cpython.PyList_New(dims[j])
 * 
 *                 strides[j] = <void*><cpython.PyObject>stride             # <<<<<<<<<<<<<<
 *                 # Take an explicit reference for PyList_SET_ITEM below
 *                 # expects this.
 */
        (__pyx_v_strides[__pyx_v_j]) = ((void *)__pyx_v_stride);

        /* "asyncpg/protocol/codecs/array.pyx":365
 *                 # Take an explicit reference for PyList_SET_ITEM below
 *                 # expects this.
 *                 cpython.Py_INCREF(stride)             # <<<<<<<<<<<<<<
 * 
 *             stride = <object><cpython.PyObject*>strides[j]
 */
        Py_INCREF(__pyx_v_stride);

        /* "asyncpg/protocol/codecs/array.pyx":358
 *         # the correctly nested sublist.
 *         for j in reversed(range(ndims)):
 *             if indexes[j] == 0:             # <<<<<<<<<<<<<<
 *                 # Allocate the list for this array level.
 *                 stride = cpython.PyList_New(dims[j])
 */
      }

      /* "asyncpg/protocol/codecs/array.pyx":367
 *                 cpython.Py_INCREF(stride)
 * 
 *             stride = <object><cpython.PyObject*>strides[j]             # <<<<<<<<<<<<<<
 *             cpython.PyList_SET_ITEM(stride, indexes[j], elem)
 *             indexes[j] += 1
 */
      __pyx_t_3 = ((PyObject *)((PyObject *)(__pyx_v_strides[__pyx_v_j])));
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_XDECREF_SET(__pyx_v_stride, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "asyncpg/protocol/codecs/array.pyx":368
 * 
 *             stride = <object><cpython.PyObject*>strides[j]
 *             cpython.PyList_SET_ITEM(stride, indexes[j], elem)             # <<<<<<<<<<<<<<
 *             indexes[j] += 1
 * 
 */
      PyList_SET_ITEM(__pyx_v_stride, (__pyx_v_indexes[__pyx_v_j]), __pyx_v_elem);

      /* "asyncpg/protocol/codecs/array.pyx":369
 *             stride = <object><cpython.PyObject*>strides[j]
 *             cpython.PyList_SET_ITEM(stride, indexes[j], elem)
 *             indexes[j] += 1             # <<<<<<<<<<<<<<
 * 
 *             if indexes[j] == dims[j] and j != 0:
 */
      __pyx_t_12 = __pyx_v_j;
      (__pyx_v_indexes[__pyx_t_12]) = ((__pyx_v_indexes[__pyx_t_12]) + 1);

      /* "asyncpg/protocol/codecs/array.pyx":371
 *             indexes[j] += 1
 * 
 *             if indexes[j] == dims[j] and j != 0:             # <<<<<<<<<<<<<<
 *                 # This array level is full, continue the
 *                 # ascent in the dimensions so that this level
 */
      __pyx_t_13 = (((__pyx_v_indexes[__pyx_v_j]) == (__pyx_v_dims[__pyx_v_j])) != 0);
      if (__pyx_t_13) {
      } else {
        __pyx_t_1 = __pyx_t_13;
        goto __pyx_L14_bool_binop_done;
      }
      __pyx_t_13 = ((__pyx_v_j != 0) != 0);
      __pyx_t_1 = __pyx_t_13;
      __pyx_L14_bool_binop_done:;
      if (__pyx_t_1) {

        /* "asyncpg/protocol/codecs/array.pyx":375
 *                 # ascent in the dimensions so that this level
 *                 # sublist will be appened to the parent list.
 *                 elem = stride             # <<<<<<<<<<<<<<
 *                 # Reset the index, this will cause the
 *                 # new list to be allocated on the next
 */
        __Pyx_INCREF(__pyx_v_stride);
        __Pyx_DECREF_SET(__pyx_v_elem, __pyx_v_stride);

        /* "asyncpg/protocol/codecs/array.pyx":379
 *                 # new list to be allocated on the next
 *                 # iteration on this array axis.
 *                 indexes[j] = 0             # <<<<<<<<<<<<<<
 *             else:
 *                 break
 */
        (__pyx_v_indexes[__pyx_v_j]) = 0;

        /* "asyncpg/protocol/codecs/array.pyx":371
 *             indexes[j] += 1
 * 
 *             if indexes[j] == dims[j] and j != 0:             # <<<<<<<<<<<<<<
 *                 # This array level is full, continue the
 *                 # ascent in the dimensions so that this level
 */
        goto __pyx_L13;
      }

      /* "asyncpg/protocol/codecs/array.pyx":381
 *                 indexes[j] = 0
 *             else:
 *                 break             # <<<<<<<<<<<<<<
 * 
 *     stride = <object><cpython.PyObject*>strides[0]
 */
      /*else*/ {
        goto __pyx_L11_break;
      }
      __pyx_L13:;
    }
    __pyx_L11_break:;
  }

  /* "asyncpg/protocol/codecs/array.pyx":383
 *                 break
 * 
 *     stride = <object><cpython.PyObject*>strides[0]             # <<<<<<<<<<<<<<
 *     # Since each element in strides has a refcount of 1,
 *     # returning strides[0] will increment it to 2, so
 */
  __pyx_t_3 = ((PyObject *)((PyObject *)(__pyx_v_strides[0])));
  __Pyx_INCREF(__pyx_t_3);
  __Pyx_XDECREF_SET(__pyx_v_stride, __pyx_t_3);
  __pyx_t_3 = 0;

  /* "asyncpg/protocol/codecs/array.pyx":387
 *     # returning strides[0] will increment it to 2, so
 *     # balance that.
 *     cpython.Py_DECREF(stride)             # <<<<<<<<<<<<<<
 *     return stride
 * 
 */
  Py_DECREF(__pyx_v_stride);

  /* "asyncpg/protocol/codecs/array.pyx":388
 *     # balance that.
 *     cpython.Py_DECREF(stride)
 *     return stride             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_stride);
  __pyx_r = __pyx_v_stride;
  goto __pyx_L0;

  /* "asyncpg/protocol/codecs/array.pyx":316
 * 
 * 
 * cdef _nested_array_decode(ConnectionSettings settings,             # <<<<<<<<<<<<<<
 *                           FastReadBuffer buf,
 *                           decode_func_ex decoder,
 */

  /* 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_AddTraceback("asyncpg.protocol.protocol._nested_array_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_elem);
  __Pyx_XDECREF(__pyx_v_stride);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/codecs/array.pyx":391
 * 
 * 
 * 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":400
 *     # 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(6, 400, __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(6, 400, __pyx_L1_error)
  __pyx_v_s = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/array.pyx":401
 *     # 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":403
 *     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":404
 * 
 *     try:
 *         return _textarray_decode(             # <<<<<<<<<<<<<<
 *             settings, array_text, decoder, decoder_arg, typdelim)
 *     except ValueError as e:
 */
        __Pyx_XDECREF(__pyx_r);

        /* "asyncpg/protocol/codecs/array.pyx":405
 *     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(6, 404, __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":403
 *     array_text = PyUnicode_AsUCS4Copy(s)
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         return _textarray_decode(
 *             settings, array_text, decoder, decoder_arg, typdelim)
 */
      }
      __pyx_L6_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "asyncpg/protocol/codecs/array.pyx":406
 *         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(6, 406, __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":408
 *     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(6, 408, __pyx_L17_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(6, 408, __pyx_L17_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(6, 408, __pyx_L17_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(6, 408, __pyx_L17_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(6, 408, __pyx_L17_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(6, 408, __pyx_L17_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(6, 408, __pyx_L17_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":407
 *             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(6, 407, __pyx_L17_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(6, 407, __pyx_L17_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(6, 407, __pyx_L17_error)
        }

        /* "asyncpg/protocol/codecs/array.pyx":406
 *         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:*/ {
          __pyx_L17_error:;
          /*exception exit:*/{
            __Pyx_PyThreadState_declare
            __Pyx_PyThreadState_assign
            __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_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;
            }
            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":403
 *     array_text = PyUnicode_AsUCS4Copy(s)
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         return _textarray_decode(
 *             settings, array_text, decoder, decoder_arg, typdelim)
 */
      __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_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":410
 *             'malformed array literal {!r}: {}'.format(s, e.args[0]))
 *     finally:
 *         PyMem_Free(array_text)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*finally:*/ {
    __pyx_L4_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __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_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);
      }
      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":391
 * 
 * 
 * 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":413
 * 
 * 
 * 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":424
 *         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":425
 *         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":426
 *         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":429
 *         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":432
 *         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":433
 *         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":434
 *         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":436
 *         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":437
 * 
 *         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":438
 *         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":439
 *         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":447
 *         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(6, 447, __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":451
 *         ssize_t pg_item_len
 * 
 *     ptr = array_text             # <<<<<<<<<<<<<<
 * 
 *     while True:
 */
  __pyx_v_ptr = __pyx_v_array_text;

  /* "asyncpg/protocol/codecs/array.pyx":453
 *     ptr = array_text
 * 
 *     while True:             # <<<<<<<<<<<<<<
 *         while apg_ascii_isspace(ptr[0]):
 *             ptr += 1
 */
  while (1) {

    /* "asyncpg/protocol/codecs/array.pyx":454
 * 
 *     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":455
 *     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":457
 *             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":459
 *         if ptr[0] != '[':
 *             # Finished parsing dimensions spec.
 *             break             # <<<<<<<<<<<<<<
 * 
 *         ptr += 1  # '['
 */
      goto __pyx_L4_break;

      /* "asyncpg/protocol/codecs/array.pyx":457
 *             ptr += 1
 * 
 *         if ptr[0] != '[':             # <<<<<<<<<<<<<<
 *             # Finished parsing dimensions spec.
 *             break
 */
    }

    /* "asyncpg/protocol/codecs/array.pyx":461
 *             break
 * 
 *         ptr += 1  # '['             # <<<<<<<<<<<<<<
 * 
 *         if ndims > ARRAY_MAXDIM:
 */
    __pyx_v_ptr = (__pyx_v_ptr + 1);

    /* "asyncpg/protocol/codecs/array.pyx":463
 *         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":466
 *             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(6, 466, __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(6, 466, __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(6, 466, __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(6, 466, __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(6, 466, __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(6, 466, __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":464
 * 
 *         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(6, 464, __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(6, 464, __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(6, 464, __pyx_L1_error)

      /* "asyncpg/protocol/codecs/array.pyx":463
 *         ptr += 1  # '['
 * 
 *         if ndims > ARRAY_MAXDIM:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'number of array dimensions ({}) exceed the '
 */
    }

    /* "asyncpg/protocol/codecs/array.pyx":468
 *                 '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":469
 * 
 *         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":470
 *         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__65, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 470, __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(6, 470, __pyx_L1_error)

      /* "asyncpg/protocol/codecs/array.pyx":469
 * 
 *         ptr = apg_parse_int32(ptr, &ubound)
 *         if ptr == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError('missing array dimension value')
 * 
 */
    }

    /* "asyncpg/protocol/codecs/array.pyx":472
 *             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":473
 * 
 *         if ptr[0] == ':':
 *             ptr += 1             # <<<<<<<<<<<<<<
 *             lbound = ubound
 * 
 */
      __pyx_v_ptr = (__pyx_v_ptr + 1);

      /* "asyncpg/protocol/codecs/array.pyx":474
 *         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":477
 * 
 *             # [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":478
 *             # [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":479
 *             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__66, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 479, __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(6, 479, __pyx_L1_error)

        /* "asyncpg/protocol/codecs/array.pyx":478
 *             # [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":472
 *             raise ValueError('missing array dimension value')
 * 
 *         if ptr[0] == ':':             # <<<<<<<<<<<<<<
 *             ptr += 1
 *             lbound = ubound
 */
      goto __pyx_L10;
    }

    /* "asyncpg/protocol/codecs/array.pyx":481
 *                 raise ValueError('missing array dimension value')
 *         else:
 *             lbound = 1             # <<<<<<<<<<<<<<
 * 
 *         if ptr[0] != ']':
 */
    /*else*/ {
      __pyx_v_lbound = 1;
    }
    __pyx_L10:;

    /* "asyncpg/protocol/codecs/array.pyx":483
 *             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":484
 * 
 *         if ptr[0] != ']':
 *             raise ValueError('missing \']\' after array dimensions')             # <<<<<<<<<<<<<<
 * 
 *         ptr += 1  # ']'
 */
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__67, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 484, __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(6, 484, __pyx_L1_error)

      /* "asyncpg/protocol/codecs/array.pyx":483
 *             lbound = 1
 * 
 *         if ptr[0] != ']':             # <<<<<<<<<<<<<<
 *             raise ValueError('missing \']\' after array dimensions')
 * 
 */
    }

    /* "asyncpg/protocol/codecs/array.pyx":486
 *             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":488
 *         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":489
 * 
 *         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":491
 *         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":493
 *     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":494
 *         # 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__68, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 494, __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(6, 494, __pyx_L1_error)

      /* "asyncpg/protocol/codecs/array.pyx":493
 *     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":496
 *             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":500
 *         # 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":501
 *         # 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":506
 *         # 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(6, 506, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/codecs/array.pyx":508
 *         _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":509
 * 
 *         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__69, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 509, __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(6, 509, __pyx_L1_error)

      /* "asyncpg/protocol/codecs/array.pyx":508
 *         _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":512
 *                 '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":513
 * 
 *         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":514
 *         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__70, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 514, __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(6, 514, __pyx_L1_error)

        /* "asyncpg/protocol/codecs/array.pyx":513
 * 
 *         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":491
 *         ndims += 1
 * 
 *     if ndims != 0:             # <<<<<<<<<<<<<<
 *         # If dimensions were given, the '=' token is expected.
 *         if ptr[0] != '=':
 */
    goto __pyx_L13;
  }

  /* "asyncpg/protocol/codecs/array.pyx":519
 *         # 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(6, 519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L13:;

  /* "asyncpg/protocol/codecs/array.pyx":521
 *         _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":525
 *         # 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":526
 *         # 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":531
 *         # 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":532
 *         # 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":534
 *         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":535
 * 
 *         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":536
 *         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":537
 *             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":538
 *                 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":537
 *             if ptr[0] == '"':
 *                 in_quotes = not in_quotes
 *                 if in_quotes:             # <<<<<<<<<<<<<<
 *                     strip_spaces = False
 *                 else:
 */
          goto __pyx_L26;
        }

        /* "asyncpg/protocol/codecs/array.pyx":540
 *                     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":541
 *                 else:
 *                     item_end = item_ptr
 *                 has_quoting = True             # <<<<<<<<<<<<<<
 * 
 *             elif ptr[0] == '\\':
 */
        __pyx_v_has_quoting = 1;

        /* "asyncpg/protocol/codecs/array.pyx":535
 * 
 *         while not end_of_item:
 *             if ptr[0] == '"':             # <<<<<<<<<<<<<<
 *                 in_quotes = not in_quotes
 *                 if in_quotes:
 */
        goto __pyx_L25;
      }

      /* "asyncpg/protocol/codecs/array.pyx":543
 *                 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":545
 *             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":546
 *                 # 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":547
 *                 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":548
 *                 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":549
 *                 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":550
 *                 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":543
 *                 has_quoting = True
 * 
 *             elif ptr[0] == '\\':             # <<<<<<<<<<<<<<
 *                 # Quoted character, collapse the backslash.
 *                 ptr += 1
 */
        goto __pyx_L25;
      }

      /* "asyncpg/protocol/codecs/array.pyx":552
 *                 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":554
 *             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":555
 *                 # 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":552
 *                 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":557
 *                 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":559
 *             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":561
 *                 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":562
 * 
 *                 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(6, 562, __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":563
 *                 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":566
 *                     <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":567
 * 
 *                 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":569
 *                     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":568
 *                 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":566
 *                     <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":573
 *                         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":557
 *                 item_ptr += 1
 * 
 *             elif ptr[0] == '{':             # <<<<<<<<<<<<<<
 *                 # Nesting level increase.
 *                 nest_level += 1
 */
        goto __pyx_L25;
      }

      /* "asyncpg/protocol/codecs/array.pyx":575
 *                     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":576
 * 
 *             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":581
 *                     # 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":576
 * 
 *             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":583
 *                     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":585
 *                 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":586
 * 
 *                 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":585
 *                 nest_level -= 1
 * 
 *                 if nest_level == 0:             # <<<<<<<<<<<<<<
 *                     end_of_array = end_of_item = True
 * 
 */
        }

        /* "asyncpg/protocol/codecs/array.pyx":575
 *                     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":588
 *                     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":590
 *             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":591
 *                 # 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":592
 *                 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":591
 *                 # Array element delimiter,
 *                 end_of_item = True
 *                 if item_level == 0:             # <<<<<<<<<<<<<<
 *                     item_level = nest_level
 * 
 */
        }

        /* "asyncpg/protocol/codecs/array.pyx":588
 *                     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":594
 *                     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":595
 * 
 *             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":596
 *             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":597
 *                 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":595
 * 
 *             elif apg_ascii_isspace(ptr[0]):
 *                 if not strip_spaces:             # <<<<<<<<<<<<<<
 *                     item_ptr[0] = ptr[0]
 *                     item_ptr += 1
 */
        }

        /* "asyncpg/protocol/codecs/array.pyx":594
 *                     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":601
 * 
 *             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":602
 *             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":603
 *                 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":604
 *                 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":606
 *                 item_end = item_ptr
 * 
 *             ptr += 1             # <<<<<<<<<<<<<<
 * 
 *         # end while not end_of_item
 */
      __pyx_v_ptr = (__pyx_v_ptr + 1);
    }

    /* "asyncpg/protocol/codecs/array.pyx":610
 *         # 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":612
 *         if item_end == item_start:
 *             # Empty array
 *             continue             # <<<<<<<<<<<<<<
 * 
 *         item_end[0] = '\0'
 */
      goto __pyx_L21_continue;

      /* "asyncpg/protocol/codecs/array.pyx":610
 *         # end while not end_of_item
 * 
 *         if item_end == item_start:             # <<<<<<<<<<<<<<
 *             # Empty array
 *             continue
 */
    }

    /* "asyncpg/protocol/codecs/array.pyx":614
 *             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":616
 *         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":618
 *         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":616
 *         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":622
 *             # 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":625
 *                 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(6, 622, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);

      /* "asyncpg/protocol/codecs/array.pyx":622
 *             # 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(6, 622, __pyx_L1_error)
      __Pyx_XDECREF_SET(__pyx_v_item_text, ((PyObject*)__pyx_t_1));
      __pyx_t_1 = 0;

      /* "asyncpg/protocol/codecs/array.pyx":629
 *             # 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(6, 629, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "asyncpg/protocol/codecs/array.pyx":631
 *             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":632
 *                 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":633
 *             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(6, 633, __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":636
 * 
 *         # 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":638
 *         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":637
 *         # 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":642
 *             item)
 * 
 *         if nest_level > 0:             # <<<<<<<<<<<<<<
 *             indexes[nest_level - 1] += 1
 * 
 */
    __pyx_t_2 = ((__pyx_v_nest_level > 0) != 0);
    if (__pyx_t_2) {

      /* "asyncpg/protocol/codecs/array.pyx":643
 * 
 *         if nest_level > 0:
 *             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);

      /* "asyncpg/protocol/codecs/array.pyx":642
 *             item)
 * 
 *         if nest_level > 0:             # <<<<<<<<<<<<<<
 *             indexes[nest_level - 1] += 1
 * 
 */
    }
    __pyx_L21_continue:;
  }

  /* "asyncpg/protocol/codecs/array.pyx":645
 *             indexes[nest_level - 1] += 1
 * 
 *     return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(!__pyx_v_result)) { __Pyx_RaiseUnboundLocalError("result"); __PYX_ERR(6, 645, __pyx_L1_error) }
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "asyncpg/protocol/codecs/array.pyx":413
 * 
 * 
 * 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":657
 * 
 * 
 * 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":658
 * 
 * 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(6, 658, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "asyncpg/protocol/codecs/array.pyx":659
 * 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(6, 659, __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(6, 659, __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(6, 658, __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(6, 658, __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(6, 658, __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(6, 658, __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":658
 * 
 * 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(6, 658, __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(6, 658, __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":657
 * 
 * 
 * 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":662
 * 
 * 
 * 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":667
 *                        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":669
 *         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":670
 *         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":671
 *         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":672
 *         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":673
 *         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":676
 *         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":678
 *         _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":679
 * 
 *     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":680
 *     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":682
 *         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":683
 * 
 *     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":685
 *         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":686
 * 
 *         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":687
 *         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__71, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(6, 687, __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(6, 687, __pyx_L1_error)

        /* "asyncpg/protocol/codecs/array.pyx":686
 * 
 *         while not end_of_item:
 *             if ptr[0] == '\0':             # <<<<<<<<<<<<<<
 *                 raise ValueError('unexpected end of string')
 * 
 */
      }

      /* "asyncpg/protocol/codecs/array.pyx":689
 *                 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":690
 * 
 *             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":691
 *             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":690
 * 
 *             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":692
 *                 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":690
 * 
 *             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":693
 *                                         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(6, 693, __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(6, 693, __pyx_L1_error)

          /* "asyncpg/protocol/codecs/array.pyx":690
 * 
 *             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":695
 *                     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":696
 * 
 *                 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":697
 *                 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":698
 *                 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":696
 * 
 *                 in_quotes = not in_quotes
 *                 if in_quotes:             # <<<<<<<<<<<<<<
 *                     parse_state = APS_ELEM_STARTED
 *                     array_is_empty = False
 */
        }

        /* "asyncpg/protocol/codecs/array.pyx":689
 *                 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":700
 *                     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":701
 * 
 *             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":702
 *             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":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 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":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(6, 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(6, 704, __pyx_L1_error)

          /* "asyncpg/protocol/codecs/array.pyx":701
 * 
 *             elif 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 ptr[1] != '\0':
 */
        __pyx_v_array_is_empty = 0;

        /* "asyncpg/protocol/codecs/array.pyx":709
 *                 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":710
 * 
 *                 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":709
 *                 array_is_empty = False
 * 
 *                 if ptr[1] != '\0':             # <<<<<<<<<<<<<<
 *                     ptr += 1
 *                 else:
 */
          goto __pyx_L17;
        }

        /* "asyncpg/protocol/codecs/array.pyx":712
 *                     ptr += 1
 *                 else:
 *                     raise ValueError('unexpected end of string')             # <<<<<<<<<<<<<<
 * 
 *             elif in_quotes:
 */
        /*else*/ {
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__72, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(6, 712, __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(6, 712, __pyx_L1_error)
        }
        __pyx_L17:;

        /* "asyncpg/protocol/codecs/array.pyx":700
 *                     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":714
 *                     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":718
 *                 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":719
 * 
 *             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":720
 *             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":721
 *                 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":719
 * 
 *             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":722
 *                                        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(6, 722, __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(6, 722, __pyx_L1_error)

          /* "asyncpg/protocol/codecs/array.pyx":719
 * 
 *             elif ptr[0] == '{':
 *                 if parse_state not in (APS_START,             # <<<<<<<<<<<<<<
 *                                        APS_STRIDE_STARTED,
 *                                        APS_STRIDE_DELIMITED):
 */
        }

        /* "asyncpg/protocol/codecs/array.pyx":724
 *                     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":725
 * 
 *                 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":728
 *                     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(6, 728, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);

          /* "asyncpg/protocol/codecs/array.pyx":729
 *                         '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(6, 729, __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(6, 728, __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(6, 728, __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(6, 728, __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(6, 728, __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":726
 *                 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(6, 726, __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(6, 726, __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(6, 726, __pyx_L1_error)

          /* "asyncpg/protocol/codecs/array.pyx":725
 * 
 *                 parse_state = APS_STRIDE_STARTED
 *                 if nest_level >= ARRAY_MAXDIM:             # <<<<<<<<<<<<<<
 *                     raise ValueError(
 *                         'number of array dimensions ({}) exceed the '
 */
        }

        /* "asyncpg/protocol/codecs/array.pyx":731
 *                             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":732
 * 
 *                 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":733
 *                 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":734
 *                 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":733
 *                 dims[nest_level] = 0
 *                 nest_level += 1
 *                 if ndims[0] < nest_level:             # <<<<<<<<<<<<<<
 *                     ndims[0] = nest_level
 * 
 */
        }

        /* "asyncpg/protocol/codecs/array.pyx":718
 *                 pass
 * 
 *             elif ptr[0] == '{':             # <<<<<<<<<<<<<<
 *                 if parse_state not in (APS_START,
 *                                        APS_STRIDE_STARTED,
 */
        goto __pyx_L9;
      }

      /* "asyncpg/protocol/codecs/array.pyx":736
 *                     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":737
 * 
 *             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":738
 *             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":739
 *                 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":738
 *             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":737
 * 
 *             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":740
 *                         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(6, 740, __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(6, 740, __pyx_L1_error)

          /* "asyncpg/protocol/codecs/array.pyx":737
 * 
 *             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":742
 *                     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":744
 *                 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":745
 * 
 *                 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(6, 745, __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(6, 745, __pyx_L1_error)

          /* "asyncpg/protocol/codecs/array.pyx":744
 *                 parse_state = APS_STRIDE_DONE
 * 
 *                 if nest_level == 0:             # <<<<<<<<<<<<<<
 *                     raise _UnexpectedCharacter(array_text, ptr)
 * 
 */
        }

        /* "asyncpg/protocol/codecs/array.pyx":747
 *                     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":749
 *                 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":750
 * 
 *                 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":749
 *                 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":753
 *                     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(6, 753, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);

          /* "asyncpg/protocol/codecs/array.pyx":754
 *                         '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(6, 754, __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(6, 753, __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(6, 753, __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(6, 753, __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(6, 753, __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(6, 753, __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":751
 *                 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(6, 751, __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(6, 751, __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(6, 751, __pyx_L1_error)

          /* "asyncpg/protocol/codecs/array.pyx":749
 *                 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":756
 *                             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":757
 * 
 *                 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":758
 *                 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":759
 *                 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":758
 *                 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":761
 *                     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":736
 *                     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":763
 *                     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":764
 * 
 *             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":765
 *             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(6, 765, __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(6, 765, __pyx_L1_error)

          /* "asyncpg/protocol/codecs/array.pyx":764
 * 
 *             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":767
 *                     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":768
 * 
 *                 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":767
 *                     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":770
 *                     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":771
 *                 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":772
 *                     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":763
 *                     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":774
 *                 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":775
 * 
 *             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":776
 *             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":777
 *                 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":775
 * 
 *             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":778
 *                                        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(6, 778, __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(6, 778, __pyx_L1_error)

          /* "asyncpg/protocol/codecs/array.pyx":775
 * 
 *             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":780
 *                     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":781
 * 
 *                 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":774
 *                 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":783
 *                 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":784
 * 
 *             if not end_of_item:
 *                 ptr += 1             # <<<<<<<<<<<<<<
 * 
 *         if not array_is_empty:
 */
        __pyx_v_ptr = (__pyx_v_ptr + 1);

        /* "asyncpg/protocol/codecs/array.pyx":783
 *                 array_is_empty = False
 * 
 *             if not end_of_item:             # <<<<<<<<<<<<<<
 *                 ptr += 1
 * 
 */
      }
    }

    /* "asyncpg/protocol/codecs/array.pyx":786
 *                 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":787
 * 
 *         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":786
 *                 ptr += 1
 * 
 *         if not array_is_empty:             # <<<<<<<<<<<<<<
 *             dims[ndims[0] - 1] += 1
 * 
 */
    }

    /* "asyncpg/protocol/codecs/array.pyx":789
 *             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":792
 * 
 *     # 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":793
 *     # 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":794
 *     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(6, 794, __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(6, 794, __pyx_L1_error)

      /* "asyncpg/protocol/codecs/array.pyx":793
 *     # 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":796
 *             raise _UnexpectedCharacter(array_text, ptr)
 * 
 *         ptr += 1             # <<<<<<<<<<<<<<
 * 
 *     if array_is_empty:
 */
    __pyx_v_ptr = (__pyx_v_ptr + 1);
  }

  /* "asyncpg/protocol/codecs/array.pyx":798
 *         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":799
 * 
 *     if array_is_empty:
 *         ndims[0] = 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
    (__pyx_v_ndims[0]) = 0;

    /* "asyncpg/protocol/codecs/array.pyx":798
 *         ptr += 1
 * 
 *     if array_is_empty:             # <<<<<<<<<<<<<<
 *         ndims[0] = 0
 * 
 */
  }

  /* "asyncpg/protocol/codecs/array.pyx":662
 * 
 * 
 * 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":802
 * 
 * 
 * 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":804
 * 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(6, 804, __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":802
 * 
 * 
 * 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":807
 * 
 * 
 * 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":809
 * 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(6, 809, __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":807
 * 
 * 
 * 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":812
 * 
 * 
 * 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":813
 * 
 * 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(6, 813, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/array.pyx":812
 * 
 * 
 * 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":817
 * 
 * 
 * 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":818
 * 
 * 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(6, 818, __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":817
 * 
 * 
 * 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":821
 * 
 * 
 * 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":823
 * 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(6, 823, __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":821
 * 
 * 
 * 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":826
 * 
 * 
 * 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":828
 * 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(6, 828, __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":826
 * 
 * 
 * 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":831
 * 
 * 
 * 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":832
 * 
 * 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(6, 832, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/array.pyx":831
 * 
 * 
 * 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":836
 * 
 * 
 * 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":837
 * 
 * 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(6, 837, __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":836
 * 
 * 
 * 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":840
 * 
 * 
 * cdef anyarray_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
 *     # Instances of anyarray (or any other polymorphic pseudotype) are
 *     # never supposed to be returned from actual queries.
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_anyarray_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
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("anyarray_decode", 0);

  /* "asyncpg/protocol/codecs/array.pyx":843
 *     # Instances of anyarray (or any other polymorphic pseudotype) are
 *     # never supposed to be returned from actual queries.
 *     raise RuntimeError('unexpected instance of \'anyarray\' type')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__73, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 843, __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(6, 843, __pyx_L1_error)

  /* "asyncpg/protocol/codecs/array.pyx":840
 * 
 * 
 * cdef anyarray_decode(ConnectionSettings settings, FastReadBuffer buf):             # <<<<<<<<<<<<<<
 *     # Instances of anyarray (or any other polymorphic pseudotype) are
 *     # never supposed to be returned from actual queries.
 */

  /* 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_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/codecs/array.pyx":846
 * 
 * 
 * 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":847
 * 
 * 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 847, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/array.pyx":855
 *     # 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 855, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/array.pyx":860
 *                         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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 860, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/array.pyx":846
 * 
 * 
 * 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(23, 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(23, 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 == ((int)-1))) __PYX_ERR(23, 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, 1, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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 == ((Py_ssize_t)-1))) __PYX_ERR(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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 == ((char const *)NULL))) __PYX_ERR(23, 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(23, 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 == ((char const *)NULL))) __PYX_ERR(23, 121, __pyx_L1_error)
    __pyx_v_bound_len = 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(23, 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(23, 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 == ((char const *)NULL))) __PYX_ERR(23, 129, __pyx_L1_error)
    __pyx_v_bound_len = 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(23, 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(23, 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(23, 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(23, 136, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_2)) __PYX_ERR(23, 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(23, 136, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_upper, __pyx_v_upper) < 0) __PYX_ERR(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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(23, 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(23, 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(24, 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(24, 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(24, 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(24, 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(24, 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(24, 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;
  Py_ssize_t __pyx_v_elem_count;
  Py_ssize_t __pyx_v_i;
  int32_t __pyx_v_elem_len;
  uint32_t __pyx_v_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;
  Py_ssize_t __pyx_t_3;
  Py_ssize_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 elem_typ
 *         Codec elem_codec
 *         FastReadBuffer elem_buf = FastReadBuffer.new()             # <<<<<<<<<<<<<<
 * 
 *     elem_count = <ssize_t><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(24, 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 = <ssize_t><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 == ((char const *)NULL))) __PYX_ERR(24, 27, __pyx_L1_error)
  __pyx_v_elem_count = ((Py_ssize_t)((uint32_t)unpack_int32(__pyx_t_2)));

  /* "asyncpg/protocol/codecs/record.pyx":28
 * 
 *     elem_count = <ssize_t><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(24, 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 == ((char const *)NULL))) __PYX_ERR(24, 31, __pyx_L1_error)
    __pyx_v_elem_typ = ((uint32_t)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 == ((char const *)NULL))) __PYX_ERR(24, 32, __pyx_L1_error)
    __pyx_v_elem_len = 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(24, 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(24, 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(24, 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(24, 41, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_9 = PyInt_FromSsize_t(__pyx_v_i); if (unlikely(!__pyx_t_9)) __PYX_ERR(24, 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(24, 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(24, 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(24, 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(24, 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(24, 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(24, 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(24, 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(24, 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(24, 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(24, 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, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(24, 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(25, 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 == ((Py_ssize_t)-1))) __PYX_ERR(25, 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__74, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 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(25, 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(25, 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 = __Pyx_HasAttr(__pyx_v_obj, __pyx_n_u_items); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(25, 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(25, 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(25, 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(25, 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(25, 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(25, 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(25, 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(25, 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(25, 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(25, 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(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(25, 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(25, 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(25, 26, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(25, 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(25, 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(25, 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(25, 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__75, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(25, 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(25, 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(25, 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(25, 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(25, 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(25, 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(25, 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(25, 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(25, 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(25, 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(25, 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(25, 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(25, 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 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 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 == ((char const *)NULL))) __PYX_ERR(25, 54, __pyx_L1_error)
  __pyx_v_elem_count = ((uint32_t)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 == ((char const *)NULL))) __PYX_ERR(25, 59, __pyx_L1_error)
    __pyx_v_elem_len = 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__76, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(25, 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(25, 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 == ((char const *)NULL))) __PYX_ERR(25, 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(25, 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(25, 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 == ((char const *)NULL))) __PYX_ERR(25, 65, __pyx_L1_error)
    __pyx_v_elem_len = 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 == ((char const *)NULL))) __PYX_ERR(25, 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(25, 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(25, 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(25, 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(25, 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_params):             # <<<<<<<<<<<<<<
 *         # type of `con_params` is `_ConnectionParameters`
 *         self.buffer = ReadBuffer()
 */

/* 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_params = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_con_params,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);
        CYTHON_FALLTHROUGH;
        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_params)) != 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(7, 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_params = 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(7, 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_params);

  /* 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_params) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "asyncpg/protocol/coreproto.pyx":15
 *     def __init__(self, con_params):
 *         # type of `con_params` is `_ConnectionParameters`
 *         self.buffer = ReadBuffer()             # <<<<<<<<<<<<<<
 *         self.user = con_params.user
 *         self.password = con_params.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(7, 15, __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":16
 *         # type of `con_params` is `_ConnectionParameters`
 *         self.buffer = ReadBuffer()
 *         self.user = con_params.user             # <<<<<<<<<<<<<<
 *         self.password = con_params.password
 *         self.auth_msg = None
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_con_params, __pyx_n_s_user); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_user, __pyx_t_1) < 0) __PYX_ERR(7, 16, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":17
 *         self.buffer = ReadBuffer()
 *         self.user = con_params.user
 *         self.password = con_params.password             # <<<<<<<<<<<<<<
 *         self.auth_msg = None
 *         self.con_params = con_params
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_con_params, __pyx_n_s_password); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_password, __pyx_t_1) < 0) __PYX_ERR(7, 17, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":18
 *         self.user = con_params.user
 *         self.password = con_params.password
 *         self.auth_msg = None             # <<<<<<<<<<<<<<
 *         self.con_params = con_params
 *         self.transport = None
 */
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_auth_msg, Py_None) < 0) __PYX_ERR(7, 18, __pyx_L1_error)

  /* "asyncpg/protocol/coreproto.pyx":19
 *         self.password = con_params.password
 *         self.auth_msg = None
 *         self.con_params = con_params             # <<<<<<<<<<<<<<
 *         self.transport = None
 *         self.con_status = CONNECTION_BAD
 */
  __Pyx_INCREF(__pyx_v_con_params);
  __Pyx_GIVEREF(__pyx_v_con_params);
  __Pyx_GOTREF(__pyx_v_self->con_params);
  __Pyx_DECREF(__pyx_v_self->con_params);
  __pyx_v_self->con_params = __pyx_v_con_params;

  /* "asyncpg/protocol/coreproto.pyx":20
 *         self.auth_msg = None
 *         self.con_params = con_params
 *         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":21
 *         self.con_params = con_params
 *         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":22
 *         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":23
 *         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":24
 *         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":26
 *         self.encoding = 'utf-8'
 * 
 *         self._skip_discard = False             # <<<<<<<<<<<<<<
 * 
 *         # executemany support data
 */
  __pyx_v_self->_skip_discard = 0;

  /* "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_iter);
  __Pyx_DECREF(__pyx_v_self->_execute_iter);
  __pyx_v_self->_execute_iter = Py_None;

  /* "asyncpg/protocol/coreproto.pyx":30
 *         # 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":31
 *         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":33
 *         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(7, 33, __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_params):             # <<<<<<<<<<<<<<
 *         # type of `con_params` is `_ConnectionParameters`
 *         self.buffer = ReadBuffer()
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __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":35
 *         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":36
 * 
 *     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(7, 36, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 36, __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(7, 36, __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(7, 36, __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(7, 36, __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(7, 36, __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(7, 36, __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(7, 36, __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":35
 *         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":38
 *         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":39
 * 
 *     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(7, 39, __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(7, 39, __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(7, 39, __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(7, 39, __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(7, 39, __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(7, 39, __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":38
 *         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":41
 *         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;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  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;
  char const *__pyx_t_23;
  __Pyx_RefNannySetupContext("_read_server_messages", 0);

  /* "asyncpg/protocol/coreproto.pyx":46
 *             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 == ((int32_t)-1))) __PYX_ERR(7, 46, __pyx_L1_error)
    __pyx_t_2 = ((__pyx_t_1 == 1) != 0);
    if (!__pyx_t_2) break;

    /* "asyncpg/protocol/coreproto.pyx":47
 * 
 *         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":48
 *         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":50
 *             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":51
 * 
 *             try:
 *                 if mtype == b'S':             # <<<<<<<<<<<<<<
 *                     # ParameterStatus
 *                     self._parse_msg_parameter_status()
 */
          switch (__pyx_v_mtype) {
            case 'S':

            /* "asyncpg/protocol/coreproto.pyx":53
 *                 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(7, 53, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

            /* "asyncpg/protocol/coreproto.pyx":54
 *                     # ParameterStatus
 *                     self._parse_msg_parameter_status()
 *                     continue             # <<<<<<<<<<<<<<
 *                 elif mtype == b'A':
 *                     # NotificationResponse
 */
            goto __pyx_L16_try_continue;

            /* "asyncpg/protocol/coreproto.pyx":51
 * 
 *             try:
 *                 if mtype == b'S':             # <<<<<<<<<<<<<<
 *                     # ParameterStatus
 *                     self._parse_msg_parameter_status()
 */
            break;

            /* "asyncpg/protocol/coreproto.pyx":55
 *                     self._parse_msg_parameter_status()
 *                     continue
 *                 elif mtype == b'A':             # <<<<<<<<<<<<<<
 *                     # NotificationResponse
 *                     self._parse_msg_notification()
 */
            case 'A':

            /* "asyncpg/protocol/coreproto.pyx":57
 *                 elif mtype == b'A':
 *                     # NotificationResponse
 *                     self._parse_msg_notification()             # <<<<<<<<<<<<<<
 *                     continue
 *                 elif mtype == b'N':
 */
            __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(7, 57, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

            /* "asyncpg/protocol/coreproto.pyx":58
 *                     # NotificationResponse
 *                     self._parse_msg_notification()
 *                     continue             # <<<<<<<<<<<<<<
 *                 elif mtype == b'N':
 *                     # 'N' - NoticeResponse
 */
            goto __pyx_L16_try_continue;

            /* "asyncpg/protocol/coreproto.pyx":55
 *                     self._parse_msg_parameter_status()
 *                     continue
 *                 elif mtype == b'A':             # <<<<<<<<<<<<<<
 *                     # NotificationResponse
 *                     self._parse_msg_notification()
 */
            break;

            /* "asyncpg/protocol/coreproto.pyx":59
 *                     self._parse_msg_notification()
 *                     continue
 *                 elif mtype == b'N':             # <<<<<<<<<<<<<<
 *                     # 'N' - NoticeResponse
 *                     self._on_notice(self._parse_msg_error_response(False))
 */
            case 'N':

            /* "asyncpg/protocol/coreproto.pyx":61
 *                 elif mtype == b'N':
 *                     # 'N' - NoticeResponse
 *                     self._on_notice(self._parse_msg_error_response(False))             # <<<<<<<<<<<<<<
 *                     continue
 * 
 */
            __pyx_t_7 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_parse_msg_error_response(__pyx_v_self, Py_False); if (unlikely(!__pyx_t_7)) __PYX_ERR(7, 61, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_7);
            __pyx_t_8 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_on_notice(__pyx_v_self, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(7, 61, __pyx_L10_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":62
 *                     # 'N' - NoticeResponse
 *                     self._on_notice(self._parse_msg_error_response(False))
 *                     continue             # <<<<<<<<<<<<<<
 * 
 *                 if state == PROTOCOL_AUTH:
 */
            goto __pyx_L16_try_continue;

            /* "asyncpg/protocol/coreproto.pyx":59
 *                     self._parse_msg_notification()
 *                     continue
 *                 elif mtype == b'N':             # <<<<<<<<<<<<<<
 *                     # 'N' - NoticeResponse
 *                     self._on_notice(self._parse_msg_error_response(False))
 */
            break;
            default: break;
          }

          /* "asyncpg/protocol/coreproto.pyx":64
 *                     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":65
 * 
 *                 if state == PROTOCOL_AUTH:
 *                     self._process__auth(mtype)             # <<<<<<<<<<<<<<
 * 
 *                 elif state == PROTOCOL_PREPARE:
 */
            __pyx_t_8 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_process__auth(__pyx_v_self, __pyx_v_mtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(7, 65, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

            /* "asyncpg/protocol/coreproto.pyx":64
 *                     continue
 * 
 *                 if state == PROTOCOL_AUTH:             # <<<<<<<<<<<<<<
 *                     self._process__auth(mtype)
 * 
 */
            break;

            /* "asyncpg/protocol/coreproto.pyx":67
 *                     self._process__auth(mtype)
 * 
 *                 elif state == PROTOCOL_PREPARE:             # <<<<<<<<<<<<<<
 *                     self._process__prepare(mtype)
 * 
 */
            case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_PREPARE:

            /* "asyncpg/protocol/coreproto.pyx":68
 * 
 *                 elif state == PROTOCOL_PREPARE:
 *                     self._process__prepare(mtype)             # <<<<<<<<<<<<<<
 * 
 *                 elif state == PROTOCOL_BIND_EXECUTE:
 */
            __pyx_t_8 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_process__prepare(__pyx_v_self, __pyx_v_mtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(7, 68, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

            /* "asyncpg/protocol/coreproto.pyx":67
 *                     self._process__auth(mtype)
 * 
 *                 elif state == PROTOCOL_PREPARE:             # <<<<<<<<<<<<<<
 *                     self._process__prepare(mtype)
 * 
 */
            break;

            /* "asyncpg/protocol/coreproto.pyx":70
 *                     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":71
 * 
 *                 elif state == PROTOCOL_BIND_EXECUTE:
 *                     self._process__bind_execute(mtype)             # <<<<<<<<<<<<<<
 * 
 *                 elif state == PROTOCOL_BIND_EXECUTE_MANY:
 */
            __pyx_t_8 = ((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_8)) __PYX_ERR(7, 71, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

            /* "asyncpg/protocol/coreproto.pyx":70
 *                     self._process__prepare(mtype)
 * 
 *                 elif state == PROTOCOL_BIND_EXECUTE:             # <<<<<<<<<<<<<<
 *                     self._process__bind_execute(mtype)
 * 
 */
            break;

            /* "asyncpg/protocol/coreproto.pyx":73
 *                     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":74
 * 
 *                 elif state == PROTOCOL_BIND_EXECUTE_MANY:
 *                     self._process__bind_execute_many(mtype)             # <<<<<<<<<<<<<<
 * 
 *                 elif state == PROTOCOL_EXECUTE:
 */
            __pyx_t_8 = ((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_8)) __PYX_ERR(7, 74, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

            /* "asyncpg/protocol/coreproto.pyx":73
 *                     self._process__bind_execute(mtype)
 * 
 *                 elif state == PROTOCOL_BIND_EXECUTE_MANY:             # <<<<<<<<<<<<<<
 *                     self._process__bind_execute_many(mtype)
 * 
 */
            break;

            /* "asyncpg/protocol/coreproto.pyx":76
 *                     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":77
 * 
 *                 elif state == PROTOCOL_EXECUTE:
 *                     self._process__bind_execute(mtype)             # <<<<<<<<<<<<<<
 * 
 *                 elif state == PROTOCOL_BIND:
 */
            __pyx_t_8 = ((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_8)) __PYX_ERR(7, 77, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

            /* "asyncpg/protocol/coreproto.pyx":76
 *                     self._process__bind_execute_many(mtype)
 * 
 *                 elif state == PROTOCOL_EXECUTE:             # <<<<<<<<<<<<<<
 *                     self._process__bind_execute(mtype)
 * 
 */
            break;

            /* "asyncpg/protocol/coreproto.pyx":79
 *                     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":80
 * 
 *                 elif state == PROTOCOL_BIND:
 *                     self._process__bind(mtype)             # <<<<<<<<<<<<<<
 * 
 *                 elif state == PROTOCOL_CLOSE_STMT_PORTAL:
 */
            __pyx_t_8 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_process__bind(__pyx_v_self, __pyx_v_mtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(7, 80, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

            /* "asyncpg/protocol/coreproto.pyx":79
 *                     self._process__bind_execute(mtype)
 * 
 *                 elif state == PROTOCOL_BIND:             # <<<<<<<<<<<<<<
 *                     self._process__bind(mtype)
 * 
 */
            break;

            /* "asyncpg/protocol/coreproto.pyx":82
 *                     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":83
 * 
 *                 elif state == PROTOCOL_CLOSE_STMT_PORTAL:
 *                     self._process__close_stmt_portal(mtype)             # <<<<<<<<<<<<<<
 * 
 *                 elif state == PROTOCOL_SIMPLE_QUERY:
 */
            __pyx_t_8 = ((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_8)) __PYX_ERR(7, 83, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

            /* "asyncpg/protocol/coreproto.pyx":82
 *                     self._process__bind(mtype)
 * 
 *                 elif state == PROTOCOL_CLOSE_STMT_PORTAL:             # <<<<<<<<<<<<<<
 *                     self._process__close_stmt_portal(mtype)
 * 
 */
            break;

            /* "asyncpg/protocol/coreproto.pyx":85
 *                     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":86
 * 
 *                 elif state == PROTOCOL_SIMPLE_QUERY:
 *                     self._process__simple_query(mtype)             # <<<<<<<<<<<<<<
 * 
 *                 elif state == PROTOCOL_COPY_OUT:
 */
            __pyx_t_8 = ((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_8)) __PYX_ERR(7, 86, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

            /* "asyncpg/protocol/coreproto.pyx":85
 *                     self._process__close_stmt_portal(mtype)
 * 
 *                 elif state == PROTOCOL_SIMPLE_QUERY:             # <<<<<<<<<<<<<<
 *                     self._process__simple_query(mtype)
 * 
 */
            break;

            /* "asyncpg/protocol/coreproto.pyx":88
 *                     self._process__simple_query(mtype)
 * 
 *                 elif state == PROTOCOL_COPY_OUT:             # <<<<<<<<<<<<<<
 *                     self._process__copy_out(mtype)
 * 
 */
            case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_COPY_OUT:

            /* "asyncpg/protocol/coreproto.pyx":89
 * 
 *                 elif state == PROTOCOL_COPY_OUT:
 *                     self._process__copy_out(mtype)             # <<<<<<<<<<<<<<
 * 
 *                 elif (state == PROTOCOL_COPY_OUT_DATA or
 */
            __pyx_t_8 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_process__copy_out(__pyx_v_self, __pyx_v_mtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(7, 89, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

            /* "asyncpg/protocol/coreproto.pyx":88
 *                     self._process__simple_query(mtype)
 * 
 *                 elif state == PROTOCOL_COPY_OUT:             # <<<<<<<<<<<<<<
 *                     self._process__copy_out(mtype)
 * 
 */
            break;

            /* "asyncpg/protocol/coreproto.pyx":91
 *                     self._process__copy_out(mtype)
 * 
 *                 elif (state == PROTOCOL_COPY_OUT_DATA or             # <<<<<<<<<<<<<<
 *                         state == PROTOCOL_COPY_OUT_DONE):
 *                     self._process__copy_out_data(mtype)
 */
            case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_COPY_OUT_DATA:

            /* "asyncpg/protocol/coreproto.pyx":92
 * 
 *                 elif (state == PROTOCOL_COPY_OUT_DATA or
 *                         state == PROTOCOL_COPY_OUT_DONE):             # <<<<<<<<<<<<<<
 *                     self._process__copy_out_data(mtype)
 * 
 */
            case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_COPY_OUT_DONE:

            /* "asyncpg/protocol/coreproto.pyx":93
 *                 elif (state == PROTOCOL_COPY_OUT_DATA or
 *                         state == PROTOCOL_COPY_OUT_DONE):
 *                     self._process__copy_out_data(mtype)             # <<<<<<<<<<<<<<
 * 
 *                 elif state == PROTOCOL_COPY_IN:
 */
            __pyx_t_8 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_process__copy_out_data(__pyx_v_self, __pyx_v_mtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(7, 93, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

            /* "asyncpg/protocol/coreproto.pyx":91
 *                     self._process__copy_out(mtype)
 * 
 *                 elif (state == PROTOCOL_COPY_OUT_DATA or             # <<<<<<<<<<<<<<
 *                         state == PROTOCOL_COPY_OUT_DONE):
 *                     self._process__copy_out_data(mtype)
 */
            break;

            /* "asyncpg/protocol/coreproto.pyx":95
 *                     self._process__copy_out_data(mtype)
 * 
 *                 elif state == PROTOCOL_COPY_IN:             # <<<<<<<<<<<<<<
 *                     self._process__copy_in(mtype)
 * 
 */
            case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_COPY_IN:

            /* "asyncpg/protocol/coreproto.pyx":96
 * 
 *                 elif state == PROTOCOL_COPY_IN:
 *                     self._process__copy_in(mtype)             # <<<<<<<<<<<<<<
 * 
 *                 elif state == PROTOCOL_COPY_IN_DATA:
 */
            __pyx_t_8 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_process__copy_in(__pyx_v_self, __pyx_v_mtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(7, 96, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

            /* "asyncpg/protocol/coreproto.pyx":95
 *                     self._process__copy_out_data(mtype)
 * 
 *                 elif state == PROTOCOL_COPY_IN:             # <<<<<<<<<<<<<<
 *                     self._process__copy_in(mtype)
 * 
 */
            break;

            /* "asyncpg/protocol/coreproto.pyx":98
 *                     self._process__copy_in(mtype)
 * 
 *                 elif state == PROTOCOL_COPY_IN_DATA:             # <<<<<<<<<<<<<<
 *                     self._process__copy_in_data(mtype)
 * 
 */
            case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_COPY_IN_DATA:

            /* "asyncpg/protocol/coreproto.pyx":99
 * 
 *                 elif state == PROTOCOL_COPY_IN_DATA:
 *                     self._process__copy_in_data(mtype)             # <<<<<<<<<<<<<<
 * 
 *                 elif state == PROTOCOL_CANCELLED:
 */
            __pyx_t_8 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_process__copy_in_data(__pyx_v_self, __pyx_v_mtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(7, 99, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

            /* "asyncpg/protocol/coreproto.pyx":98
 *                     self._process__copy_in(mtype)
 * 
 *                 elif state == PROTOCOL_COPY_IN_DATA:             # <<<<<<<<<<<<<<
 *                     self._process__copy_in_data(mtype)
 * 
 */
            break;

            /* "asyncpg/protocol/coreproto.pyx":101
 *                     self._process__copy_in_data(mtype)
 * 
 *                 elif state == PROTOCOL_CANCELLED:             # <<<<<<<<<<<<<<
 *                     # discard all messages until the sync message
 *                     if mtype == b'E':
 */
            case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_CANCELLED:

            /* "asyncpg/protocol/coreproto.pyx":103
 *                 elif state == PROTOCOL_CANCELLED:
 *                     # discard all messages until the sync message
 *                     if mtype == b'E':             # <<<<<<<<<<<<<<
 *                         self._parse_msg_error_response(True)
 *                     elif mtype == b'Z':
 */
            __pyx_t_2 = ((__pyx_v_mtype == 'E') != 0);
            if (__pyx_t_2) {

              /* "asyncpg/protocol/coreproto.pyx":104
 *                     # discard all messages until the sync message
 *                     if mtype == b'E':
 *                         self._parse_msg_error_response(True)             # <<<<<<<<<<<<<<
 *                     elif mtype == b'Z':
 *                         self._parse_msg_ready_for_query()
 */
              __pyx_t_8 = ((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_8)) __PYX_ERR(7, 104, __pyx_L10_error)
              __Pyx_GOTREF(__pyx_t_8);
              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

              /* "asyncpg/protocol/coreproto.pyx":103
 *                 elif state == PROTOCOL_CANCELLED:
 *                     # discard all messages until the sync message
 *                     if mtype == b'E':             # <<<<<<<<<<<<<<
 *                         self._parse_msg_error_response(True)
 *                     elif mtype == b'Z':
 */
              goto __pyx_L18;
            }

            /* "asyncpg/protocol/coreproto.pyx":105
 *                     if mtype == b'E':
 *                         self._parse_msg_error_response(True)
 *                     elif mtype == b'Z':             # <<<<<<<<<<<<<<
 *                         self._parse_msg_ready_for_query()
 *                         self._push_result()
 */
            __pyx_t_2 = ((__pyx_v_mtype == 'Z') != 0);
            if (__pyx_t_2) {

              /* "asyncpg/protocol/coreproto.pyx":106
 *                         self._parse_msg_error_response(True)
 *                     elif mtype == b'Z':
 *                         self._parse_msg_ready_for_query()             # <<<<<<<<<<<<<<
 *                         self._push_result()
 *                     else:
 */
              __pyx_t_8 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_parse_msg_ready_for_query(__pyx_v_self); if (unlikely(!__pyx_t_8)) __PYX_ERR(7, 106, __pyx_L10_error)
              __Pyx_GOTREF(__pyx_t_8);
              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

              /* "asyncpg/protocol/coreproto.pyx":107
 *                     elif mtype == b'Z':
 *                         self._parse_msg_ready_for_query()
 *                         self._push_result()             # <<<<<<<<<<<<<<
 *                     else:
 *                         self.buffer.consume_message()
 */
              __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(7, 107, __pyx_L10_error)
              __Pyx_GOTREF(__pyx_t_8);
              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

              /* "asyncpg/protocol/coreproto.pyx":105
 *                     if mtype == b'E':
 *                         self._parse_msg_error_response(True)
 *                     elif mtype == b'Z':             # <<<<<<<<<<<<<<
 *                         self._parse_msg_ready_for_query()
 *                         self._push_result()
 */
              goto __pyx_L18;
            }

            /* "asyncpg/protocol/coreproto.pyx":109
 *                         self._push_result()
 *                     else:
 *                         self.buffer.consume_message()             # <<<<<<<<<<<<<<
 * 
 *                 elif state == PROTOCOL_ERROR_CONSUME:
 */
            /*else*/ {
              __pyx_t_8 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(__pyx_v_self->buffer)); if (unlikely(!__pyx_t_8)) __PYX_ERR(7, 109, __pyx_L10_error)
              __Pyx_GOTREF(__pyx_t_8);
              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            }
            __pyx_L18:;

            /* "asyncpg/protocol/coreproto.pyx":101
 *                     self._process__copy_in_data(mtype)
 * 
 *                 elif state == PROTOCOL_CANCELLED:             # <<<<<<<<<<<<<<
 *                     # discard all messages until the sync message
 *                     if mtype == b'E':
 */
            break;

            /* "asyncpg/protocol/coreproto.pyx":111
 *                         self.buffer.consume_message()
 * 
 *                 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":115
 *                     # 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":117
 *                     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":118
 *                         # 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":119
 *                         if self.result_type != RESULT_FAILED:
 *                             self.result_type = RESULT_FAILED
 *                             self.result = RuntimeError(             # <<<<<<<<<<<<<<
 *                                 'unknown error in protocol implementation')
 * 
 */
                __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__77, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(7, 119, __pyx_L10_error)
                __Pyx_GOTREF(__pyx_t_8);
                __Pyx_GIVEREF(__pyx_t_8);
                __Pyx_GOTREF(__pyx_v_self->result);
                __Pyx_DECREF(__pyx_v_self->result);
                __pyx_v_self->result = __pyx_t_8;
                __pyx_t_8 = 0;

                /* "asyncpg/protocol/coreproto.pyx":117
 *                     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":122
 *                                 'unknown error in protocol implementation')
 * 
 *                         self._push_result()             # <<<<<<<<<<<<<<
 * 
 *                     else:
 */
              __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(7, 122, __pyx_L10_error)
              __Pyx_GOTREF(__pyx_t_8);
              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

              /* "asyncpg/protocol/coreproto.pyx":115
 *                     # 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_L19;
            }

            /* "asyncpg/protocol/coreproto.pyx":125
 * 
 *                     else:
 *                         self.buffer.consume_message()             # <<<<<<<<<<<<<<
 * 
 *                 else:
 */
            /*else*/ {
              __pyx_t_8 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(__pyx_v_self->buffer)); if (unlikely(!__pyx_t_8)) __PYX_ERR(7, 125, __pyx_L10_error)
              __Pyx_GOTREF(__pyx_t_8);
              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            }
            __pyx_L19:;

            /* "asyncpg/protocol/coreproto.pyx":111
 *                         self.buffer.consume_message()
 * 
 *                 elif state == PROTOCOL_ERROR_CONSUME:             # <<<<<<<<<<<<<<
 *                     # Error in protocol (on asyncpg side);
 *                     # discard all messages until sync message
 */
            break;
            default:

            /* "asyncpg/protocol/coreproto.pyx":128
 * 
 *                 else:
 *                     raise apg_exc.InternalClientError(             # <<<<<<<<<<<<<<
 *                         'protocol is in an unknown state {}'.format(state))
 * 
 */
            __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc); if (unlikely(!__pyx_t_7)) __PYX_ERR(7, 128, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_7);
            __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_InternalClientError); if (unlikely(!__pyx_t_9)) __PYX_ERR(7, 128, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

            /* "asyncpg/protocol/coreproto.pyx":129
 *                 else:
 *                     raise apg_exc.InternalClientError(
 *                         'protocol is in an unknown state {}'.format(state))             # <<<<<<<<<<<<<<
 * 
 *             except Exception as ex:
 */
            __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_protocol_is_in_an_unknown_state, __pyx_n_s_format); if (unlikely(!__pyx_t_10)) __PYX_ERR(7, 129, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_11 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ProtocolState(__pyx_v_state); if (unlikely(!__pyx_t_11)) __PYX_ERR(7, 129, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_11);
            __pyx_t_12 = NULL;
            if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
              __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_10);
              if (likely(__pyx_t_12)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
                __Pyx_INCREF(__pyx_t_12);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_10, function);
              }
            }
            if (!__pyx_t_12) {
              __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(7, 129, __pyx_L10_error)
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
              __Pyx_GOTREF(__pyx_t_7);
            } else {
              #if CYTHON_FAST_PYCALL
              if (PyFunction_Check(__pyx_t_10)) {
                PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_11};
                __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(7, 129, __pyx_L10_error)
                __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                __Pyx_GOTREF(__pyx_t_7);
                __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
              } else
              #endif
              #if CYTHON_FAST_PYCCALL
              if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
                PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_11};
                __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(7, 129, __pyx_L10_error)
                __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                __Pyx_GOTREF(__pyx_t_7);
                __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
              } else
              #endif
              {
                __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(7, 129, __pyx_L10_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_GIVEREF(__pyx_t_11);
                PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_t_11);
                __pyx_t_11 = 0;
                __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_13, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(7, 129, __pyx_L10_error)
                __Pyx_GOTREF(__pyx_t_7);
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              }
            }
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __pyx_t_10 = NULL;
            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);
              }
            }
            if (!__pyx_t_10) {
              __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(7, 128, __pyx_L10_error)
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              __Pyx_GOTREF(__pyx_t_8);
            } else {
              #if CYTHON_FAST_PYCALL
              if (PyFunction_Check(__pyx_t_9)) {
                PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_7};
                __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(7, 128, __pyx_L10_error)
                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                __Pyx_GOTREF(__pyx_t_8);
                __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[2] = {__pyx_t_10, __pyx_t_7};
                __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(7, 128, __pyx_L10_error)
                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                __Pyx_GOTREF(__pyx_t_8);
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              } else
              #endif
              {
                __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(7, 128, __pyx_L10_error)
                __Pyx_GOTREF(__pyx_t_13);
                __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_10); __pyx_t_10 = NULL;
                __Pyx_GIVEREF(__pyx_t_7);
                PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_t_7);
                __pyx_t_7 = 0;
                __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_13, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(7, 128, __pyx_L10_error)
                __Pyx_GOTREF(__pyx_t_8);
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              }
            }
            __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(7, 128, __pyx_L10_error)
            break;
          }

          /* "asyncpg/protocol/coreproto.pyx":50
 *             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_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

        /* "asyncpg/protocol/coreproto.pyx":131
 *                         'protocol is in an unknown state {}'.format(state))
 * 
 *             except Exception as ex:             # <<<<<<<<<<<<<<
 *                 self.result_type = RESULT_FAILED
 *                 self.result = ex
 */
        __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
        if (__pyx_t_14) {
          __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._read_server_messages", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_9, &__pyx_t_13) < 0) __PYX_ERR(7, 131, __pyx_L12_except_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_INCREF(__pyx_t_9);
          __pyx_v_ex = __pyx_t_9;
          /*try:*/ {

            /* "asyncpg/protocol/coreproto.pyx":132
 * 
 *             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":133
 *             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":135
 *                 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":136
 * 
 *                 if mtype == b'Z':
 *                     self._push_result()             # <<<<<<<<<<<<<<
 *                 else:
 *                     self.state = PROTOCOL_ERROR_CONSUME
 */
              __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(7, 136, __pyx_L26_error)
              __Pyx_GOTREF(__pyx_t_7);
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

              /* "asyncpg/protocol/coreproto.pyx":135
 *                 self.result = ex
 * 
 *                 if mtype == b'Z':             # <<<<<<<<<<<<<<
 *                     self._push_result()
 *                 else:
 */
              goto __pyx_L28;
            }

            /* "asyncpg/protocol/coreproto.pyx":138
 *                     self._push_result()
 *                 else:
 *                     self.state = PROTOCOL_ERROR_CONSUME             # <<<<<<<<<<<<<<
 * 
 *             finally:
 */
            /*else*/ {
              __pyx_v_self->state = __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_ERROR_CONSUME;
            }
            __pyx_L28:;
          }

          /* "asyncpg/protocol/coreproto.pyx":131
 *                         '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_L27;
            }
            __pyx_L26_error:;
            /*exception exit:*/{
              __Pyx_PyThreadState_declare
              __Pyx_PyThreadState_assign
              __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_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 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_14 = __pyx_lineno; __pyx_t_15 = __pyx_clineno; __pyx_t_16 = __pyx_filename;
              {
                __Pyx_DECREF(__pyx_v_ex);
                __pyx_v_ex = NULL;
              }
              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_14; __pyx_clineno = __pyx_t_15; __pyx_filename = __pyx_t_16;
              goto __pyx_L12_except_error;
            }
            __pyx_L27:;
          }
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          goto __pyx_L11_exception_handled;
        }
        goto __pyx_L12_except_error;
        __pyx_L12_except_error:;

        /* "asyncpg/protocol/coreproto.pyx":50
 *             state = self.state
 * 
 *             try:             # <<<<<<<<<<<<<<
 *                 if mtype == b'S':
 *                     # ParameterStatus
 */
        __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_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_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":141
 * 
 *             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":142
 *             finally:
 *                 if self._skip_discard:
 *                     self._skip_discard = False             # <<<<<<<<<<<<<<
 *                 else:
 *                     self.buffer.discard_message()
 */
          __pyx_v_self->_skip_discard = 0;

          /* "asyncpg/protocol/coreproto.pyx":141
 * 
 *             finally:
 *                 if self._skip_discard:             # <<<<<<<<<<<<<<
 *                     self._skip_discard = False
 *                 else:
 */
          goto __pyx_L33;
        }

        /* "asyncpg/protocol/coreproto.pyx":144
 *                     self._skip_discard = False
 *                 else:
 *                     self.buffer.discard_message()             # <<<<<<<<<<<<<<
 * 
 *     cdef _process__auth(self, char mtype):
 */
        /*else*/ {
          __pyx_t_13 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_discard_message(__pyx_v_self->buffer); if (unlikely(!__pyx_t_13)) __PYX_ERR(7, 144, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        }
        __pyx_L33:;
        goto __pyx_L9;
      }
      __pyx_L8_error:;
      /*exception exit:*/{
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_4 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0;
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __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;
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
        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_22);
        __Pyx_XGOTREF(__pyx_t_21);
        __Pyx_XGOTREF(__pyx_t_20);
        __pyx_t_15 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_23 = __pyx_filename;
        {

          /* "asyncpg/protocol/coreproto.pyx":141
 * 
 *             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":142
 *             finally:
 *                 if self._skip_discard:
 *                     self._skip_discard = False             # <<<<<<<<<<<<<<
 *                 else:
 *                     self.buffer.discard_message()
 */
            __pyx_v_self->_skip_discard = 0;

            /* "asyncpg/protocol/coreproto.pyx":141
 * 
 *             finally:
 *                 if self._skip_discard:             # <<<<<<<<<<<<<<
 *                     self._skip_discard = False
 *                 else:
 */
            goto __pyx_L38;
          }

          /* "asyncpg/protocol/coreproto.pyx":144
 *                     self._skip_discard = False
 *                 else:
 *                     self.buffer.discard_message()             # <<<<<<<<<<<<<<
 * 
 *     cdef _process__auth(self, char mtype):
 */
          /*else*/ {
            __pyx_t_13 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_discard_message(__pyx_v_self->buffer); if (unlikely(!__pyx_t_13)) __PYX_ERR(7, 144, __pyx_L37_error)
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          }
          __pyx_L38:;
        }
        if (PY_MAJOR_VERSION >= 3) {
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_21, __pyx_t_20);
        }
        __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_22 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0;
        __pyx_lineno = __pyx_t_15; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_23;
        goto __pyx_L1_error;
        __pyx_L37_error:;
        if (PY_MAJOR_VERSION >= 3) {
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_21, __pyx_t_20);
        }
        __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_22 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0;
        goto __pyx_L1_error;
      }
      __pyx_L5_continue: {

        /* "asyncpg/protocol/coreproto.pyx":141
 * 
 *             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":142
 *             finally:
 *                 if self._skip_discard:
 *                     self._skip_discard = False             # <<<<<<<<<<<<<<
 *                 else:
 *                     self.buffer.discard_message()
 */
          __pyx_v_self->_skip_discard = 0;

          /* "asyncpg/protocol/coreproto.pyx":141
 * 
 *             finally:
 *                 if self._skip_discard:             # <<<<<<<<<<<<<<
 *                     self._skip_discard = False
 *                 else:
 */
          goto __pyx_L39;
        }

        /* "asyncpg/protocol/coreproto.pyx":144
 *                     self._skip_discard = False
 *                 else:
 *                     self.buffer.discard_message()             # <<<<<<<<<<<<<<
 * 
 *     cdef _process__auth(self, char mtype):
 */
        /*else*/ {
          __pyx_t_13 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_discard_message(__pyx_v_self->buffer); if (unlikely(!__pyx_t_13)) __PYX_ERR(7, 144, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        }
        __pyx_L39:;
        goto __pyx_L3_continue;
      }
      __pyx_L9:;
    }
    __pyx_L3_continue:;
  }

  /* "asyncpg/protocol/coreproto.pyx":41
 *         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_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __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":146
 *                     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":147
 * 
 *     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":149
 *         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(7, 149, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":150
 *             # 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":151
 *             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":152
 *             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(7, 152, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "asyncpg/protocol/coreproto.pyx":153
 *                 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(7, 153, __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(7, 153, __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(7, 153, __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":150
 *             # 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":155
 *                 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(7, 155, __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":157
 *             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(7, 157, __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(7, 157, __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":158
 *                 # 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(7, 158, __pyx_L1_error)

      /* "asyncpg/protocol/coreproto.pyx":155
 *                 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":147
 * 
 *     cdef _process__auth(self, char mtype):
 *         if mtype == b'R':             # <<<<<<<<<<<<<<
 *             # Authentication...
 *             self._parse_msg_authentication()
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":160
 *                 self.auth_msg = None
 * 
 *         elif mtype == b'K':             # <<<<<<<<<<<<<<
 *             # BackendKeyData
 *             self._parse_msg_backend_key_data()
 */
    case 'K':

    /* "asyncpg/protocol/coreproto.pyx":162
 *         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(7, 162, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "asyncpg/protocol/coreproto.pyx":160
 *                 self.auth_msg = None
 * 
 *         elif mtype == b'K':             # <<<<<<<<<<<<<<
 *             # BackendKeyData
 *             self._parse_msg_backend_key_data()
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":164
 *             self._parse_msg_backend_key_data()
 * 
 *         elif mtype == b'E':             # <<<<<<<<<<<<<<
 *             # ErrorResponse
 *             self.con_status = CONNECTION_BAD
 */
    case 'E':

    /* "asyncpg/protocol/coreproto.pyx":166
 *         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":167
 *             # 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(7, 167, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "asyncpg/protocol/coreproto.pyx":168
 *             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(7, 168, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "asyncpg/protocol/coreproto.pyx":164
 *             self._parse_msg_backend_key_data()
 * 
 *         elif mtype == b'E':             # <<<<<<<<<<<<<<
 *             # ErrorResponse
 *             self.con_status = CONNECTION_BAD
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":170
 *             self._push_result()
 * 
 *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 */
    case 'Z':

    /* "asyncpg/protocol/coreproto.pyx":172
 *         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(7, 172, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "asyncpg/protocol/coreproto.pyx":173
 *             # 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":174
 *             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(7, 174, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "asyncpg/protocol/coreproto.pyx":170
 *             self._push_result()
 * 
 *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 */
    break;
    default: break;
  }

  /* "asyncpg/protocol/coreproto.pyx":146
 *                     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":176
 *             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":177
 * 
 *     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":179
 *         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(7, 179, __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(7, 179, __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(7, 179, __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":177
 * 
 *     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":181
 *             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":183
 *         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(7, 183, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "asyncpg/protocol/coreproto.pyx":181
 *             self.result_param_desc = self.buffer.consume_message().as_bytes()
 * 
 *         elif mtype == b'1':             # <<<<<<<<<<<<<<
 *             # ParseComplete
 *             self.buffer.consume_message()
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":185
 *             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":187
 *         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(7, 187, __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(7, 187, __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(7, 187, __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":185
 *             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":189
 *             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":191
 *         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(7, 191, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":189
 *             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":193
 *             self._parse_msg_error_response(True)
 * 
 *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 */
    case 'Z':

    /* "asyncpg/protocol/coreproto.pyx":195
 *         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(7, 195, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":196
 *             # 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(7, 196, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":193
 *             self._parse_msg_error_response(True)
 * 
 *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":198
 *             self._push_result()
 * 
 *         elif mtype == b'n':             # <<<<<<<<<<<<<<
 *             # NoData
 *             self.buffer.consume_message()
 */
    case 'n':

    /* "asyncpg/protocol/coreproto.pyx":200
 *         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(7, 200, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":198
 *             self._push_result()
 * 
 *         elif mtype == b'n':             # <<<<<<<<<<<<<<
 *             # NoData
 *             self.buffer.consume_message()
 */
    break;
    default: break;
  }

  /* "asyncpg/protocol/coreproto.pyx":176
 *             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":202
 *             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":203
 * 
 *     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":205
 *         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(7, 205, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":203
 * 
 *     cdef _process__bind_execute(self, char mtype):
 *         if mtype == b'D':             # <<<<<<<<<<<<<<
 *             # DataRow
 *             self._parse_data_msgs()
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":207
 *             self._parse_data_msgs()
 * 
 *         elif mtype == b's':             # <<<<<<<<<<<<<<
 *             # PortalSuspended
 *             self.buffer.consume_message()
 */
    case 's':

    /* "asyncpg/protocol/coreproto.pyx":209
 *         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(7, 209, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":207
 *             self._parse_data_msgs()
 * 
 *         elif mtype == b's':             # <<<<<<<<<<<<<<
 *             # PortalSuspended
 *             self.buffer.consume_message()
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":211
 *             self.buffer.consume_message()
 * 
 *         elif mtype == b'C':             # <<<<<<<<<<<<<<
 *             # CommandComplete
 *             self.result_execute_completed = True
 */
    case 'C':

    /* "asyncpg/protocol/coreproto.pyx":213
 *         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":214
 *             # 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(7, 214, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":211
 *             self.buffer.consume_message()
 * 
 *         elif mtype == b'C':             # <<<<<<<<<<<<<<
 *             # CommandComplete
 *             self.result_execute_completed = True
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":216
 *             self._parse_msg_command_complete()
 * 
 *         elif mtype == b'E':             # <<<<<<<<<<<<<<
 *             # ErrorResponse
 *             self._parse_msg_error_response(True)
 */
    case 'E':

    /* "asyncpg/protocol/coreproto.pyx":218
 *         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(7, 218, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":216
 *             self._parse_msg_command_complete()
 * 
 *         elif mtype == b'E':             # <<<<<<<<<<<<<<
 *             # ErrorResponse
 *             self._parse_msg_error_response(True)
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":220
 *             self._parse_msg_error_response(True)
 * 
 *         elif mtype == b'2':             # <<<<<<<<<<<<<<
 *             # BindComplete
 *             self.buffer.consume_message()
 */
    case '2':

    /* "asyncpg/protocol/coreproto.pyx":222
 *         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(7, 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_error_response(True)
 * 
 *         elif mtype == b'2':             # <<<<<<<<<<<<<<
 *             # BindComplete
 *             self.buffer.consume_message()
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":224
 *             self.buffer.consume_message()
 * 
 *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 */
    case 'Z':

    /* "asyncpg/protocol/coreproto.pyx":226
 *         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(7, 226, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":227
 *             # 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(7, 227, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":224
 *             self.buffer.consume_message()
 * 
 *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":229
 *             self._push_result()
 * 
 *         elif mtype == b'I':             # <<<<<<<<<<<<<<
 *             # EmptyQueryResponse
 *             self.buffer.consume_message()
 */
    case 'I':

    /* "asyncpg/protocol/coreproto.pyx":231
 *         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(7, 231, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":229
 *             self._push_result()
 * 
 *         elif mtype == b'I':             # <<<<<<<<<<<<<<
 *             # EmptyQueryResponse
 *             self.buffer.consume_message()
 */
    break;
    default: break;
  }

  /* "asyncpg/protocol/coreproto.pyx":202
 *             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":233
 *             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_v_e = 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;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  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("_process__bind_execute_many", 0);

  /* "asyncpg/protocol/coreproto.pyx":236
 *         cdef WriteBuffer buf
 * 
 *         if mtype == b'D':             # <<<<<<<<<<<<<<
 *             # DataRow
 *             self._parse_data_msgs()
 */
  switch (__pyx_v_mtype) {
    case 'D':

    /* "asyncpg/protocol/coreproto.pyx":238
 *         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(7, 238, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":236
 *         cdef WriteBuffer buf
 * 
 *         if mtype == b'D':             # <<<<<<<<<<<<<<
 *             # DataRow
 *             self._parse_data_msgs()
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":240
 *             self._parse_data_msgs()
 * 
 *         elif mtype == b's':             # <<<<<<<<<<<<<<
 *             # PortalSuspended
 *             self.buffer.consume_message()
 */
    case 's':

    /* "asyncpg/protocol/coreproto.pyx":242
 *         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(7, 242, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":240
 *             self._parse_data_msgs()
 * 
 *         elif mtype == b's':             # <<<<<<<<<<<<<<
 *             # PortalSuspended
 *             self.buffer.consume_message()
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":244
 *             self.buffer.consume_message()
 * 
 *         elif mtype == b'C':             # <<<<<<<<<<<<<<
 *             # CommandComplete
 *             self._parse_msg_command_complete()
 */
    case 'C':

    /* "asyncpg/protocol/coreproto.pyx":246
 *         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(7, 246, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":244
 *             self.buffer.consume_message()
 * 
 *         elif mtype == b'C':             # <<<<<<<<<<<<<<
 *             # CommandComplete
 *             self._parse_msg_command_complete()
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":248
 *             self._parse_msg_command_complete()
 * 
 *         elif mtype == b'E':             # <<<<<<<<<<<<<<
 *             # ErrorResponse
 *             self._parse_msg_error_response(True)
 */
    case 'E':

    /* "asyncpg/protocol/coreproto.pyx":250
 *         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(7, 250, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":248
 *             self._parse_msg_command_complete()
 * 
 *         elif mtype == b'E':             # <<<<<<<<<<<<<<
 *             # ErrorResponse
 *             self._parse_msg_error_response(True)
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":252
 *             self._parse_msg_error_response(True)
 * 
 *         elif mtype == b'2':             # <<<<<<<<<<<<<<
 *             # BindComplete
 *             self.buffer.consume_message()
 */
    case '2':

    /* "asyncpg/protocol/coreproto.pyx":254
 *         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(7, 254, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":252
 *             self._parse_msg_error_response(True)
 * 
 *         elif mtype == b'2':             # <<<<<<<<<<<<<<
 *             # BindComplete
 *             self.buffer.consume_message()
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":256
 *             self.buffer.consume_message()
 * 
 *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 */
    case 'Z':

    /* "asyncpg/protocol/coreproto.pyx":258
 *         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(7, 258, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":259
 *             # 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":260
 *             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(7, 260, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "asyncpg/protocol/coreproto.pyx":259
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 *             if self.result_type == RESULT_FAILED:             # <<<<<<<<<<<<<<
 *                 self._push_result()
 *             else:
 */
      goto __pyx_L3;
    }

    /* "asyncpg/protocol/coreproto.pyx":262
 *                 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":263
 *             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(7, 263, __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":262
 *                 self._push_result()
 *             else:
 *                 try:             # <<<<<<<<<<<<<<
 *                     buf = <WriteBuffer>next(self._execute_iter)
 *                 except StopIteration:
 */
        }

        /* "asyncpg/protocol/coreproto.pyx":272
 *                 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":273
 *                     # 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":272
 *                 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(7, 272, __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_L9_try_end;
        __pyx_L4_error:;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "asyncpg/protocol/coreproto.pyx":264
 *                 try:
 *                     buf = <WriteBuffer>next(self._execute_iter)
 *                 except StopIteration:             # <<<<<<<<<<<<<<
 *                     self._push_result()
 *                 except Exception as e:
 */
        __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(7, 264, __pyx_L6_except_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_GOTREF(__pyx_t_1);

          /* "asyncpg/protocol/coreproto.pyx":265
 *                     buf = <WriteBuffer>next(self._execute_iter)
 *                 except StopIteration:
 *                     self._push_result()             # <<<<<<<<<<<<<<
 *                 except Exception as e:
 *                     self.result_type = RESULT_FAILED
 */
          __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(7, 265, __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;
        }

        /* "asyncpg/protocol/coreproto.pyx":266
 *                 except StopIteration:
 *                     self._push_result()
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     self.result_type = RESULT_FAILED
 *                     self.result = e
 */
        __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
        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_1, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(7, 266, __pyx_L6_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/coreproto.pyx":267
 *                     self._push_result()
 *                 except Exception as e:
 *                     self.result_type = RESULT_FAILED             # <<<<<<<<<<<<<<
 *                     self.result = e
 *                     self._push_result()
 */
            __pyx_v_self->result_type = __pyx_e_7asyncpg_8protocol_8protocol_RESULT_FAILED;

            /* "asyncpg/protocol/coreproto.pyx":268
 *                 except Exception as e:
 *                     self.result_type = RESULT_FAILED
 *                     self.result = e             # <<<<<<<<<<<<<<
 *                     self._push_result()
 *                 else:
 */
            __Pyx_INCREF(__pyx_v_e);
            __Pyx_GIVEREF(__pyx_v_e);
            __Pyx_GOTREF(__pyx_v_self->result);
            __Pyx_DECREF(__pyx_v_self->result);
            __pyx_v_self->result = __pyx_v_e;

            /* "asyncpg/protocol/coreproto.pyx":269
 *                     self.result_type = RESULT_FAILED
 *                     self.result = e
 *                     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(7, 269, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          }

          /* "asyncpg/protocol/coreproto.pyx":266
 *                 except StopIteration:
 *                     self._push_result()
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     self.result_type = RESULT_FAILED
 *                     self.result = e
 */
          /*finally:*/ {
            /*normal exit:*/{
              __Pyx_DECREF(__pyx_v_e);
              __pyx_v_e = NULL;
              goto __pyx_L18;
            }
            __pyx_L17_error:;
            /*exception exit:*/{
              __Pyx_PyThreadState_declare
              __Pyx_PyThreadState_assign
              __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_XDECREF(__pyx_t_9); __pyx_t_9 = 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_8 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_11 = __pyx_filename;
              {
                __Pyx_DECREF(__pyx_v_e);
                __pyx_v_e = NULL;
              }
              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_8; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_11;
              goto __pyx_L6_except_error;
            }
            __pyx_L18:;
          }
          __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;
          goto __pyx_L5_exception_handled;
        }
        goto __pyx_L6_except_error;
        __pyx_L6_except_error:;

        /* "asyncpg/protocol/coreproto.pyx":262
 *                 self._push_result()
 *             else:
 *                 try:             # <<<<<<<<<<<<<<
 *                     buf = <WriteBuffer>next(self._execute_iter)
 *                 except StopIteration:
 */
        __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_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_L9_try_end:;
      }
    }
    __pyx_L3:;

    /* "asyncpg/protocol/coreproto.pyx":256
 *             self.buffer.consume_message()
 * 
 *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":276
 *                         buf, 0)
 * 
 *         elif mtype == b'I':             # <<<<<<<<<<<<<<
 *             # EmptyQueryResponse
 *             self.buffer.consume_message()
 */
    case 'I':

    /* "asyncpg/protocol/coreproto.pyx":278
 *         elif mtype == b'I':
 *             # EmptyQueryResponse
 *             self.buffer.consume_message()             # <<<<<<<<<<<<<<
 * 
 *     cdef _process__bind(self, char mtype):
 */
    __pyx_t_7 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(__pyx_v_self->buffer)); if (unlikely(!__pyx_t_7)) __PYX_ERR(7, 278, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "asyncpg/protocol/coreproto.pyx":276
 *                         buf, 0)
 * 
 *         elif mtype == b'I':             # <<<<<<<<<<<<<<
 *             # EmptyQueryResponse
 *             self.buffer.consume_message()
 */
    break;
    default: break;
  }

  /* "asyncpg/protocol/coreproto.pyx":233
 *             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_XDECREF(__pyx_v_e);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/coreproto.pyx":280
 *             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":281
 * 
 *     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":283
 *         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(7, 283, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":281
 * 
 *     cdef _process__bind(self, char mtype):
 *         if mtype == b'E':             # <<<<<<<<<<<<<<
 *             # ErrorResponse
 *             self._parse_msg_error_response(True)
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":285
 *             self._parse_msg_error_response(True)
 * 
 *         elif mtype == b'2':             # <<<<<<<<<<<<<<
 *             # BindComplete
 *             self.buffer.consume_message()
 */
    case '2':

    /* "asyncpg/protocol/coreproto.pyx":287
 *         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(7, 287, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":285
 *             self._parse_msg_error_response(True)
 * 
 *         elif mtype == b'2':             # <<<<<<<<<<<<<<
 *             # BindComplete
 *             self.buffer.consume_message()
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":289
 *             self.buffer.consume_message()
 * 
 *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 */
    case 'Z':

    /* "asyncpg/protocol/coreproto.pyx":291
 *         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(7, 291, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":292
 *             # 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(7, 292, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":289
 *             self.buffer.consume_message()
 * 
 *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 */
    break;
    default: break;
  }

  /* "asyncpg/protocol/coreproto.pyx":280
 *             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":294
 *             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":295
 * 
 *     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":297
 *         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(7, 297, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":295
 * 
 *     cdef _process__close_stmt_portal(self, char mtype):
 *         if mtype == b'E':             # <<<<<<<<<<<<<<
 *             # ErrorResponse
 *             self._parse_msg_error_response(True)
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":299
 *             self._parse_msg_error_response(True)
 * 
 *         elif mtype == b'3':             # <<<<<<<<<<<<<<
 *             # CloseComplete
 *             self.buffer.consume_message()
 */
    case '3':

    /* "asyncpg/protocol/coreproto.pyx":301
 *         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(7, 301, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":299
 *             self._parse_msg_error_response(True)
 * 
 *         elif mtype == b'3':             # <<<<<<<<<<<<<<
 *             # CloseComplete
 *             self.buffer.consume_message()
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":303
 *             self.buffer.consume_message()
 * 
 *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 */
    case 'Z':

    /* "asyncpg/protocol/coreproto.pyx":305
 *         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(7, 305, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":306
 *             # 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(7, 306, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":303
 *             self.buffer.consume_message()
 * 
 *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 */
    break;
    default: break;
  }

  /* "asyncpg/protocol/coreproto.pyx":294
 *             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":308
 *             self._push_result()
 * 
 *     cdef _process__simple_query(self, char mtype):             # <<<<<<<<<<<<<<
 *         if mtype in {b'D', b'I', 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":309
 * 
 *     cdef _process__simple_query(self, char mtype):
 *         if mtype in {b'D', b'I', b'T'}:             # <<<<<<<<<<<<<<
 *             # 'D' - DataRow
 *             # 'I' - EmptyQueryResponse
 */
  switch (__pyx_v_mtype) {
    case 'D':
    case 'I':
    case 'T':

    /* "asyncpg/protocol/coreproto.pyx":313
 *             # 'I' - EmptyQueryResponse
 *             # '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(7, 313, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":309
 * 
 *     cdef _process__simple_query(self, char mtype):
 *         if mtype in {b'D', b'I', b'T'}:             # <<<<<<<<<<<<<<
 *             # 'D' - DataRow
 *             # 'I' - EmptyQueryResponse
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":315
 *             self.buffer.consume_message()
 * 
 *         elif mtype == b'E':             # <<<<<<<<<<<<<<
 *             # ErrorResponse
 *             self._parse_msg_error_response(True)
 */
    case 'E':

    /* "asyncpg/protocol/coreproto.pyx":317
 *         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(7, 317, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":315
 *             self.buffer.consume_message()
 * 
 *         elif mtype == b'E':             # <<<<<<<<<<<<<<
 *             # ErrorResponse
 *             self._parse_msg_error_response(True)
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":319
 *             self._parse_msg_error_response(True)
 * 
 *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 */
    case 'Z':

    /* "asyncpg/protocol/coreproto.pyx":321
 *         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(7, 321, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":322
 *             # 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(7, 322, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":319
 *             self._parse_msg_error_response(True)
 * 
 *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":324
 *             self._push_result()
 * 
 *         elif mtype == b'C':             # <<<<<<<<<<<<<<
 *             # CommandComplete
 *             self._parse_msg_command_complete()
 */
    case 'C':

    /* "asyncpg/protocol/coreproto.pyx":326
 *         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(7, 326, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":324
 *             self._push_result()
 * 
 *         elif mtype == b'C':             # <<<<<<<<<<<<<<
 *             # CommandComplete
 *             self._parse_msg_command_complete()
 */
    break;
    default:

    /* "asyncpg/protocol/coreproto.pyx":330
 *         else:
 *             # We don't really care about COPY IN etc
 *             self.buffer.consume_message()             # <<<<<<<<<<<<<<
 * 
 *     cdef _process__copy_out(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(7, 330, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    break;
  }

  /* "asyncpg/protocol/coreproto.pyx":308
 *             self._push_result()
 * 
 *     cdef _process__simple_query(self, char mtype):             # <<<<<<<<<<<<<<
 *         if mtype in {b'D', b'I', 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":332
 *             self.buffer.consume_message()
 * 
 *     cdef _process__copy_out(self, char mtype):             # <<<<<<<<<<<<<<
 *         if mtype == b'E':
 *             self._parse_msg_error_response(True)
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__copy_out(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__copy_out", 0);

  /* "asyncpg/protocol/coreproto.pyx":333
 * 
 *     cdef _process__copy_out(self, char mtype):
 *         if mtype == b'E':             # <<<<<<<<<<<<<<
 *             self._parse_msg_error_response(True)
 * 
 */
  switch (__pyx_v_mtype) {
    case 'E':

    /* "asyncpg/protocol/coreproto.pyx":334
 *     cdef _process__copy_out(self, char mtype):
 *         if mtype == b'E':
 *             self._parse_msg_error_response(True)             # <<<<<<<<<<<<<<
 * 
 *         elif mtype == b'H':
 */
    __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(7, 334, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":333
 * 
 *     cdef _process__copy_out(self, char mtype):
 *         if mtype == b'E':             # <<<<<<<<<<<<<<
 *             self._parse_msg_error_response(True)
 * 
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":336
 *             self._parse_msg_error_response(True)
 * 
 *         elif mtype == b'H':             # <<<<<<<<<<<<<<
 *             # CopyOutResponse
 *             self._set_state(PROTOCOL_COPY_OUT_DATA)
 */
    case 'H':

    /* "asyncpg/protocol/coreproto.pyx":338
 *         elif mtype == b'H':
 *             # CopyOutResponse
 *             self._set_state(PROTOCOL_COPY_OUT_DATA)             # <<<<<<<<<<<<<<
 *             self.buffer.consume_message()
 * 
 */
    __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_COPY_OUT_DATA); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 338, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":339
 *             # CopyOutResponse
 *             self._set_state(PROTOCOL_COPY_OUT_DATA)
 *             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(7, 339, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":336
 *             self._parse_msg_error_response(True)
 * 
 *         elif mtype == b'H':             # <<<<<<<<<<<<<<
 *             # CopyOutResponse
 *             self._set_state(PROTOCOL_COPY_OUT_DATA)
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":341
 *             self.buffer.consume_message()
 * 
 *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 */
    case 'Z':

    /* "asyncpg/protocol/coreproto.pyx":343
 *         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(7, 343, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":344
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 *             self._push_result()             # <<<<<<<<<<<<<<
 * 
 *     cdef _process__copy_out_data(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(7, 344, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":341
 *             self.buffer.consume_message()
 * 
 *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 */
    break;
    default: break;
  }

  /* "asyncpg/protocol/coreproto.pyx":332
 *             self.buffer.consume_message()
 * 
 *     cdef _process__copy_out(self, char mtype):             # <<<<<<<<<<<<<<
 *         if mtype == b'E':
 *             self._parse_msg_error_response(True)
 */

  /* 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__copy_out", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/coreproto.pyx":346
 *             self._push_result()
 * 
 *     cdef _process__copy_out_data(self, char mtype):             # <<<<<<<<<<<<<<
 *         if mtype == b'E':
 *             self._parse_msg_error_response(True)
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__copy_out_data(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__copy_out_data", 0);

  /* "asyncpg/protocol/coreproto.pyx":347
 * 
 *     cdef _process__copy_out_data(self, char mtype):
 *         if mtype == b'E':             # <<<<<<<<<<<<<<
 *             self._parse_msg_error_response(True)
 * 
 */
  switch (__pyx_v_mtype) {
    case 'E':

    /* "asyncpg/protocol/coreproto.pyx":348
 *     cdef _process__copy_out_data(self, char mtype):
 *         if mtype == b'E':
 *             self._parse_msg_error_response(True)             # <<<<<<<<<<<<<<
 * 
 *         elif mtype == b'd':
 */
    __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(7, 348, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":347
 * 
 *     cdef _process__copy_out_data(self, char mtype):
 *         if mtype == b'E':             # <<<<<<<<<<<<<<
 *             self._parse_msg_error_response(True)
 * 
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":350
 *             self._parse_msg_error_response(True)
 * 
 *         elif mtype == b'd':             # <<<<<<<<<<<<<<
 *             # CopyData
 *             self._parse_copy_data_msgs()
 */
    case 'd':

    /* "asyncpg/protocol/coreproto.pyx":352
 *         elif mtype == b'd':
 *             # CopyData
 *             self._parse_copy_data_msgs()             # <<<<<<<<<<<<<<
 * 
 *         elif mtype == b'c':
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_parse_copy_data_msgs(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 352, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":350
 *             self._parse_msg_error_response(True)
 * 
 *         elif mtype == b'd':             # <<<<<<<<<<<<<<
 *             # CopyData
 *             self._parse_copy_data_msgs()
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":354
 *             self._parse_copy_data_msgs()
 * 
 *         elif mtype == b'c':             # <<<<<<<<<<<<<<
 *             # CopyDone
 *             self.buffer.consume_message()
 */
    case 'c':

    /* "asyncpg/protocol/coreproto.pyx":356
 *         elif mtype == b'c':
 *             # CopyDone
 *             self.buffer.consume_message()             # <<<<<<<<<<<<<<
 *             self._set_state(PROTOCOL_COPY_OUT_DONE)
 * 
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(__pyx_v_self->buffer)); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 356, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":357
 *             # CopyDone
 *             self.buffer.consume_message()
 *             self._set_state(PROTOCOL_COPY_OUT_DONE)             # <<<<<<<<<<<<<<
 * 
 *         elif mtype == 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_COPY_OUT_DONE); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 357, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":354
 *             self._parse_copy_data_msgs()
 * 
 *         elif mtype == b'c':             # <<<<<<<<<<<<<<
 *             # CopyDone
 *             self.buffer.consume_message()
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":359
 *             self._set_state(PROTOCOL_COPY_OUT_DONE)
 * 
 *         elif mtype == b'C':             # <<<<<<<<<<<<<<
 *             # CommandComplete
 *             self._parse_msg_command_complete()
 */
    case 'C':

    /* "asyncpg/protocol/coreproto.pyx":361
 *         elif mtype == b'C':
 *             # CommandComplete
 *             self._parse_msg_command_complete()             # <<<<<<<<<<<<<<
 * 
 *         elif mtype == b'Z':
 */
    __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(7, 361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":359
 *             self._set_state(PROTOCOL_COPY_OUT_DONE)
 * 
 *         elif mtype == b'C':             # <<<<<<<<<<<<<<
 *             # CommandComplete
 *             self._parse_msg_command_complete()
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":363
 *             self._parse_msg_command_complete()
 * 
 *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 */
    case 'Z':

    /* "asyncpg/protocol/coreproto.pyx":365
 *         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(7, 365, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":366
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 *             self._push_result()             # <<<<<<<<<<<<<<
 * 
 *     cdef _process__copy_in(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(7, 366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":363
 *             self._parse_msg_command_complete()
 * 
 *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 */
    break;
    default: break;
  }

  /* "asyncpg/protocol/coreproto.pyx":346
 *             self._push_result()
 * 
 *     cdef _process__copy_out_data(self, char mtype):             # <<<<<<<<<<<<<<
 *         if mtype == b'E':
 *             self._parse_msg_error_response(True)
 */

  /* 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__copy_out_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":368
 *             self._push_result()
 * 
 *     cdef _process__copy_in(self, char mtype):             # <<<<<<<<<<<<<<
 *         if mtype == b'E':
 *             self._parse_msg_error_response(True)
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__copy_in(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__copy_in", 0);

  /* "asyncpg/protocol/coreproto.pyx":369
 * 
 *     cdef _process__copy_in(self, char mtype):
 *         if mtype == b'E':             # <<<<<<<<<<<<<<
 *             self._parse_msg_error_response(True)
 * 
 */
  switch (__pyx_v_mtype) {
    case 'E':

    /* "asyncpg/protocol/coreproto.pyx":370
 *     cdef _process__copy_in(self, char mtype):
 *         if mtype == b'E':
 *             self._parse_msg_error_response(True)             # <<<<<<<<<<<<<<
 * 
 *         elif mtype == b'G':
 */
    __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(7, 370, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":369
 * 
 *     cdef _process__copy_in(self, char mtype):
 *         if mtype == b'E':             # <<<<<<<<<<<<<<
 *             self._parse_msg_error_response(True)
 * 
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":372
 *             self._parse_msg_error_response(True)
 * 
 *         elif mtype == b'G':             # <<<<<<<<<<<<<<
 *             # CopyInResponse
 *             self._set_state(PROTOCOL_COPY_IN_DATA)
 */
    case 'G':

    /* "asyncpg/protocol/coreproto.pyx":374
 *         elif mtype == b'G':
 *             # CopyInResponse
 *             self._set_state(PROTOCOL_COPY_IN_DATA)             # <<<<<<<<<<<<<<
 *             self.buffer.consume_message()
 * 
 */
    __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_COPY_IN_DATA); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 374, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":375
 *             # CopyInResponse
 *             self._set_state(PROTOCOL_COPY_IN_DATA)
 *             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(7, 375, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":372
 *             self._parse_msg_error_response(True)
 * 
 *         elif mtype == b'G':             # <<<<<<<<<<<<<<
 *             # CopyInResponse
 *             self._set_state(PROTOCOL_COPY_IN_DATA)
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":377
 *             self.buffer.consume_message()
 * 
 *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 */
    case 'Z':

    /* "asyncpg/protocol/coreproto.pyx":379
 *         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(7, 379, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":380
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 *             self._push_result()             # <<<<<<<<<<<<<<
 * 
 *     cdef _process__copy_in_data(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(7, 380, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":377
 *             self.buffer.consume_message()
 * 
 *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 */
    break;
    default: break;
  }

  /* "asyncpg/protocol/coreproto.pyx":368
 *             self._push_result()
 * 
 *     cdef _process__copy_in(self, char mtype):             # <<<<<<<<<<<<<<
 *         if mtype == b'E':
 *             self._parse_msg_error_response(True)
 */

  /* 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__copy_in", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/coreproto.pyx":382
 *             self._push_result()
 * 
 *     cdef _process__copy_in_data(self, char mtype):             # <<<<<<<<<<<<<<
 *         if mtype == b'E':
 *             self._parse_msg_error_response(True)
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__copy_in_data(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__copy_in_data", 0);

  /* "asyncpg/protocol/coreproto.pyx":383
 * 
 *     cdef _process__copy_in_data(self, char mtype):
 *         if mtype == b'E':             # <<<<<<<<<<<<<<
 *             self._parse_msg_error_response(True)
 * 
 */
  switch (__pyx_v_mtype) {
    case 'E':

    /* "asyncpg/protocol/coreproto.pyx":384
 *     cdef _process__copy_in_data(self, char mtype):
 *         if mtype == b'E':
 *             self._parse_msg_error_response(True)             # <<<<<<<<<<<<<<
 * 
 *         elif mtype == b'C':
 */
    __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(7, 384, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":383
 * 
 *     cdef _process__copy_in_data(self, char mtype):
 *         if mtype == b'E':             # <<<<<<<<<<<<<<
 *             self._parse_msg_error_response(True)
 * 
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":386
 *             self._parse_msg_error_response(True)
 * 
 *         elif mtype == b'C':             # <<<<<<<<<<<<<<
 *             # CommandComplete
 *             self._parse_msg_command_complete()
 */
    case 'C':

    /* "asyncpg/protocol/coreproto.pyx":388
 *         elif mtype == b'C':
 *             # CommandComplete
 *             self._parse_msg_command_complete()             # <<<<<<<<<<<<<<
 * 
 *         elif mtype == b'Z':
 */
    __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(7, 388, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":386
 *             self._parse_msg_error_response(True)
 * 
 *         elif mtype == b'C':             # <<<<<<<<<<<<<<
 *             # CommandComplete
 *             self._parse_msg_command_complete()
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":390
 *             self._parse_msg_command_complete()
 * 
 *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 */
    case 'Z':

    /* "asyncpg/protocol/coreproto.pyx":392
 *         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(7, 392, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":393
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 *             self._push_result()             # <<<<<<<<<<<<<<
 * 
 *     cdef _parse_msg_command_complete(self):
 */
    __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(7, 393, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":390
 *             self._parse_msg_command_complete()
 * 
 *         elif mtype == b'Z':             # <<<<<<<<<<<<<<
 *             # ReadyForQuery
 *             self._parse_msg_ready_for_query()
 */
    break;
    default: break;
  }

  /* "asyncpg/protocol/coreproto.pyx":382
 *             self._push_result()
 * 
 *     cdef _process__copy_in_data(self, char mtype):             # <<<<<<<<<<<<<<
 *         if mtype == b'E':
 *             self._parse_msg_error_response(True)
 */

  /* 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__copy_in_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":395
 *             self._push_result()
 * 
 *     cdef _parse_msg_command_complete(self):             # <<<<<<<<<<<<<<
 *         cdef:
 *             const 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 const *__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":400
 *             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":401
 * 
 *         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":402
 *         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(7, 402, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_msg = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "asyncpg/protocol/coreproto.pyx":401
 * 
 *         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":404
 *             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(7, 404, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_msg = __pyx_t_3;
    __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "asyncpg/protocol/coreproto.pyx":405
 *         else:
 *             msg = self.buffer.read_cstr()
 *         self.result_status_msg = msg             # <<<<<<<<<<<<<<
 * 
 *     cdef _parse_copy_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(7, 405, __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":395
 *             self._push_result()
 * 
 *     cdef _parse_msg_command_complete(self):             # <<<<<<<<<<<<<<
 *         cdef:
 *             const 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":407
 *         self.result_status_msg = msg
 * 
 *     cdef _parse_copy_data_msgs(self):             # <<<<<<<<<<<<<<
 *         cdef:
 *             ReadBuffer buf = self.buffer
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__parse_copy_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_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int32_t __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("_parse_copy_data_msgs", 0);

  /* "asyncpg/protocol/coreproto.pyx":409
 *     cdef _parse_copy_data_msgs(self):
 *         cdef:
 *             ReadBuffer buf = self.buffer             # <<<<<<<<<<<<<<
 * 
 *         self.result = buf.consume_messages(b'd')
 */
  __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":411
 *             ReadBuffer buf = self.buffer
 * 
 *         self.result = buf.consume_messages(b'd')             # <<<<<<<<<<<<<<
 * 
 *         self._skip_discard = True
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_messages(__pyx_v_buf, 'd'); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 411, __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":413
 *         self.result = buf.consume_messages(b'd')
 * 
 *         self._skip_discard = True             # <<<<<<<<<<<<<<
 * 
 *         # By this point we have consumed all CopyData messages
 */
  __pyx_v_self->_skip_discard = 1;

  /* "asyncpg/protocol/coreproto.pyx":422
 *         # we must not push the result here and let the
 *         # _process__copy_out_data subprotocol do the job.
 *         if not buf.has_message():             # <<<<<<<<<<<<<<
 *             self._on_result()
 *             self.result = None
 */
  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_has_message(__pyx_v_buf); if (unlikely(__pyx_t_2 == ((int32_t)-1))) __PYX_ERR(7, 422, __pyx_L1_error)
  __pyx_t_3 = ((!(__pyx_t_2 != 0)) != 0);
  if (__pyx_t_3) {

    /* "asyncpg/protocol/coreproto.pyx":423
 *         # _process__copy_out_data subprotocol do the job.
 *         if not buf.has_message():
 *             self._on_result()             # <<<<<<<<<<<<<<
 *             self.result = None
 * 
 */
    __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(7, 423, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":424
 *         if not buf.has_message():
 *             self._on_result()
 *             self.result = None             # <<<<<<<<<<<<<<
 * 
 *     cdef _write_copy_data_msg(self, object 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":422
 *         # we must not push the result here and let the
 *         # _process__copy_out_data subprotocol do the job.
 *         if not buf.has_message():             # <<<<<<<<<<<<<<
 *             self._on_result()
 *             self.result = None
 */
  }

  /* "asyncpg/protocol/coreproto.pyx":407
 *         self.result_status_msg = msg
 * 
 *     cdef _parse_copy_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_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._parse_copy_data_msgs", __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":426
 *             self.result = None
 * 
 *     cdef _write_copy_data_msg(self, object data):             # <<<<<<<<<<<<<<
 *         cdef:
 *             WriteBuffer buf
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__write_copy_data_msg(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_data) {
  struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *__pyx_v_buf = 0;
  PyObject *__pyx_v_mview = 0;
  Py_buffer *__pyx_v_pybuf;
  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;
  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("_write_copy_data_msg", 0);

  /* "asyncpg/protocol/coreproto.pyx":432
 *             Py_buffer *pybuf
 * 
 *         mview = PyMemoryView_GetContiguous(data, cpython.PyBUF_SIMPLE, b'C')             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
  __pyx_t_1 = PyMemoryView_GetContiguous(__pyx_v_data, PyBUF_SIMPLE, 'C'); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 432, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_mview = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":434
 *         mview = PyMemoryView_GetContiguous(data, cpython.PyBUF_SIMPLE, b'C')
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             pybuf = PyMemoryView_GET_BUFFER(mview)
 * 
 */
  /*try:*/ {

    /* "asyncpg/protocol/coreproto.pyx":435
 * 
 *         try:
 *             pybuf = PyMemoryView_GET_BUFFER(mview)             # <<<<<<<<<<<<<<
 * 
 *             buf = WriteBuffer.new_message(b'd')
 */
    __pyx_v_pybuf = PyMemoryView_GET_BUFFER(__pyx_v_mview);

    /* "asyncpg/protocol/coreproto.pyx":437
 *             pybuf = PyMemoryView_GET_BUFFER(mview)
 * 
 *             buf = WriteBuffer.new_message(b'd')             # <<<<<<<<<<<<<<
 *             buf.write_cstr(<const char *>pybuf.buf, pybuf.len)
 *             buf.end_message()
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new_message('d')); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 437, __pyx_L4_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":438
 * 
 *             buf = WriteBuffer.new_message(b'd')
 *             buf.write_cstr(<const char *>pybuf.buf, pybuf.len)             # <<<<<<<<<<<<<<
 *             buf.end_message()
 *         finally:
 */
    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_cstr(__pyx_v_buf, ((char const *)__pyx_v_pybuf->buf), __pyx_v_pybuf->len); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 438, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":439
 *             buf = WriteBuffer.new_message(b'd')
 *             buf.write_cstr(<const char *>pybuf.buf, pybuf.len)
 *             buf.end_message()             # <<<<<<<<<<<<<<
 *         finally:
 *             mview.release()
 */
    __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_end_message(__pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 439, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "asyncpg/protocol/coreproto.pyx":441
 *             buf.end_message()
 *         finally:
 *             mview.release()             # <<<<<<<<<<<<<<
 * 
 *         self._write(buf)
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_mview, __pyx_n_s_release); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 441, __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(7, 441, __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(7, 441, __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;
      goto __pyx_L5;
    }
    __pyx_L4_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __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_XDECREF(__pyx_t_1); __pyx_t_1 = 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_4 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_6 = __pyx_filename;
      {
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_mview, __pyx_n_s_release); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 441, __pyx_L7_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(7, 441, __pyx_L7_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(7, 441, __pyx_L7_error)
        }
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      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_4; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_6;
      goto __pyx_L1_error;
      __pyx_L7_error:;
      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_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;
      __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L5:;
  }

  /* "asyncpg/protocol/coreproto.pyx":443
 *             mview.release()
 * 
 *         self._write(buf)             # <<<<<<<<<<<<<<
 * 
 *     cdef _write_copy_done_msg(self):
 */
  __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(7, 443, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":426
 *             self.result = None
 * 
 *     cdef _write_copy_data_msg(self, object data):             # <<<<<<<<<<<<<<
 *         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_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._write_copy_data_msg", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_buf);
  __Pyx_XDECREF(__pyx_v_mview);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/coreproto.pyx":445
 *         self._write(buf)
 * 
 *     cdef _write_copy_done_msg(self):             # <<<<<<<<<<<<<<
 *         cdef:
 *             WriteBuffer buf
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__write_copy_done_msg(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("_write_copy_done_msg", 0);

  /* "asyncpg/protocol/coreproto.pyx":449
 *             WriteBuffer buf
 * 
 *         buf = WriteBuffer.new_message(b'c')             # <<<<<<<<<<<<<<
 *         buf.end_message()
 *         self._write(buf)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new_message('c')); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 449, __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":450
 * 
 *         buf = WriteBuffer.new_message(b'c')
 *         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(7, 450, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":451
 *         buf = WriteBuffer.new_message(b'c')
 *         buf.end_message()
 *         self._write(buf)             # <<<<<<<<<<<<<<
 * 
 *     cdef _write_copy_fail_msg(self, str cause):
 */
  __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(7, 451, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":445
 *         self._write(buf)
 * 
 *     cdef _write_copy_done_msg(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_1);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._write_copy_done_msg", __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":453
 *         self._write(buf)
 * 
 *     cdef _write_copy_fail_msg(self, str cause):             # <<<<<<<<<<<<<<
 *         cdef:
 *             WriteBuffer buf
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__write_copy_fail_msg(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_cause) {
  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;
  __Pyx_RefNannySetupContext("_write_copy_fail_msg", 0);

  /* "asyncpg/protocol/coreproto.pyx":457
 *             WriteBuffer buf
 * 
 *         buf = WriteBuffer.new_message(b'f')             # <<<<<<<<<<<<<<
 *         buf.write_str(cause or '', self.encoding)
 *         buf.end_message()
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new_message('f')); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 457, __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":458
 * 
 *         buf = WriteBuffer.new_message(b'f')
 *         buf.write_str(cause or '', self.encoding)             # <<<<<<<<<<<<<<
 *         buf.end_message()
 *         self._write(buf)
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_cause); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(7, 458, __pyx_L1_error)
  if (!__pyx_t_2) {
  } else {
    __Pyx_INCREF(__pyx_v_cause);
    __pyx_t_1 = __pyx_v_cause;
    goto __pyx_L3_bool_binop_done;
  }
  __Pyx_INCREF(__pyx_kp_u__22);
  __pyx_t_1 = __pyx_kp_u__22;
  __pyx_L3_bool_binop_done:;
  __pyx_t_3 = __pyx_v_self->encoding;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_str(__pyx_v_buf, ((PyObject*)__pyx_t_1), ((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_4)) __PYX_ERR(7, 458, __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_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "asyncpg/protocol/coreproto.pyx":459
 *         buf = WriteBuffer.new_message(b'f')
 *         buf.write_str(cause or '', self.encoding)
 *         buf.end_message()             # <<<<<<<<<<<<<<
 *         self._write(buf)
 * 
 */
  __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_end_message(__pyx_v_buf); if (unlikely(!__pyx_t_4)) __PYX_ERR(7, 459, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "asyncpg/protocol/coreproto.pyx":460
 *         buf.write_str(cause or '', self.encoding)
 *         buf.end_message()
 *         self._write(buf)             # <<<<<<<<<<<<<<
 * 
 *     cdef _parse_data_msgs(self):
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_write(__pyx_v_self, ((PyObject *)__pyx_v_buf)); if (unlikely(!__pyx_t_4)) __PYX_ERR(7, 460, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "asyncpg/protocol/coreproto.pyx":453
 *         self._write(buf)
 * 
 *     cdef _write_copy_fail_msg(self, str cause):             # <<<<<<<<<<<<<<
 *         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_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._write_copy_fail_msg", __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":462
 *         self._write(buf)
 * 
 *     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 const *__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;
  PyObject *__pyx_t_3 = NULL;
  int32_t __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;
  int __pyx_t_10;
  __Pyx_RefNannySetupContext("_parse_data_msgs", 0);

  /* "asyncpg/protocol/coreproto.pyx":464
 *     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":466
 *             ReadBuffer buf = self.buffer
 *             list rows
 *             decode_row_method decoder = <decode_row_method>self._decode_row             # <<<<<<<<<<<<<<
 * 
 *             const 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":473
 *             Memory mem
 * 
 *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
 *             if buf.get_message_type() != b'D':
 *                 raise apg_exc.InternalClientError(
 */
  __pyx_t_2 = (ASYNCPG_DEBUG != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/coreproto.pyx":474
 * 
 *         if ASYNCPG_DEBUG:
 *             if buf.get_message_type() != b'D':             # <<<<<<<<<<<<<<
 *                 raise apg_exc.InternalClientError(
 *                     '_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":475
 *         if ASYNCPG_DEBUG:
 *             if buf.get_message_type() != b'D':
 *                 raise apg_exc.InternalClientError(             # <<<<<<<<<<<<<<
 *                     '_parse_data_msgs: first message is not "D"')
 * 
 */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 475, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_InternalClientError); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 475, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__78, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 475, __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(7, 475, __pyx_L1_error)

      /* "asyncpg/protocol/coreproto.pyx":474
 * 
 *         if ASYNCPG_DEBUG:
 *             if buf.get_message_type() != b'D':             # <<<<<<<<<<<<<<
 *                 raise apg_exc.InternalClientError(
 *                     '_parse_data_msgs: first message is not "D"')
 */
    }

    /* "asyncpg/protocol/coreproto.pyx":473
 *             Memory mem
 * 
 *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
 *             if buf.get_message_type() != b'D':
 *                 raise apg_exc.InternalClientError(
 */
  }

  /* "asyncpg/protocol/coreproto.pyx":478
 *                     '_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":479
 * 
 *         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":480
 *         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(7, 480, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "asyncpg/protocol/coreproto.pyx":481
 *             while True:
 *                 buf.consume_message()
 *                 if not buf.has_message() or buf.get_message_type() != b'D':             # <<<<<<<<<<<<<<
 *                     self._skip_discard = True
 *                     return
 */
      __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_has_message(__pyx_v_buf); if (unlikely(__pyx_t_4 == ((int32_t)-1))) __PYX_ERR(7, 481, __pyx_L1_error)
      __pyx_t_5 = ((!(__pyx_t_4 != 0)) != 0);
      if (!__pyx_t_5) {
      } else {
        __pyx_t_2 = __pyx_t_5;
        goto __pyx_L9_bool_binop_done;
      }
      __pyx_t_5 = ((__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_get_message_type(__pyx_v_buf) != 'D') != 0);
      __pyx_t_2 = __pyx_t_5;
      __pyx_L9_bool_binop_done:;
      if (__pyx_t_2) {

        /* "asyncpg/protocol/coreproto.pyx":482
 *                 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":483
 *                 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":481
 *             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":478
 *                     '_parse_data_msgs: first message is not "D"')
 * 
 *         if self._discard_data:             # <<<<<<<<<<<<<<
 *             while True:
 *                 buf.consume_message()
 */
  }

  /* "asyncpg/protocol/coreproto.pyx":485
 *                     return
 * 
 *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
 *             if type(self.result) is not list:
 *                 raise apg_exc.InternalClientError(
 */
  __pyx_t_2 = (ASYNCPG_DEBUG != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/coreproto.pyx":486
 * 
 *         if ASYNCPG_DEBUG:
 *             if type(self.result) is not list:             # <<<<<<<<<<<<<<
 *                 raise apg_exc.InternalClientError(
 *                     '_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_5 = (__pyx_t_2 != 0);
    if (__pyx_t_5) {

      /* "asyncpg/protocol/coreproto.pyx":487
 *         if ASYNCPG_DEBUG:
 *             if type(self.result) is not list:
 *                 raise apg_exc.InternalClientError(             # <<<<<<<<<<<<<<
 *                     '_parse_data_msgs: result is not a list, but {!r}'.
 *                     format(self.result))
 */
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 487, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_InternalClientError); if (unlikely(!__pyx_t_6)) __PYX_ERR(7, 487, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "asyncpg/protocol/coreproto.pyx":488
 *             if type(self.result) is not list:
 *                 raise apg_exc.InternalClientError(
 *                     '_parse_data_msgs: result is not a list, but {!r}'.             # <<<<<<<<<<<<<<
 *                     format(self.result))
 * 
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_parse_data_msgs_result_is_not_a, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(7, 488, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);

      /* "asyncpg/protocol/coreproto.pyx":489
 *                 raise apg_exc.InternalClientError(
 *                     '_parse_data_msgs: result is not a list, but {!r}'.
 *                     format(self.result))             # <<<<<<<<<<<<<<
 * 
 *         rows = self.result
 */
      __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->result); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 489, __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->result};
          __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 489, __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->result};
          __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 489, __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(7, 489, __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->result);
          __Pyx_GIVEREF(__pyx_v_self->result);
          PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_self->result);
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 489, __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_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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 487, __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_6)) {
          PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_3};
          __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 487, __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;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
          PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_3};
          __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 487, __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;
        } else
        #endif
        {
          __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(7, 487, __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_3);
          PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_3);
          __pyx_t_3 = 0;
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 487, __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_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __PYX_ERR(7, 487, __pyx_L1_error)

      /* "asyncpg/protocol/coreproto.pyx":486
 * 
 *         if ASYNCPG_DEBUG:
 *             if type(self.result) is not list:             # <<<<<<<<<<<<<<
 *                 raise apg_exc.InternalClientError(
 *                     '_parse_data_msgs: result is not a list, but {!r}'.
 */
    }

    /* "asyncpg/protocol/coreproto.pyx":485
 *                     return
 * 
 *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
 *             if type(self.result) is not list:
 *                 raise apg_exc.InternalClientError(
 */
  }

  /* "asyncpg/protocol/coreproto.pyx":491
 *                     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(7, 491, __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":492
 * 
 *         rows = self.result
 *         while True:             # <<<<<<<<<<<<<<
 *             cbuf = buf.try_consume_message(&cbuf_len)
 *             if cbuf != NULL:
 */
  while (1) {

    /* "asyncpg/protocol/coreproto.pyx":493
 *         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":494
 *         while True:
 *             cbuf = buf.try_consume_message(&cbuf_len)
 *             if cbuf != NULL:             # <<<<<<<<<<<<<<
 *                 row = decoder(self, cbuf, cbuf_len)
 *             else:
 */
    __pyx_t_5 = ((__pyx_v_cbuf != NULL) != 0);
    if (__pyx_t_5) {

      /* "asyncpg/protocol/coreproto.pyx":495
 *             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(7, 495, __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":494
 *         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":497
 *                 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(7, 497, __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":498
 *             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(7, 498, __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":500
 *                 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_10 = PyList_Append(__pyx_v_rows, __pyx_v_row); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(7, 500, __pyx_L1_error)

    /* "asyncpg/protocol/coreproto.pyx":502
 *             cpython.PyList_Append(rows, row)
 * 
 *             if not buf.has_message() or buf.get_message_type() != b'D':             # <<<<<<<<<<<<<<
 *                 self._skip_discard = True
 *                 return
 */
    __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_has_message(__pyx_v_buf); if (unlikely(__pyx_t_4 == ((int32_t)-1))) __PYX_ERR(7, 502, __pyx_L1_error)
    __pyx_t_2 = ((!(__pyx_t_4 != 0)) != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_5 = __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_5 = __pyx_t_2;
    __pyx_L17_bool_binop_done:;
    if (__pyx_t_5) {

      /* "asyncpg/protocol/coreproto.pyx":503
 * 
 *             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":504
 *             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":502
 *             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":462
 *         self._write(buf)
 * 
 *     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_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.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":506
 *                 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":507
 * 
 *     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(7, 507, __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(7, 507, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->backend_pid = __pyx_t_2;

  /* "asyncpg/protocol/coreproto.pyx":508
 *     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(7, 508, __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(7, 508, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->backend_secret = __pyx_t_2;

  /* "asyncpg/protocol/coreproto.pyx":506
 *                 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":510
 *         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":511
 * 
 *     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(7, 511, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_name = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":512
 *     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(7, 512, __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(7, 512, __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(7, 512, __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(7, 512, __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(7, 512, __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(7, 512, __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":514
 *         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(7, 514, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_val = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":515
 * 
 *         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(7, 515, __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(7, 515, __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(7, 515, __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(7, 515, __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(7, 515, __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(7, 515, __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":517
 *         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(7, 517, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":510
 *         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":519
 *         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":520
 * 
 *     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(7, 520, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_pid = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":521
 *     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(7, 521, __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(7, 521, __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(7, 521, __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(7, 521, __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(7, 521, __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(7, 521, __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(7, 521, __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":522
 *         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(7, 522, __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, 522, __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(7, 522, __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(7, 522, __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(7, 522, __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(7, 522, __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(7, 522, __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":523
 *         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(7, 523, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":519
 *         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":525
 *         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 const *__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":530
 *             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(7, 530, __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(7, 530, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_status = __pyx_t_2;

  /* "asyncpg/protocol/coreproto.pyx":532
 *         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":534
 *         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":532
 *         status = self.buffer.read_int32()
 * 
 *         if status == AUTH_SUCCESSFUL:             # <<<<<<<<<<<<<<
 *             # AuthenticationOk
 *             self.result_type = RESULT_OK
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":536
 *             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":538
 *         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":539
 *             # 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(7, 539, __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(7, 539, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":536
 *             self.result_type = RESULT_OK
 * 
 *         elif status == AUTH_REQUIRED_PASSWORD:             # <<<<<<<<<<<<<<
 *             # AuthenticationCleartextPassword
 *             self.result_type = RESULT_OK
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":541
 *             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":545
 *             # 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_3 = __pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_read_bytes(__pyx_v_self->buffer, 4); if (unlikely(__pyx_t_3 == ((char const *)NULL))) __PYX_ERR(7, 545, __pyx_L1_error)

    /* "asyncpg/protocol/coreproto.pyx":544
 *             # 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_1 = PyBytes_FromStringAndSize(__pyx_t_3, 4); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 544, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_md5_salt = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":546
 *             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_1 = ((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_1)) __PYX_ERR(7, 546, __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(7, 546, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":541
 *             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":548
 *             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":549
 * 
 *         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":550
 *         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":551
 *                         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":552
 *                         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_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc); if (unlikely(!__pyx_t_4)) __PYX_ERR(7, 552, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_InterfaceError); if (unlikely(!__pyx_t_5)) __PYX_ERR(7, 552, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "asyncpg/protocol/coreproto.pyx":554
 *             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(7, 554, __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(7, 554, __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(7, 554, __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_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(7, 554, __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(7, 554, __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(7, 554, __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_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(7, 554, __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_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(7, 554, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 552, __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_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_4};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 552, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 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_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_4};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 552, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(7, 552, __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_4);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 552, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "asyncpg/protocol/coreproto.pyx":552
 *                         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_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":548
 *             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":557
 * 
 *         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":558
 *         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(7, 558, __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(7, 558, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "asyncpg/protocol/coreproto.pyx":560
 *             self.result = apg_exc.InterfaceError(
 *                 'unsupported authentication method requested by the '
 *                 'server: {}'.format(status))             # <<<<<<<<<<<<<<
 * 
 *         self.buffer.consume_message()
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_unsupported_authentication_metho_2, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(7, 560, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = __Pyx_PyInt_From_int32_t(__pyx_v_status); if (unlikely(!__pyx_t_6)) __PYX_ERR(7, 560, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(7, 560, __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_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(7, 560, __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_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(7, 560, __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(7, 560, __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_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(7, 560, __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_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 558, __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_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_5};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 558, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 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_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_5};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 558, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 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(7, 558, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __pyx_t_4 = 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_9, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 558, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "asyncpg/protocol/coreproto.pyx":558
 *         else:
 *             self.result_type = RESULT_FAILED
 *             self.result = apg_exc.InterfaceError(             # <<<<<<<<<<<<<<
 *                 'unsupported authentication method requested by the '
 *                 'server: {}'.format(status))
 */
    __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;
    break;
  }

  /* "asyncpg/protocol/coreproto.pyx":562
 *                 'server: {}'.format(status))
 * 
 *         self.buffer.consume_message()             # <<<<<<<<<<<<<<
 * 
 *     cdef _auth_password_message_cleartext(self):
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_message(__pyx_v_self->buffer)); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 562, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":525
 *         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":564
 *         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":568
 *             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(7, 568, __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":569
 * 
 *         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(7, 569, __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(7, 569, __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__79, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 569, __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(7, 569, __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(7, 569, __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":570
 *         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(7, 570, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/coreproto.pyx":572
 *         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":564
 *         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":574
 *         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":578
 *             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(7, 578, __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":581
 * 
 *         # '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(7, 581, __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(7, 581, __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__22);
  __pyx_t_1 = __pyx_kp_u__22;
  __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(7, 581, __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(7, 581, __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__22);
  __pyx_t_2 = __pyx_kp_u__22;
  __pyx_L5_bool_binop_done:;
  __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(7, 581, __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(7, 581, __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__80, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(7, 581, __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":582
 *         # '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(7, 582, __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(7, 582, __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(7, 582, __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(7, 582, __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(7, 582, __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(7, 582, __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(7, 582, __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(7, 582, __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(7, 582, __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(7, 582, __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(7, 582, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "asyncpg/protocol/coreproto.pyx":583
 *         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__81, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(7, 583, __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(7, 583, __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(7, 582, __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(7, 582, __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(7, 582, __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(7, 582, __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(7, 582, __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(7, 583, __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(7, 583, __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(7, 583, __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(7, 583, __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__82, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(7, 583, __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":585
 *                 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(7, 585, __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(7, 585, __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(7, 585, __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":586
 * 
 *         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(7, 586, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":588
 *         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":574
 *         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":590
 *         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":591
 * 
 *     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(7, 591, __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(7, 591, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_status = __pyx_t_2;

  /* "asyncpg/protocol/coreproto.pyx":593
 *         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":594
 * 
 *         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":593
 *         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":595
 *         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":596
 *             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":595
 *         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":597
 *         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":598
 *             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":597
 *         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":600
 *             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":590
 *         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":602
 *             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":606
 *             char code
 *             bytes message
 *             dict parsed = {}             # <<<<<<<<<<<<<<
 * 
 *         while True:
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 606, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_parsed = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":608
 *             dict parsed = {}
 * 
 *         while True:             # <<<<<<<<<<<<<<
 *             code = self.buffer.read_byte()
 *             if code == 0:
 */
  while (1) {

    /* "asyncpg/protocol/coreproto.pyx":609
 * 
 *         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(7, 609, __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(7, 609, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_code = __pyx_t_2;

    /* "asyncpg/protocol/coreproto.pyx":610
 *         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":611
 *             code = self.buffer.read_byte()
 *             if code == 0:
 *                 break             # <<<<<<<<<<<<<<
 * 
 *             message = self.buffer.read_cstr()
 */
      goto __pyx_L4_break;

      /* "asyncpg/protocol/coreproto.pyx":610
 *         while True:
 *             code = self.buffer.read_byte()
 *             if code == 0:             # <<<<<<<<<<<<<<
 *                 break
 * 
 */
    }

    /* "asyncpg/protocol/coreproto.pyx":613
 *                 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(7, 613, __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(7, 613, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_message, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":615
 *             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 '%.30s'", "decode");
      __PYX_ERR(7, 615, __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(7, 615, __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(7, 615, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(7, 615, __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(7, 615, __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(7, 615, __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":617
 *             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(7, 617, __pyx_L1_error)
  if (__pyx_t_3) {

    /* "asyncpg/protocol/coreproto.pyx":618
 * 
 *         if is_error:
 *             self.result_type = RESULT_FAILED             # <<<<<<<<<<<<<<
 *             self.result = parsed
 *         else:
 */
    __pyx_v_self->result_type = __pyx_e_7asyncpg_8protocol_8protocol_RESULT_FAILED;

    /* "asyncpg/protocol/coreproto.pyx":619
 *         if is_error:
 *             self.result_type = RESULT_FAILED
 *             self.result = parsed             # <<<<<<<<<<<<<<
 *         else:
 *             return parsed
 */
    __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":617
 *             parsed[chr(code)] = message.decode()
 * 
 *         if is_error:             # <<<<<<<<<<<<<<
 *             self.result_type = RESULT_FAILED
 *             self.result = parsed
 */
    goto __pyx_L6;
  }

  /* "asyncpg/protocol/coreproto.pyx":621
 *             self.result = parsed
 *         else:
 *             return parsed             # <<<<<<<<<<<<<<
 * 
 *     cdef _push_result(self):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_parsed);
    __pyx_r = __pyx_v_parsed;
    goto __pyx_L0;
  }
  __pyx_L6:;

  /* "asyncpg/protocol/coreproto.pyx":602
 *             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":623
 *             return 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":624
 * 
 *     cdef _push_result(self):
 *         try:             # <<<<<<<<<<<<<<
 *             self._on_result()
 *         finally:
 */
  /*try:*/ {

    /* "asyncpg/protocol/coreproto.pyx":625
 *     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(7, 625, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "asyncpg/protocol/coreproto.pyx":627
 *             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(7, 627, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "asyncpg/protocol/coreproto.pyx":628
 *         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(7, 628, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L5;
    }
    __pyx_L4_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __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_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":627
 *             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(7, 627, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "asyncpg/protocol/coreproto.pyx":628
 *         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(7, 628, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      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:;
      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":623
 *             return 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":630
 *             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":631
 * 
 *     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":632
 *     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":633
 *         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":634
 *         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":635
 *         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":636
 *         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":637
 *         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":630
 *             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":639
 *         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;
  int __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;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("_set_state", 0);

  /* "asyncpg/protocol/coreproto.pyx":640
 * 
 *     cdef _set_state(self, ProtocolState new_state):
 *         if new_state == PROTOCOL_IDLE:             # <<<<<<<<<<<<<<
 *             if self.state == PROTOCOL_FAILED:
 *                 raise apg_exc.InternalClientError(
 */
  switch (__pyx_v_new_state) {
    case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_IDLE:

    /* "asyncpg/protocol/coreproto.pyx":641
 *     cdef _set_state(self, ProtocolState new_state):
 *         if new_state == PROTOCOL_IDLE:
 *             if self.state == PROTOCOL_FAILED:             # <<<<<<<<<<<<<<
 *                 raise apg_exc.InternalClientError(
 *                     '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":642
 *         if new_state == PROTOCOL_IDLE:
 *             if self.state == PROTOCOL_FAILED:
 *                 raise apg_exc.InternalClientError(             # <<<<<<<<<<<<<<
 *                     'cannot switch to "idle" state; '
 *                     'protocol is in the "failed" state')
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 642, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_InternalClientError); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 642, __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__83, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 642, __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(7, 642, __pyx_L1_error)

      /* "asyncpg/protocol/coreproto.pyx":641
 *     cdef _set_state(self, ProtocolState new_state):
 *         if new_state == PROTOCOL_IDLE:
 *             if self.state == PROTOCOL_FAILED:             # <<<<<<<<<<<<<<
 *                 raise apg_exc.InternalClientError(
 *                     'cannot switch to "idle" state; '
 */
    }

    /* "asyncpg/protocol/coreproto.pyx":645
 *                     'cannot switch to "idle" state; '
 *                     'protocol is in the "failed" state')
 *             elif self.state == PROTOCOL_IDLE:             # <<<<<<<<<<<<<<
 *                 raise apg_exc.InternalClientError(
 *                     '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":646
 *                     'protocol is in the "failed" state')
 *             elif self.state == PROTOCOL_IDLE:
 *                 raise apg_exc.InternalClientError(             # <<<<<<<<<<<<<<
 *                     'protocol is already in the "idle" state')
 *             else:
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 646, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_InternalClientError); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 646, __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__84, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 646, __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(7, 646, __pyx_L1_error)

      /* "asyncpg/protocol/coreproto.pyx":645
 *                     'cannot switch to "idle" state; '
 *                     'protocol is in the "failed" state')
 *             elif self.state == PROTOCOL_IDLE:             # <<<<<<<<<<<<<<
 *                 raise apg_exc.InternalClientError(
 *                     'protocol is already in the "idle" state')
 */
    }

    /* "asyncpg/protocol/coreproto.pyx":649
 *                     '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":640
 * 
 *     cdef _set_state(self, ProtocolState new_state):
 *         if new_state == PROTOCOL_IDLE:             # <<<<<<<<<<<<<<
 *             if self.state == PROTOCOL_FAILED:
 *                 raise apg_exc.InternalClientError(
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":651
 *                 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":652
 * 
 *         elif new_state == PROTOCOL_FAILED:
 *             self.state = PROTOCOL_FAILED             # <<<<<<<<<<<<<<
 * 
 *         elif new_state == PROTOCOL_CANCELLED:
 */
    __pyx_v_self->state = __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_FAILED;

    /* "asyncpg/protocol/coreproto.pyx":651
 *                 self.state = new_state
 * 
 *         elif new_state == PROTOCOL_FAILED:             # <<<<<<<<<<<<<<
 *             self.state = PROTOCOL_FAILED
 * 
 */
    break;

    /* "asyncpg/protocol/coreproto.pyx":654
 *             self.state = PROTOCOL_FAILED
 * 
 *         elif new_state == PROTOCOL_CANCELLED:             # <<<<<<<<<<<<<<
 *             self.state = PROTOCOL_CANCELLED
 * 
 */
    case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_CANCELLED:

    /* "asyncpg/protocol/coreproto.pyx":655
 * 
 *         elif new_state == PROTOCOL_CANCELLED:
 *             self.state = PROTOCOL_CANCELLED             # <<<<<<<<<<<<<<
 * 
 *         else:
 */
    __pyx_v_self->state = __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_CANCELLED;

    /* "asyncpg/protocol/coreproto.pyx":654
 *             self.state = PROTOCOL_FAILED
 * 
 *         elif new_state == PROTOCOL_CANCELLED:             # <<<<<<<<<<<<<<
 *             self.state = PROTOCOL_CANCELLED
 * 
 */
    break;
    default:

    /* "asyncpg/protocol/coreproto.pyx":658
 * 
 *         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":659
 *         else:
 *             if self.state == PROTOCOL_IDLE:
 *                 self.state = new_state             # <<<<<<<<<<<<<<
 * 
 *             elif (self.state == PROTOCOL_COPY_OUT and
 */
      __pyx_v_self->state = __pyx_v_new_state;

      /* "asyncpg/protocol/coreproto.pyx":658
 * 
 *         else:
 *             if self.state == PROTOCOL_IDLE:             # <<<<<<<<<<<<<<
 *                 self.state = new_state
 * 
 */
      goto __pyx_L4;
    }

    /* "asyncpg/protocol/coreproto.pyx":661
 *                 self.state = new_state
 * 
 *             elif (self.state == PROTOCOL_COPY_OUT and             # <<<<<<<<<<<<<<
 *                     new_state == PROTOCOL_COPY_OUT_DATA):
 *                 self.state = new_state
 */
    __pyx_t_4 = ((__pyx_v_self->state == __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_COPY_OUT) != 0);
    if (__pyx_t_4) {
    } else {
      __pyx_t_1 = __pyx_t_4;
      goto __pyx_L5_bool_binop_done;
    }

    /* "asyncpg/protocol/coreproto.pyx":662
 * 
 *             elif (self.state == PROTOCOL_COPY_OUT and
 *                     new_state == PROTOCOL_COPY_OUT_DATA):             # <<<<<<<<<<<<<<
 *                 self.state = new_state
 * 
 */
    __pyx_t_4 = ((__pyx_v_new_state == __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_COPY_OUT_DATA) != 0);
    __pyx_t_1 = __pyx_t_4;
    __pyx_L5_bool_binop_done:;

    /* "asyncpg/protocol/coreproto.pyx":661
 *                 self.state = new_state
 * 
 *             elif (self.state == PROTOCOL_COPY_OUT and             # <<<<<<<<<<<<<<
 *                     new_state == PROTOCOL_COPY_OUT_DATA):
 *                 self.state = new_state
 */
    if (__pyx_t_1) {

      /* "asyncpg/protocol/coreproto.pyx":663
 *             elif (self.state == PROTOCOL_COPY_OUT and
 *                     new_state == PROTOCOL_COPY_OUT_DATA):
 *                 self.state = new_state             # <<<<<<<<<<<<<<
 * 
 *             elif (self.state == PROTOCOL_COPY_OUT_DATA and
 */
      __pyx_v_self->state = __pyx_v_new_state;

      /* "asyncpg/protocol/coreproto.pyx":661
 *                 self.state = new_state
 * 
 *             elif (self.state == PROTOCOL_COPY_OUT and             # <<<<<<<<<<<<<<
 *                     new_state == PROTOCOL_COPY_OUT_DATA):
 *                 self.state = new_state
 */
      goto __pyx_L4;
    }

    /* "asyncpg/protocol/coreproto.pyx":665
 *                 self.state = new_state
 * 
 *             elif (self.state == PROTOCOL_COPY_OUT_DATA and             # <<<<<<<<<<<<<<
 *                     new_state == PROTOCOL_COPY_OUT_DONE):
 *                 self.state = new_state
 */
    __pyx_t_4 = ((__pyx_v_self->state == __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_COPY_OUT_DATA) != 0);
    if (__pyx_t_4) {
    } else {
      __pyx_t_1 = __pyx_t_4;
      goto __pyx_L7_bool_binop_done;
    }

    /* "asyncpg/protocol/coreproto.pyx":666
 * 
 *             elif (self.state == PROTOCOL_COPY_OUT_DATA and
 *                     new_state == PROTOCOL_COPY_OUT_DONE):             # <<<<<<<<<<<<<<
 *                 self.state = new_state
 * 
 */
    __pyx_t_4 = ((__pyx_v_new_state == __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_COPY_OUT_DONE) != 0);
    __pyx_t_1 = __pyx_t_4;
    __pyx_L7_bool_binop_done:;

    /* "asyncpg/protocol/coreproto.pyx":665
 *                 self.state = new_state
 * 
 *             elif (self.state == PROTOCOL_COPY_OUT_DATA and             # <<<<<<<<<<<<<<
 *                     new_state == PROTOCOL_COPY_OUT_DONE):
 *                 self.state = new_state
 */
    if (__pyx_t_1) {

      /* "asyncpg/protocol/coreproto.pyx":667
 *             elif (self.state == PROTOCOL_COPY_OUT_DATA and
 *                     new_state == PROTOCOL_COPY_OUT_DONE):
 *                 self.state = new_state             # <<<<<<<<<<<<<<
 * 
 *             elif (self.state == PROTOCOL_COPY_IN and
 */
      __pyx_v_self->state = __pyx_v_new_state;

      /* "asyncpg/protocol/coreproto.pyx":665
 *                 self.state = new_state
 * 
 *             elif (self.state == PROTOCOL_COPY_OUT_DATA and             # <<<<<<<<<<<<<<
 *                     new_state == PROTOCOL_COPY_OUT_DONE):
 *                 self.state = new_state
 */
      goto __pyx_L4;
    }

    /* "asyncpg/protocol/coreproto.pyx":669
 *                 self.state = new_state
 * 
 *             elif (self.state == PROTOCOL_COPY_IN and             # <<<<<<<<<<<<<<
 *                     new_state == PROTOCOL_COPY_IN_DATA):
 *                 self.state = new_state
 */
    __pyx_t_4 = ((__pyx_v_self->state == __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_COPY_IN) != 0);
    if (__pyx_t_4) {
    } else {
      __pyx_t_1 = __pyx_t_4;
      goto __pyx_L9_bool_binop_done;
    }

    /* "asyncpg/protocol/coreproto.pyx":670
 * 
 *             elif (self.state == PROTOCOL_COPY_IN and
 *                     new_state == PROTOCOL_COPY_IN_DATA):             # <<<<<<<<<<<<<<
 *                 self.state = new_state
 * 
 */
    __pyx_t_4 = ((__pyx_v_new_state == __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_COPY_IN_DATA) != 0);
    __pyx_t_1 = __pyx_t_4;
    __pyx_L9_bool_binop_done:;

    /* "asyncpg/protocol/coreproto.pyx":669
 *                 self.state = new_state
 * 
 *             elif (self.state == PROTOCOL_COPY_IN and             # <<<<<<<<<<<<<<
 *                     new_state == PROTOCOL_COPY_IN_DATA):
 *                 self.state = new_state
 */
    if (__pyx_t_1) {

      /* "asyncpg/protocol/coreproto.pyx":671
 *             elif (self.state == PROTOCOL_COPY_IN and
 *                     new_state == PROTOCOL_COPY_IN_DATA):
 *                 self.state = new_state             # <<<<<<<<<<<<<<
 * 
 *             elif self.state == PROTOCOL_FAILED:
 */
      __pyx_v_self->state = __pyx_v_new_state;

      /* "asyncpg/protocol/coreproto.pyx":669
 *                 self.state = new_state
 * 
 *             elif (self.state == PROTOCOL_COPY_IN and             # <<<<<<<<<<<<<<
 *                     new_state == PROTOCOL_COPY_IN_DATA):
 *                 self.state = new_state
 */
      goto __pyx_L4;
    }

    /* "asyncpg/protocol/coreproto.pyx":673
 *                 self.state = new_state
 * 
 *             elif self.state == PROTOCOL_FAILED:             # <<<<<<<<<<<<<<
 *                 raise apg_exc.InternalClientError(
 *                     '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":674
 * 
 *             elif self.state == PROTOCOL_FAILED:
 *                 raise apg_exc.InternalClientError(             # <<<<<<<<<<<<<<
 *                     'cannot switch to state {}; '
 *                     'protocol is in the "failed" state'.format(new_state))
 */
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 674, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_InternalClientError); if (unlikely(!__pyx_t_5)) __PYX_ERR(7, 674, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "asyncpg/protocol/coreproto.pyx":676
 *                 raise apg_exc.InternalClientError(
 *                     'cannot switch to state {}; '
 *                     'protocol is in the "failed" state'.format(new_state))             # <<<<<<<<<<<<<<
 *             else:
 *                 raise apg_exc.InternalClientError(
 */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_cannot_switch_to_state_protocol, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(7, 676, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ProtocolState(__pyx_v_new_state); if (unlikely(!__pyx_t_7)) __PYX_ERR(7, 676, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = NULL;
      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);
        }
      }
      if (!__pyx_t_8) {
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 676, __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_6)) {
          PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_7};
          __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 676, __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[2] = {__pyx_t_8, __pyx_t_7};
          __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 676, __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(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(7, 676, __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_GIVEREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_7);
          __pyx_t_7 = 0;
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 676, __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;
      __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_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 674, __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_5)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_3};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 674, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 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_5)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_3};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 674, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __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(7, 674, __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_3);
          PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_3);
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 674, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __PYX_ERR(7, 674, __pyx_L1_error)

      /* "asyncpg/protocol/coreproto.pyx":673
 *                 self.state = new_state
 * 
 *             elif self.state == PROTOCOL_FAILED:             # <<<<<<<<<<<<<<
 *                 raise apg_exc.InternalClientError(
 *                     'cannot switch to state {}; '
 */
    }

    /* "asyncpg/protocol/coreproto.pyx":678
 *                     'protocol is in the "failed" state'.format(new_state))
 *             else:
 *                 raise apg_exc.InternalClientError(             # <<<<<<<<<<<<<<
 *                     'cannot switch to state {}; '
 *                     'another operation ({}) is in progress'.format(
 */
    /*else*/ {
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc); if (unlikely(!__pyx_t_5)) __PYX_ERR(7, 678, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_InternalClientError); if (unlikely(!__pyx_t_9)) __PYX_ERR(7, 678, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "asyncpg/protocol/coreproto.pyx":680
 *                 raise apg_exc.InternalClientError(
 *                     '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(7, 680, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);

      /* "asyncpg/protocol/coreproto.pyx":681
 *                     '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(7, 681, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ProtocolState(__pyx_v_self->state); if (unlikely(!__pyx_t_7)) __PYX_ERR(7, 681, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = NULL;
      __pyx_t_10 = 0;
      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);
          __pyx_t_10 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_6, __pyx_t_7};
        __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(7, 680, __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;
        __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_8, __pyx_t_6, __pyx_t_7};
        __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(7, 680, __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;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(7, 680, __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_6);
        PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_7);
        __pyx_t_6 = 0;
        __pyx_t_7 = 0;
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(7, 680, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (!__pyx_t_3) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 678, __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_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_5};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 678, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 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_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_5};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 678, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(7, 678, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3); __pyx_t_3 = NULL;
          __Pyx_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_5);
          __pyx_t_5 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 678, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __PYX_ERR(7, 678, __pyx_L1_error)
    }
    __pyx_L4:;
    break;
  }

  /* "asyncpg/protocol/coreproto.pyx":639
 *         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_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_11);
  __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":683
 *                         new_state, self.state))
 * 
 *     cdef _ensure_connected(self):             # <<<<<<<<<<<<<<
 *         if self.con_status != CONNECTION_OK:
 *             raise apg_exc.InternalClientError('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;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("_ensure_connected", 0);

  /* "asyncpg/protocol/coreproto.pyx":684
 * 
 *     cdef _ensure_connected(self):
 *         if self.con_status != CONNECTION_OK:             # <<<<<<<<<<<<<<
 *             raise apg_exc.InternalClientError('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":685
 *     cdef _ensure_connected(self):
 *         if self.con_status != CONNECTION_OK:
 *             raise apg_exc.InternalClientError('not connected')             # <<<<<<<<<<<<<<
 * 
 *     cdef WriteBuffer _build_bind_message(self, str portal_name,
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 685, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_InternalClientError); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 685, __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__85, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 685, __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(7, 685, __pyx_L1_error)

    /* "asyncpg/protocol/coreproto.pyx":684
 * 
 *     cdef _ensure_connected(self):
 *         if self.con_status != CONNECTION_OK:             # <<<<<<<<<<<<<<
 *             raise apg_exc.InternalClientError('not connected')
 * 
 */
  }

  /* "asyncpg/protocol/coreproto.pyx":683
 *                         new_state, self.state))
 * 
 *     cdef _ensure_connected(self):             # <<<<<<<<<<<<<<
 *         if self.con_status != CONNECTION_OK:
 *             raise apg_exc.InternalClientError('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_XDECREF(__pyx_t_3);
  __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":687
 *             raise apg_exc.InternalClientError('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":692
 *         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(7, 692, __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":693
 * 
 *         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(7, 693, __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":694
 *         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(7, 694, __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":697
 * 
 *         # 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(7, 697, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":699
 *         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(7, 699, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":700
 * 
 *         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":687
 *             raise apg_exc.InternalClientError('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":704
 *     # 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_k = NULL;
  PyObject *__pyx_v_v = 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;
  Py_ssize_t __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int32_t __pyx_t_11;
  __Pyx_RefNannySetupContext("_connect", 0);

  /* "asyncpg/protocol/coreproto.pyx":709
 *             WriteBuffer outbuf
 * 
 *         if self.con_status != CONNECTION_BAD:             # <<<<<<<<<<<<<<
 *             raise apg_exc.InternalClientError('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":710
 * 
 *         if self.con_status != CONNECTION_BAD:
 *             raise apg_exc.InternalClientError('already connected')             # <<<<<<<<<<<<<<
 * 
 *         self._set_state(PROTOCOL_AUTH)
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 710, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_InternalClientError); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 710, __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__86, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 710, __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(7, 710, __pyx_L1_error)

    /* "asyncpg/protocol/coreproto.pyx":709
 *             WriteBuffer outbuf
 * 
 *         if self.con_status != CONNECTION_BAD:             # <<<<<<<<<<<<<<
 *             raise apg_exc.InternalClientError('already connected')
 * 
 */
  }

  /* "asyncpg/protocol/coreproto.pyx":712
 *             raise apg_exc.InternalClientError('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(7, 712, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/coreproto.pyx":713
 * 
 *         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":716
 * 
 *         # 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(7, 716, __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":719
 * 
 *         # 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(7, 719, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/coreproto.pyx":720
 *         # 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(7, 720, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/coreproto.pyx":722
 *         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(7, 722, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/coreproto.pyx":723
 * 
 *         buf.write_bytestring(b'client_encoding')
 *         buf.write_bytestring("'{}'".format(self.encoding).encode('ascii'))             # <<<<<<<<<<<<<<
 * 
 *         buf.write_str('user', self.encoding)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u__87, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 723, __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(7, 723, __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(7, 723, __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(7, 723, __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(7, 723, __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(7, 723, __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(7, 723, __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__88, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 723, __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(7, 723, __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(7, 723, __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":725
 *         buf.write_bytestring("'{}'".format(self.encoding).encode('ascii'))
 * 
 *         buf.write_str('user', self.encoding)             # <<<<<<<<<<<<<<
 *         buf.write_str(self.con_params.user, self.encoding)
 * 
 */
  __pyx_t_3 = __pyx_v_self->encoding;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_str(__pyx_v_buf, __pyx_n_u_user, ((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 725, __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/coreproto.pyx":726
 * 
 *         buf.write_str('user', self.encoding)
 *         buf.write_str(self.con_params.user, self.encoding)             # <<<<<<<<<<<<<<
 * 
 *         buf.write_str('database', self.encoding)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->con_params, __pyx_n_s_user); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 726, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (!(likely(PyUnicode_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(7, 726, __pyx_L1_error)
  __pyx_t_3 = __pyx_v_self->encoding;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_5 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_str(__pyx_v_buf, ((PyObject*)__pyx_t_2), ((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_5)) __PYX_ERR(7, 726, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "asyncpg/protocol/coreproto.pyx":728
 *         buf.write_str(self.con_params.user, self.encoding)
 * 
 *         buf.write_str('database', self.encoding)             # <<<<<<<<<<<<<<
 *         buf.write_str(self.con_params.database, self.encoding)
 * 
 */
  __pyx_t_5 = __pyx_v_self->encoding;
  __Pyx_INCREF(__pyx_t_5);
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_str(__pyx_v_buf, __pyx_n_u_database, ((PyObject*)__pyx_t_5)); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 728, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/coreproto.pyx":729
 * 
 *         buf.write_str('database', self.encoding)
 *         buf.write_str(self.con_params.database, self.encoding)             # <<<<<<<<<<<<<<
 * 
 *         if self.con_params.server_settings is not None:
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->con_params, __pyx_n_s_database); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 729, __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(7, 729, __pyx_L1_error)
  __pyx_t_5 = __pyx_v_self->encoding;
  __Pyx_INCREF(__pyx_t_5);
  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_str(__pyx_v_buf, ((PyObject*)__pyx_t_3), ((PyObject*)__pyx_t_5)); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 729, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/coreproto.pyx":731
 *         buf.write_str(self.con_params.database, self.encoding)
 * 
 *         if self.con_params.server_settings is not None:             # <<<<<<<<<<<<<<
 *             for k, v in self.con_params.server_settings.items():
 *                 buf.write_str(k, self.encoding)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->con_params, __pyx_n_s_server_settings); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 731, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = (__pyx_t_2 != Py_None);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "asyncpg/protocol/coreproto.pyx":732
 * 
 *         if self.con_params.server_settings is not None:
 *             for k, v in self.con_params.server_settings.items():             # <<<<<<<<<<<<<<
 *                 buf.write_str(k, self.encoding)
 *                 buf.write_str(v, self.encoding)
 */
    __pyx_t_7 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->con_params, __pyx_n_s_server_settings); if (unlikely(!__pyx_t_5)) __PYX_ERR(7, 732, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (unlikely(__pyx_t_5 == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items");
      __PYX_ERR(7, 732, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_dict_iterator(__pyx_t_5, 0, __pyx_n_s_items, (&__pyx_t_8), (&__pyx_t_9)); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 732, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_2);
    __pyx_t_2 = __pyx_t_3;
    __pyx_t_3 = 0;
    while (1) {
      __pyx_t_10 = __Pyx_dict_iter_next(__pyx_t_2, __pyx_t_8, &__pyx_t_7, &__pyx_t_3, &__pyx_t_5, NULL, __pyx_t_9);
      if (unlikely(__pyx_t_10 == 0)) break;
      if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(7, 732, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_5);
      __pyx_t_5 = 0;

      /* "asyncpg/protocol/coreproto.pyx":733
 *         if self.con_params.server_settings is not None:
 *             for k, v in self.con_params.server_settings.items():
 *                 buf.write_str(k, self.encoding)             # <<<<<<<<<<<<<<
 *                 buf.write_str(v, self.encoding)
 * 
 */
      if (!(likely(PyUnicode_CheckExact(__pyx_v_k))||((__pyx_v_k) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_v_k)->tp_name), 0))) __PYX_ERR(7, 733, __pyx_L1_error)
      __pyx_t_5 = __pyx_v_self->encoding;
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_str(__pyx_v_buf, ((PyObject*)__pyx_v_k), ((PyObject*)__pyx_t_5)); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 733, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "asyncpg/protocol/coreproto.pyx":734
 *             for k, v in self.con_params.server_settings.items():
 *                 buf.write_str(k, self.encoding)
 *                 buf.write_str(v, self.encoding)             # <<<<<<<<<<<<<<
 * 
 *         buf.write_bytestring(b'')
 */
      if (!(likely(PyUnicode_CheckExact(__pyx_v_v))||((__pyx_v_v) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_v_v)->tp_name), 0))) __PYX_ERR(7, 734, __pyx_L1_error)
      __pyx_t_3 = __pyx_v_self->encoding;
      __Pyx_INCREF(__pyx_t_3);
      __pyx_t_5 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_str(__pyx_v_buf, ((PyObject*)__pyx_v_v), ((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_5)) __PYX_ERR(7, 734, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "asyncpg/protocol/coreproto.pyx":731
 *         buf.write_str(self.con_params.database, self.encoding)
 * 
 *         if self.con_params.server_settings is not None:             # <<<<<<<<<<<<<<
 *             for k, v in self.con_params.server_settings.items():
 *                 buf.write_str(k, self.encoding)
 */
  }

  /* "asyncpg/protocol/coreproto.pyx":736
 *                 buf.write_str(v, self.encoding)
 * 
 *         buf.write_bytestring(b'')             # <<<<<<<<<<<<<<
 * 
 *         # Send the buffer
 */
  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_bytestring(__pyx_v_buf, __pyx_kp_b__22); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 736, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/coreproto.pyx":739
 * 
 *         # Send the buffer
 *         outbuf = WriteBuffer()             # <<<<<<<<<<<<<<
 *         outbuf.write_int32(buf.len() + 4)
 *         outbuf.write_buffer(buf)
 */
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_WriteBuffer), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 739, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_outbuf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "asyncpg/protocol/coreproto.pyx":740
 *         # Send the buffer
 *         outbuf = WriteBuffer()
 *         outbuf.write_int32(buf.len() + 4)             # <<<<<<<<<<<<<<
 *         outbuf.write_buffer(buf)
 *         self._write(outbuf)
 */
  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_len(__pyx_v_buf); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 740, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyInt_AddObjC(__pyx_t_2, __pyx_int_4, 4, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(7, 740, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_11 = __Pyx_PyInt_As_int32_t(__pyx_t_5); if (unlikely((__pyx_t_11 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(7, 740, __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_outbuf, __pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(7, 740, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "asyncpg/protocol/coreproto.pyx":741
 *         outbuf = WriteBuffer()
 *         outbuf.write_int32(buf.len() + 4)
 *         outbuf.write_buffer(buf)             # <<<<<<<<<<<<<<
 *         self._write(outbuf)
 * 
 */
  __pyx_t_5 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_buffer(__pyx_v_outbuf, __pyx_v_buf); if (unlikely(!__pyx_t_5)) __PYX_ERR(7, 741, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "asyncpg/protocol/coreproto.pyx":742
 *         outbuf.write_int32(buf.len() + 4)
 *         outbuf.write_buffer(buf)
 *         self._write(outbuf)             # <<<<<<<<<<<<<<
 * 
 *     cdef _prepare(self, str stmt_name, str query):
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self->__pyx_vtab)->_write(__pyx_v_self, ((PyObject *)__pyx_v_outbuf)); if (unlikely(!__pyx_t_5)) __PYX_ERR(7, 742, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "asyncpg/protocol/coreproto.pyx":704
 *     # 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_k);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/coreproto.pyx":744
 *         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":749
 *             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(7, 749, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":750
 * 
 *         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(7, 750, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":752
 *         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(7, 752, __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":754
 *         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(7, 754, __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":755
 * 
 *         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(7, 755, __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":756
 *         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(7, 756, __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":757
 *         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(7, 757, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":758
 *         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(7, 758, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":759
 *         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(7, 759, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":761
 *         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(7, 761, __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":762
 * 
 *         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(7, 762, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":763
 *         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(7, 763, __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":764
 *         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(7, 764, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/coreproto.pyx":765
 *         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(7, 765, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/coreproto.pyx":767
 *         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(7, 767, __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":769
 *         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(7, 769, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 769, __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(7, 769, __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(7, 769, __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(7, 769, __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(7, 769, __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(7, 769, __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(7, 769, __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":744
 *         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":771
 *         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":776
 *         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(7, 776, __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":777
 * 
 *         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(7, 777, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":779
 *         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(7, 779, __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":780
 * 
 *         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(7, 780, __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":781
 *         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(7, 781, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/coreproto.pyx":782
 *         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(7, 782, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/coreproto.pyx":783
 *         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(7, 783, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/coreproto.pyx":785
 *         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(7, 785, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/coreproto.pyx":771
 *         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":787
 *         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":792
 *         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(7, 792, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":793
 * 
 *         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(7, 793, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":795
 *         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(7, 795, __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":797
 *         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(7, 797, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":787
 *         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":799
 *         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_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;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  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("_bind_execute_many", 0);

  /* "asyncpg/protocol/coreproto.pyx":804
 *         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(7, 804, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":805
 * 
 *         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(7, 805, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":807
 *         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":808
 * 
 *         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":809
 *         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":810
 *         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":811
 *         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":813
 *         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":814
 * 
 *         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(7, 814, __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":813
 *         self._execute_stmt_name = stmt_name
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             buf = <WriteBuffer>next(bind_data)
 *         except StopIteration:
 */
    }

    /* "asyncpg/protocol/coreproto.pyx":822
 *             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(7, 822, __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_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "asyncpg/protocol/coreproto.pyx":815
 *         try:
 *             buf = <WriteBuffer>next(bind_data)
 *         except StopIteration:             # <<<<<<<<<<<<<<
 *             self._push_result()
 *         except Exception as e:
 */
    __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(7, 815, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_7);

      /* "asyncpg/protocol/coreproto.pyx":816
 *             buf = <WriteBuffer>next(bind_data)
 *         except StopIteration:
 *             self._push_result()             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             self.result_type = RESULT_FAILED
 */
      __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(7, 816, __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;
    }

    /* "asyncpg/protocol/coreproto.pyx":817
 *         except StopIteration:
 *             self._push_result()
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             self.result_type = RESULT_FAILED
 *             self.result = e
 */
    __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
    if (__pyx_t_6) {
      __Pyx_AddTraceback("asyncpg.protocol.protocol.CoreProtocol._bind_execute_many", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_1, &__pyx_t_5) < 0) __PYX_ERR(7, 817, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_v_e = __pyx_t_1;
      /*try:*/ {

        /* "asyncpg/protocol/coreproto.pyx":818
 *             self._push_result()
 *         except Exception as e:
 *             self.result_type = RESULT_FAILED             # <<<<<<<<<<<<<<
 *             self.result = e
 *             self._push_result()
 */
        __pyx_v_self->result_type = __pyx_e_7asyncpg_8protocol_8protocol_RESULT_FAILED;

        /* "asyncpg/protocol/coreproto.pyx":819
 *         except Exception as e:
 *             self.result_type = RESULT_FAILED
 *             self.result = e             # <<<<<<<<<<<<<<
 *             self._push_result()
 *         else:
 */
        __Pyx_INCREF(__pyx_v_e);
        __Pyx_GIVEREF(__pyx_v_e);
        __Pyx_GOTREF(__pyx_v_self->result);
        __Pyx_DECREF(__pyx_v_self->result);
        __pyx_v_self->result = __pyx_v_e;

        /* "asyncpg/protocol/coreproto.pyx":820
 *             self.result_type = RESULT_FAILED
 *             self.result = e
 *             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(7, 820, __pyx_L16_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }

      /* "asyncpg/protocol/coreproto.pyx":817
 *         except StopIteration:
 *             self._push_result()
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             self.result_type = RESULT_FAILED
 *             self.result = e
 */
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_DECREF(__pyx_v_e);
          __pyx_v_e = NULL;
          goto __pyx_L17;
        }
        __pyx_L16_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __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_XDECREF(__pyx_t_8); __pyx_t_8 = 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_6 = __pyx_lineno; __pyx_t_9 = __pyx_clineno; __pyx_t_10 = __pyx_filename;
          {
            __Pyx_DECREF(__pyx_v_e);
            __pyx_v_e = NULL;
          }
          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_6; __pyx_clineno = __pyx_t_9; __pyx_filename = __pyx_t_10;
          goto __pyx_L5_except_error;
        }
        __pyx_L17:;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 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/coreproto.pyx":813
 *         self._execute_stmt_name = stmt_name
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             buf = <WriteBuffer>next(bind_data)
 *         except StopIteration:
 */
    __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_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_L8_try_end:;
  }

  /* "asyncpg/protocol/coreproto.pyx":799
 *         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_XDECREF(__pyx_v_e);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/coreproto.pyx":824
 *             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":827
 *         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(7, 827, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":828
 * 
 *         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(7, 828, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":830
 *         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(7, 830, __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":832
 *         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(7, 832, __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":833
 * 
 *         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(7, 833, __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":834
 *         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(7, 834, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/coreproto.pyx":835
 *         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(7, 835, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/coreproto.pyx":836
 *         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(7, 836, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/coreproto.pyx":837
 *         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(7, 837, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/coreproto.pyx":824
 *             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":839
 *         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":844
 *         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(7, 844, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":845
 * 
 *         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(7, 845, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":847
 *         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(7, 847, __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":848
 * 
 *         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(7, 848, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":849
 *         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(7, 849, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":839
 *         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":851
 *         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":854
 *         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(7, 854, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":855
 * 
 *         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(7, 855, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":857
 *         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(7, 857, __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":859
 *         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":860
 * 
 *         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(7, 860, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/coreproto.pyx":859
 *         buf = WriteBuffer.new_message(b'C')
 * 
 *         if is_portal:             # <<<<<<<<<<<<<<
 *             buf.write_byte(b'P')
 *         else:
 */
    goto __pyx_L3;
  }

  /* "asyncpg/protocol/coreproto.pyx":862
 *             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(7, 862, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "asyncpg/protocol/coreproto.pyx":864
 *             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(7, 864, __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":865
 * 
 *         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(7, 865, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/coreproto.pyx":866
 *         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(7, 866, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/coreproto.pyx":868
 *         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(7, 868, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/coreproto.pyx":851
 *         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":870
 *         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":872
 *     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(7, 872, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":873
 *         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(7, 873, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":874
 *         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(7, 874, __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":875
 *         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(7, 875, __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":876
 *         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(7, 876, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/coreproto.pyx":877
 *         buf.write_str(query, self.encoding)
 *         buf.end_message()
 *         self._write(buf)             # <<<<<<<<<<<<<<
 * 
 *     cdef _copy_out(self, str copy_stmt):
 */
  __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(7, 877, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/coreproto.pyx":870
 *         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":879
 *         self._write(buf)
 * 
 *     cdef _copy_out(self, str copy_stmt):             # <<<<<<<<<<<<<<
 *         cdef WriteBuffer buf
 * 
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__copy_out(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_copy_stmt) {
  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("_copy_out", 0);

  /* "asyncpg/protocol/coreproto.pyx":882
 *         cdef WriteBuffer buf
 * 
 *         self._ensure_connected()             # <<<<<<<<<<<<<<
 *         self._set_state(PROTOCOL_COPY_OUT)
 * 
 */
  __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(7, 882, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":883
 * 
 *         self._ensure_connected()
 *         self._set_state(PROTOCOL_COPY_OUT)             # <<<<<<<<<<<<<<
 * 
 *         # Send the COPY .. TO STDOUT using the SimpleQuery protocol.
 */
  __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_COPY_OUT); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 883, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":886
 * 
 *         # Send the COPY .. TO STDOUT using the SimpleQuery protocol.
 *         buf = WriteBuffer.new_message(b'Q')             # <<<<<<<<<<<<<<
 *         buf.write_str(copy_stmt, 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(7, 886, __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":887
 *         # Send the COPY .. TO STDOUT using the SimpleQuery protocol.
 *         buf = WriteBuffer.new_message(b'Q')
 *         buf.write_str(copy_stmt, 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_copy_stmt, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 887, __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":888
 *         buf = WriteBuffer.new_message(b'Q')
 *         buf.write_str(copy_stmt, 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(7, 888, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/coreproto.pyx":889
 *         buf.write_str(copy_stmt, self.encoding)
 *         buf.end_message()
 *         self._write(buf)             # <<<<<<<<<<<<<<
 * 
 *     cdef _copy_in(self, str copy_stmt):
 */
  __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(7, 889, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/coreproto.pyx":879
 *         self._write(buf)
 * 
 *     cdef _copy_out(self, str copy_stmt):             # <<<<<<<<<<<<<<
 *         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._copy_out", __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":891
 *         self._write(buf)
 * 
 *     cdef _copy_in(self, str copy_stmt):             # <<<<<<<<<<<<<<
 *         cdef WriteBuffer buf
 * 
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__copy_in(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v_copy_stmt) {
  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("_copy_in", 0);

  /* "asyncpg/protocol/coreproto.pyx":894
 *         cdef WriteBuffer buf
 * 
 *         self._ensure_connected()             # <<<<<<<<<<<<<<
 *         self._set_state(PROTOCOL_COPY_IN)
 * 
 */
  __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(7, 894, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":895
 * 
 *         self._ensure_connected()
 *         self._set_state(PROTOCOL_COPY_IN)             # <<<<<<<<<<<<<<
 * 
 *         buf = WriteBuffer.new_message(b'Q')
 */
  __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_COPY_IN); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 895, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":897
 *         self._set_state(PROTOCOL_COPY_IN)
 * 
 *         buf = WriteBuffer.new_message(b'Q')             # <<<<<<<<<<<<<<
 *         buf.write_str(copy_stmt, 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(7, 897, __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":898
 * 
 *         buf = WriteBuffer.new_message(b'Q')
 *         buf.write_str(copy_stmt, 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_copy_stmt, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 898, __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":899
 *         buf = WriteBuffer.new_message(b'Q')
 *         buf.write_str(copy_stmt, 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(7, 899, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/coreproto.pyx":900
 *         buf.write_str(copy_stmt, 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(7, 900, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/coreproto.pyx":891
 *         self._write(buf)
 * 
 *     cdef _copy_in(self, str copy_stmt):             # <<<<<<<<<<<<<<
 *         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._copy_in", __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":902
 *         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":904
 *     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(7, 904, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":905
 *         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(7, 905, __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":906
 *         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(7, 906, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":907
 *         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(7, 907, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":902
 *         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":909
 *         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":912
 *         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":915
 *         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":918
 *         pass
 * 
 *     cdef _on_notice(self, parsed):             # <<<<<<<<<<<<<<
 *         pass
 * 
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__on_notice(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_parsed) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_on_notice", 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":921
 *         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":924
 *         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":929
 *     # 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":930
 * 
 *     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(7, 930, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":931
 *     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(7, 931, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":929
 *     # 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":933
 *         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":934
 * 
 *     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":936
 *         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(7, 936, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__89, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 936, __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":937
 * 
 *         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":938
 *         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(7, 938, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_HasAttr(__pyx_t_2, __pyx_n_u_AF_UNIX); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(7, 938, __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":939
 *         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(7, 939, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_socket); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 939, __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(7, 939, __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(7, 939, __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(7, 939, __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":937
 * 
 *         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":940
 *               (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(7, 940, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_socket); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 940, __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(7, 940, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "asyncpg/protocol/coreproto.pyx":941
 *                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(7, 941, __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(7, 941, __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(7, 940, __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(7, 940, __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(7, 940, __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(7, 940, __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":937
 * 
 *         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":943
 *                             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":944
 * 
 *         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(7, 944, __pyx_L7_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "asyncpg/protocol/coreproto.pyx":943
 *                             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_L12_try_end;
    __pyx_L7_error:;
    __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":945
 *         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(7, 945, __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":946
 *             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(7, 946, __pyx_L18_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(7, 946, __pyx_L18_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(7, 946, __pyx_L18_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":947
 *         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":948
 *             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(7, 948, __pyx_L18_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

        /* "asyncpg/protocol/coreproto.pyx":949
 *             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(7, 949, __pyx_L18_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(7, 949, __pyx_L18_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(7, 949, __pyx_L18_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(7, 949, __pyx_L18_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(7, 949, __pyx_L18_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(7, 949, __pyx_L18_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":945
 *         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_L19;
        }
        __pyx_L18_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __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_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;
          }
          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_L19:;
      }
      __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":943
 *                             socket.TCP_NODELAY, 1)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             self._connect()
 *         except Exception as ex:
 */
    __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_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_L12_try_end:;
  }

  /* "asyncpg/protocol/coreproto.pyx":933
 *         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":951
 *             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":952
 * 
 *     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":953
 *     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(7, 953, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":954
 *         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(7, 954, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/coreproto.pyx":951
 *             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":94
 *         object con_params
 * 
 *         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(26, 94, __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":95
 * 
 *         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(26, 95, __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;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self._discard_data, self._execute_iter, self._execute_portal_name, self._execute_stmt_name, self._skip_discard, self.backend_pid, self.backend_secret, self.buffer, self.con_params, self.con_status, self.encoding, self.result, self.result_execute_completed, self.result_param_desc, self.result_row_desc, self.result_status_msg, self.result_type, self.state, self.transport, self.xact_status)
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12CoreProtocol_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12CoreProtocol_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12CoreProtocol_8__reduce_cython__(((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_8__reduce_cython__(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = 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;
  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;
  int __pyx_t_12;
  int __pyx_t_13;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     cdef bint use_setstate
 *     state = (self._discard_data, self._execute_iter, self._execute_portal_name, self._execute_stmt_name, self._skip_discard, self.backend_pid, self.backend_secret, self.buffer, self.con_params, self.con_status, self.encoding, self.result, self.result_execute_completed, self.result_param_desc, self.result_row_desc, self.result_status_msg, self.result_type, self.state, self.transport, self.xact_status)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_discard_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->_skip_discard); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_int32_t(__pyx_v_self->backend_pid); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_From_int32_t(__pyx_v_self->backend_secret); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus(__pyx_v_self->con_status); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyBool_FromLong(__pyx_v_self->result_execute_completed); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ResultType(__pyx_v_self->result_type); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ProtocolState(__pyx_v_self->state); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus(__pyx_v_self->xact_status); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_10 = PyTuple_New(20); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->_execute_iter);
  __Pyx_GIVEREF(__pyx_v_self->_execute_iter);
  PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_v_self->_execute_iter);
  __Pyx_INCREF(__pyx_v_self->_execute_portal_name);
  __Pyx_GIVEREF(__pyx_v_self->_execute_portal_name);
  PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_v_self->_execute_portal_name);
  __Pyx_INCREF(__pyx_v_self->_execute_stmt_name);
  __Pyx_GIVEREF(__pyx_v_self->_execute_stmt_name);
  PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_v_self->_execute_stmt_name);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_10, 4, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_10, 5, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_10, 6, __pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->buffer));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->buffer));
  PyTuple_SET_ITEM(__pyx_t_10, 7, ((PyObject *)__pyx_v_self->buffer));
  __Pyx_INCREF(__pyx_v_self->con_params);
  __Pyx_GIVEREF(__pyx_v_self->con_params);
  PyTuple_SET_ITEM(__pyx_t_10, 8, __pyx_v_self->con_params);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_10, 9, __pyx_t_5);
  __Pyx_INCREF(__pyx_v_self->encoding);
  __Pyx_GIVEREF(__pyx_v_self->encoding);
  PyTuple_SET_ITEM(__pyx_t_10, 10, __pyx_v_self->encoding);
  __Pyx_INCREF(__pyx_v_self->result);
  __Pyx_GIVEREF(__pyx_v_self->result);
  PyTuple_SET_ITEM(__pyx_t_10, 11, __pyx_v_self->result);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_10, 12, __pyx_t_6);
  __Pyx_INCREF(__pyx_v_self->result_param_desc);
  __Pyx_GIVEREF(__pyx_v_self->result_param_desc);
  PyTuple_SET_ITEM(__pyx_t_10, 13, __pyx_v_self->result_param_desc);
  __Pyx_INCREF(__pyx_v_self->result_row_desc);
  __Pyx_GIVEREF(__pyx_v_self->result_row_desc);
  PyTuple_SET_ITEM(__pyx_t_10, 14, __pyx_v_self->result_row_desc);
  __Pyx_INCREF(__pyx_v_self->result_status_msg);
  __Pyx_GIVEREF(__pyx_v_self->result_status_msg);
  PyTuple_SET_ITEM(__pyx_t_10, 15, __pyx_v_self->result_status_msg);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_10, 16, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_10, 17, __pyx_t_8);
  __Pyx_INCREF(__pyx_v_self->transport);
  __Pyx_GIVEREF(__pyx_v_self->transport);
  PyTuple_SET_ITEM(__pyx_t_10, 18, __pyx_v_self->transport);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_10, 19, __pyx_t_9);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;
  __pyx_t_8 = 0;
  __pyx_t_9 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_10);
  __pyx_t_10 = 0;

  /* "(tree fragment)":4
 *     cdef bint use_setstate
 *     state = (self._discard_data, self._execute_iter, self._execute_portal_name, self._execute_stmt_name, self._skip_discard, self.backend_pid, self.backend_secret, self.buffer, self.con_params, self.con_status, self.encoding, self.result, self.result_execute_completed, self.result_param_desc, self.result_row_desc, self.result_status_msg, self.result_type, self.state, self.transport, self.xact_status)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_10 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_v__dict = __pyx_t_10;
  __pyx_t_10 = 0;

  /* "(tree fragment)":5
 *     state = (self._discard_data, self._execute_iter, self._execute_portal_name, self._execute_stmt_name, self._skip_discard, self.backend_pid, self.backend_secret, self.buffer, self.con_params, self.con_status, self.encoding, self.result, self.result_execute_completed, self.result_param_desc, self.result_row_desc, self.result_status_msg, self.result_type, self.state, self.transport, self.xact_status)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_11 = (__pyx_v__dict != Py_None);
  __pyx_t_12 = (__pyx_t_11 != 0);
  if (__pyx_t_12) {

    /* "(tree fragment)":6
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v__dict);
    __pyx_t_9 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_9));
    __pyx_t_9 = 0;

    /* "(tree fragment)":7
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self._execute_iter is not None or self._execute_portal_name is not None or self._execute_stmt_name is not None or self.buffer is not None or self.con_params is not None or self.encoding is not None or self.result is not None or self.result_param_desc is not None or self.result_row_desc is not None or self.result_status_msg is not None or self.transport is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":5
 *     state = (self._discard_data, self._execute_iter, self._execute_portal_name, self._execute_stmt_name, self._skip_discard, self.backend_pid, self.backend_secret, self.buffer, self.con_params, self.con_status, self.encoding, self.result, self.result_execute_completed, self.result_param_desc, self.result_row_desc, self.result_status_msg, self.result_type, self.state, self.transport, self.xact_status)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         use_setstate = True
 *     else:
 *         use_setstate = self._execute_iter is not None or self._execute_portal_name is not None or self._execute_stmt_name is not None or self.buffer is not None or self.con_params is not None or self.encoding is not None or self.result is not None or self.result_param_desc is not None or self.result_row_desc is not None or self.result_status_msg is not None or self.transport is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_CoreProtocol, (type(self), 0x197884c, None), state
 */
  /*else*/ {
    __pyx_t_11 = (__pyx_v_self->_execute_iter != Py_None);
    __pyx_t_13 = (__pyx_t_11 != 0);
    if (!__pyx_t_13) {
    } else {
      __pyx_t_12 = __pyx_t_13;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_13 = (__pyx_v_self->_execute_portal_name != ((PyObject*)Py_None));
    __pyx_t_11 = (__pyx_t_13 != 0);
    if (!__pyx_t_11) {
    } else {
      __pyx_t_12 = __pyx_t_11;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_11 = (__pyx_v_self->_execute_stmt_name != ((PyObject*)Py_None));
    __pyx_t_13 = (__pyx_t_11 != 0);
    if (!__pyx_t_13) {
    } else {
      __pyx_t_12 = __pyx_t_13;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_13 = (((PyObject *)__pyx_v_self->buffer) != Py_None);
    __pyx_t_11 = (__pyx_t_13 != 0);
    if (!__pyx_t_11) {
    } else {
      __pyx_t_12 = __pyx_t_11;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_11 = (__pyx_v_self->con_params != Py_None);
    __pyx_t_13 = (__pyx_t_11 != 0);
    if (!__pyx_t_13) {
    } else {
      __pyx_t_12 = __pyx_t_13;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_13 = (__pyx_v_self->encoding != ((PyObject*)Py_None));
    __pyx_t_11 = (__pyx_t_13 != 0);
    if (!__pyx_t_11) {
    } else {
      __pyx_t_12 = __pyx_t_11;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_11 = (__pyx_v_self->result != Py_None);
    __pyx_t_13 = (__pyx_t_11 != 0);
    if (!__pyx_t_13) {
    } else {
      __pyx_t_12 = __pyx_t_13;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_13 = (__pyx_v_self->result_param_desc != ((PyObject*)Py_None));
    __pyx_t_11 = (__pyx_t_13 != 0);
    if (!__pyx_t_11) {
    } else {
      __pyx_t_12 = __pyx_t_11;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_11 = (__pyx_v_self->result_row_desc != ((PyObject*)Py_None));
    __pyx_t_13 = (__pyx_t_11 != 0);
    if (!__pyx_t_13) {
    } else {
      __pyx_t_12 = __pyx_t_13;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_13 = (__pyx_v_self->result_status_msg != ((PyObject*)Py_None));
    __pyx_t_11 = (__pyx_t_13 != 0);
    if (!__pyx_t_11) {
    } else {
      __pyx_t_12 = __pyx_t_11;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_11 = (__pyx_v_self->transport != Py_None);
    __pyx_t_13 = (__pyx_t_11 != 0);
    __pyx_t_12 = __pyx_t_13;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_12;
  }
  __pyx_L3:;

  /* "(tree fragment)":10
 *     else:
 *         use_setstate = self._execute_iter is not None or self._execute_portal_name is not None or self._execute_stmt_name is not None or self.buffer is not None or self.con_params is not None or self.encoding is not None or self.result is not None or self.result_param_desc is not None or self.result_row_desc is not None or self.result_status_msg is not None or self.transport is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_CoreProtocol, (type(self), 0x197884c, None), state
 *     else:
 */
  __pyx_t_12 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_12) {

    /* "(tree fragment)":11
 *         use_setstate = self._execute_iter is not None or self._execute_portal_name is not None or self._execute_stmt_name is not None or self.buffer is not None or self.con_params is not None or self.encoding is not None or self.result is not None or self.result_param_desc is not None or self.result_row_desc is not None or self.result_status_msg is not None or self.transport is not None
 *     if use_setstate:
 *         return __pyx_unpickle_CoreProtocol, (type(self), 0x197884c, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_CoreProtocol, (type(self), 0x197884c, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_CoreProtocol); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_26708044);
    __Pyx_GIVEREF(__pyx_int_26708044);
    PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_int_26708044);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_10, 2, Py_None);
    __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_10);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_v_state);
    __pyx_t_9 = 0;
    __pyx_t_10 = 0;
    __pyx_r = __pyx_t_8;
    __pyx_t_8 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":10
 *     else:
 *         use_setstate = self._execute_iter is not None or self._execute_portal_name is not None or self._execute_stmt_name is not None or self.buffer is not None or self.con_params is not None or self.encoding is not None or self.result is not None or self.result_param_desc is not None or self.result_row_desc is not None or self.result_status_msg is not None or self.transport is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_CoreProtocol, (type(self), 0x197884c, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         return __pyx_unpickle_CoreProtocol, (type(self), 0x197884c, None), state
 *     else:
 *         return __pyx_unpickle_CoreProtocol, (type(self), 0x197884c, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_CoreProtocol__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_CoreProtocol); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_26708044);
    __Pyx_GIVEREF(__pyx_int_26708044);
    PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_int_26708044);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_v_state);
    __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_10);
    __pyx_t_8 = 0;
    __pyx_t_10 = 0;
    __pyx_r = __pyx_t_9;
    __pyx_t_9 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self._discard_data, self._execute_iter, self._execute_portal_name, self._execute_stmt_name, self._skip_discard, self.backend_pid, self.backend_secret, self.buffer, self.con_params, self.con_status, self.encoding, self.result, self.result_execute_completed, self.result_param_desc, self.result_row_desc, self.result_status_msg, self.result_type, self.state, self.transport, self.xact_status)
 */

  /* 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.CoreProtocol.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_CoreProtocol, (type(self), 0x197884c, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_CoreProtocol__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12CoreProtocol_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12CoreProtocol_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12CoreProtocol_10__setstate_cython__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12CoreProtocol_10__setstate_cython__(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":15
 *         return __pyx_unpickle_CoreProtocol, (type(self), 0x197884c, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_CoreProtocol__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol___pyx_unpickle_CoreProtocol__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_CoreProtocol, (type(self), 0x197884c, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_CoreProtocol__set_state(self, __pyx_state)
 */

  /* 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.__setstate_cython__", __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":14
 * 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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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;
        CYTHON_FALLTHROUGH;
        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(27, 14, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        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(27, 14, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(27, 14, __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(27, 14, __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(27, 14, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_query), (&PyUnicode_Type), 1, "query", 1))) __PYX_ERR(27, 14, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_protocol), __pyx_ptype_7asyncpg_8protocol_8protocol_BaseProtocol, 1, "protocol", 0))) __PYX_ERR(27, 14, __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":15
 * 
 *     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":16
 *     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":17
 *         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":18
 *         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":19
 *         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":20
 *         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":21
 *         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":22
 *         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":23
 *         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":24
 *         self.cols_desc = None
 *         self.closed = False
 *         self.refs = 0             # <<<<<<<<<<<<<<
 *         self.buffer = FastReadBuffer.new()
 * 
 */
  __pyx_v_self->refs = 0;

  /* "asyncpg/protocol/prepared_stmt.pyx":25
 *         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(27, 25, __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":14
 * 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":27
 *         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":30
 *         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(27, 30, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "asyncpg/protocol/prepared_stmt.pyx":31
 * 
 *         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(27, 31, __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(27, 31, __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(27, 31, __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":32
 *         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(27, 32, __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(27, 32, __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":33
 *         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":34
 *             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(27, 34, __pyx_L1_error)

      /* "asyncpg/protocol/prepared_stmt.pyx":33
 *         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":35
 *             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(27, 35, __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(27, 35, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "asyncpg/protocol/prepared_stmt.pyx":36
 *                 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(27, 35, __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(27, 35, __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(27, 35, __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(27, 35, __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":35
 *             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 == ((int)-1))) __PYX_ERR(27, 35, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "asyncpg/protocol/prepared_stmt.pyx":31
 * 
 *         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":38
 *                 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(27, 38, __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":27
 *         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":40
 *         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
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  uint32_t __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":43
 *         cdef Codec codec
 * 
 *         if not self.row_desc:             # <<<<<<<<<<<<<<
 *             return ()
 * 
 */
  __pyx_t_1 = (__pyx_v_self->row_desc != Py_None) && (PyList_GET_SIZE(__pyx_v_self->row_desc) != 0);
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/prepared_stmt.pyx":44
 * 
 *         if not self.row_desc:
 *             return ()             # <<<<<<<<<<<<<<
 * 
 *         result = []
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_r = __pyx_empty_tuple;
    goto __pyx_L0;

    /* "asyncpg/protocol/prepared_stmt.pyx":43
 *         cdef Codec codec
 * 
 *         if not self.row_desc:             # <<<<<<<<<<<<<<
 *             return ()
 * 
 */
  }

  /* "asyncpg/protocol/prepared_stmt.pyx":46
 *             return ()
 * 
 *         result = []             # <<<<<<<<<<<<<<
 *         for d in self.row_desc:
 *             name = d[0]
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 46, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_result = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "asyncpg/protocol/prepared_stmt.pyx":47
 * 
 *         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(27, 47, __pyx_L1_error)
  }
  __pyx_t_3 = __pyx_v_self->row_desc; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
  for (;;) {
    if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_5 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(27, 47, __pyx_L1_error)
    #else
    __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 47, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_d, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "asyncpg/protocol/prepared_stmt.pyx":48
 *         result = []
 *         for d in self.row_desc:
 *             name = d[0]             # <<<<<<<<<<<<<<
 *             oid = d[3]
 * 
 */
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_d, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 48, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "asyncpg/protocol/prepared_stmt.pyx":49
 *         for d in self.row_desc:
 *             name = d[0]
 *             oid = d[3]             # <<<<<<<<<<<<<<
 * 
 *             codec = self.settings.get_data_codec(oid)
 */
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_d, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 49, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_XDECREF_SET(__pyx_v_oid, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "asyncpg/protocol/prepared_stmt.pyx":51
 *             oid = d[3]
 * 
 *             codec = self.settings.get_data_codec(oid)             # <<<<<<<<<<<<<<
 *             if codec is None:
 *                 raise RuntimeError
 */
    __pyx_t_6 = __Pyx_PyInt_As_uint32_t(__pyx_v_oid); if (unlikely((__pyx_t_6 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(27, 51, __pyx_L1_error)
    __pyx_t_5 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_get_data_codec(__pyx_v_self->settings, __pyx_t_6, 0, NULL)); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 51, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_XDECREF_SET(__pyx_v_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_5));
    __pyx_t_5 = 0;

    /* "asyncpg/protocol/prepared_stmt.pyx":52
 * 
 *             codec = self.settings.get_data_codec(oid)
 *             if codec is None:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError
 * 
 */
    __pyx_t_2 = (((PyObject *)__pyx_v_codec) == Py_None);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "asyncpg/protocol/prepared_stmt.pyx":53
 *             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(27, 53, __pyx_L1_error)

      /* "asyncpg/protocol/prepared_stmt.pyx":52
 * 
 *             codec = self.settings.get_data_codec(oid)
 *             if codec is None:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError
 * 
 */
    }

    /* "asyncpg/protocol/prepared_stmt.pyx":55
 *                 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(27, 55, __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_5 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_self->settings->_encoding); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 55, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    } 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_5 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 55, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_5);
      } 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_5 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 55, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_5);
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(27, 55, __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_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 55, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __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_5);
    __pyx_t_5 = 0;

    /* "asyncpg/protocol/prepared_stmt.pyx":58
 * 
 *             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(27, 58, __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(27, 58, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "asyncpg/protocol/prepared_stmt.pyx":59
 *             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(27, 59, __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(27, 59, __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(27, 59, __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(27, 59, __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(27, 59, __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(27, 59, __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_5 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 58, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __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_5 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 58, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __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(27, 58, __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_5 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 58, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "asyncpg/protocol/prepared_stmt.pyx":57
 *             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_5); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(27, 57, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "asyncpg/protocol/prepared_stmt.pyx":47
 * 
 *         result = []
 *         for d in self.row_desc:             # <<<<<<<<<<<<<<
 *             name = d[0]
 *             oid = d[3]
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/prepared_stmt.pyx":61
 *                     apg_types.Type(oid, codec.name, codec.kind, codec.schema)))
 * 
 *         return tuple(result)             # <<<<<<<<<<<<<<
 * 
 *     def _init_types(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyList_AsTuple(__pyx_v_result); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 61, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "asyncpg/protocol/prepared_stmt.pyx":40
 *         return tuple(result)
 * 
 *     def _get_attributes(self):             # <<<<<<<<<<<<<<
 *         cdef Codec codec
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __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":63
 *         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":66
 *         cdef:
 *             Codec codec
 *             set result = set()             # <<<<<<<<<<<<<<
 * 
 *         if self.parameters_desc:
 */
  __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 66, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "asyncpg/protocol/prepared_stmt.pyx":68
 *             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":69
 * 
 *         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(27, 69, __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(27, 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(27, 69, __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":70
 *         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(27, 70, __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(27, 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 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(27, 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(27, 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_L7_bool_binop_done:;
      if (__pyx_t_2) {

        /* "asyncpg/protocol/prepared_stmt.pyx":72
 *                 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 == ((int)-1))) __PYX_ERR(27, 72, __pyx_L1_error)

        /* "asyncpg/protocol/prepared_stmt.pyx":71
 *             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":69
 * 
 *         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":68
 *             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":74
 *                     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":75
 * 
 *         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(27, 75, __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(27, 75, __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(27, 75, __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":76
 *         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(27, 76, __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(27, 76, __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(27, 76, __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":77
 *             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(27, 77, __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(27, 77, __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":78
 *                 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(27, 78, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_8 = PySet_Add(__pyx_v_result, __pyx_t_4); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(27, 78, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "asyncpg/protocol/prepared_stmt.pyx":77
 *             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":75
 * 
 *         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":74
 *                     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":80
 *                     result.add(rdesc[3])
 * 
 *         if len(result):             # <<<<<<<<<<<<<<
 *             return result
 *         else:
 */
  __pyx_t_3 = PySet_GET_SIZE(__pyx_v_result); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(27, 80, __pyx_L1_error)
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/prepared_stmt.pyx":81
 * 
 *         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":80
 *                     result.add(rdesc[3])
 * 
 *         if len(result):             # <<<<<<<<<<<<<<
 *             return result
 *         else:
 */
  }

  /* "asyncpg/protocol/prepared_stmt.pyx":83
 *             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":63
 *         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":85
 *             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":86
 * 
 *     def attach(self):
 *         self.refs += 1             # <<<<<<<<<<<<<<
 * 
 *     def detach(self):
 */
  __pyx_v_self->refs = (__pyx_v_self->refs + 1);

  /* "asyncpg/protocol/prepared_stmt.pyx":85
 *             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":88
 *         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":89
 * 
 *     def detach(self):
 *         self.refs -= 1             # <<<<<<<<<<<<<<
 * 
 *     def mark_closed(self):
 */
  __pyx_v_self->refs = (__pyx_v_self->refs - 1);

  /* "asyncpg/protocol/prepared_stmt.pyx":88
 *         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":91
 *         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":92
 * 
 *     def mark_closed(self):
 *         self.closed = True             # <<<<<<<<<<<<<<
 * 
 *     cdef _encode_bind_msg(self, args):
 */
  __pyx_v_self->closed = 1;

  /* "asyncpg/protocol/prepared_stmt.pyx":91
 *         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":94
 *         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;
  Py_ssize_t __pyx_v_num_args_passed;
  PyObject *__pyx_v_hint = NULL;
  PyObject *__pyx_v_arg = 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;
  int16_t __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("_encode_bind_msg", 0);

  /* "asyncpg/protocol/prepared_stmt.pyx":100
 *             Codec codec
 * 
 *         if len(args) > 32767:             # <<<<<<<<<<<<<<
 *             raise exceptions.InterfaceError(
 *                 'the number of query arguments cannot exceed 32767')
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(27, 100, __pyx_L1_error)
  __pyx_t_2 = ((__pyx_t_1 > 0x7FFF) != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/prepared_stmt.pyx":101
 * 
 *         if len(args) > 32767:
 *             raise exceptions.InterfaceError(             # <<<<<<<<<<<<<<
 *                 'the number of query arguments cannot exceed 32767')
 * 
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_exceptions); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 101, __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, 101, __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__90, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 101, __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, 101, __pyx_L1_error)

    /* "asyncpg/protocol/prepared_stmt.pyx":100
 *             Codec codec
 * 
 *         if len(args) > 32767:             # <<<<<<<<<<<<<<
 *             raise exceptions.InterfaceError(
 *                 'the number of query arguments cannot exceed 32767')
 */
  }

  /* "asyncpg/protocol/prepared_stmt.pyx":104
 *                 'the number of query arguments cannot exceed 32767')
 * 
 *         self._ensure_args_encoder()             # <<<<<<<<<<<<<<
 *         self._ensure_rows_decoder()
 * 
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__ensure_args_encoder(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/prepared_stmt.pyx":105
 * 
 *         self._ensure_args_encoder()
 *         self._ensure_rows_decoder()             # <<<<<<<<<<<<<<
 * 
 *         writer = WriteBuffer.new()
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__ensure_rows_decoder(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 105, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/prepared_stmt.pyx":107
 *         self._ensure_rows_decoder()
 * 
 *         writer = WriteBuffer.new()             # <<<<<<<<<<<<<<
 * 
 *         num_args_passed = len(args)
 */
  __pyx_t_3 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new()); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_writer = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "asyncpg/protocol/prepared_stmt.pyx":109
 *         writer = WriteBuffer.new()
 * 
 *         num_args_passed = len(args)             # <<<<<<<<<<<<<<
 *         if self.args_num != num_args_passed:
 *             hint = 'Check the query against the passed list of arguments.'
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(27, 109, __pyx_L1_error)
  __pyx_v_num_args_passed = __pyx_t_1;

  /* "asyncpg/protocol/prepared_stmt.pyx":110
 * 
 *         num_args_passed = len(args)
 *         if self.args_num != num_args_passed:             # <<<<<<<<<<<<<<
 *             hint = 'Check the query against the passed list of arguments.'
 * 
 */
  __pyx_t_2 = ((__pyx_v_self->args_num != __pyx_v_num_args_passed) != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/prepared_stmt.pyx":111
 *         num_args_passed = len(args)
 *         if self.args_num != num_args_passed:
 *             hint = 'Check the query against the passed list of arguments.'             # <<<<<<<<<<<<<<
 * 
 *             if self.args_num == 0:
 */
    __Pyx_INCREF(__pyx_kp_u_Check_the_query_against_the_pass);
    __pyx_v_hint = __pyx_kp_u_Check_the_query_against_the_pass;

    /* "asyncpg/protocol/prepared_stmt.pyx":113
 *             hint = 'Check the query against the passed list of arguments.'
 * 
 *             if self.args_num == 0:             # <<<<<<<<<<<<<<
 *                 # If the server was expecting zero arguments, it is likely
 *                 # that the user tried to parametrize a statement that does
 */
    __pyx_t_2 = ((__pyx_v_self->args_num == 0) != 0);
    if (__pyx_t_2) {

      /* "asyncpg/protocol/prepared_stmt.pyx":117
 *                 # that the user tried to parametrize a statement that does
 *                 # not support parameters.
 *                 hint += (r'  Note that parameters are supported only in'             # <<<<<<<<<<<<<<
 *                          r' SELECT, INSERT, UPDATE, DELETE, and VALUES'
 *                          r' statements, and will *not* work in statements '
 */
      __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_v_hint, __pyx_kp_u_Note_that_parameters_are_suppor); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 117, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF_SET(__pyx_v_hint, ((PyObject*)__pyx_t_3));
      __pyx_t_3 = 0;

      /* "asyncpg/protocol/prepared_stmt.pyx":113
 *             hint = 'Check the query against the passed list of arguments.'
 * 
 *             if self.args_num == 0:             # <<<<<<<<<<<<<<
 *                 # If the server was expecting zero arguments, it is likely
 *                 # that the user tried to parametrize a statement that does
 */
    }

    /* "asyncpg/protocol/prepared_stmt.pyx":122
 *                          r' like CREATE VIEW or DECLARE CURSOR.')
 * 
 *             raise exceptions.InterfaceError(             # <<<<<<<<<<<<<<
 *                 'the server expects {x} argument{s} for this query, '
 *                 '{y} {w} passed'.format(
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_exceptions); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 122, __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, 122, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "asyncpg/protocol/prepared_stmt.pyx":124
 *             raise exceptions.InterfaceError(
 *                 'the server expects {x} argument{s} for this query, '
 *                 '{y} {w} passed'.format(             # <<<<<<<<<<<<<<
 *                     x=self.args_num, s='s' if self.args_num != 1 else '',
 *                     y=num_args_passed,
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_the_server_expects_x_argument_s, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 124, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);

    /* "asyncpg/protocol/prepared_stmt.pyx":125
 *                 'the server expects {x} argument{s} for this query, '
 *                 '{y} {w} passed'.format(
 *                     x=self.args_num, s='s' if self.args_num != 1 else '',             # <<<<<<<<<<<<<<
 *                     y=num_args_passed,
 *                     w='was' if num_args_passed == 1 else 'were'),
 */
    __pyx_t_5 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 125, __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(27, 125, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_x, __pyx_t_6) < 0) __PYX_ERR(27, 125, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (((__pyx_v_self->args_num != 1) != 0)) {
      __Pyx_INCREF(__pyx_n_u_s);
      __pyx_t_6 = __pyx_n_u_s;
    } else {
      __Pyx_INCREF(__pyx_kp_u__22);
      __pyx_t_6 = __pyx_kp_u__22;
    }
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_s, __pyx_t_6) < 0) __PYX_ERR(27, 125, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "asyncpg/protocol/prepared_stmt.pyx":126
 *                 '{y} {w} passed'.format(
 *                     x=self.args_num, s='s' if self.args_num != 1 else '',
 *                     y=num_args_passed,             # <<<<<<<<<<<<<<
 *                     w='was' if num_args_passed == 1 else 'were'),
 *                 hint=hint)
 */
    __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_num_args_passed); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 126, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_y, __pyx_t_6) < 0) __PYX_ERR(27, 125, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "asyncpg/protocol/prepared_stmt.pyx":127
 *                     x=self.args_num, s='s' if self.args_num != 1 else '',
 *                     y=num_args_passed,
 *                     w='was' if num_args_passed == 1 else 'were'),             # <<<<<<<<<<<<<<
 *                 hint=hint)
 * 
 */
    if (((__pyx_v_num_args_passed == 1) != 0)) {
      __Pyx_INCREF(__pyx_n_u_was);
      __pyx_t_6 = __pyx_n_u_was;
    } else {
      __Pyx_INCREF(__pyx_n_u_were);
      __pyx_t_6 = __pyx_n_u_were;
    }
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_w, __pyx_t_6) < 0) __PYX_ERR(27, 125, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "asyncpg/protocol/prepared_stmt.pyx":124
 *             raise exceptions.InterfaceError(
 *                 'the server expects {x} argument{s} for this query, '
 *                 '{y} {w} passed'.format(             # <<<<<<<<<<<<<<
 *                     x=self.args_num, s='s' if self.args_num != 1 else '',
 *                     y=num_args_passed,
 */
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_empty_tuple, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 124, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "asyncpg/protocol/prepared_stmt.pyx":122
 *                          r' like CREATE VIEW or DECLARE CURSOR.')
 * 
 *             raise exceptions.InterfaceError(             # <<<<<<<<<<<<<<
 *                 'the server expects {x} argument{s} for this query, '
 *                 '{y} {w} passed'.format(
 */
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(27, 122, __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 = 0;

    /* "asyncpg/protocol/prepared_stmt.pyx":128
 *                     y=num_args_passed,
 *                     w='was' if num_args_passed == 1 else 'were'),
 *                 hint=hint)             # <<<<<<<<<<<<<<
 * 
 *         if self.have_text_args:
 */
    __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 128, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_hint, __pyx_v_hint) < 0) __PYX_ERR(27, 128, __pyx_L1_error)

    /* "asyncpg/protocol/prepared_stmt.pyx":122
 *                          r' like CREATE VIEW or DECLARE CURSOR.')
 * 
 *             raise exceptions.InterfaceError(             # <<<<<<<<<<<<<<
 *                 'the server expects {x} argument{s} for this query, '
 *                 '{y} {w} passed'.format(
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 122, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __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_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(27, 122, __pyx_L1_error)

    /* "asyncpg/protocol/prepared_stmt.pyx":110
 * 
 *         num_args_passed = len(args)
 *         if self.args_num != num_args_passed:             # <<<<<<<<<<<<<<
 *             hint = 'Check the query against the passed list of arguments.'
 * 
 */
  }

  /* "asyncpg/protocol/prepared_stmt.pyx":130
 *                 hint=hint)
 * 
 *         if self.have_text_args:             # <<<<<<<<<<<<<<
 *             writer.write_int16(self.args_num)
 *             for idx from 0 <= idx < self.args_num:
 */
  __pyx_t_2 = (__pyx_v_self->have_text_args != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/prepared_stmt.pyx":131
 * 
 *         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_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int16(__pyx_v_writer, __pyx_v_self->args_num); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 131, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "asyncpg/protocol/prepared_stmt.pyx":132
 *         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_7 = __pyx_v_self->args_num;
    for (__pyx_v_idx = 0; __pyx_v_idx < __pyx_t_7; __pyx_v_idx++) {

      /* "asyncpg/protocol/prepared_stmt.pyx":133
 *             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(27, 133, __pyx_L1_error)
      }
      __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_self->args_codecs, __pyx_v_idx, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 133, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = __pyx_t_3;
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF_SET(__pyx_v_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_6));
      __pyx_t_6 = 0;

      /* "asyncpg/protocol/prepared_stmt.pyx":134
 *             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_6 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int16(__pyx_v_writer, __pyx_v_codec->format); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 134, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }

    /* "asyncpg/protocol/prepared_stmt.pyx":130
 *                 hint=hint)
 * 
 *         if self.have_text_args:             # <<<<<<<<<<<<<<
 *             writer.write_int16(self.args_num)
 *             for idx from 0 <= idx < self.args_num:
 */
    goto __pyx_L6;
  }

  /* "asyncpg/protocol/prepared_stmt.pyx":137
 *         else:
 *             # All arguments are in binary format
 *             writer.write_int32(0x00010001)             # <<<<<<<<<<<<<<
 * 
 *         writer.write_int16(self.args_num)
 */
  /*else*/ {
    __pyx_t_6 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_writer, 0x00010001); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 137, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __pyx_L6:;

  /* "asyncpg/protocol/prepared_stmt.pyx":139
 *             writer.write_int32(0x00010001)
 * 
 *         writer.write_int16(self.args_num)             # <<<<<<<<<<<<<<
 * 
 *         for idx from 0 <= idx < self.args_num:
 */
  __pyx_t_6 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int16(__pyx_v_writer, __pyx_v_self->args_num); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 139, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "asyncpg/protocol/prepared_stmt.pyx":141
 *         writer.write_int16(self.args_num)
 * 
 *         for idx from 0 <= idx < self.args_num:             # <<<<<<<<<<<<<<
 *             arg = args[idx]
 *             if arg is None:
 */
  __pyx_t_7 = __pyx_v_self->args_num;
  for (__pyx_v_idx = 0; __pyx_v_idx < __pyx_t_7; __pyx_v_idx++) {

    /* "asyncpg/protocol/prepared_stmt.pyx":142
 * 
 *         for idx from 0 <= idx < self.args_num:
 *             arg = args[idx]             # <<<<<<<<<<<<<<
 *             if arg is None:
 *                 writer.write_int32(-1)
 */
    __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_args, __pyx_v_idx, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 142, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_XDECREF_SET(__pyx_v_arg, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "asyncpg/protocol/prepared_stmt.pyx":143
 *         for idx from 0 <= idx < self.args_num:
 *             arg = args[idx]
 *             if arg is None:             # <<<<<<<<<<<<<<
 *                 writer.write_int32(-1)
 *             else:
 */
    __pyx_t_2 = (__pyx_v_arg == Py_None);
    __pyx_t_8 = (__pyx_t_2 != 0);
    if (__pyx_t_8) {

      /* "asyncpg/protocol/prepared_stmt.pyx":144
 *             arg = args[idx]
 *             if arg is None:
 *                 writer.write_int32(-1)             # <<<<<<<<<<<<<<
 *             else:
 *                 codec = <Codec>(self.args_codecs[idx])
 */
      __pyx_t_6 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_writer, -1); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 144, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "asyncpg/protocol/prepared_stmt.pyx":143
 *         for idx from 0 <= idx < self.args_num:
 *             arg = args[idx]
 *             if arg is None:             # <<<<<<<<<<<<<<
 *                 writer.write_int32(-1)
 *             else:
 */
      goto __pyx_L11;
    }

    /* "asyncpg/protocol/prepared_stmt.pyx":146
 *                 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(27, 146, __pyx_L1_error)
      }
      __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v_self->args_codecs, __pyx_v_idx, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 146, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_3 = __pyx_t_6;
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __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":147
 *             else:
 *                 codec = <Codec>(self.args_codecs[idx])
 *                 codec.encode(self.settings, writer, arg)             # <<<<<<<<<<<<<<
 * 
 *         if self.have_text_cols:
 */
      __pyx_t_3 = ((PyObject *)__pyx_v_self->settings);
      __Pyx_INCREF(__pyx_t_3);
      __pyx_t_6 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode(__pyx_v_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *)__pyx_t_3), __pyx_v_writer, __pyx_v_arg); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 147, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __pyx_L11:;
  }

  /* "asyncpg/protocol/prepared_stmt.pyx":149
 *                 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_8 = (__pyx_v_self->have_text_cols != 0);
  if (__pyx_t_8) {

    /* "asyncpg/protocol/prepared_stmt.pyx":150
 * 
 *         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_6 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int16(__pyx_v_writer, __pyx_v_self->cols_num); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 150, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "asyncpg/protocol/prepared_stmt.pyx":151
 *         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_7 = __pyx_v_self->cols_num;
    for (__pyx_v_idx = 0; __pyx_v_idx < __pyx_t_7; __pyx_v_idx++) {

      /* "asyncpg/protocol/prepared_stmt.pyx":152
 *             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(27, 152, __pyx_L1_error)
      }
      __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v_self->rows_codecs, __pyx_v_idx, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(27, 152, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_3 = __pyx_t_6;
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __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":153
 *             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_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int16(__pyx_v_writer, __pyx_v_codec->format); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 153, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }

    /* "asyncpg/protocol/prepared_stmt.pyx":149
 *                 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_L12;
  }

  /* "asyncpg/protocol/prepared_stmt.pyx":156
 *         else:
 *             # All columns are in binary format
 *             writer.write_int32(0x00010001)             # <<<<<<<<<<<<<<
 * 
 *         return writer
 */
  /*else*/ {
    __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_v_writer, 0x00010001); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 156, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __pyx_L12:;

  /* "asyncpg/protocol/prepared_stmt.pyx":158
 *             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":94
 *         self.closed = True
 * 
 *     cdef _encode_bind_msg(self, args):             # <<<<<<<<<<<<<<
 *         cdef:
 *             int idx
 */

  /* 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_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_hint);
  __Pyx_XDECREF(__pyx_v_arg);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/prepared_stmt.pyx":160
 *         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":169
 *             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":170
 * 
 *         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":169
 *             list codecs
 * 
 *         if self.cols_desc is not None:             # <<<<<<<<<<<<<<
 *             return
 * 
 */
  }

  /* "asyncpg/protocol/prepared_stmt.pyx":172
 *             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":173
 * 
 *         if self.cols_num == 0:
 *             self.cols_desc = record.ApgRecordDesc_New({}, ())             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 173, __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, 173, __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":174
 *         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":172
 *             return
 * 
 *         if self.cols_num == 0:             # <<<<<<<<<<<<<<
 *             self.cols_desc = record.ApgRecordDesc_New({}, ())
 *             return
 */
  }

  /* "asyncpg/protocol/prepared_stmt.pyx":176
 *             return
 * 
 *         cols_mapping = collections.OrderedDict()             # <<<<<<<<<<<<<<
 *         cols_names = []
 *         codecs = []
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_collections); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 176, __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(27, 176, __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(27, 176, __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(27, 176, __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":177
 * 
 *         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(27, 177, __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":178
 *         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(27, 178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_codecs = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "asyncpg/protocol/prepared_stmt.pyx":179
 *         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":180
 *         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(27, 180, __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(27, 180, __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(27, 180, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_row, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "asyncpg/protocol/prepared_stmt.pyx":181
 *         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(27, 181, __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(27, 181, __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(27, 181, __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(27, 181, __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(27, 181, __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(27, 181, __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(27, 181, __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(27, 181, __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":182
 *             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(27, 182, __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(27, 182, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "asyncpg/protocol/prepared_stmt.pyx":183
 *             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 == ((int)-1))) __PYX_ERR(27, 183, __pyx_L1_error)

    /* "asyncpg/protocol/prepared_stmt.pyx":184
 *             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(27, 184, __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(27, 184, __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(27, 184, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_oid = __pyx_t_9;

    /* "asyncpg/protocol/prepared_stmt.pyx":185
 *             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(27, 185, __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":186
 *             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(27, 186, __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(27, 186, __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":187
 *             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(27, 187, __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(27, 187, __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(27, 187, __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(27, 187, __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(27, 187, __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(27, 187, __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(27, 187, __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(27, 187, __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(27, 187, __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(27, 187, __pyx_L1_error)

      /* "asyncpg/protocol/prepared_stmt.pyx":186
 *             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":188
 *             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(27, 188, __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(27, 188, __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":189
 *                 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":188
 *             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":191
 *                 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 == ((int)-1))) __PYX_ERR(27, 191, __pyx_L1_error)
  }

  /* "asyncpg/protocol/prepared_stmt.pyx":194
 * 
 *         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(27, 194, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "asyncpg/protocol/prepared_stmt.pyx":193
 *             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(27, 193, __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":196
 *             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(27, 196, __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":160
 *         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":198
 *         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":202
 *             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(27, 202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_codecs = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "asyncpg/protocol/prepared_stmt.pyx":204
 *             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":205
 * 
 *         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":204
 *             list codecs = []
 * 
 *         if self.args_num == 0 or self.args_codecs is not None:             # <<<<<<<<<<<<<<
 *             return
 * 
 */
  }

  /* "asyncpg/protocol/prepared_stmt.pyx":207
 *             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":208
 * 
 *         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(27, 208, __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(27, 208, __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(27, 208, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_p_oid = __pyx_t_6;

    /* "asyncpg/protocol/prepared_stmt.pyx":209
 *         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(27, 209, __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":210
 *             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(27, 210, __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(27, 210, __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":211
 *             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(27, 211, __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(27, 211, __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(27, 211, __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(27, 211, __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(27, 211, __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(27, 211, __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(27, 211, __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(27, 211, __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(27, 211, __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(27, 211, __pyx_L1_error)

      /* "asyncpg/protocol/prepared_stmt.pyx":210
 *             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":212
 *             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(27, 212, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(27, 212, __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(27, 212, __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":213
 *                 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":212
 *             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":215
 *                 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 == ((int)-1))) __PYX_ERR(27, 215, __pyx_L1_error)
  }

  /* "asyncpg/protocol/prepared_stmt.pyx":217
 *             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(27, 217, __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":198
 *         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":219
 *         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":220
 * 
 *     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(27, 220, __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(27, 220, __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":221
 *     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(27, 221, __pyx_L1_error)
  }
  __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(27, 221, __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":219
 *         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":223
 *         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":224
 * 
 *     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(27, 224, __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(27, 224, __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":225
 *     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(27, 225, __pyx_L1_error)
  }
  __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(27, 225, __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":223
 *         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":227
 *         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":233
 *             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":234
 *             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":236
 *             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":239
 *             ssize_t bl
 * 
 *         rbuf.buf = cbuf             # <<<<<<<<<<<<<<
 *         rbuf.len = buf_len
 * 
 */
  __pyx_v_rbuf->buf = __pyx_v_cbuf;

  /* "asyncpg/protocol/prepared_stmt.pyx":240
 * 
 *         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":242
 *         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 == ((char const *)NULL))) __PYX_ERR(27, 242, __pyx_L1_error)
  __pyx_v_fnum = unpack_int16(__pyx_t_2);

  /* "asyncpg/protocol/prepared_stmt.pyx":244
 *         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":247
 *             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(27, 247, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);

    /* "asyncpg/protocol/prepared_stmt.pyx":248
 *                 '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(27, 248, __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(27, 248, __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(27, 247, __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(27, 247, __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(27, 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_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(27, 247, __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":245
 * 
 *         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(27, 245, __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(27, 245, __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(27, 245, __pyx_L1_error)

    /* "asyncpg/protocol/prepared_stmt.pyx":244
 *         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":250
 *                     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(27, 250, __pyx_L1_error)
  }
  __pyx_t_12 = PyTuple_GET_SIZE(__pyx_v_rows_codecs); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(27, 250, __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":251
 * 
 *         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":253
 *             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__91, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 253, __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, 253, __pyx_L1_error)

      /* "asyncpg/protocol/prepared_stmt.pyx":251
 * 
 *         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":250
 *                     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":255
 *                 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(27, 255, __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":256
 * 
 *         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":257
 *         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 == ((char const *)NULL))) __PYX_ERR(27, 257, __pyx_L1_error)
    __pyx_v_flen = unpack_int32(__pyx_t_2);

    /* "asyncpg/protocol/prepared_stmt.pyx":259
 *             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":260
 * 
 *             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":259
 *             flen = hton.unpack_int32(rbuf.read(4))
 * 
 *             if flen == -1:             # <<<<<<<<<<<<<<
 *                 val = None
 *             else:
 */
      goto __pyx_L10;
    }

    /* "asyncpg/protocol/prepared_stmt.pyx":265
 *                 # 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":266
 *                 # 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":268
 *                 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(27, 268, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "asyncpg/protocol/prepared_stmt.pyx":266
 *                 # properly.
 *                 bl = rbuf.len
 *                 if flen > bl:             # <<<<<<<<<<<<<<
 *                     # Check for overflow
 *                     rbuf._raise_ins_err(flen, bl)
 */
      }

      /* "asyncpg/protocol/prepared_stmt.pyx":269
 *                     # 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":270
 *                     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":271
 *                 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(27, 271, __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":272
 *                 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":273
 *                 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(27, 273, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);

        /* "asyncpg/protocol/prepared_stmt.pyx":274
 *                 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(27, 274, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);

        /* "asyncpg/protocol/prepared_stmt.pyx":275
 *                     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(27, 275, __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(27, 274, __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(27, 274, __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(27, 274, __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(27, 274, __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(27, 274, __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(27, 273, __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(27, 273, __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(27, 273, __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(27, 273, __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(27, 273, __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(27, 273, __pyx_L1_error)

        /* "asyncpg/protocol/prepared_stmt.pyx":272
 *                 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":276
 *                         '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":278
 *                 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":279
 * 
 *             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":281
 *             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":282
 * 
 *         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(27, 282, __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(27, 282, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);

    /* "asyncpg/protocol/prepared_stmt.pyx":283
 *         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(27, 283, __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(27, 282, __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(27, 282, __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(27, 282, __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(27, 282, __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(27, 282, __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(27, 282, __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(27, 282, __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(27, 282, __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(27, 282, __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(27, 282, __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(27, 282, __pyx_L1_error)

    /* "asyncpg/protocol/prepared_stmt.pyx":281
 *             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":285
 *                 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":227
 *         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(28, 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(28, 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;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_15__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_15__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_14__reduce_cython__(((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_14__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__92, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __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, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.PreparedStatementState.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_17__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_17__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_16__setstate_cython__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_22PreparedStatementState_16__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__93, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __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, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.PreparedStatementState.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/prepared_stmt.pyx":288
 * 
 * 
 * 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":293
 *         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(27, 293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "asyncpg/protocol/prepared_stmt.pyx":295
 *         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(27, 295, __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":296
 * 
 *     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(27, 296, __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(27, 296, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_nparams = __pyx_t_2;

  /* "asyncpg/protocol/prepared_stmt.pyx":298
 *     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":299
 * 
 *     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(27, 299, __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(27, 299, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_p_oid = __pyx_t_3;

    /* "asyncpg/protocol/prepared_stmt.pyx":300
 *     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(27, 300, __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 == ((int)-1))) __PYX_ERR(27, 300, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "asyncpg/protocol/prepared_stmt.pyx":302
 *         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":288
 * 
 * 
 * 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":305
 * 
 * 
 * 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":321
 *         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(27, 321, __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":322
 * 
 *     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(27, 322, __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(27, 322, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_nfields = __pyx_t_2;

  /* "asyncpg/protocol/prepared_stmt.pyx":323
 *     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(27, 323, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "asyncpg/protocol/prepared_stmt.pyx":325
 *     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":326
 * 
 *     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(27, 326, __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(27, 326, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_f_name, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "asyncpg/protocol/prepared_stmt.pyx":327
 *     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(27, 327, __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(27, 327, __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":328
 *         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(27, 328, __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(27, 328, __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":329
 *         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(27, 329, __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(27, 329, __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":330
 *         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(27, 330, __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(27, 330, __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":331
 *         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(27, 331, __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(27, 331, __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":332
 *         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(27, 332, __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(27, 332, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_f_format = __pyx_t_4;

    /* "asyncpg/protocol/prepared_stmt.pyx":335
 * 
 *         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(27, 335, __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(27, 335, __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(27, 335, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);

    /* "asyncpg/protocol/prepared_stmt.pyx":336
 *         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(27, 336, __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(27, 336, __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(27, 336, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);

    /* "asyncpg/protocol/prepared_stmt.pyx":335
 * 
 *         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(27, 335, __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":334
 *         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 == ((int)-1))) __PYX_ERR(27, 334, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }

  /* "asyncpg/protocol/prepared_stmt.pyx":338
 *              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":305
 * 
 * 
 * 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":92
 * 
 * cdef class BaseProtocol(CoreProtocol):
 *     def __init__(self, addr, connected_fut, con_params, loop):             # <<<<<<<<<<<<<<
 *         # type of `con_params` is `_ConnectionParameters`
 *         CoreProtocol.__init__(self, con_params)
 */

/* 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_params = 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_params,&__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);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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;
        CYTHON_FALLTHROUGH;
        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(0, 92, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_con_params)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 2); __PYX_ERR(0, 92, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        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(0, 92, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 92, __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_params = 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(0, 92, __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_params, __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_params, 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":94
 *     def __init__(self, addr, connected_fut, con_params, loop):
 *         # type of `con_params` is `_ConnectionParameters`
 *         CoreProtocol.__init__(self, con_params)             # <<<<<<<<<<<<<<
 * 
 *         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(0, 94, __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_params};
    __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(0, 94, __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_params};
    __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(0, 94, __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(0, 94, __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_params);
    __Pyx_GIVEREF(__pyx_v_con_params);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_con_params);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __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":96
 *         CoreProtocol.__init__(self, con_params)
 * 
 *         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":97
 * 
 *         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":98
 *         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":99
 *         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":101
 *         self.cancel_sent_waiter = None
 * 
 *         self.address = addr             # <<<<<<<<<<<<<<
 *         self.settings = ConnectionSettings((self.address, con_params.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":102
 * 
 *         self.address = addr
 *         self.settings = ConnectionSettings((self.address, con_params.database))             # <<<<<<<<<<<<<<
 * 
 *         self.statement = None
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_con_params, __pyx_n_s_database); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 102, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 102, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_self->address);
  __Pyx_GIVEREF(__pyx_v_self->address);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->address);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 102, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_ConnectionSettings), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 102, __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->settings);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->settings));
  __pyx_v_self->settings = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "asyncpg/protocol/protocol.pyx":104
 *         self.settings = ConnectionSettings((self.address, con_params.database))
 * 
 *         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":105
 * 
 *         self.statement = None
 *         self.return_extra = False             # <<<<<<<<<<<<<<
 * 
 *         self.last_query = None
 */
  __pyx_v_self->return_extra = 0;

  /* "asyncpg/protocol/protocol.pyx":107
 *         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":109
 *         self.last_query = None
 * 
 *         self.closing = False             # <<<<<<<<<<<<<<
 *         self.is_reading = True
 *         self.writing_allowed = asyncio.Event(loop=self.loop)
 */
  __pyx_v_self->closing = 0;

  /* "asyncpg/protocol/protocol.pyx":110
 * 
 *         self.closing = False
 *         self.is_reading = True             # <<<<<<<<<<<<<<
 *         self.writing_allowed = asyncio.Event(loop=self.loop)
 *         self.writing_allowed.set()
 */
  __pyx_v_self->is_reading = 1;

  /* "asyncpg/protocol/protocol.pyx":111
 *         self.closing = False
 *         self.is_reading = True
 *         self.writing_allowed = asyncio.Event(loop=self.loop)             # <<<<<<<<<<<<<<
 *         self.writing_allowed.set()
 * 
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_asyncio); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 111, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Event); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 111, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 111, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_loop, __pyx_v_self->loop) < 0) __PYX_ERR(0, 111, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 111, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_writing_allowed, __pyx_t_5) < 0) __PYX_ERR(0, 111, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "asyncpg/protocol/protocol.pyx":112
 *         self.is_reading = True
 *         self.writing_allowed = asyncio.Event(loop=self.loop)
 *         self.writing_allowed.set()             # <<<<<<<<<<<<<<
 * 
 *         self.timeout_handle = None
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_writing_allowed); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 112, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_set); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 112, __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_5 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 112, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 112, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "asyncpg/protocol/protocol.pyx":114
 *         self.writing_allowed.set()
 * 
 *         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":115
 * 
 *         self.timeout_handle = None
 *         self.timeout_callback = self._on_timeout             # <<<<<<<<<<<<<<
 *         self.completed_callback = self._on_waiter_completed
 * 
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_timeout); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 115, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __Pyx_GOTREF(__pyx_v_self->timeout_callback);
  __Pyx_DECREF(__pyx_v_self->timeout_callback);
  __pyx_v_self->timeout_callback = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "asyncpg/protocol/protocol.pyx":116
 *         self.timeout_handle = None
 *         self.timeout_callback = self._on_timeout
 *         self.completed_callback = self._on_waiter_completed             # <<<<<<<<<<<<<<
 * 
 *         self.queries_count = 0
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_waiter_completed); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __Pyx_GOTREF(__pyx_v_self->completed_callback);
  __Pyx_DECREF(__pyx_v_self->completed_callback);
  __pyx_v_self->completed_callback = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "asyncpg/protocol/protocol.pyx":118
 *         self.completed_callback = self._on_waiter_completed
 * 
 *         self.queries_count = 0             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
  __pyx_v_self->queries_count = 0;

  /* "asyncpg/protocol/protocol.pyx":120
 *         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":121
 * 
 *         try:
 *             self.create_future = loop.create_future             # <<<<<<<<<<<<<<
 *         except AttributeError:
 *             self.create_future = self._create_future_fallback
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_loop, __pyx_n_s_create_future); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 121, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_v_self->create_future);
      __Pyx_DECREF(__pyx_v_self->create_future);
      __pyx_v_self->create_future = __pyx_t_5;
      __pyx_t_5 = 0;

      /* "asyncpg/protocol/protocol.pyx":120
 *         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_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "asyncpg/protocol/protocol.pyx":122
 *         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_5, &__pyx_t_1, &__pyx_t_2) < 0) __PYX_ERR(0, 122, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);

      /* "asyncpg/protocol/protocol.pyx":123
 *             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(0, 123, __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_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L4_exception_handled;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "asyncpg/protocol/protocol.pyx":120
 *         self.queries_count = 0
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             self.create_future = loop.create_future
 *         except AttributeError:
 */
    __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_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_L8_try_end:;
  }

  /* "asyncpg/protocol/protocol.pyx":92
 * 
 * cdef class BaseProtocol(CoreProtocol):
 *     def __init__(self, addr, connected_fut, con_params, loop):             # <<<<<<<<<<<<<<
 *         # type of `con_params` is `_ConnectionParameters`
 *         CoreProtocol.__init__(self, con_params)
 */

  /* 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":125
 *             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":126
 * 
 *     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":125
 *             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":128
 *         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":129
 * 
 *     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(0, 129, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "asyncpg/protocol/protocol.pyx":128
 *         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":131
 *         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":132
 * 
 *     def get_settings(self):
 *         return self.settings             # <<<<<<<<<<<<<<
 * 
 *     def is_in_transaction(self):
 */
  __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":131
 *         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;
}

/* "asyncpg/protocol/protocol.pyx":134
 *         return self.settings
 * 
 *     def is_in_transaction(self):             # <<<<<<<<<<<<<<
 *         # PQTRANS_INTRANS = idle, within transaction block
 *         # PQTRANS_INERROR = idle, within failed transaction
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_9is_in_transaction(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_9is_in_transaction(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_in_transaction (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_8is_in_transaction(((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_8is_in_transaction(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;
  __Pyx_RefNannySetupContext("is_in_transaction", 0);

  /* "asyncpg/protocol/protocol.pyx":137
 *         # PQTRANS_INTRANS = idle, within transaction block
 *         # PQTRANS_INERROR = idle, within failed transaction
 *         return self.xact_status in (PQTRANS_INTRANS, PQTRANS_INERROR)             # <<<<<<<<<<<<<<
 * 
 *     cdef inline resume_reading(self):
 */
  __Pyx_XDECREF(__pyx_r);
  switch (__pyx_v_self->__pyx_base.xact_status) {
    case __pyx_e_7asyncpg_8protocol_8protocol_PQTRANS_INTRANS:
    case __pyx_e_7asyncpg_8protocol_8protocol_PQTRANS_INERROR:
    __pyx_t_1 = 1;
    break;
    default:
    __pyx_t_1 = 0;
    break;
  }
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "asyncpg/protocol/protocol.pyx":134
 *         return self.settings
 * 
 *     def is_in_transaction(self):             # <<<<<<<<<<<<<<
 *         # PQTRANS_INTRANS = idle, within transaction block
 *         # PQTRANS_INERROR = idle, within failed transaction
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.is_in_transaction", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/protocol.pyx":139
 *         return self.xact_status in (PQTRANS_INTRANS, PQTRANS_INERROR)
 * 
 *     cdef inline resume_reading(self):             # <<<<<<<<<<<<<<
 *         if not self.is_reading:
 *             self.is_reading = True
 */

static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol_resume_reading(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("resume_reading", 0);

  /* "asyncpg/protocol/protocol.pyx":140
 * 
 *     cdef inline resume_reading(self):
 *         if not self.is_reading:             # <<<<<<<<<<<<<<
 *             self.is_reading = True
 *             self.transport.resume_reading()
 */
  __pyx_t_1 = ((!(__pyx_v_self->is_reading != 0)) != 0);
  if (__pyx_t_1) {

    /* "asyncpg/protocol/protocol.pyx":141
 *     cdef inline resume_reading(self):
 *         if not self.is_reading:
 *             self.is_reading = True             # <<<<<<<<<<<<<<
 *             self.transport.resume_reading()
 * 
 */
    __pyx_v_self->is_reading = 1;

    /* "asyncpg/protocol/protocol.pyx":142
 *         if not self.is_reading:
 *             self.is_reading = True
 *             self.transport.resume_reading()             # <<<<<<<<<<<<<<
 * 
 *     cdef inline pause_reading(self):
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.transport, __pyx_n_s_resume_reading); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 142, __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(0, 142, __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(0, 142, __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":140
 * 
 *     cdef inline resume_reading(self):
 *         if not self.is_reading:             # <<<<<<<<<<<<<<
 *             self.is_reading = True
 *             self.transport.resume_reading()
 */
  }

  /* "asyncpg/protocol/protocol.pyx":139
 *         return self.xact_status in (PQTRANS_INTRANS, PQTRANS_INERROR)
 * 
 *     cdef inline resume_reading(self):             # <<<<<<<<<<<<<<
 *         if not self.is_reading:
 *             self.is_reading = True
 */

  /* 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.resume_reading", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/protocol.pyx":144
 *             self.transport.resume_reading()
 * 
 *     cdef inline pause_reading(self):             # <<<<<<<<<<<<<<
 *         if self.is_reading:
 *             self.is_reading = False
 */

static CYTHON_INLINE PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol_pause_reading(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("pause_reading", 0);

  /* "asyncpg/protocol/protocol.pyx":145
 * 
 *     cdef inline pause_reading(self):
 *         if self.is_reading:             # <<<<<<<<<<<<<<
 *             self.is_reading = False
 *             self.transport.pause_reading()
 */
  __pyx_t_1 = (__pyx_v_self->is_reading != 0);
  if (__pyx_t_1) {

    /* "asyncpg/protocol/protocol.pyx":146
 *     cdef inline pause_reading(self):
 *         if self.is_reading:
 *             self.is_reading = False             # <<<<<<<<<<<<<<
 *             self.transport.pause_reading()
 * 
 */
    __pyx_v_self->is_reading = 0;

    /* "asyncpg/protocol/protocol.pyx":147
 *         if self.is_reading:
 *             self.is_reading = False
 *             self.transport.pause_reading()             # <<<<<<<<<<<<<<
 * 
 *     async def prepare(self, stmt_name, query, timeout):
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.transport, __pyx_n_s_pause_reading); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 147, __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(0, 147, __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(0, 147, __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":145
 * 
 *     cdef inline pause_reading(self):
 *         if self.is_reading:             # <<<<<<<<<<<<<<
 *             self.is_reading = False
 *             self.transport.pause_reading()
 */
  }

  /* "asyncpg/protocol/protocol.pyx":144
 *             self.transport.resume_reading()
 * 
 *     cdef inline pause_reading(self):             # <<<<<<<<<<<<<<
 *         if self.is_reading:
 *             self.is_reading = False
 */

  /* 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.pause_reading", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_12generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "asyncpg/protocol/protocol.pyx":149
 *             self.transport.pause_reading()
 * 
 *     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_11prepare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_11prepare(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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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;
        CYTHON_FALLTHROUGH;
        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(0, 149, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        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(0, 149, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "prepare") < 0)) __PYX_ERR(0, 149, __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(0, 149, __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_10prepare(((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_10prepare(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(0, 149, __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_12generator, (PyObject *) __pyx_cur_scope, __pyx_n_s_prepare, __pyx_n_s_BaseProtocol_prepare, __pyx_n_s_asyncpg_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(0, 149, __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_12generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, 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;
  int __pyx_t_8;
  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;
  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_RefNannyDeclarations
  __Pyx_RefNannySetupContext("prepare", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L5_resume_from_await;
    case 2: goto __pyx_L7_resume_from_await;
    case 3: goto __pyx_L28_resume_from_await;
    case 4: goto __pyx_L31_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 149, __pyx_L1_error)

  /* "asyncpg/protocol/protocol.pyx":150
 * 
 *     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":151
 *     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();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 1;
      return __pyx_r;
      __pyx_L5_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 151, __pyx_L1_error)
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (exc_type) {
        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
        else __PYX_ERR(0, 151, __pyx_L1_error)
      }
    }

    /* "asyncpg/protocol/protocol.pyx":150
 * 
 *     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":152
 *         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":153
 *             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();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 2;
      return __pyx_r;
      __pyx_L7_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 153, __pyx_L1_error)
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (exc_type) {
        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
        else __PYX_ERR(0, 153, __pyx_L1_error)
      }
    }

    /* "asyncpg/protocol/protocol.pyx":154
 *         if self.cancel_sent_waiter is not None:
 *             await self.cancel_sent_waiter
 *             self.cancel_sent_waiter = None             # <<<<<<<<<<<<<<
 * 
 *         self._check_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":152
 *         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":156
 *             self.cancel_sent_waiter = None
 * 
 *         self._check_state()             # <<<<<<<<<<<<<<
 *         timeout = self._get_timeout_impl(timeout)
 * 
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_check_state(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 156, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":157
 * 
 *         self._check_state()
 *         timeout = self._get_timeout_impl(timeout)             # <<<<<<<<<<<<<<
 * 
 *         waiter = self._new_waiter(timeout)
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__get_timeout_impl(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_timeout); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_timeout);
  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_timeout, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":159
 *         timeout = self._get_timeout_impl(timeout)
 * 
 *         waiter = self._new_waiter(timeout)             # <<<<<<<<<<<<<<
 *         try:
 *             self._prepare(stmt_name, query)  # network op
 */
  __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(0, 159, __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":160
 * 
 *         waiter = self._new_waiter(timeout)
 *         try:             # <<<<<<<<<<<<<<
 *             self._prepare(stmt_name, query)  # network op
 *             self.last_query = query
 */
  /*try:*/ {
    {
      __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/protocol.pyx":161
 *         waiter = self._new_waiter(timeout)
 *         try:
 *             self._prepare(stmt_name, query)  # network op             # <<<<<<<<<<<<<<
 *             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(0, 161, __pyx_L11_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(0, 161, __pyx_L11_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(0, 161, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "asyncpg/protocol/protocol.pyx":162
 *         try:
 *             self._prepare(stmt_name, query)  # network op
 *             self.last_query = query             # <<<<<<<<<<<<<<
 *             self.statement = PreparedStatementState(stmt_name, query, self)
 *         except Exception as ex:
 */
        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(0, 162, __pyx_L11_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":163
 *             self._prepare(stmt_name, query)  # network op
 *             self.last_query = query
 *             self.statement = PreparedStatementState(stmt_name, query, self)             # <<<<<<<<<<<<<<
 *         except Exception as ex:
 *             waiter.set_exception(ex)
 */
        __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 163, __pyx_L11_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_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_PreparedStatementState), __pyx_t_3, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 163, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GIVEREF(__pyx_t_7);
        __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_7);
        __pyx_t_7 = 0;

        /* "asyncpg/protocol/protocol.pyx":160
 * 
 *         waiter = self._new_waiter(timeout)
 *         try:             # <<<<<<<<<<<<<<
 *             self._prepare(stmt_name, query)  # network op
 *             self.last_query = query
 */
      }
      __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_L16_try_end;
      __pyx_L11_error:;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "asyncpg/protocol/protocol.pyx":164
 *             self.last_query = query
 *             self.statement = PreparedStatementState(stmt_name, query, self)
 *         except Exception as ex:             # <<<<<<<<<<<<<<
 *             waiter.set_exception(ex)
 *             self._coreproto_error()
 */
      __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
      if (__pyx_t_8) {
        __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.prepare", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_3, &__pyx_t_9) < 0) __PYX_ERR(0, 164, __pyx_L13_except_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_v_ex = __pyx_t_3;
        /*try:*/ {

          /* "asyncpg/protocol/protocol.pyx":165
 *             self.statement = PreparedStatementState(stmt_name, query, self)
 *         except Exception as ex:
 *             waiter.set_exception(ex)             # <<<<<<<<<<<<<<
 *             self._coreproto_error()
 *         finally:
 */
          __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_waiter, __pyx_n_s_set_exception); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 165, __pyx_L22_error)
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_12 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
            __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
            if (likely(__pyx_t_12)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
              __Pyx_INCREF(__pyx_t_12);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_11, function);
            }
          }
          if (!__pyx_t_12) {
            __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_cur_scope->__pyx_v_ex); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 165, __pyx_L22_error)
            __Pyx_GOTREF(__pyx_t_10);
          } else {
            #if CYTHON_FAST_PYCALL
            if (PyFunction_Check(__pyx_t_11)) {
              PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_cur_scope->__pyx_v_ex};
              __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 165, __pyx_L22_error)
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_GOTREF(__pyx_t_10);
            } else
            #endif
            #if CYTHON_FAST_PYCCALL
            if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
              PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_cur_scope->__pyx_v_ex};
              __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 165, __pyx_L22_error)
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_GOTREF(__pyx_t_10);
            } else
            #endif
            {
              __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 165, __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_cur_scope->__pyx_v_ex);
              __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_ex);
              PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_cur_scope->__pyx_v_ex);
              __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_13, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 165, __pyx_L22_error)
              __Pyx_GOTREF(__pyx_t_10);
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            }
          }
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

          /* "asyncpg/protocol/protocol.pyx":166
 *         except Exception as ex:
 *             waiter.set_exception(ex)
 *             self._coreproto_error()             # <<<<<<<<<<<<<<
 *         finally:
 *             return await waiter
 */
          __pyx_t_10 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_coreproto_error(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 166, __pyx_L22_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }

        /* "asyncpg/protocol/protocol.pyx":164
 *             self.last_query = query
 *             self.statement = PreparedStatementState(stmt_name, query, self)
 *         except Exception as ex:             # <<<<<<<<<<<<<<
 *             waiter.set_exception(ex)
 *             self._coreproto_error()
 */
        /*finally:*/ {
          /*normal exit:*/{
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_ex);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_ex);
            __pyx_cur_scope->__pyx_v_ex = NULL;
            goto __pyx_L23;
          }
          __pyx_L22_error:;
          /*exception exit:*/{
            __Pyx_PyThreadState_assign
            __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_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 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_8 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_15 = __pyx_filename;
            {
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_ex);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_ex);
              __pyx_cur_scope->__pyx_v_ex = NULL;
            }
            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_8; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_15;
            goto __pyx_L13_except_error;
          }
          __pyx_L23:;
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L12_exception_handled;
      }
      goto __pyx_L13_except_error;
      __pyx_L13_except_error:;

      /* "asyncpg/protocol/protocol.pyx":160
 * 
 *         waiter = self._new_waiter(timeout)
 *         try:             # <<<<<<<<<<<<<<
 *             self._prepare(stmt_name, query)  # network op
 *             self.last_query = query
 */
      __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_L9_error;
      __pyx_L12_exception_handled:;
      __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_L16_try_end:;
    }
  }

  /* "asyncpg/protocol/protocol.pyx":168
 *             self._coreproto_error()
 *         finally:
 *             return await waiter             # <<<<<<<<<<<<<<
 * 
 *     async def bind_execute(self, PreparedStatementState state, args,
 */
  /*finally:*/ {
    /*normal exit:*/{
      __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();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 3;
        return __pyx_r;
        __pyx_L28_resume_from_await:;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 168, __pyx_L1_error)
        __pyx_t_9 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_9);
      } else {
        __pyx_t_9 = NULL;
        if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_9) < 0) __PYX_ERR(0, 168, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
      }
      __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = 0;
      goto __pyx_L0;
    }
    __pyx_L9_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_assign
      __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_4 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_21, &__pyx_t_20, &__pyx_t_19);
      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_21);
      __Pyx_XGOTREF(__pyx_t_20);
      __Pyx_XGOTREF(__pyx_t_19);
      {
        __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_t_4);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_4;
          __Pyx_XGIVEREF(__pyx_t_5);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_5;
          __Pyx_XGIVEREF(__pyx_t_6);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_6;
          __Pyx_XGIVEREF(__pyx_t_19);
          __pyx_cur_scope->__pyx_t_3 = __pyx_t_19;
          __Pyx_XGIVEREF(__pyx_t_20);
          __pyx_cur_scope->__pyx_t_4 = __pyx_t_20;
          __Pyx_XGIVEREF(__pyx_t_21);
          __pyx_cur_scope->__pyx_t_5 = __pyx_t_21;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 4;
          return __pyx_r;
          __pyx_L31_resume_from_await:;
          __pyx_t_4 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_4);
          __pyx_t_5 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_5);
          __pyx_t_6 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_6);
          __pyx_t_19 = __pyx_cur_scope->__pyx_t_3;
          __pyx_cur_scope->__pyx_t_3 = 0;
          __Pyx_XGOTREF(__pyx_t_19);
          __pyx_t_20 = __pyx_cur_scope->__pyx_t_4;
          __pyx_cur_scope->__pyx_t_4 = 0;
          __Pyx_XGOTREF(__pyx_t_20);
          __pyx_t_21 = __pyx_cur_scope->__pyx_t_5;
          __pyx_cur_scope->__pyx_t_5 = 0;
          __Pyx_XGOTREF(__pyx_t_21);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 168, __pyx_L30_error)
          __pyx_t_9 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_9);
        } else {
          __pyx_t_9 = NULL;
          if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_9) < 0) __PYX_ERR(0, 168, __pyx_L30_error)
          __Pyx_GOTREF(__pyx_t_9);
        }
        __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_9 = 0;
        goto __pyx_L29_return;
      }
      __pyx_L29_return:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_21);
        __Pyx_XGIVEREF(__pyx_t_20);
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_20, __pyx_t_19);
      }
      __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_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
      goto __pyx_L0;
      __pyx_L30_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_21);
        __Pyx_XGIVEREF(__pyx_t_20);
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_20, __pyx_t_19);
      }
      __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_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
      goto __pyx_L1_error;
    }
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "asyncpg/protocol/protocol.pyx":149
 *             self.transport.pause_reading()
 * 
 *     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_7);
  __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_AddTraceback("prepare", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_15generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "asyncpg/protocol/protocol.pyx":170
 *             return await waiter
 * 
 *     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_14bind_execute(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_14bind_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);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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;
        CYTHON_FALLTHROUGH;
        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(0, 170, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        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(0, 170, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        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(0, 170, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        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(0, 170, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        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(0, 170, __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(0, 170, __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(0, 171, __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(0, 170, __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(0, 170, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_portal_name), (&PyUnicode_Type), 1, "portal_name", 1))) __PYX_ERR(0, 171, __pyx_L1_error)
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_13bind_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_13bind_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(0, 170, __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_15generator1, (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(0, 170, __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_15generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, 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;
  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;
  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_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bind_execute", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L5_resume_from_await;
    case 2: goto __pyx_L7_resume_from_await;
    case 3: goto __pyx_L28_resume_from_await;
    case 4: goto __pyx_L31_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 170, __pyx_L1_error)

  /* "asyncpg/protocol/protocol.pyx":174
 *                            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":175
 * 
 *         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();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 1;
      return __pyx_r;
      __pyx_L5_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 175, __pyx_L1_error)
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (exc_type) {
        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
        else __PYX_ERR(0, 175, __pyx_L1_error)
      }
    }

    /* "asyncpg/protocol/protocol.pyx":174
 *                            timeout):
 * 
 *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
 *             await self.cancel_waiter
 *         if self.cancel_sent_waiter is not None:
 */
  }

  /* "asyncpg/protocol/protocol.pyx":176
 *         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":177
 *             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();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 2;
      return __pyx_r;
      __pyx_L7_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 177, __pyx_L1_error)
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (exc_type) {
        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
        else __PYX_ERR(0, 177, __pyx_L1_error)
      }
    }

    /* "asyncpg/protocol/protocol.pyx":178
 *         if self.cancel_sent_waiter is not None:
 *             await self.cancel_sent_waiter
 *             self.cancel_sent_waiter = None             # <<<<<<<<<<<<<<
 * 
 *         self._check_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":176
 *         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":180
 *             self.cancel_sent_waiter = None
 * 
 *         self._check_state()             # <<<<<<<<<<<<<<
 *         timeout = self._get_timeout_impl(timeout)
 *         args_buf = state._encode_bind_msg(args)
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_check_state(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":181
 * 
 *         self._check_state()
 *         timeout = self._get_timeout_impl(timeout)             # <<<<<<<<<<<<<<
 *         args_buf = state._encode_bind_msg(args)
 * 
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__get_timeout_impl(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_timeout); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 181, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_timeout);
  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_timeout, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":182
 *         self._check_state()
 *         timeout = self._get_timeout_impl(timeout)
 *         args_buf = state._encode_bind_msg(args)             # <<<<<<<<<<<<<<
 * 
 *         waiter = self._new_waiter(timeout)
 */
  __pyx_t_3 = __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_3)) __PYX_ERR(0, 182, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_args_buf = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":184
 *         args_buf = state._encode_bind_msg(args)
 * 
 *         waiter = self._new_waiter(timeout)             # <<<<<<<<<<<<<<
 *         try:
 *             self._bind_execute(
 */
  __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(0, 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":185
 * 
 *         waiter = self._new_waiter(timeout)
 *         try:             # <<<<<<<<<<<<<<
 *             self._bind_execute(
 *                 portal_name,
 */
  /*try:*/ {
    {
      __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/protocol.pyx":188
 *             self._bind_execute(
 *                 portal_name,
 *                 state.name,             # <<<<<<<<<<<<<<
 *                 args_buf,
 *                 limit)  # network op
 */
        __pyx_t_3 = __pyx_cur_scope->__pyx_v_state->name;
        __Pyx_INCREF(__pyx_t_3);

        /* "asyncpg/protocol/protocol.pyx":189
 *                 portal_name,
 *                 state.name,
 *                 args_buf,             # <<<<<<<<<<<<<<
 *                 limit)  # network op
 * 
 */
        if (!(likely(((__pyx_cur_scope->__pyx_v_args_buf) == Py_None) || likely(__Pyx_TypeTest(__pyx_cur_scope->__pyx_v_args_buf, __pyx_ptype_7asyncpg_8protocol_8protocol_WriteBuffer))))) __PYX_ERR(0, 189, __pyx_L11_error)

        /* "asyncpg/protocol/protocol.pyx":186
 *         waiter = self._new_waiter(timeout)
 *         try:
 *             self._bind_execute(             # <<<<<<<<<<<<<<
 *                 portal_name,
 *                 state.name,
 */
        __pyx_t_7 = ((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_cur_scope->__pyx_v_args_buf), __pyx_cur_scope->__pyx_v_limit); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 186, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "asyncpg/protocol/protocol.pyx":192
 *                 limit)  # network op
 * 
 *             self.last_query = state.query             # <<<<<<<<<<<<<<
 *             self.statement = state
 *             self.return_extra = return_extra
 */
        __pyx_t_7 = __pyx_cur_scope->__pyx_v_state->query;
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_7);
        __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_7);
        __pyx_t_7 = 0;

        /* "asyncpg/protocol/protocol.pyx":193
 * 
 *             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":194
 *             self.last_query = state.query
 *             self.statement = state
 *             self.return_extra = return_extra             # <<<<<<<<<<<<<<
 *             self.queries_count += 1
 *         except Exception as ex:
 */
        __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_return_extra); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 194, __pyx_L11_error)
        __pyx_cur_scope->__pyx_v_self->return_extra = __pyx_t_1;

        /* "asyncpg/protocol/protocol.pyx":195
 *             self.statement = state
 *             self.return_extra = return_extra
 *             self.queries_count += 1             # <<<<<<<<<<<<<<
 *         except Exception as ex:
 *             waiter.set_exception(ex)
 */
        __pyx_cur_scope->__pyx_v_self->queries_count = (__pyx_cur_scope->__pyx_v_self->queries_count + 1);

        /* "asyncpg/protocol/protocol.pyx":185
 * 
 *         waiter = self._new_waiter(timeout)
 *         try:             # <<<<<<<<<<<<<<
 *             self._bind_execute(
 *                 portal_name,
 */
      }
      __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_L16_try_end;
      __pyx_L11_error:;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "asyncpg/protocol/protocol.pyx":196
 *             self.return_extra = return_extra
 *             self.queries_count += 1
 *         except Exception as ex:             # <<<<<<<<<<<<<<
 *             waiter.set_exception(ex)
 *             self._coreproto_error()
 */
      __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
      if (__pyx_t_8) {
        __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.bind_execute", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_3, &__pyx_t_9) < 0) __PYX_ERR(0, 196, __pyx_L13_except_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_v_ex = __pyx_t_3;
        /*try:*/ {

          /* "asyncpg/protocol/protocol.pyx":197
 *             self.queries_count += 1
 *         except Exception as ex:
 *             waiter.set_exception(ex)             # <<<<<<<<<<<<<<
 *             self._coreproto_error()
 *         finally:
 */
          __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_waiter, __pyx_n_s_set_exception); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 197, __pyx_L22_error)
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_12 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
            __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
            if (likely(__pyx_t_12)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
              __Pyx_INCREF(__pyx_t_12);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_11, function);
            }
          }
          if (!__pyx_t_12) {
            __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_cur_scope->__pyx_v_ex); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 197, __pyx_L22_error)
            __Pyx_GOTREF(__pyx_t_10);
          } else {
            #if CYTHON_FAST_PYCALL
            if (PyFunction_Check(__pyx_t_11)) {
              PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_cur_scope->__pyx_v_ex};
              __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 197, __pyx_L22_error)
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_GOTREF(__pyx_t_10);
            } else
            #endif
            #if CYTHON_FAST_PYCCALL
            if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
              PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_cur_scope->__pyx_v_ex};
              __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 197, __pyx_L22_error)
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_GOTREF(__pyx_t_10);
            } else
            #endif
            {
              __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 197, __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_cur_scope->__pyx_v_ex);
              __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_ex);
              PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_cur_scope->__pyx_v_ex);
              __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_13, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 197, __pyx_L22_error)
              __Pyx_GOTREF(__pyx_t_10);
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            }
          }
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

          /* "asyncpg/protocol/protocol.pyx":198
 *         except Exception as ex:
 *             waiter.set_exception(ex)
 *             self._coreproto_error()             # <<<<<<<<<<<<<<
 *         finally:
 *             return await waiter
 */
          __pyx_t_10 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_coreproto_error(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 198, __pyx_L22_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }

        /* "asyncpg/protocol/protocol.pyx":196
 *             self.return_extra = return_extra
 *             self.queries_count += 1
 *         except Exception as ex:             # <<<<<<<<<<<<<<
 *             waiter.set_exception(ex)
 *             self._coreproto_error()
 */
        /*finally:*/ {
          /*normal exit:*/{
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_ex);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_ex);
            __pyx_cur_scope->__pyx_v_ex = NULL;
            goto __pyx_L23;
          }
          __pyx_L22_error:;
          /*exception exit:*/{
            __Pyx_PyThreadState_assign
            __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_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 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_8 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_15 = __pyx_filename;
            {
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_ex);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_ex);
              __pyx_cur_scope->__pyx_v_ex = NULL;
            }
            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_8; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_15;
            goto __pyx_L13_except_error;
          }
          __pyx_L23:;
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L12_exception_handled;
      }
      goto __pyx_L13_except_error;
      __pyx_L13_except_error:;

      /* "asyncpg/protocol/protocol.pyx":185
 * 
 *         waiter = self._new_waiter(timeout)
 *         try:             # <<<<<<<<<<<<<<
 *             self._bind_execute(
 *                 portal_name,
 */
      __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_L9_error;
      __pyx_L12_exception_handled:;
      __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_L16_try_end:;
    }
  }

  /* "asyncpg/protocol/protocol.pyx":200
 *             self._coreproto_error()
 *         finally:
 *             return await waiter             # <<<<<<<<<<<<<<
 * 
 *     async def bind_execute_many(self, PreparedStatementState state, args,
 */
  /*finally:*/ {
    /*normal exit:*/{
      __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();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 3;
        return __pyx_r;
        __pyx_L28_resume_from_await:;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 200, __pyx_L1_error)
        __pyx_t_9 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_9);
      } else {
        __pyx_t_9 = NULL;
        if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_9) < 0) __PYX_ERR(0, 200, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
      }
      __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = 0;
      goto __pyx_L0;
    }
    __pyx_L9_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_assign
      __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_4 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_21, &__pyx_t_20, &__pyx_t_19);
      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_21);
      __Pyx_XGOTREF(__pyx_t_20);
      __Pyx_XGOTREF(__pyx_t_19);
      {
        __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_t_4);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_4;
          __Pyx_XGIVEREF(__pyx_t_5);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_5;
          __Pyx_XGIVEREF(__pyx_t_6);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_6;
          __Pyx_XGIVEREF(__pyx_t_19);
          __pyx_cur_scope->__pyx_t_3 = __pyx_t_19;
          __Pyx_XGIVEREF(__pyx_t_20);
          __pyx_cur_scope->__pyx_t_4 = __pyx_t_20;
          __Pyx_XGIVEREF(__pyx_t_21);
          __pyx_cur_scope->__pyx_t_5 = __pyx_t_21;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 4;
          return __pyx_r;
          __pyx_L31_resume_from_await:;
          __pyx_t_4 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_4);
          __pyx_t_5 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_5);
          __pyx_t_6 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_6);
          __pyx_t_19 = __pyx_cur_scope->__pyx_t_3;
          __pyx_cur_scope->__pyx_t_3 = 0;
          __Pyx_XGOTREF(__pyx_t_19);
          __pyx_t_20 = __pyx_cur_scope->__pyx_t_4;
          __pyx_cur_scope->__pyx_t_4 = 0;
          __Pyx_XGOTREF(__pyx_t_20);
          __pyx_t_21 = __pyx_cur_scope->__pyx_t_5;
          __pyx_cur_scope->__pyx_t_5 = 0;
          __Pyx_XGOTREF(__pyx_t_21);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 200, __pyx_L30_error)
          __pyx_t_9 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_9);
        } else {
          __pyx_t_9 = NULL;
          if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_9) < 0) __PYX_ERR(0, 200, __pyx_L30_error)
          __Pyx_GOTREF(__pyx_t_9);
        }
        __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_9 = 0;
        goto __pyx_L29_return;
      }
      __pyx_L29_return:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_21);
        __Pyx_XGIVEREF(__pyx_t_20);
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_20, __pyx_t_19);
      }
      __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_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
      goto __pyx_L0;
      __pyx_L30_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_21);
        __Pyx_XGIVEREF(__pyx_t_20);
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_20, __pyx_t_19);
      }
      __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_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
      goto __pyx_L1_error;
    }
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "asyncpg/protocol/protocol.pyx":170
 *             return await waiter
 * 
 *     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_7);
  __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_AddTraceback("bind_execute", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_18generator2(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "asyncpg/protocol/protocol.pyx":202
 *             return await waiter
 * 
 *     async def bind_execute_many(self, PreparedStatementState state, args,             # <<<<<<<<<<<<<<
 *                                 str portal_name, timeout):
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_17bind_execute_many(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_17bind_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);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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;
        CYTHON_FALLTHROUGH;
        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(0, 202, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        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(0, 202, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        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(0, 202, __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(0, 202, __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(0, 202, __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(0, 202, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_portal_name), (&PyUnicode_Type), 1, "portal_name", 1))) __PYX_ERR(0, 203, __pyx_L1_error)
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_16bind_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_2generator11(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "asyncpg/protocol/protocol.pyx":217
 *         # 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(0, 217, __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_2generator11, (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(0, 217, __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_2generator11(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, 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("genexpr", 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(0, 217, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_args)) { __Pyx_RaiseClosureNameError("args"); __PYX_ERR(0, 217, __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(0, 217, __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(0, 217, __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(0, 217, __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(0, 217, __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(0, 217, __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(0, 217, __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(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 217, __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(0, 217, __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(0, 217, __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();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* 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(0, 217, __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_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/protocol.pyx":202
 *             return await waiter
 * 
 *     async def bind_execute_many(self, PreparedStatementState state, args,             # <<<<<<<<<<<<<<
 *                                 str portal_name, timeout):
 * 
 */

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_16bind_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(0, 202, __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_18generator2, (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(0, 202, __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_18generator2(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, 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;
  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;
  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_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bind_execute_many", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L5_resume_from_await;
    case 2: goto __pyx_L7_resume_from_await;
    case 3: goto __pyx_L28_resume_from_await;
    case 4: goto __pyx_L31_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 202, __pyx_L1_error)

  /* "asyncpg/protocol/protocol.pyx":205
 *                                 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":206
 * 
 *         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();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 1;
      return __pyx_r;
      __pyx_L5_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 206, __pyx_L1_error)
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (exc_type) {
        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
        else __PYX_ERR(0, 206, __pyx_L1_error)
      }
    }

    /* "asyncpg/protocol/protocol.pyx":205
 *                                 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":207
 *         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":208
 *             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();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 2;
      return __pyx_r;
      __pyx_L7_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 208, __pyx_L1_error)
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (exc_type) {
        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
        else __PYX_ERR(0, 208, __pyx_L1_error)
      }
    }

    /* "asyncpg/protocol/protocol.pyx":209
 *         if self.cancel_sent_waiter is not None:
 *             await self.cancel_sent_waiter
 *             self.cancel_sent_waiter = None             # <<<<<<<<<<<<<<
 * 
 *         self._check_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":207
 *         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":211
 *             self.cancel_sent_waiter = None
 * 
 *         self._check_state()             # <<<<<<<<<<<<<<
 *         timeout = self._get_timeout_impl(timeout)
 * 
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_check_state(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 211, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":212
 * 
 *         self._check_state()
 *         timeout = self._get_timeout_impl(timeout)             # <<<<<<<<<<<<<<
 * 
 *         # Make sure the argument sequence is encoded lazily with
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__get_timeout_impl(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_timeout); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 212, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_timeout);
  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_timeout, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":217
 *         # 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(0, 217, __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":218
 *         # 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(0, 218, __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":220
 *         arg_bufs = iter(data_gen)
 * 
 *         waiter = self._new_waiter(timeout)             # <<<<<<<<<<<<<<
 *         try:
 *             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(0, 220, __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":221
 * 
 *         waiter = self._new_waiter(timeout)
 *         try:             # <<<<<<<<<<<<<<
 *             self._bind_execute_many(
 *                 portal_name,
 */
  /*try:*/ {
    {
      __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/protocol.pyx":224
 *             self._bind_execute_many(
 *                 portal_name,
 *                 state.name,             # <<<<<<<<<<<<<<
 *                 arg_bufs)  # network op
 * 
 */
        __pyx_t_3 = __pyx_cur_scope->__pyx_v_state->name;
        __Pyx_INCREF(__pyx_t_3);

        /* "asyncpg/protocol/protocol.pyx":222
 *         waiter = self._new_waiter(timeout)
 *         try:
 *             self._bind_execute_many(             # <<<<<<<<<<<<<<
 *                 portal_name,
 *                 state.name,
 */
        __pyx_t_7 = ((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_7)) __PYX_ERR(0, 222, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "asyncpg/protocol/protocol.pyx":227
 *                 arg_bufs)  # network op
 * 
 *             self.last_query = state.query             # <<<<<<<<<<<<<<
 *             self.statement = state
 *             self.return_extra = False
 */
        __pyx_t_7 = __pyx_cur_scope->__pyx_v_state->query;
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_7);
        __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_7);
        __pyx_t_7 = 0;

        /* "asyncpg/protocol/protocol.pyx":228
 * 
 *             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":229
 *             self.last_query = state.query
 *             self.statement = state
 *             self.return_extra = False             # <<<<<<<<<<<<<<
 *             self.queries_count += 1
 *         except Exception as ex:
 */
        __pyx_cur_scope->__pyx_v_self->return_extra = 0;

        /* "asyncpg/protocol/protocol.pyx":230
 *             self.statement = state
 *             self.return_extra = False
 *             self.queries_count += 1             # <<<<<<<<<<<<<<
 *         except Exception as ex:
 *             waiter.set_exception(ex)
 */
        __pyx_cur_scope->__pyx_v_self->queries_count = (__pyx_cur_scope->__pyx_v_self->queries_count + 1);

        /* "asyncpg/protocol/protocol.pyx":221
 * 
 *         waiter = self._new_waiter(timeout)
 *         try:             # <<<<<<<<<<<<<<
 *             self._bind_execute_many(
 *                 portal_name,
 */
      }
      __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_L16_try_end;
      __pyx_L11_error:;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "asyncpg/protocol/protocol.pyx":231
 *             self.return_extra = False
 *             self.queries_count += 1
 *         except Exception as ex:             # <<<<<<<<<<<<<<
 *             waiter.set_exception(ex)
 *             self._coreproto_error()
 */
      __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
      if (__pyx_t_8) {
        __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.bind_execute_many", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_3, &__pyx_t_9) < 0) __PYX_ERR(0, 231, __pyx_L13_except_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_v_ex = __pyx_t_3;
        /*try:*/ {

          /* "asyncpg/protocol/protocol.pyx":232
 *             self.queries_count += 1
 *         except Exception as ex:
 *             waiter.set_exception(ex)             # <<<<<<<<<<<<<<
 *             self._coreproto_error()
 *         finally:
 */
          __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_waiter, __pyx_n_s_set_exception); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 232, __pyx_L22_error)
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_12 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
            __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
            if (likely(__pyx_t_12)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
              __Pyx_INCREF(__pyx_t_12);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_11, function);
            }
          }
          if (!__pyx_t_12) {
            __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_cur_scope->__pyx_v_ex); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 232, __pyx_L22_error)
            __Pyx_GOTREF(__pyx_t_10);
          } else {
            #if CYTHON_FAST_PYCALL
            if (PyFunction_Check(__pyx_t_11)) {
              PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_cur_scope->__pyx_v_ex};
              __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 232, __pyx_L22_error)
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_GOTREF(__pyx_t_10);
            } else
            #endif
            #if CYTHON_FAST_PYCCALL
            if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
              PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_cur_scope->__pyx_v_ex};
              __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 232, __pyx_L22_error)
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_GOTREF(__pyx_t_10);
            } else
            #endif
            {
              __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 232, __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_cur_scope->__pyx_v_ex);
              __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_ex);
              PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_cur_scope->__pyx_v_ex);
              __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_13, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 232, __pyx_L22_error)
              __Pyx_GOTREF(__pyx_t_10);
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            }
          }
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

          /* "asyncpg/protocol/protocol.pyx":233
 *         except Exception as ex:
 *             waiter.set_exception(ex)
 *             self._coreproto_error()             # <<<<<<<<<<<<<<
 *         finally:
 *             return await waiter
 */
          __pyx_t_10 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_coreproto_error(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 233, __pyx_L22_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }

        /* "asyncpg/protocol/protocol.pyx":231
 *             self.return_extra = False
 *             self.queries_count += 1
 *         except Exception as ex:             # <<<<<<<<<<<<<<
 *             waiter.set_exception(ex)
 *             self._coreproto_error()
 */
        /*finally:*/ {
          /*normal exit:*/{
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_ex);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_ex);
            __pyx_cur_scope->__pyx_v_ex = NULL;
            goto __pyx_L23;
          }
          __pyx_L22_error:;
          /*exception exit:*/{
            __Pyx_PyThreadState_assign
            __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_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 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_8 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_15 = __pyx_filename;
            {
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_ex);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_ex);
              __pyx_cur_scope->__pyx_v_ex = NULL;
            }
            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_8; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_15;
            goto __pyx_L13_except_error;
          }
          __pyx_L23:;
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L12_exception_handled;
      }
      goto __pyx_L13_except_error;
      __pyx_L13_except_error:;

      /* "asyncpg/protocol/protocol.pyx":221
 * 
 *         waiter = self._new_waiter(timeout)
 *         try:             # <<<<<<<<<<<<<<
 *             self._bind_execute_many(
 *                 portal_name,
 */
      __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_L9_error;
      __pyx_L12_exception_handled:;
      __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_L16_try_end:;
    }
  }

  /* "asyncpg/protocol/protocol.pyx":235
 *             self._coreproto_error()
 *         finally:
 *             return await waiter             # <<<<<<<<<<<<<<
 * 
 *     async def bind(self, PreparedStatementState state, args,
 */
  /*finally:*/ {
    /*normal exit:*/{
      __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();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 3;
        return __pyx_r;
        __pyx_L28_resume_from_await:;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 235, __pyx_L1_error)
        __pyx_t_9 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_9);
      } else {
        __pyx_t_9 = NULL;
        if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_9) < 0) __PYX_ERR(0, 235, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
      }
      __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = 0;
      goto __pyx_L0;
    }
    __pyx_L9_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_assign
      __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_4 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_21, &__pyx_t_20, &__pyx_t_19);
      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_21);
      __Pyx_XGOTREF(__pyx_t_20);
      __Pyx_XGOTREF(__pyx_t_19);
      {
        __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_t_4);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_4;
          __Pyx_XGIVEREF(__pyx_t_5);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_5;
          __Pyx_XGIVEREF(__pyx_t_6);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_6;
          __Pyx_XGIVEREF(__pyx_t_19);
          __pyx_cur_scope->__pyx_t_3 = __pyx_t_19;
          __Pyx_XGIVEREF(__pyx_t_20);
          __pyx_cur_scope->__pyx_t_4 = __pyx_t_20;
          __Pyx_XGIVEREF(__pyx_t_21);
          __pyx_cur_scope->__pyx_t_5 = __pyx_t_21;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 4;
          return __pyx_r;
          __pyx_L31_resume_from_await:;
          __pyx_t_4 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_4);
          __pyx_t_5 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_5);
          __pyx_t_6 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_6);
          __pyx_t_19 = __pyx_cur_scope->__pyx_t_3;
          __pyx_cur_scope->__pyx_t_3 = 0;
          __Pyx_XGOTREF(__pyx_t_19);
          __pyx_t_20 = __pyx_cur_scope->__pyx_t_4;
          __pyx_cur_scope->__pyx_t_4 = 0;
          __Pyx_XGOTREF(__pyx_t_20);
          __pyx_t_21 = __pyx_cur_scope->__pyx_t_5;
          __pyx_cur_scope->__pyx_t_5 = 0;
          __Pyx_XGOTREF(__pyx_t_21);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 235, __pyx_L30_error)
          __pyx_t_9 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_9);
        } else {
          __pyx_t_9 = NULL;
          if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_9) < 0) __PYX_ERR(0, 235, __pyx_L30_error)
          __Pyx_GOTREF(__pyx_t_9);
        }
        __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_9 = 0;
        goto __pyx_L29_return;
      }
      __pyx_L29_return:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_21);
        __Pyx_XGIVEREF(__pyx_t_20);
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_20, __pyx_t_19);
      }
      __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_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
      goto __pyx_L0;
      __pyx_L30_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_21);
        __Pyx_XGIVEREF(__pyx_t_20);
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_20, __pyx_t_19);
      }
      __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_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
      goto __pyx_L1_error;
    }
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "asyncpg/protocol/protocol.pyx":202
 *             return await waiter
 * 
 *     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_7);
  __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_AddTraceback("bind_execute_many", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_21generator3(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "asyncpg/protocol/protocol.pyx":237
 *             return await waiter
 * 
 *     async def bind(self, PreparedStatementState state, args,             # <<<<<<<<<<<<<<
 *                    str portal_name, timeout):
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_20bind(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_20bind(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);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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;
        CYTHON_FALLTHROUGH;
        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(0, 237, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        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(0, 237, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        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(0, 237, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "bind") < 0)) __PYX_ERR(0, 237, __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(0, 237, __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(0, 237, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_portal_name), (&PyUnicode_Type), 1, "portal_name", 1))) __PYX_ERR(0, 238, __pyx_L1_error)
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_19bind(((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_19bind(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(0, 237, __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_21generator3, (PyObject *) __pyx_cur_scope, __pyx_n_s_bind, __pyx_n_s_BaseProtocol_bind, __pyx_n_s_asyncpg_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(0, 237, __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_21generator3(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, 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;
  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;
  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_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bind", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L5_resume_from_await;
    case 2: goto __pyx_L7_resume_from_await;
    case 3: goto __pyx_L28_resume_from_await;
    case 4: goto __pyx_L31_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 237, __pyx_L1_error)

  /* "asyncpg/protocol/protocol.pyx":240
 *                    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":241
 * 
 *         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();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 1;
      return __pyx_r;
      __pyx_L5_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 241, __pyx_L1_error)
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (exc_type) {
        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
        else __PYX_ERR(0, 241, __pyx_L1_error)
      }
    }

    /* "asyncpg/protocol/protocol.pyx":240
 *                    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":242
 *         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":243
 *             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();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 2;
      return __pyx_r;
      __pyx_L7_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 243, __pyx_L1_error)
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (exc_type) {
        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
        else __PYX_ERR(0, 243, __pyx_L1_error)
      }
    }

    /* "asyncpg/protocol/protocol.pyx":244
 *         if self.cancel_sent_waiter is not None:
 *             await self.cancel_sent_waiter
 *             self.cancel_sent_waiter = None             # <<<<<<<<<<<<<<
 * 
 *         self._check_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":242
 *         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":246
 *             self.cancel_sent_waiter = None
 * 
 *         self._check_state()             # <<<<<<<<<<<<<<
 *         timeout = self._get_timeout_impl(timeout)
 *         args_buf = state._encode_bind_msg(args)
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_check_state(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 246, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":247
 * 
 *         self._check_state()
 *         timeout = self._get_timeout_impl(timeout)             # <<<<<<<<<<<<<<
 *         args_buf = state._encode_bind_msg(args)
 * 
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__get_timeout_impl(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_timeout); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 247, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_timeout);
  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_timeout, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":248
 *         self._check_state()
 *         timeout = self._get_timeout_impl(timeout)
 *         args_buf = state._encode_bind_msg(args)             # <<<<<<<<<<<<<<
 * 
 *         waiter = self._new_waiter(timeout)
 */
  __pyx_t_3 = __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_3)) __PYX_ERR(0, 248, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_args_buf = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":250
 *         args_buf = state._encode_bind_msg(args)
 * 
 *         waiter = self._new_waiter(timeout)             # <<<<<<<<<<<<<<
 *         try:
 *             self._bind(
 */
  __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(0, 250, __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":251
 * 
 *         waiter = self._new_waiter(timeout)
 *         try:             # <<<<<<<<<<<<<<
 *             self._bind(
 *                 portal_name,
 */
  /*try:*/ {
    {
      __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/protocol.pyx":254
 *             self._bind(
 *                 portal_name,
 *                 state.name,             # <<<<<<<<<<<<<<
 *                 args_buf)  # network op
 * 
 */
        __pyx_t_3 = __pyx_cur_scope->__pyx_v_state->name;
        __Pyx_INCREF(__pyx_t_3);

        /* "asyncpg/protocol/protocol.pyx":255
 *                 portal_name,
 *                 state.name,
 *                 args_buf)  # network op             # <<<<<<<<<<<<<<
 * 
 *             self.last_query = state.query
 */
        if (!(likely(((__pyx_cur_scope->__pyx_v_args_buf) == Py_None) || likely(__Pyx_TypeTest(__pyx_cur_scope->__pyx_v_args_buf, __pyx_ptype_7asyncpg_8protocol_8protocol_WriteBuffer))))) __PYX_ERR(0, 255, __pyx_L11_error)

        /* "asyncpg/protocol/protocol.pyx":252
 *         waiter = self._new_waiter(timeout)
 *         try:
 *             self._bind(             # <<<<<<<<<<<<<<
 *                 portal_name,
 *                 state.name,
 */
        __pyx_t_7 = ((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_cur_scope->__pyx_v_args_buf)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 252, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "asyncpg/protocol/protocol.pyx":257
 *                 args_buf)  # network op
 * 
 *             self.last_query = state.query             # <<<<<<<<<<<<<<
 *             self.statement = state
 *         except Exception as ex:
 */
        __pyx_t_7 = __pyx_cur_scope->__pyx_v_state->query;
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_7);
        __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_7);
        __pyx_t_7 = 0;

        /* "asyncpg/protocol/protocol.pyx":258
 * 
 *             self.last_query = state.query
 *             self.statement = state             # <<<<<<<<<<<<<<
 *         except Exception as ex:
 *             waiter.set_exception(ex)
 */
        __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":251
 * 
 *         waiter = self._new_waiter(timeout)
 *         try:             # <<<<<<<<<<<<<<
 *             self._bind(
 *                 portal_name,
 */
      }
      __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_L16_try_end;
      __pyx_L11_error:;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "asyncpg/protocol/protocol.pyx":259
 *             self.last_query = state.query
 *             self.statement = state
 *         except Exception as ex:             # <<<<<<<<<<<<<<
 *             waiter.set_exception(ex)
 *             self._coreproto_error()
 */
      __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
      if (__pyx_t_8) {
        __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.bind", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_3, &__pyx_t_9) < 0) __PYX_ERR(0, 259, __pyx_L13_except_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_v_ex = __pyx_t_3;
        /*try:*/ {

          /* "asyncpg/protocol/protocol.pyx":260
 *             self.statement = state
 *         except Exception as ex:
 *             waiter.set_exception(ex)             # <<<<<<<<<<<<<<
 *             self._coreproto_error()
 *         finally:
 */
          __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_waiter, __pyx_n_s_set_exception); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 260, __pyx_L22_error)
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_12 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
            __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
            if (likely(__pyx_t_12)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
              __Pyx_INCREF(__pyx_t_12);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_11, function);
            }
          }
          if (!__pyx_t_12) {
            __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_cur_scope->__pyx_v_ex); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 260, __pyx_L22_error)
            __Pyx_GOTREF(__pyx_t_10);
          } else {
            #if CYTHON_FAST_PYCALL
            if (PyFunction_Check(__pyx_t_11)) {
              PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_cur_scope->__pyx_v_ex};
              __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 260, __pyx_L22_error)
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_GOTREF(__pyx_t_10);
            } else
            #endif
            #if CYTHON_FAST_PYCCALL
            if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
              PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_cur_scope->__pyx_v_ex};
              __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 260, __pyx_L22_error)
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_GOTREF(__pyx_t_10);
            } else
            #endif
            {
              __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 260, __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_cur_scope->__pyx_v_ex);
              __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_ex);
              PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_cur_scope->__pyx_v_ex);
              __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_13, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 260, __pyx_L22_error)
              __Pyx_GOTREF(__pyx_t_10);
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            }
          }
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

          /* "asyncpg/protocol/protocol.pyx":261
 *         except Exception as ex:
 *             waiter.set_exception(ex)
 *             self._coreproto_error()             # <<<<<<<<<<<<<<
 *         finally:
 *             return await waiter
 */
          __pyx_t_10 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_coreproto_error(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 261, __pyx_L22_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }

        /* "asyncpg/protocol/protocol.pyx":259
 *             self.last_query = state.query
 *             self.statement = state
 *         except Exception as ex:             # <<<<<<<<<<<<<<
 *             waiter.set_exception(ex)
 *             self._coreproto_error()
 */
        /*finally:*/ {
          /*normal exit:*/{
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_ex);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_ex);
            __pyx_cur_scope->__pyx_v_ex = NULL;
            goto __pyx_L23;
          }
          __pyx_L22_error:;
          /*exception exit:*/{
            __Pyx_PyThreadState_assign
            __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_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 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_8 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_15 = __pyx_filename;
            {
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_ex);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_ex);
              __pyx_cur_scope->__pyx_v_ex = NULL;
            }
            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_8; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_15;
            goto __pyx_L13_except_error;
          }
          __pyx_L23:;
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L12_exception_handled;
      }
      goto __pyx_L13_except_error;
      __pyx_L13_except_error:;

      /* "asyncpg/protocol/protocol.pyx":251
 * 
 *         waiter = self._new_waiter(timeout)
 *         try:             # <<<<<<<<<<<<<<
 *             self._bind(
 *                 portal_name,
 */
      __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_L9_error;
      __pyx_L12_exception_handled:;
      __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_L16_try_end:;
    }
  }

  /* "asyncpg/protocol/protocol.pyx":263
 *             self._coreproto_error()
 *         finally:
 *             return await waiter             # <<<<<<<<<<<<<<
 * 
 *     async def execute(self, PreparedStatementState state,
 */
  /*finally:*/ {
    /*normal exit:*/{
      __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();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 3;
        return __pyx_r;
        __pyx_L28_resume_from_await:;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 263, __pyx_L1_error)
        __pyx_t_9 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_9);
      } else {
        __pyx_t_9 = NULL;
        if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_9) < 0) __PYX_ERR(0, 263, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
      }
      __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = 0;
      goto __pyx_L0;
    }
    __pyx_L9_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_assign
      __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_4 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_21, &__pyx_t_20, &__pyx_t_19);
      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_21);
      __Pyx_XGOTREF(__pyx_t_20);
      __Pyx_XGOTREF(__pyx_t_19);
      {
        __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_t_4);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_4;
          __Pyx_XGIVEREF(__pyx_t_5);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_5;
          __Pyx_XGIVEREF(__pyx_t_6);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_6;
          __Pyx_XGIVEREF(__pyx_t_19);
          __pyx_cur_scope->__pyx_t_3 = __pyx_t_19;
          __Pyx_XGIVEREF(__pyx_t_20);
          __pyx_cur_scope->__pyx_t_4 = __pyx_t_20;
          __Pyx_XGIVEREF(__pyx_t_21);
          __pyx_cur_scope->__pyx_t_5 = __pyx_t_21;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 4;
          return __pyx_r;
          __pyx_L31_resume_from_await:;
          __pyx_t_4 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_4);
          __pyx_t_5 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_5);
          __pyx_t_6 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_6);
          __pyx_t_19 = __pyx_cur_scope->__pyx_t_3;
          __pyx_cur_scope->__pyx_t_3 = 0;
          __Pyx_XGOTREF(__pyx_t_19);
          __pyx_t_20 = __pyx_cur_scope->__pyx_t_4;
          __pyx_cur_scope->__pyx_t_4 = 0;
          __Pyx_XGOTREF(__pyx_t_20);
          __pyx_t_21 = __pyx_cur_scope->__pyx_t_5;
          __pyx_cur_scope->__pyx_t_5 = 0;
          __Pyx_XGOTREF(__pyx_t_21);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 263, __pyx_L30_error)
          __pyx_t_9 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_9);
        } else {
          __pyx_t_9 = NULL;
          if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_9) < 0) __PYX_ERR(0, 263, __pyx_L30_error)
          __Pyx_GOTREF(__pyx_t_9);
        }
        __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_9 = 0;
        goto __pyx_L29_return;
      }
      __pyx_L29_return:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_21);
        __Pyx_XGIVEREF(__pyx_t_20);
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_20, __pyx_t_19);
      }
      __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_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
      goto __pyx_L0;
      __pyx_L30_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_21);
        __Pyx_XGIVEREF(__pyx_t_20);
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_20, __pyx_t_19);
      }
      __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_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
      goto __pyx_L1_error;
    }
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "asyncpg/protocol/protocol.pyx":237
 *             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_7);
  __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_AddTraceback("bind", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_24generator4(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "asyncpg/protocol/protocol.pyx":265
 *             return await waiter
 * 
 *     async def execute(self, PreparedStatementState state,             # <<<<<<<<<<<<<<
 *                       str portal_name, int limit, return_extra,
 *                       timeout):
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_23execute(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_23execute(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);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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;
        CYTHON_FALLTHROUGH;
        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(0, 265, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        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(0, 265, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        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(0, 265, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        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(0, 265, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "execute") < 0)) __PYX_ERR(0, 265, __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(0, 266, __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(0, 265, __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(0, 265, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_portal_name), (&PyUnicode_Type), 1, "portal_name", 1))) __PYX_ERR(0, 266, __pyx_L1_error)
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_22execute(((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_22execute(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(0, 265, __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_24generator4, (PyObject *) __pyx_cur_scope, __pyx_n_s_execute, __pyx_n_s_BaseProtocol_execute, __pyx_n_s_asyncpg_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(0, 265, __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_24generator4(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, 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;
  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 = 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;
  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_RefNannyDeclarations
  __Pyx_RefNannySetupContext("execute", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L5_resume_from_await;
    case 2: goto __pyx_L7_resume_from_await;
    case 3: goto __pyx_L28_resume_from_await;
    case 4: goto __pyx_L31_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 265, __pyx_L1_error)

  /* "asyncpg/protocol/protocol.pyx":269
 *                       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":270
 * 
 *         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();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 1;
      return __pyx_r;
      __pyx_L5_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 270, __pyx_L1_error)
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (exc_type) {
        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
        else __PYX_ERR(0, 270, __pyx_L1_error)
      }
    }

    /* "asyncpg/protocol/protocol.pyx":269
 *                       timeout):
 * 
 *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
 *             await self.cancel_waiter
 *         if self.cancel_sent_waiter is not None:
 */
  }

  /* "asyncpg/protocol/protocol.pyx":271
 *         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":272
 *             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();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 2;
      return __pyx_r;
      __pyx_L7_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 272, __pyx_L1_error)
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (exc_type) {
        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
        else __PYX_ERR(0, 272, __pyx_L1_error)
      }
    }

    /* "asyncpg/protocol/protocol.pyx":273
 *         if self.cancel_sent_waiter is not None:
 *             await self.cancel_sent_waiter
 *             self.cancel_sent_waiter = None             # <<<<<<<<<<<<<<
 * 
 *         self._check_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":271
 *         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":275
 *             self.cancel_sent_waiter = None
 * 
 *         self._check_state()             # <<<<<<<<<<<<<<
 *         timeout = self._get_timeout_impl(timeout)
 * 
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_check_state(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":276
 * 
 *         self._check_state()
 *         timeout = self._get_timeout_impl(timeout)             # <<<<<<<<<<<<<<
 * 
 *         waiter = self._new_waiter(timeout)
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__get_timeout_impl(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_timeout); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_timeout);
  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_timeout, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":278
 *         timeout = self._get_timeout_impl(timeout)
 * 
 *         waiter = self._new_waiter(timeout)             # <<<<<<<<<<<<<<
 *         try:
 *             self._execute(
 */
  __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(0, 278, __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":279
 * 
 *         waiter = self._new_waiter(timeout)
 *         try:             # <<<<<<<<<<<<<<
 *             self._execute(
 *                 portal_name,
 */
  /*try:*/ {
    {
      __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/protocol.pyx":280
 *         waiter = self._new_waiter(timeout)
 *         try:
 *             self._execute(             # <<<<<<<<<<<<<<
 *                 portal_name,
 *                 limit)  # network op
 */
        __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(0, 280, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "asyncpg/protocol/protocol.pyx":284
 *                 limit)  # network op
 * 
 *             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":285
 * 
 *             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":286
 *             self.last_query = state.query
 *             self.statement = state
 *             self.return_extra = return_extra             # <<<<<<<<<<<<<<
 *             self.queries_count += 1
 *         except Exception as ex:
 */
        __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_return_extra); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 286, __pyx_L11_error)
        __pyx_cur_scope->__pyx_v_self->return_extra = __pyx_t_1;

        /* "asyncpg/protocol/protocol.pyx":287
 *             self.statement = state
 *             self.return_extra = return_extra
 *             self.queries_count += 1             # <<<<<<<<<<<<<<
 *         except Exception as ex:
 *             waiter.set_exception(ex)
 */
        __pyx_cur_scope->__pyx_v_self->queries_count = (__pyx_cur_scope->__pyx_v_self->queries_count + 1);

        /* "asyncpg/protocol/protocol.pyx":279
 * 
 *         waiter = self._new_waiter(timeout)
 *         try:             # <<<<<<<<<<<<<<
 *             self._execute(
 *                 portal_name,
 */
      }
      __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_L16_try_end;
      __pyx_L11_error:;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "asyncpg/protocol/protocol.pyx":288
 *             self.return_extra = return_extra
 *             self.queries_count += 1
 *         except Exception as ex:             # <<<<<<<<<<<<<<
 *             waiter.set_exception(ex)
 *             self._coreproto_error()
 */
      __pyx_t_7 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
      if (__pyx_t_7) {
        __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.execute", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_8, &__pyx_t_9) < 0) __PYX_ERR(0, 288, __pyx_L13_except_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_8);
        __pyx_cur_scope->__pyx_v_ex = __pyx_t_8;
        /*try:*/ {

          /* "asyncpg/protocol/protocol.pyx":289
 *             self.queries_count += 1
 *         except Exception as ex:
 *             waiter.set_exception(ex)             # <<<<<<<<<<<<<<
 *             self._coreproto_error()
 *         finally:
 */
          __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_waiter, __pyx_n_s_set_exception); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 289, __pyx_L22_error)
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_12 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
            __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
            if (likely(__pyx_t_12)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
              __Pyx_INCREF(__pyx_t_12);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_11, function);
            }
          }
          if (!__pyx_t_12) {
            __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_cur_scope->__pyx_v_ex); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 289, __pyx_L22_error)
            __Pyx_GOTREF(__pyx_t_10);
          } else {
            #if CYTHON_FAST_PYCALL
            if (PyFunction_Check(__pyx_t_11)) {
              PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_cur_scope->__pyx_v_ex};
              __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 289, __pyx_L22_error)
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_GOTREF(__pyx_t_10);
            } else
            #endif
            #if CYTHON_FAST_PYCCALL
            if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
              PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_cur_scope->__pyx_v_ex};
              __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 289, __pyx_L22_error)
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_GOTREF(__pyx_t_10);
            } else
            #endif
            {
              __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 289, __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_cur_scope->__pyx_v_ex);
              __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_ex);
              PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_cur_scope->__pyx_v_ex);
              __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_13, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 289, __pyx_L22_error)
              __Pyx_GOTREF(__pyx_t_10);
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            }
          }
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

          /* "asyncpg/protocol/protocol.pyx":290
 *         except Exception as ex:
 *             waiter.set_exception(ex)
 *             self._coreproto_error()             # <<<<<<<<<<<<<<
 *         finally:
 *             return await waiter
 */
          __pyx_t_10 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_coreproto_error(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 290, __pyx_L22_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }

        /* "asyncpg/protocol/protocol.pyx":288
 *             self.return_extra = return_extra
 *             self.queries_count += 1
 *         except Exception as ex:             # <<<<<<<<<<<<<<
 *             waiter.set_exception(ex)
 *             self._coreproto_error()
 */
        /*finally:*/ {
          /*normal exit:*/{
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_ex);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_ex);
            __pyx_cur_scope->__pyx_v_ex = NULL;
            goto __pyx_L23;
          }
          __pyx_L22_error:;
          /*exception exit:*/{
            __Pyx_PyThreadState_assign
            __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_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 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_7 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_15 = __pyx_filename;
            {
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_ex);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_ex);
              __pyx_cur_scope->__pyx_v_ex = NULL;
            }
            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_7; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_15;
            goto __pyx_L13_except_error;
          }
          __pyx_L23:;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L12_exception_handled;
      }
      goto __pyx_L13_except_error;
      __pyx_L13_except_error:;

      /* "asyncpg/protocol/protocol.pyx":279
 * 
 *         waiter = self._new_waiter(timeout)
 *         try:             # <<<<<<<<<<<<<<
 *             self._execute(
 *                 portal_name,
 */
      __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_L9_error;
      __pyx_L12_exception_handled:;
      __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_L16_try_end:;
    }
  }

  /* "asyncpg/protocol/protocol.pyx":292
 *             self._coreproto_error()
 *         finally:
 *             return await waiter             # <<<<<<<<<<<<<<
 * 
 *     async def query(self, query, timeout):
 */
  /*finally:*/ {
    /*normal exit:*/{
      __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();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 3;
        return __pyx_r;
        __pyx_L28_resume_from_await:;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 292, __pyx_L1_error)
        __pyx_t_9 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_9);
      } else {
        __pyx_t_9 = NULL;
        if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_9) < 0) __PYX_ERR(0, 292, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
      }
      __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = 0;
      goto __pyx_L0;
    }
    __pyx_L9_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_assign
      __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_4 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_21, &__pyx_t_20, &__pyx_t_19);
      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_21);
      __Pyx_XGOTREF(__pyx_t_20);
      __Pyx_XGOTREF(__pyx_t_19);
      {
        __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_t_4);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_4;
          __Pyx_XGIVEREF(__pyx_t_5);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_5;
          __Pyx_XGIVEREF(__pyx_t_6);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_6;
          __Pyx_XGIVEREF(__pyx_t_19);
          __pyx_cur_scope->__pyx_t_3 = __pyx_t_19;
          __Pyx_XGIVEREF(__pyx_t_20);
          __pyx_cur_scope->__pyx_t_4 = __pyx_t_20;
          __Pyx_XGIVEREF(__pyx_t_21);
          __pyx_cur_scope->__pyx_t_5 = __pyx_t_21;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 4;
          return __pyx_r;
          __pyx_L31_resume_from_await:;
          __pyx_t_4 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_4);
          __pyx_t_5 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_5);
          __pyx_t_6 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_6);
          __pyx_t_19 = __pyx_cur_scope->__pyx_t_3;
          __pyx_cur_scope->__pyx_t_3 = 0;
          __Pyx_XGOTREF(__pyx_t_19);
          __pyx_t_20 = __pyx_cur_scope->__pyx_t_4;
          __pyx_cur_scope->__pyx_t_4 = 0;
          __Pyx_XGOTREF(__pyx_t_20);
          __pyx_t_21 = __pyx_cur_scope->__pyx_t_5;
          __pyx_cur_scope->__pyx_t_5 = 0;
          __Pyx_XGOTREF(__pyx_t_21);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 292, __pyx_L30_error)
          __pyx_t_9 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_9);
        } else {
          __pyx_t_9 = NULL;
          if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_9) < 0) __PYX_ERR(0, 292, __pyx_L30_error)
          __Pyx_GOTREF(__pyx_t_9);
        }
        __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_9 = 0;
        goto __pyx_L29_return;
      }
      __pyx_L29_return:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_21);
        __Pyx_XGIVEREF(__pyx_t_20);
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_20, __pyx_t_19);
      }
      __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_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
      goto __pyx_L0;
      __pyx_L30_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_21);
        __Pyx_XGIVEREF(__pyx_t_20);
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_20, __pyx_t_19);
      }
      __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_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
      goto __pyx_L1_error;
    }
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "asyncpg/protocol/protocol.pyx":265
 *             return await waiter
 * 
 *     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_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_AddTraceback("execute", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_27generator5(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "asyncpg/protocol/protocol.pyx":294
 *             return await waiter
 * 
 *     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_26query(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_26query(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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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;
        CYTHON_FALLTHROUGH;
        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(0, 294, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "query") < 0)) __PYX_ERR(0, 294, __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(0, 294, __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_25query(((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_25query(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(0, 294, __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_27generator5, (PyObject *) __pyx_cur_scope, __pyx_n_s_query, __pyx_n_s_BaseProtocol_query, __pyx_n_s_asyncpg_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(0, 294, __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_27generator5(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, 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;
  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;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  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_RefNannyDeclarations
  __Pyx_RefNannySetupContext("query", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L5_resume_from_await;
    case 2: goto __pyx_L7_resume_from_await;
    case 3: goto __pyx_L28_resume_from_await;
    case 4: goto __pyx_L31_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 294, __pyx_L1_error)

  /* "asyncpg/protocol/protocol.pyx":295
 * 
 *     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":296
 *     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();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 1;
      return __pyx_r;
      __pyx_L5_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 296, __pyx_L1_error)
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (exc_type) {
        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
        else __PYX_ERR(0, 296, __pyx_L1_error)
      }
    }

    /* "asyncpg/protocol/protocol.pyx":295
 * 
 *     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":297
 *         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":298
 *             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();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 2;
      return __pyx_r;
      __pyx_L7_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 298, __pyx_L1_error)
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (exc_type) {
        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
        else __PYX_ERR(0, 298, __pyx_L1_error)
      }
    }

    /* "asyncpg/protocol/protocol.pyx":299
 *         if self.cancel_sent_waiter is not None:
 *             await self.cancel_sent_waiter
 *             self.cancel_sent_waiter = None             # <<<<<<<<<<<<<<
 * 
 *         self._check_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":297
 *         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":301
 *             self.cancel_sent_waiter = None
 * 
 *         self._check_state()             # <<<<<<<<<<<<<<
 *         # query() needs to call _get_timeout instead of _get_timeout_impl
 *         # for consistent validation, as it is called differently from
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_check_state(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 301, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":305
 *         # for consistent validation, as it is called differently from
 *         # prepare/bind/execute methods.
 *         timeout = self._get_timeout(timeout)             # <<<<<<<<<<<<<<
 * 
 *         waiter = self._new_waiter(timeout)
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_get_timeout); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 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_cur_scope->__pyx_v_timeout); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 305, __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_cur_scope->__pyx_v_timeout};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 305, __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_cur_scope->__pyx_v_timeout};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 305, __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(0, 305, __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_cur_scope->__pyx_v_timeout);
      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_timeout);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_cur_scope->__pyx_v_timeout);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 305, __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_GOTREF(__pyx_cur_scope->__pyx_v_timeout);
  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_timeout, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":307
 *         timeout = self._get_timeout(timeout)
 * 
 *         waiter = self._new_waiter(timeout)             # <<<<<<<<<<<<<<
 *         try:
 *             self._simple_query(query)  # network op
 */
  __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(0, 307, __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":308
 * 
 *         waiter = self._new_waiter(timeout)
 *         try:             # <<<<<<<<<<<<<<
 *             self._simple_query(query)  # network op
 *             self.last_query = query
 */
  /*try:*/ {
    {
      __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":309
 *         waiter = self._new_waiter(timeout)
 *         try:
 *             self._simple_query(query)  # network op             # <<<<<<<<<<<<<<
 *             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(0, 309, __pyx_L11_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(0, 309, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "asyncpg/protocol/protocol.pyx":310
 *         try:
 *             self._simple_query(query)  # network op
 *             self.last_query = query             # <<<<<<<<<<<<<<
 *             self.queries_count += 1
 *         except Exception as ex:
 */
        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(0, 310, __pyx_L11_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":311
 *             self._simple_query(query)  # network op
 *             self.last_query = query
 *             self.queries_count += 1             # <<<<<<<<<<<<<<
 *         except Exception as ex:
 *             waiter.set_exception(ex)
 */
        __pyx_cur_scope->__pyx_v_self->queries_count = (__pyx_cur_scope->__pyx_v_self->queries_count + 1);

        /* "asyncpg/protocol/protocol.pyx":308
 * 
 *         waiter = self._new_waiter(timeout)
 *         try:             # <<<<<<<<<<<<<<
 *             self._simple_query(query)  # network op
 *             self.last_query = query
 */
      }
      __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_L11_error:;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "asyncpg/protocol/protocol.pyx":312
 *             self.last_query = query
 *             self.queries_count += 1
 *         except Exception as ex:             # <<<<<<<<<<<<<<
 *             waiter.set_exception(ex)
 *             self._coreproto_error()
 */
      __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
      if (__pyx_t_10) {
        __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.query", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_4, &__pyx_t_6) < 0) __PYX_ERR(0, 312, __pyx_L13_except_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        __pyx_cur_scope->__pyx_v_ex = __pyx_t_4;
        /*try:*/ {

          /* "asyncpg/protocol/protocol.pyx":313
 *             self.queries_count += 1
 *         except Exception as ex:
 *             waiter.set_exception(ex)             # <<<<<<<<<<<<<<
 *             self._coreproto_error()
 *         finally:
 */
          __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_waiter, __pyx_n_s_set_exception); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 313, __pyx_L22_error)
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_12 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
            __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
            if (likely(__pyx_t_12)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
              __Pyx_INCREF(__pyx_t_12);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_11, function);
            }
          }
          if (!__pyx_t_12) {
            __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_cur_scope->__pyx_v_ex); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 313, __pyx_L22_error)
            __Pyx_GOTREF(__pyx_t_5);
          } else {
            #if CYTHON_FAST_PYCALL
            if (PyFunction_Check(__pyx_t_11)) {
              PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_cur_scope->__pyx_v_ex};
              __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 313, __pyx_L22_error)
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_GOTREF(__pyx_t_5);
            } else
            #endif
            #if CYTHON_FAST_PYCCALL
            if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
              PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_cur_scope->__pyx_v_ex};
              __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 313, __pyx_L22_error)
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_GOTREF(__pyx_t_5);
            } else
            #endif
            {
              __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 313, __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_cur_scope->__pyx_v_ex);
              __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_ex);
              PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_cur_scope->__pyx_v_ex);
              __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_13, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 313, __pyx_L22_error)
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            }
          }
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "asyncpg/protocol/protocol.pyx":314
 *         except Exception as ex:
 *             waiter.set_exception(ex)
 *             self._coreproto_error()             # <<<<<<<<<<<<<<
 *         finally:
 *             return await waiter
 */
          __pyx_t_5 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_coreproto_error(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 314, __pyx_L22_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        }

        /* "asyncpg/protocol/protocol.pyx":312
 *             self.last_query = query
 *             self.queries_count += 1
 *         except Exception as ex:             # <<<<<<<<<<<<<<
 *             waiter.set_exception(ex)
 *             self._coreproto_error()
 */
        /*finally:*/ {
          /*normal exit:*/{
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_ex);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_ex);
            __pyx_cur_scope->__pyx_v_ex = NULL;
            goto __pyx_L23;
          }
          __pyx_L22_error:;
          /*exception exit:*/{
            __Pyx_PyThreadState_assign
            __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_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 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_10 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_15 = __pyx_filename;
            {
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_ex);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_ex);
              __pyx_cur_scope->__pyx_v_ex = NULL;
            }
            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_10; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_15;
            goto __pyx_L13_except_error;
          }
          __pyx_L23:;
        }
        __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;
        goto __pyx_L12_exception_handled;
      }
      goto __pyx_L13_except_error;
      __pyx_L13_except_error:;

      /* "asyncpg/protocol/protocol.pyx":308
 * 
 *         waiter = self._new_waiter(timeout)
 *         try:             # <<<<<<<<<<<<<<
 *             self._simple_query(query)  # network op
 *             self.last_query = query
 */
      __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_L9_error;
      __pyx_L12_exception_handled:;
      __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":316
 *             self._coreproto_error()
 *         finally:
 *             return await waiter             # <<<<<<<<<<<<<<
 * 
 *     async def copy_out(self, copy_stmt, sink, timeout):
 */
  /*finally:*/ {
    /*normal exit:*/{
      __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();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 3;
        return __pyx_r;
        __pyx_L28_resume_from_await:;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 316, __pyx_L1_error)
        __pyx_t_6 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_6);
      } else {
        __pyx_t_6 = NULL;
        if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_6) < 0) __PYX_ERR(0, 316, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
      }
      __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = 0;
      goto __pyx_L0;
    }
    __pyx_L9_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_assign
      __pyx_t_9 = 0; __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_21, &__pyx_t_20, &__pyx_t_19);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_21);
      __Pyx_XGOTREF(__pyx_t_20);
      __Pyx_XGOTREF(__pyx_t_19);
      {
        __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_t_7);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_7;
          __Pyx_XGIVEREF(__pyx_t_8);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_8;
          __Pyx_XGIVEREF(__pyx_t_9);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
          __Pyx_XGIVEREF(__pyx_t_19);
          __pyx_cur_scope->__pyx_t_3 = __pyx_t_19;
          __Pyx_XGIVEREF(__pyx_t_20);
          __pyx_cur_scope->__pyx_t_4 = __pyx_t_20;
          __Pyx_XGIVEREF(__pyx_t_21);
          __pyx_cur_scope->__pyx_t_5 = __pyx_t_21;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 4;
          return __pyx_r;
          __pyx_L31_resume_from_await:;
          __pyx_t_7 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_7);
          __pyx_t_8 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_8);
          __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_9);
          __pyx_t_19 = __pyx_cur_scope->__pyx_t_3;
          __pyx_cur_scope->__pyx_t_3 = 0;
          __Pyx_XGOTREF(__pyx_t_19);
          __pyx_t_20 = __pyx_cur_scope->__pyx_t_4;
          __pyx_cur_scope->__pyx_t_4 = 0;
          __Pyx_XGOTREF(__pyx_t_20);
          __pyx_t_21 = __pyx_cur_scope->__pyx_t_5;
          __pyx_cur_scope->__pyx_t_5 = 0;
          __Pyx_XGOTREF(__pyx_t_21);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 316, __pyx_L30_error)
          __pyx_t_6 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_6);
        } else {
          __pyx_t_6 = NULL;
          if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_6) < 0) __PYX_ERR(0, 316, __pyx_L30_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = 0;
        goto __pyx_L29_return;
      }
      __pyx_L29_return:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_21);
        __Pyx_XGIVEREF(__pyx_t_20);
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_20, __pyx_t_19);
      }
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
      goto __pyx_L0;
      __pyx_L30_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_21);
        __Pyx_XGIVEREF(__pyx_t_20);
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_20, __pyx_t_19);
      }
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
      goto __pyx_L1_error;
    }
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "asyncpg/protocol/protocol.pyx":294
 *             return await waiter
 * 
 *     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_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("query", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_30generator6(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "asyncpg/protocol/protocol.pyx":318
 *             return await waiter
 * 
 *     async def copy_out(self, copy_stmt, sink, timeout):             # <<<<<<<<<<<<<<
 *         if self.cancel_waiter is not None:
 *             await self.cancel_waiter
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_29copy_out(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_29copy_out(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_copy_stmt = 0;
  PyObject *__pyx_v_sink = 0;
  PyObject *__pyx_v_timeout = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("copy_out (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_copy_stmt,&__pyx_n_s_sink,&__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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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_copy_stmt)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_sink)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("copy_out", 1, 3, 3, 1); __PYX_ERR(0, 318, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_timeout)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("copy_out", 1, 3, 3, 2); __PYX_ERR(0, 318, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "copy_out") < 0)) __PYX_ERR(0, 318, __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_copy_stmt = values[0];
    __pyx_v_sink = values[1];
    __pyx_v_timeout = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("copy_out", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 318, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.copy_out", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_28copy_out(((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self), __pyx_v_copy_stmt, __pyx_v_sink, __pyx_v_timeout);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/protocol.pyx":358
 *                         # Make asyncio shut up about unretrieved
 *                         # QueryCanceledError
 *                         waiter.add_done_callback(lambda f: f.exception())             # <<<<<<<<<<<<<<
 *                         raise
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_8copy_out_lambda1(PyObject *__pyx_self, PyObject *__pyx_v_f); /*proto*/
static PyMethodDef __pyx_mdef_7asyncpg_8protocol_8protocol_12BaseProtocol_8copy_out_lambda1 = {"lambda1", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_8copy_out_lambda1, METH_O, 0};
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_8copy_out_lambda1(PyObject *__pyx_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("lambda1 (wrapper)", 0);
  __pyx_r = __pyx_lambda_funcdef_lambda1(__pyx_self, ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_lambda_funcdef_lambda1(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("lambda1", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_exception); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 358, __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(0, 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(0, 358, __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;

  /* 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.copy_out.lambda1", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/protocol.pyx":318
 *             return await waiter
 * 
 *     async def copy_out(self, copy_stmt, sink, timeout):             # <<<<<<<<<<<<<<
 *         if self.cancel_waiter is not None:
 *             await self.cancel_waiter
 */

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_28copy_out(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_copy_stmt, PyObject *__pyx_v_sink, PyObject *__pyx_v_timeout) {
  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("copy_out", 0);
  __pyx_cur_scope = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out *)__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out(__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 318, __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_copy_stmt = __pyx_v_copy_stmt;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_copy_stmt);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_copy_stmt);
  __pyx_cur_scope->__pyx_v_sink = __pyx_v_sink;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_sink);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_sink);
  __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_30generator6, (PyObject *) __pyx_cur_scope, __pyx_n_s_copy_out, __pyx_n_s_BaseProtocol_copy_out, __pyx_n_s_asyncpg_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(0, 318, __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.copy_out", __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_30generator6(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out *__pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out *)__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;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *(*__pyx_t_12)(PyObject *);
  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;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  int __pyx_t_21;
  char const *__pyx_t_22;
  PyObject *__pyx_t_23 = NULL;
  char const *__pyx_t_24;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("copy_out", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L5_resume_from_await;
    case 2: goto __pyx_L7_resume_from_await;
    case 3: goto __pyx_L27_resume_from_await;
    case 4: goto __pyx_L57_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 318, __pyx_L1_error)

  /* "asyncpg/protocol/protocol.pyx":319
 * 
 *     async def copy_out(self, copy_stmt, sink, 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":320
 *     async def copy_out(self, copy_stmt, sink, 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();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 1;
      return __pyx_r;
      __pyx_L5_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 320, __pyx_L1_error)
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (exc_type) {
        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
        else __PYX_ERR(0, 320, __pyx_L1_error)
      }
    }

    /* "asyncpg/protocol/protocol.pyx":319
 * 
 *     async def copy_out(self, copy_stmt, sink, timeout):
 *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
 *             await self.cancel_waiter
 *         if self.cancel_sent_waiter is not None:
 */
  }

  /* "asyncpg/protocol/protocol.pyx":321
 *         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":322
 *             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();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 2;
      return __pyx_r;
      __pyx_L7_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 322, __pyx_L1_error)
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (exc_type) {
        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
        else __PYX_ERR(0, 322, __pyx_L1_error)
      }
    }

    /* "asyncpg/protocol/protocol.pyx":323
 *         if self.cancel_sent_waiter is not None:
 *             await self.cancel_sent_waiter
 *             self.cancel_sent_waiter = None             # <<<<<<<<<<<<<<
 * 
 *         self._check_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":321
 *         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":325
 *             self.cancel_sent_waiter = None
 * 
 *         self._check_state()             # <<<<<<<<<<<<<<
 * 
 *         timeout = self._get_timeout_impl(timeout)
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_check_state(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 325, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":327
 *         self._check_state()
 * 
 *         timeout = self._get_timeout_impl(timeout)             # <<<<<<<<<<<<<<
 *         timer = Timer(timeout)
 * 
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__get_timeout_impl(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_timeout); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 327, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_timeout);
  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_timeout, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":328
 * 
 *         timeout = self._get_timeout_impl(timeout)
 *         timer = Timer(timeout)             # <<<<<<<<<<<<<<
 * 
 *         # The copy operation is guarded by a single timeout
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_Timer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 328, __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_cur_scope->__pyx_v_timeout); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 328, __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_cur_scope->__pyx_v_timeout};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 328, __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_cur_scope->__pyx_v_timeout};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 328, __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(0, 328, __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_cur_scope->__pyx_v_timeout);
      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_timeout);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_cur_scope->__pyx_v_timeout);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 328, __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_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_timer = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":332
 *         # The copy operation is guarded by a single timeout
 *         # on the top level.
 *         waiter = self._new_waiter(timer.get_remaining_budget())             # <<<<<<<<<<<<<<
 * 
 *         self._copy_out(copy_stmt)
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_timer, __pyx_n_s_get_remaining_budget); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 332, __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_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 332, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 332, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __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_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_cur_scope->__pyx_v_waiter = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "asyncpg/protocol/protocol.pyx":334
 *         waiter = self._new_waiter(timer.get_remaining_budget())
 * 
 *         self._copy_out(copy_stmt)             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
  if (!(likely(PyUnicode_CheckExact(__pyx_cur_scope->__pyx_v_copy_stmt))||((__pyx_cur_scope->__pyx_v_copy_stmt) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_cur_scope->__pyx_v_copy_stmt)->tp_name), 0))) __PYX_ERR(0, 334, __pyx_L1_error)
  __pyx_t_4 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._copy_out(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_cur_scope->__pyx_v_self), ((PyObject*)__pyx_cur_scope->__pyx_v_copy_stmt)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "asyncpg/protocol/protocol.pyx":336
 *         self._copy_out(copy_stmt)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             while True:
 *                 self.resume_reading()
 */
  /*try:*/ {

    /* "asyncpg/protocol/protocol.pyx":337
 * 
 *         try:
 *             while True:             # <<<<<<<<<<<<<<
 *                 self.resume_reading()
 * 
 */
    while (1) {

      /* "asyncpg/protocol/protocol.pyx":338
 *         try:
 *             while True:
 *                 self.resume_reading()             # <<<<<<<<<<<<<<
 * 
 *                 with timer:
 */
      __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol_resume_reading(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 338, __pyx_L9_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "asyncpg/protocol/protocol.pyx":340
 *                 self.resume_reading()
 * 
 *                 with timer:             # <<<<<<<<<<<<<<
 *                     buffer, done, status_msg = await waiter
 * 
 */
      /*with:*/ {
        __pyx_t_7 = __Pyx_PyObject_LookupSpecial(__pyx_cur_scope->__pyx_v_timer, __pyx_n_s_exit); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 340, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_3 = __Pyx_PyObject_LookupSpecial(__pyx_cur_scope->__pyx_v_timer, __pyx_n_s_enter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 340, __pyx_L13_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_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 340, __pyx_L13_error)
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        } else {
          __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 340, __pyx_L13_error)
        }
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        /*try:*/ {
          {
            __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
            __Pyx_XGOTREF(__pyx_t_8);
            __Pyx_XGOTREF(__pyx_t_9);
            __Pyx_XGOTREF(__pyx_t_10);
            /*try:*/ {

              /* "asyncpg/protocol/protocol.pyx":341
 * 
 *                 with timer:
 *                     buffer, done, status_msg = await waiter             # <<<<<<<<<<<<<<
 * 
 *                 # buffer will be empty if CopyDone was received apart from
 */
              __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_t_7);
                __pyx_cur_scope->__pyx_t_0 = __pyx_t_7;
                __Pyx_XGIVEREF(__pyx_t_8);
                __pyx_cur_scope->__pyx_t_1 = __pyx_t_8;
                __Pyx_XGIVEREF(__pyx_t_9);
                __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
                __Pyx_XGIVEREF(__pyx_t_10);
                __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                __Pyx_XGIVEREF(__pyx_r);
                __Pyx_RefNannyFinishContext();
                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                /* return from generator, awaiting value */
                __pyx_generator->resume_label = 3;
                return __pyx_r;
                __pyx_L27_resume_from_await:;
                __pyx_t_7 = __pyx_cur_scope->__pyx_t_0;
                __pyx_cur_scope->__pyx_t_0 = 0;
                __Pyx_XGOTREF(__pyx_t_7);
                __pyx_t_8 = __pyx_cur_scope->__pyx_t_1;
                __pyx_cur_scope->__pyx_t_1 = 0;
                __Pyx_XGOTREF(__pyx_t_8);
                __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
                __pyx_cur_scope->__pyx_t_2 = 0;
                __Pyx_XGOTREF(__pyx_t_9);
                __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                __pyx_cur_scope->__pyx_t_3 = 0;
                __Pyx_XGOTREF(__pyx_t_10);
                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 341, __pyx_L19_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(0, 341, __pyx_L19_error)
                __Pyx_GOTREF(__pyx_t_4);
              }
              if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
                PyObject* sequence = __pyx_t_4;
                #if !CYTHON_COMPILING_IN_PYPY
                Py_ssize_t size = Py_SIZE(sequence);
                #else
                Py_ssize_t size = PySequence_Size(sequence);
                #endif
                if (unlikely(size != 3)) {
                  if (size > 3) __Pyx_RaiseTooManyValuesError(3);
                  else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
                  __PYX_ERR(0, 341, __pyx_L19_error)
                }
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                if (likely(PyTuple_CheckExact(sequence))) {
                  __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
                  __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
                  __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); 
                } else {
                  __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
                  __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
                  __pyx_t_5 = PyList_GET_ITEM(sequence, 2); 
                }
                __Pyx_INCREF(__pyx_t_3);
                __Pyx_INCREF(__pyx_t_6);
                __Pyx_INCREF(__pyx_t_5);
                #else
                __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 341, __pyx_L19_error)
                __Pyx_GOTREF(__pyx_t_3);
                __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 341, __pyx_L19_error)
                __Pyx_GOTREF(__pyx_t_6);
                __pyx_t_5 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 341, __pyx_L19_error)
                __Pyx_GOTREF(__pyx_t_5);
                #endif
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              } else {
                Py_ssize_t index = -1;
                __pyx_t_11 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 341, __pyx_L19_error)
                __Pyx_GOTREF(__pyx_t_11);
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                __pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext;
                index = 0; __pyx_t_3 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_3)) goto __pyx_L28_unpacking_failed;
                __Pyx_GOTREF(__pyx_t_3);
                index = 1; __pyx_t_6 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_6)) goto __pyx_L28_unpacking_failed;
                __Pyx_GOTREF(__pyx_t_6);
                index = 2; __pyx_t_5 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_5)) goto __pyx_L28_unpacking_failed;
                __Pyx_GOTREF(__pyx_t_5);
                if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 3) < 0) __PYX_ERR(0, 341, __pyx_L19_error)
                __pyx_t_12 = NULL;
                __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
                goto __pyx_L29_unpacking_done;
                __pyx_L28_unpacking_failed:;
                __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
                __pyx_t_12 = NULL;
                if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
                __PYX_ERR(0, 341, __pyx_L19_error)
                __pyx_L29_unpacking_done:;
              }
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_buffer);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_buffer, __pyx_t_3);
              __Pyx_GIVEREF(__pyx_t_3);
              __pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_done);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_done, __pyx_t_6);
              __Pyx_GIVEREF(__pyx_t_6);
              __pyx_t_6 = 0;
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_status_msg);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_status_msg, __pyx_t_5);
              __Pyx_GIVEREF(__pyx_t_5);
              __pyx_t_5 = 0;

              /* "asyncpg/protocol/protocol.pyx":340
 *                 self.resume_reading()
 * 
 *                 with timer:             # <<<<<<<<<<<<<<
 *                     buffer, done, status_msg = await waiter
 * 
 */
            }
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            goto __pyx_L26_try_end;
            __pyx_L19_error:;
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __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;
            /*except:*/ {
              __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.copy_out", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6) < 0) __PYX_ERR(0, 340, __pyx_L21_except_error)
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_GOTREF(__pyx_t_6);
              __pyx_t_3 = PyTuple_Pack(3, __pyx_t_4, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 340, __pyx_L21_except_error)
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_3, NULL);
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 340, __pyx_L21_except_error)
              __Pyx_GOTREF(__pyx_t_13);
              __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_13);
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              if (__pyx_t_1 < 0) __PYX_ERR(0, 340, __pyx_L21_except_error)
              __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
              if (__pyx_t_2) {
                __Pyx_GIVEREF(__pyx_t_4);
                __Pyx_GIVEREF(__pyx_t_5);
                __Pyx_XGIVEREF(__pyx_t_6);
                __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_5, __pyx_t_6);
                __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; 
                __PYX_ERR(0, 340, __pyx_L21_except_error)
              }
              __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;
              goto __pyx_L20_exception_handled;
            }
            __pyx_L21_except_error:;
            __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);
            goto __pyx_L9_error;
            __pyx_L20_exception_handled:;
            __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_L26_try_end:;
          }
        }
        /*finally:*/ {
          /*normal exit:*/{
            if (__pyx_t_7) {
              __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__94, NULL);
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 340, __pyx_L9_error)
              __Pyx_GOTREF(__pyx_t_10);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            }
            goto __pyx_L18;
          }
          __pyx_L18:;
        }
        goto __pyx_L33;
        __pyx_L13_error:;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L9_error;
        __pyx_L33:;
      }

      /* "asyncpg/protocol/protocol.pyx":345
 *                 # buffer will be empty if CopyDone was received apart from
 *                 # the last CopyData message.
 *                 if buffer:             # <<<<<<<<<<<<<<
 *                     try:
 *                         with timer:
 */
      if (unlikely(!__pyx_cur_scope->__pyx_v_buffer)) { __Pyx_RaiseUnboundLocalError("buffer"); __PYX_ERR(0, 345, __pyx_L9_error) }
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_buffer); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 345, __pyx_L9_error)
      if (__pyx_t_2) {

        /* "asyncpg/protocol/protocol.pyx":346
 *                 # the last CopyData message.
 *                 if buffer:
 *                     try:             # <<<<<<<<<<<<<<
 *                         with timer:
 *                             await asyncio.wait_for(
 */
        {
          __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_10, &__pyx_t_9);
          __Pyx_XGOTREF(__pyx_t_7);
          __Pyx_XGOTREF(__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_9);
          /*try:*/ {

            /* "asyncpg/protocol/protocol.pyx":347
 *                 if buffer:
 *                     try:
 *                         with timer:             # <<<<<<<<<<<<<<
 *                             await asyncio.wait_for(
 *                                 sink(buffer),
 */
            /*with:*/ {
              __pyx_t_8 = __Pyx_PyObject_LookupSpecial(__pyx_cur_scope->__pyx_v_timer, __pyx_n_s_exit); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 347, __pyx_L35_error)
              __Pyx_GOTREF(__pyx_t_8);
              __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_cur_scope->__pyx_v_timer, __pyx_n_s_enter); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 347, __pyx_L43_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_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 347, __pyx_L43_error)
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              } else {
                __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 347, __pyx_L43_error)
              }
              __Pyx_GOTREF(__pyx_t_6);
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              /*try:*/ {
                {
                  __Pyx_ExceptionSave(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
                  __Pyx_XGOTREF(__pyx_t_13);
                  __Pyx_XGOTREF(__pyx_t_14);
                  __Pyx_XGOTREF(__pyx_t_15);
                  /*try:*/ {

                    /* "asyncpg/protocol/protocol.pyx":348
 *                     try:
 *                         with timer:
 *                             await asyncio.wait_for(             # <<<<<<<<<<<<<<
 *                                 sink(buffer),
 *                                 timeout=timer.get_remaining_budget(),
 */
                    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_asyncio); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 348, __pyx_L49_error)
                    __Pyx_GOTREF(__pyx_t_6);
                    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_wait_for); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 348, __pyx_L49_error)
                    __Pyx_GOTREF(__pyx_t_5);
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

                    /* "asyncpg/protocol/protocol.pyx":349
 *                         with timer:
 *                             await asyncio.wait_for(
 *                                 sink(buffer),             # <<<<<<<<<<<<<<
 *                                 timeout=timer.get_remaining_budget(),
 *                                 loop=self.loop)
 */
                    if (unlikely(!__pyx_cur_scope->__pyx_v_buffer)) { __Pyx_RaiseUnboundLocalError("buffer"); __PYX_ERR(0, 349, __pyx_L49_error) }
                    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_sink);
                    __pyx_t_4 = __pyx_cur_scope->__pyx_v_sink; __pyx_t_3 = NULL;
                    if (CYTHON_UNPACK_METHODS && unlikely(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_6 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_cur_scope->__pyx_v_buffer); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 349, __pyx_L49_error)
                      __Pyx_GOTREF(__pyx_t_6);
                    } else {
                      #if CYTHON_FAST_PYCALL
                      if (PyFunction_Check(__pyx_t_4)) {
                        PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_buffer};
                        __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 349, __pyx_L49_error)
                        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                        __Pyx_GOTREF(__pyx_t_6);
                      } else
                      #endif
                      #if CYTHON_FAST_PYCCALL
                      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
                        PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_buffer};
                        __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 349, __pyx_L49_error)
                        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                        __Pyx_GOTREF(__pyx_t_6);
                      } else
                      #endif
                      {
                        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 349, __pyx_L49_error)
                        __Pyx_GOTREF(__pyx_t_11);
                        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3); __pyx_t_3 = NULL;
                        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_buffer);
                        __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_buffer);
                        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_cur_scope->__pyx_v_buffer);
                        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 349, __pyx_L49_error)
                        __Pyx_GOTREF(__pyx_t_6);
                        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
                      }
                    }
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                    /* "asyncpg/protocol/protocol.pyx":348
 *                     try:
 *                         with timer:
 *                             await asyncio.wait_for(             # <<<<<<<<<<<<<<
 *                                 sink(buffer),
 *                                 timeout=timer.get_remaining_budget(),
 */
                    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 348, __pyx_L49_error)
                    __Pyx_GOTREF(__pyx_t_4);
                    __Pyx_GIVEREF(__pyx_t_6);
                    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6);
                    __pyx_t_6 = 0;

                    /* "asyncpg/protocol/protocol.pyx":350
 *                             await asyncio.wait_for(
 *                                 sink(buffer),
 *                                 timeout=timer.get_remaining_budget(),             # <<<<<<<<<<<<<<
 *                                 loop=self.loop)
 *                     except Exception as ex:
 */
                    __pyx_t_6 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 350, __pyx_L49_error)
                    __Pyx_GOTREF(__pyx_t_6);
                    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_timer, __pyx_n_s_get_remaining_budget); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 350, __pyx_L49_error)
                    __Pyx_GOTREF(__pyx_t_3);
                    __pyx_t_16 = NULL;
                    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
                      __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_3);
                      if (likely(__pyx_t_16)) {
                        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
                        __Pyx_INCREF(__pyx_t_16);
                        __Pyx_INCREF(function);
                        __Pyx_DECREF_SET(__pyx_t_3, function);
                      }
                    }
                    if (__pyx_t_16) {
                      __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_16); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 350, __pyx_L49_error)
                      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                    } else {
                      __pyx_t_11 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 350, __pyx_L49_error)
                    }
                    __Pyx_GOTREF(__pyx_t_11);
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_timeout, __pyx_t_11) < 0) __PYX_ERR(0, 350, __pyx_L49_error)
                    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

                    /* "asyncpg/protocol/protocol.pyx":351
 *                                 sink(buffer),
 *                                 timeout=timer.get_remaining_budget(),
 *                                 loop=self.loop)             # <<<<<<<<<<<<<<
 *                     except Exception as ex:
 *                         # Abort the COPY operation on any error in
 */
                    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_loop, __pyx_cur_scope->__pyx_v_self->loop) < 0) __PYX_ERR(0, 350, __pyx_L49_error)

                    /* "asyncpg/protocol/protocol.pyx":348
 *                     try:
 *                         with timer:
 *                             await asyncio.wait_for(             # <<<<<<<<<<<<<<
 *                                 sink(buffer),
 *                                 timeout=timer.get_remaining_budget(),
 */
                    __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 348, __pyx_L49_error)
                    __Pyx_GOTREF(__pyx_t_11);
                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_11);
                    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
                    __Pyx_XGOTREF(__pyx_r);
                    if (likely(__pyx_r)) {
                      __Pyx_XGIVEREF(__pyx_t_7);
                      __pyx_cur_scope->__pyx_t_0 = __pyx_t_7;
                      __Pyx_XGIVEREF(__pyx_t_8);
                      __pyx_cur_scope->__pyx_t_1 = __pyx_t_8;
                      __Pyx_XGIVEREF(__pyx_t_9);
                      __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
                      __Pyx_XGIVEREF(__pyx_t_10);
                      __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                      __Pyx_XGIVEREF(__pyx_t_13);
                      __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                      __Pyx_XGIVEREF(__pyx_t_14);
                      __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                      __Pyx_XGIVEREF(__pyx_t_15);
                      __pyx_cur_scope->__pyx_t_6 = __pyx_t_15;
                      __Pyx_XGIVEREF(__pyx_r);
                      __Pyx_RefNannyFinishContext();
                      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                      /* return from generator, awaiting value */
                      __pyx_generator->resume_label = 4;
                      return __pyx_r;
                      __pyx_L57_resume_from_await:;
                      __pyx_t_7 = __pyx_cur_scope->__pyx_t_0;
                      __pyx_cur_scope->__pyx_t_0 = 0;
                      __Pyx_XGOTREF(__pyx_t_7);
                      __pyx_t_8 = __pyx_cur_scope->__pyx_t_1;
                      __pyx_cur_scope->__pyx_t_1 = 0;
                      __Pyx_XGOTREF(__pyx_t_8);
                      __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
                      __pyx_cur_scope->__pyx_t_2 = 0;
                      __Pyx_XGOTREF(__pyx_t_9);
                      __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                      __pyx_cur_scope->__pyx_t_3 = 0;
                      __Pyx_XGOTREF(__pyx_t_10);
                      __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                      __pyx_cur_scope->__pyx_t_4 = 0;
                      __Pyx_XGOTREF(__pyx_t_13);
                      __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                      __pyx_cur_scope->__pyx_t_5 = 0;
                      __Pyx_XGOTREF(__pyx_t_14);
                      __pyx_t_15 = __pyx_cur_scope->__pyx_t_6;
                      __pyx_cur_scope->__pyx_t_6 = 0;
                      __Pyx_XGOTREF(__pyx_t_15);
                      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 348, __pyx_L49_error)
                    } else {
                      PyObject* exc_type = __Pyx_PyErr_Occurred();
                      if (exc_type) {
                        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
                        else __PYX_ERR(0, 348, __pyx_L49_error)
                      }
                    }

                    /* "asyncpg/protocol/protocol.pyx":347
 *                 if buffer:
 *                     try:
 *                         with timer:             # <<<<<<<<<<<<<<
 *                             await asyncio.wait_for(
 *                                 sink(buffer),
 */
                  }
                  __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  goto __pyx_L56_try_end;
                  __pyx_L49_error:;
                  __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
                  /*except:*/ {
                    __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.copy_out", __pyx_clineno, __pyx_lineno, __pyx_filename);
                    if (__Pyx_GetException(&__pyx_t_11, &__pyx_t_6, &__pyx_t_4) < 0) __PYX_ERR(0, 347, __pyx_L51_except_error)
                    __Pyx_GOTREF(__pyx_t_11);
                    __Pyx_GOTREF(__pyx_t_6);
                    __Pyx_GOTREF(__pyx_t_4);
                    __pyx_t_5 = PyTuple_Pack(3, __pyx_t_11, __pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 347, __pyx_L51_except_error)
                    __Pyx_GOTREF(__pyx_t_5);
                    __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_5, NULL);
                    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                    if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 347, __pyx_L51_except_error)
                    __Pyx_GOTREF(__pyx_t_17);
                    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_17);
                    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                    if (__pyx_t_2 < 0) __PYX_ERR(0, 347, __pyx_L51_except_error)
                    __pyx_t_1 = ((!(__pyx_t_2 != 0)) != 0);
                    if (__pyx_t_1) {
                      __Pyx_GIVEREF(__pyx_t_11);
                      __Pyx_GIVEREF(__pyx_t_6);
                      __Pyx_XGIVEREF(__pyx_t_4);
                      __Pyx_ErrRestoreWithState(__pyx_t_11, __pyx_t_6, __pyx_t_4);
                      __pyx_t_11 = 0; __pyx_t_6 = 0; __pyx_t_4 = 0; 
                      __PYX_ERR(0, 347, __pyx_L51_except_error)
                    }
                    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    goto __pyx_L50_exception_handled;
                  }
                  __pyx_L51_except_error:;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __Pyx_XGIVEREF(__pyx_t_14);
                  __Pyx_XGIVEREF(__pyx_t_15);
                  __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
                  goto __pyx_L35_error;
                  __pyx_L50_exception_handled:;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __Pyx_XGIVEREF(__pyx_t_14);
                  __Pyx_XGIVEREF(__pyx_t_15);
                  __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
                  __pyx_L56_try_end:;
                }
              }
              /*finally:*/ {
                /*normal exit:*/{
                  if (__pyx_t_8) {
                    __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__95, NULL);
                    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                    if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 347, __pyx_L35_error)
                    __Pyx_GOTREF(__pyx_t_15);
                    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  }
                  goto __pyx_L48;
                }
                __pyx_L48:;
              }
              goto __pyx_L61;
              __pyx_L43_error:;
              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
              goto __pyx_L35_error;
              __pyx_L61:;
            }

            /* "asyncpg/protocol/protocol.pyx":346
 *                 # the last CopyData message.
 *                 if buffer:
 *                     try:             # <<<<<<<<<<<<<<
 *                         with timer:
 *                             await asyncio.wait_for(
 */
          }
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          goto __pyx_L42_try_end;
          __pyx_L35_error:;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

          /* "asyncpg/protocol/protocol.pyx":352
 *                                 timeout=timer.get_remaining_budget(),
 *                                 loop=self.loop)
 *                     except Exception as ex:             # <<<<<<<<<<<<<<
 *                         # Abort the COPY operation on any error in
 *                         # output sink.
 */
          __pyx_t_18 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
          if (__pyx_t_18) {
            __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.copy_out", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_11) < 0) __PYX_ERR(0, 352, __pyx_L37_except_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_GOTREF(__pyx_t_11);
            __Pyx_INCREF(__pyx_t_6);
            __Pyx_GIVEREF(__pyx_t_6);
            __pyx_cur_scope->__pyx_v_ex = __pyx_t_6;
            /*try:*/ {

              /* "asyncpg/protocol/protocol.pyx":355
 *                         # Abort the COPY operation on any error in
 *                         # output sink.
 *                         self._request_cancel()             # <<<<<<<<<<<<<<
 *                         # Make asyncio shut up about unretrieved
 *                         # QueryCanceledError
 */
              __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_request_cancel); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 355, __pyx_L67_error)
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_16 = NULL;
              if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
                __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_3);
                if (likely(__pyx_t_16)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
                  __Pyx_INCREF(__pyx_t_16);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_3, function);
                }
              }
              if (__pyx_t_16) {
                __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_16); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 355, __pyx_L67_error)
                __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
              } else {
                __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 355, __pyx_L67_error)
              }
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

              /* "asyncpg/protocol/protocol.pyx":358
 *                         # Make asyncio shut up about unretrieved
 *                         # QueryCanceledError
 *                         waiter.add_done_callback(lambda f: f.exception())             # <<<<<<<<<<<<<<
 *                         raise
 * 
 */
              __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_waiter, __pyx_n_s_add_done_callback); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 358, __pyx_L67_error)
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_16 = __Pyx_CyFunction_NewEx(&__pyx_mdef_7asyncpg_8protocol_8protocol_12BaseProtocol_8copy_out_lambda1, 0, __pyx_n_s_copy_out_locals_lambda, NULL, __pyx_n_s_asyncpg_protocol_protocol, __pyx_d, NULL); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 358, __pyx_L67_error)
              __Pyx_GOTREF(__pyx_t_16);
              __pyx_t_19 = NULL;
              if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
                __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_3);
                if (likely(__pyx_t_19)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
                  __Pyx_INCREF(__pyx_t_19);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_3, function);
                }
              }
              if (!__pyx_t_19) {
                __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_16); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 358, __pyx_L67_error)
                __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                __Pyx_GOTREF(__pyx_t_5);
              } else {
                #if CYTHON_FAST_PYCALL
                if (PyFunction_Check(__pyx_t_3)) {
                  PyObject *__pyx_temp[2] = {__pyx_t_19, __pyx_t_16};
                  __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 358, __pyx_L67_error)
                  __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                  __Pyx_GOTREF(__pyx_t_5);
                  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                } else
                #endif
                #if CYTHON_FAST_PYCCALL
                if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
                  PyObject *__pyx_temp[2] = {__pyx_t_19, __pyx_t_16};
                  __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 358, __pyx_L67_error)
                  __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                  __Pyx_GOTREF(__pyx_t_5);
                  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                } else
                #endif
                {
                  __pyx_t_20 = PyTuple_New(1+1); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 358, __pyx_L67_error)
                  __Pyx_GOTREF(__pyx_t_20);
                  __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_t_19); __pyx_t_19 = NULL;
                  __Pyx_GIVEREF(__pyx_t_16);
                  PyTuple_SET_ITEM(__pyx_t_20, 0+1, __pyx_t_16);
                  __pyx_t_16 = 0;
                  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_20, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 358, __pyx_L67_error)
                  __Pyx_GOTREF(__pyx_t_5);
                  __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                }
              }
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

              /* "asyncpg/protocol/protocol.pyx":359
 *                         # QueryCanceledError
 *                         waiter.add_done_callback(lambda f: f.exception())
 *                         raise             # <<<<<<<<<<<<<<
 * 
 *                 # done will be True upon receipt of CopyDone.
 */
              __Pyx_GIVEREF(__pyx_t_4);
              __Pyx_GIVEREF(__pyx_t_6);
              __Pyx_XGIVEREF(__pyx_t_11);
              __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_6, __pyx_t_11);
              __pyx_t_4 = 0; __pyx_t_6 = 0; __pyx_t_11 = 0; 
              __PYX_ERR(0, 359, __pyx_L67_error)
            }

            /* "asyncpg/protocol/protocol.pyx":352
 *                                 timeout=timer.get_remaining_budget(),
 *                                 loop=self.loop)
 *                     except Exception as ex:             # <<<<<<<<<<<<<<
 *                         # Abort the COPY operation on any error in
 *                         # output sink.
 */
            /*finally:*/ {
              __pyx_L67_error:;
              /*exception exit:*/{
                __Pyx_PyThreadState_assign
                __pyx_t_8 = 0; __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_t_13 = 0; __pyx_t_17 = 0; __pyx_t_23 = 0;
                __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_13, &__pyx_t_17, &__pyx_t_23);
                if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_8, &__pyx_t_15, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_8, &__pyx_t_15, &__pyx_t_14);
                __Pyx_XGOTREF(__pyx_t_8);
                __Pyx_XGOTREF(__pyx_t_15);
                __Pyx_XGOTREF(__pyx_t_14);
                __Pyx_XGOTREF(__pyx_t_13);
                __Pyx_XGOTREF(__pyx_t_17);
                __Pyx_XGOTREF(__pyx_t_23);
                __pyx_t_18 = __pyx_lineno; __pyx_t_21 = __pyx_clineno; __pyx_t_22 = __pyx_filename;
                {
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_ex);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_ex);
                  __pyx_cur_scope->__pyx_v_ex = NULL;
                }
                if (PY_MAJOR_VERSION >= 3) {
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __Pyx_XGIVEREF(__pyx_t_17);
                  __Pyx_XGIVEREF(__pyx_t_23);
                  __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_17, __pyx_t_23);
                }
                __Pyx_XGIVEREF(__pyx_t_8);
                __Pyx_XGIVEREF(__pyx_t_15);
                __Pyx_XGIVEREF(__pyx_t_14);
                __Pyx_ErrRestore(__pyx_t_8, __pyx_t_15, __pyx_t_14);
                __pyx_t_8 = 0; __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_t_13 = 0; __pyx_t_17 = 0; __pyx_t_23 = 0;
                __pyx_lineno = __pyx_t_18; __pyx_clineno = __pyx_t_21; __pyx_filename = __pyx_t_22;
                goto __pyx_L37_except_error;
              }
            }
          }
          goto __pyx_L37_except_error;
          __pyx_L37_except_error:;

          /* "asyncpg/protocol/protocol.pyx":346
 *                 # the last CopyData message.
 *                 if buffer:
 *                     try:             # <<<<<<<<<<<<<<
 *                         with timer:
 *                             await asyncio.wait_for(
 */
          __Pyx_XGIVEREF(__pyx_t_7);
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_9);
          __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_10, __pyx_t_9);
          goto __pyx_L9_error;
          __pyx_L42_try_end:;
        }

        /* "asyncpg/protocol/protocol.pyx":345
 *                 # buffer will be empty if CopyDone was received apart from
 *                 # the last CopyData message.
 *                 if buffer:             # <<<<<<<<<<<<<<
 *                     try:
 *                         with timer:
 */
      }

      /* "asyncpg/protocol/protocol.pyx":362
 * 
 *                 # done will be True upon receipt of CopyDone.
 *                 if done:             # <<<<<<<<<<<<<<
 *                     break
 * 
 */
      if (unlikely(!__pyx_cur_scope->__pyx_v_done)) { __Pyx_RaiseUnboundLocalError("done"); __PYX_ERR(0, 362, __pyx_L9_error) }
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_done); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 362, __pyx_L9_error)
      if (__pyx_t_1) {

        /* "asyncpg/protocol/protocol.pyx":363
 *                 # done will be True upon receipt of CopyDone.
 *                 if done:
 *                     break             # <<<<<<<<<<<<<<
 * 
 *                 waiter = self._new_waiter(timer.get_remaining_budget())
 */
        goto __pyx_L12_break;

        /* "asyncpg/protocol/protocol.pyx":362
 * 
 *                 # done will be True upon receipt of CopyDone.
 *                 if done:             # <<<<<<<<<<<<<<
 *                     break
 * 
 */
      }

      /* "asyncpg/protocol/protocol.pyx":365
 *                     break
 * 
 *                 waiter = self._new_waiter(timer.get_remaining_budget())             # <<<<<<<<<<<<<<
 * 
 *         finally:
 */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_timer, __pyx_n_s_get_remaining_budget); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 365, __pyx_L9_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 365, __pyx_L9_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_11 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 365, __pyx_L9_error)
      }
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = ((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_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 365, __pyx_L9_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_waiter);
      __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_waiter, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_t_6 = 0;
    }
    __pyx_L12_break:;
  }

  /* "asyncpg/protocol/protocol.pyx":368
 * 
 *         finally:
 *             self.resume_reading()             # <<<<<<<<<<<<<<
 * 
 *         return status_msg
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_t_6 = __pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol_resume_reading(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 368, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L10;
    }
    __pyx_L9_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_assign
      __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_7 = 0; __pyx_t_23 = 0; __pyx_t_17 = 0; __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
      __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_23, &__pyx_t_17, &__pyx_t_13);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_10, &__pyx_t_7) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_23);
      __Pyx_XGOTREF(__pyx_t_17);
      __Pyx_XGOTREF(__pyx_t_13);
      __pyx_t_21 = __pyx_lineno; __pyx_t_18 = __pyx_clineno; __pyx_t_24 = __pyx_filename;
      {
        __pyx_t_6 = __pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol_resume_reading(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 368, __pyx_L75_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_23);
        __Pyx_XGIVEREF(__pyx_t_17);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_17, __pyx_t_13);
      }
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_ErrRestore(__pyx_t_9, __pyx_t_10, __pyx_t_7);
      __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_7 = 0; __pyx_t_23 = 0; __pyx_t_17 = 0; __pyx_t_13 = 0;
      __pyx_lineno = __pyx_t_21; __pyx_clineno = __pyx_t_18; __pyx_filename = __pyx_t_24;
      goto __pyx_L1_error;
      __pyx_L75_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_23);
        __Pyx_XGIVEREF(__pyx_t_17);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_17, __pyx_t_13);
      }
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_23 = 0; __pyx_t_17 = 0; __pyx_t_13 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L10:;
  }

  /* "asyncpg/protocol/protocol.pyx":370
 *             self.resume_reading()
 * 
 *         return status_msg             # <<<<<<<<<<<<<<
 * 
 *     async def copy_in(self, copy_stmt, reader, data,
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(!__pyx_cur_scope->__pyx_v_status_msg)) { __Pyx_RaiseUnboundLocalError("status_msg"); __PYX_ERR(0, 370, __pyx_L1_error) }
  __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_cur_scope->__pyx_v_status_msg);
  goto __pyx_L0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "asyncpg/protocol/protocol.pyx":318
 *             return await waiter
 * 
 *     async def copy_out(self, copy_stmt, sink, 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_11);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_AddTraceback("copy_out", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_33generator7(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "asyncpg/protocol/protocol.pyx":372
 *         return status_msg
 * 
 *     async def copy_in(self, copy_stmt, reader, data,             # <<<<<<<<<<<<<<
 *                       records, PreparedStatementState record_stmt, timeout):
 *         cdef:
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_32copy_in(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_32copy_in(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_copy_stmt = 0;
  PyObject *__pyx_v_reader = 0;
  PyObject *__pyx_v_data = 0;
  PyObject *__pyx_v_records = 0;
  struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_record_stmt = 0;
  PyObject *__pyx_v_timeout = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("copy_in (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_copy_stmt,&__pyx_n_s_reader,&__pyx_n_s_data,&__pyx_n_s_records,&__pyx_n_s_record_stmt,&__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);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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_copy_stmt)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_reader)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("copy_in", 1, 6, 6, 1); __PYX_ERR(0, 372, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("copy_in", 1, 6, 6, 2); __PYX_ERR(0, 372, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_records)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("copy_in", 1, 6, 6, 3); __PYX_ERR(0, 372, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_record_stmt)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("copy_in", 1, 6, 6, 4); __PYX_ERR(0, 372, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_timeout)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("copy_in", 1, 6, 6, 5); __PYX_ERR(0, 372, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "copy_in") < 0)) __PYX_ERR(0, 372, __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_copy_stmt = values[0];
    __pyx_v_reader = values[1];
    __pyx_v_data = values[2];
    __pyx_v_records = values[3];
    __pyx_v_record_stmt = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)values[4]);
    __pyx_v_timeout = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("copy_in", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 372, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.copy_in", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_record_stmt), __pyx_ptype_7asyncpg_8protocol_8protocol_PreparedStatementState, 1, "record_stmt", 0))) __PYX_ERR(0, 373, __pyx_L1_error)
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_31copy_in(((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self), __pyx_v_copy_stmt, __pyx_v_reader, __pyx_v_data, __pyx_v_records, __pyx_v_record_stmt, __pyx_v_timeout);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/protocol.pyx":481
 *             self._request_cancel()
 *             # Make asyncio shut up about unretrieved QueryCanceledError
 *             waiter.add_done_callback(lambda f: f.exception())             # <<<<<<<<<<<<<<
 *             raise
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_7copy_in_lambda2(PyObject *__pyx_self, PyObject *__pyx_v_f); /*proto*/
static PyMethodDef __pyx_mdef_7asyncpg_8protocol_8protocol_12BaseProtocol_7copy_in_lambda2 = {"lambda2", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_7copy_in_lambda2, METH_O, 0};
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_7copy_in_lambda2(PyObject *__pyx_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("lambda2 (wrapper)", 0);
  __pyx_r = __pyx_lambda_funcdef_lambda2(__pyx_self, ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_lambda_funcdef_lambda2(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("lambda2", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_exception); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 481, __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(0, 481, __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(0, 481, __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;

  /* 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.copy_in.lambda2", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/protocol.pyx":372
 *         return status_msg
 * 
 *     async def copy_in(self, copy_stmt, reader, data,             # <<<<<<<<<<<<<<
 *                       records, PreparedStatementState record_stmt, timeout):
 *         cdef:
 */

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_31copy_in(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_copy_stmt, PyObject *__pyx_v_reader, PyObject *__pyx_v_data, PyObject *__pyx_v_records, struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *__pyx_v_record_stmt, PyObject *__pyx_v_timeout) {
  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("copy_in", 0);
  __pyx_cur_scope = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in *)__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in(__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 372, __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_copy_stmt = __pyx_v_copy_stmt;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_copy_stmt);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_copy_stmt);
  __pyx_cur_scope->__pyx_v_reader = __pyx_v_reader;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_reader);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_reader);
  __pyx_cur_scope->__pyx_v_data = __pyx_v_data;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_data);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_data);
  __pyx_cur_scope->__pyx_v_records = __pyx_v_records;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_records);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_records);
  __pyx_cur_scope->__pyx_v_record_stmt = __pyx_v_record_stmt;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_record_stmt);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_record_stmt);
  __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_33generator7, (PyObject *) __pyx_cur_scope, __pyx_n_s_copy_in, __pyx_n_s_BaseProtocol_copy_in, __pyx_n_s_asyncpg_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(0, 372, __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.copy_in", __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_33generator7(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in *__pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in *)__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;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  Py_ssize_t __pyx_t_10;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  PyObject *(*__pyx_t_17)(PyObject *);
  Py_ssize_t __pyx_t_18;
  Py_ssize_t __pyx_t_19;
  PyObject *__pyx_t_20;
  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;
  PyObject *__pyx_t_26 = NULL;
  PyObject *__pyx_t_27 = NULL;
  PyObject *__pyx_t_28 = NULL;
  int __pyx_t_29;
  char const *__pyx_t_30;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("copy_in", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L5_resume_from_await;
    case 2: goto __pyx_L7_resume_from_await;
    case 3: goto __pyx_L40_resume_from_await;
    case 4: goto __pyx_L75_resume_from_await;
    case 5: goto __pyx_L94_resume_from_await;
    case 6: goto __pyx_L99_resume_from_await;
    case 7: goto __pyx_L110_resume_from_await;
    case 8: goto __pyx_L124_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 372, __pyx_L1_error)

  /* "asyncpg/protocol/protocol.pyx":379
 *             Codec codec
 * 
 *         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":380
 * 
 *         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();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 1;
      return __pyx_r;
      __pyx_L5_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 380, __pyx_L1_error)
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (exc_type) {
        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
        else __PYX_ERR(0, 380, __pyx_L1_error)
      }
    }

    /* "asyncpg/protocol/protocol.pyx":379
 *             Codec codec
 * 
 *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
 *             await self.cancel_waiter
 *         if self.cancel_sent_waiter is not None:
 */
  }

  /* "asyncpg/protocol/protocol.pyx":381
 *         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":382
 *             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();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 2;
      return __pyx_r;
      __pyx_L7_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 382, __pyx_L1_error)
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (exc_type) {
        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
        else __PYX_ERR(0, 382, __pyx_L1_error)
      }
    }

    /* "asyncpg/protocol/protocol.pyx":383
 *         if self.cancel_sent_waiter is not None:
 *             await self.cancel_sent_waiter
 *             self.cancel_sent_waiter = None             # <<<<<<<<<<<<<<
 * 
 *         self._check_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":381
 *         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":385
 *             self.cancel_sent_waiter = None
 * 
 *         self._check_state()             # <<<<<<<<<<<<<<
 * 
 *         timeout = self._get_timeout_impl(timeout)
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_check_state(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":387
 *         self._check_state()
 * 
 *         timeout = self._get_timeout_impl(timeout)             # <<<<<<<<<<<<<<
 *         timer = Timer(timeout)
 * 
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__get_timeout_impl(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_timeout); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 387, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_timeout);
  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_timeout, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":388
 * 
 *         timeout = self._get_timeout_impl(timeout)
 *         timer = Timer(timeout)             # <<<<<<<<<<<<<<
 * 
 *         waiter = self._new_waiter(timer.get_remaining_budget())
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_Timer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 388, __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_cur_scope->__pyx_v_timeout); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 388, __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_cur_scope->__pyx_v_timeout};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 388, __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_cur_scope->__pyx_v_timeout};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 388, __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(0, 388, __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_cur_scope->__pyx_v_timeout);
      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_timeout);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_cur_scope->__pyx_v_timeout);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 388, __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_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_timer = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":390
 *         timer = Timer(timeout)
 * 
 *         waiter = self._new_waiter(timer.get_remaining_budget())             # <<<<<<<<<<<<<<
 * 
 *         # Initiate COPY IN.
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_timer, __pyx_n_s_get_remaining_budget); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 390, __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_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 390, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 390, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __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_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 390, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_cur_scope->__pyx_v_waiter = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "asyncpg/protocol/protocol.pyx":393
 * 
 *         # Initiate COPY IN.
 *         self._copy_in(copy_stmt)             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
  if (!(likely(PyUnicode_CheckExact(__pyx_cur_scope->__pyx_v_copy_stmt))||((__pyx_cur_scope->__pyx_v_copy_stmt) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_cur_scope->__pyx_v_copy_stmt)->tp_name), 0))) __PYX_ERR(0, 393, __pyx_L1_error)
  __pyx_t_4 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._copy_in(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_cur_scope->__pyx_v_self), ((PyObject*)__pyx_cur_scope->__pyx_v_copy_stmt)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 393, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "asyncpg/protocol/protocol.pyx":395
 *         self._copy_in(copy_stmt)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if record_stmt is not None:
 *                 # copy_in_records in binary mode
 */
  {
    __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":396
 * 
 *         try:
 *             if record_stmt is not None:             # <<<<<<<<<<<<<<
 *                 # copy_in_records in binary mode
 *                 wbuf = WriteBuffer.new()
 */
      __pyx_t_1 = (((PyObject *)__pyx_cur_scope->__pyx_v_record_stmt) != Py_None);
      __pyx_t_2 = (__pyx_t_1 != 0);
      if (__pyx_t_2) {

        /* "asyncpg/protocol/protocol.pyx":398
 *             if record_stmt is not None:
 *                 # copy_in_records in binary mode
 *                 wbuf = WriteBuffer.new()             # <<<<<<<<<<<<<<
 *                 # Signature
 *                 wbuf.write_bytes(_COPY_SIGNATURE)
 */
        __pyx_t_4 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new()); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 398, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        __pyx_cur_scope->__pyx_v_wbuf = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_4);
        __pyx_t_4 = 0;

        /* "asyncpg/protocol/protocol.pyx":400
 *                 wbuf = WriteBuffer.new()
 *                 # Signature
 *                 wbuf.write_bytes(_COPY_SIGNATURE)             # <<<<<<<<<<<<<<
 *                 # Flags field
 *                 wbuf.write_int32(0)
 */
        __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_bytes(__pyx_cur_scope->__pyx_v_wbuf, __pyx_kp_b_PGCOPY); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 400, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "asyncpg/protocol/protocol.pyx":402
 *                 wbuf.write_bytes(_COPY_SIGNATURE)
 *                 # Flags field
 *                 wbuf.write_int32(0)             # <<<<<<<<<<<<<<
 *                 # No header extension
 *                 wbuf.write_int32(0)
 */
        __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_cur_scope->__pyx_v_wbuf, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 402, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "asyncpg/protocol/protocol.pyx":404
 *                 wbuf.write_int32(0)
 *                 # No header extension
 *                 wbuf.write_int32(0)             # <<<<<<<<<<<<<<
 * 
 *                 record_stmt._ensure_rows_decoder()
 */
        __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_cur_scope->__pyx_v_wbuf, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 404, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "asyncpg/protocol/protocol.pyx":406
 *                 wbuf.write_int32(0)
 * 
 *                 record_stmt._ensure_rows_decoder()             # <<<<<<<<<<<<<<
 *                 codecs = record_stmt.rows_codecs
 *                 num_cols = len(codecs)
 */
        __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_22PreparedStatementState__ensure_rows_decoder(__pyx_cur_scope->__pyx_v_record_stmt); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 406, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "asyncpg/protocol/protocol.pyx":407
 * 
 *                 record_stmt._ensure_rows_decoder()
 *                 codecs = record_stmt.rows_codecs             # <<<<<<<<<<<<<<
 *                 num_cols = len(codecs)
 *                 settings = self.settings
 */
        __pyx_t_4 = __pyx_cur_scope->__pyx_v_record_stmt->rows_codecs;
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        __pyx_cur_scope->__pyx_v_codecs = ((PyObject*)__pyx_t_4);
        __pyx_t_4 = 0;

        /* "asyncpg/protocol/protocol.pyx":408
 *                 record_stmt._ensure_rows_decoder()
 *                 codecs = record_stmt.rows_codecs
 *                 num_cols = len(codecs)             # <<<<<<<<<<<<<<
 *                 settings = self.settings
 * 
 */
        if (unlikely(__pyx_cur_scope->__pyx_v_codecs == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
          __PYX_ERR(0, 408, __pyx_L8_error)
        }
        __pyx_t_10 = PyTuple_GET_SIZE(__pyx_cur_scope->__pyx_v_codecs); if (unlikely(__pyx_t_10 == ((Py_ssize_t)-1))) __PYX_ERR(0, 408, __pyx_L8_error)
        __pyx_cur_scope->__pyx_v_num_cols = __pyx_t_10;

        /* "asyncpg/protocol/protocol.pyx":409
 *                 codecs = record_stmt.rows_codecs
 *                 num_cols = len(codecs)
 *                 settings = self.settings             # <<<<<<<<<<<<<<
 * 
 *                 for codec in codecs:
 */
        __pyx_t_4 = ((PyObject *)__pyx_cur_scope->__pyx_v_self->settings);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        __pyx_cur_scope->__pyx_v_settings = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *)__pyx_t_4);
        __pyx_t_4 = 0;

        /* "asyncpg/protocol/protocol.pyx":411
 *                 settings = self.settings
 * 
 *                 for codec in codecs:             # <<<<<<<<<<<<<<
 *                     if (not codec.has_encoder() or
 *                             codec.format != PG_FORMAT_BINARY):
 */
        if (unlikely(__pyx_cur_scope->__pyx_v_codecs == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
          __PYX_ERR(0, 411, __pyx_L8_error)
        }
        __pyx_t_4 = __pyx_cur_scope->__pyx_v_codecs; __Pyx_INCREF(__pyx_t_4); __pyx_t_10 = 0;
        for (;;) {
          if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_10); __Pyx_INCREF(__pyx_t_3); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 411, __pyx_L8_error)
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 411, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
          if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_7asyncpg_8protocol_8protocol_Codec))))) __PYX_ERR(0, 411, __pyx_L8_error)
          __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_codec));
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_3));
          __Pyx_GIVEREF(__pyx_t_3);
          __pyx_t_3 = 0;

          /* "asyncpg/protocol/protocol.pyx":412
 * 
 *                 for codec in codecs:
 *                     if (not codec.has_encoder() or             # <<<<<<<<<<<<<<
 *                             codec.format != PG_FORMAT_BINARY):
 *                         raise apg_exc.InternalClientError(
 */
          __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_has_encoder(__pyx_cur_scope->__pyx_v_codec); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 412, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 412, __pyx_L8_error)
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_11 = ((!__pyx_t_1) != 0);
          if (!__pyx_t_11) {
          } else {
            __pyx_t_2 = __pyx_t_11;
            goto __pyx_L18_bool_binop_done;
          }

          /* "asyncpg/protocol/protocol.pyx":413
 *                 for codec in codecs:
 *                     if (not codec.has_encoder() or
 *                             codec.format != PG_FORMAT_BINARY):             # <<<<<<<<<<<<<<
 *                         raise apg_exc.InternalClientError(
 *                             'no binary format encoder for '
 */
          __pyx_t_11 = ((__pyx_cur_scope->__pyx_v_codec->format != __pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_BINARY) != 0);
          __pyx_t_2 = __pyx_t_11;
          __pyx_L18_bool_binop_done:;

          /* "asyncpg/protocol/protocol.pyx":412
 * 
 *                 for codec in codecs:
 *                     if (not codec.has_encoder() or             # <<<<<<<<<<<<<<
 *                             codec.format != PG_FORMAT_BINARY):
 *                         raise apg_exc.InternalClientError(
 */
          if (__pyx_t_2) {

            /* "asyncpg/protocol/protocol.pyx":414
 *                     if (not codec.has_encoder() or
 *                             codec.format != PG_FORMAT_BINARY):
 *                         raise apg_exc.InternalClientError(             # <<<<<<<<<<<<<<
 *                             'no binary format encoder for '
 *                             'type {} (OID {})'.format(codec.name, codec.oid))
 */
            __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 414, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_InternalClientError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 414, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

            /* "asyncpg/protocol/protocol.pyx":416
 *                         raise apg_exc.InternalClientError(
 *                             'no binary format encoder for '
 *                             'type {} (OID {})'.format(codec.name, codec.oid))             # <<<<<<<<<<<<<<
 * 
 *                 for row in records:
 */
            __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_no_binary_format_encoder_for_typ, __pyx_n_s_format); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 416, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_12);
            __pyx_t_13 = __Pyx_PyInt_From_uint32_t(__pyx_cur_scope->__pyx_v_codec->oid); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 416, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_13);
            __pyx_t_14 = NULL;
            __pyx_t_15 = 0;
            if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) {
              __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_12);
              if (likely(__pyx_t_14)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
                __Pyx_INCREF(__pyx_t_14);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_12, function);
                __pyx_t_15 = 1;
              }
            }
            #if CYTHON_FAST_PYCALL
            if (PyFunction_Check(__pyx_t_12)) {
              PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_cur_scope->__pyx_v_codec->name, __pyx_t_13};
              __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 416, __pyx_L8_error)
              __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_GOTREF(__pyx_t_6);
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            } else
            #endif
            #if CYTHON_FAST_PYCCALL
            if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
              PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_cur_scope->__pyx_v_codec->name, __pyx_t_13};
              __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 416, __pyx_L8_error)
              __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_GOTREF(__pyx_t_6);
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            } else
            #endif
            {
              __pyx_t_16 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 416, __pyx_L8_error)
              __Pyx_GOTREF(__pyx_t_16);
              if (__pyx_t_14) {
                __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_14); __pyx_t_14 = NULL;
              }
              __Pyx_INCREF(__pyx_cur_scope->__pyx_v_codec->name);
              __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_codec->name);
              PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_15, __pyx_cur_scope->__pyx_v_codec->name);
              __Pyx_GIVEREF(__pyx_t_13);
              PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_15, __pyx_t_13);
              __pyx_t_13 = 0;
              __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_16, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 416, __pyx_L8_error)
              __Pyx_GOTREF(__pyx_t_6);
              __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
            }
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            __pyx_t_12 = NULL;
            if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
              __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_5);
              if (likely(__pyx_t_12)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
                __Pyx_INCREF(__pyx_t_12);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_5, function);
              }
            }
            if (!__pyx_t_12) {
              __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 414, __pyx_L8_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_5)) {
                PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_6};
                __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 414, __pyx_L8_error)
                __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 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_5)) {
                PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_6};
                __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 414, __pyx_L8_error)
                __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                __Pyx_GOTREF(__pyx_t_3);
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              } else
              #endif
              {
                __pyx_t_16 = PyTuple_New(1+1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 414, __pyx_L8_error)
                __Pyx_GOTREF(__pyx_t_16);
                __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_12); __pyx_t_12 = NULL;
                __Pyx_GIVEREF(__pyx_t_6);
                PyTuple_SET_ITEM(__pyx_t_16, 0+1, __pyx_t_6);
                __pyx_t_6 = 0;
                __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_16, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 414, __pyx_L8_error)
                __Pyx_GOTREF(__pyx_t_3);
                __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
              }
            }
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_Raise(__pyx_t_3, 0, 0, 0);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __PYX_ERR(0, 414, __pyx_L8_error)

            /* "asyncpg/protocol/protocol.pyx":412
 * 
 *                 for codec in codecs:
 *                     if (not codec.has_encoder() or             # <<<<<<<<<<<<<<
 *                             codec.format != PG_FORMAT_BINARY):
 *                         raise apg_exc.InternalClientError(
 */
          }

          /* "asyncpg/protocol/protocol.pyx":411
 *                 settings = self.settings
 * 
 *                 for codec in codecs:             # <<<<<<<<<<<<<<
 *                     if (not codec.has_encoder() or
 *                             codec.format != PG_FORMAT_BINARY):
 */
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "asyncpg/protocol/protocol.pyx":418
 *                             'type {} (OID {})'.format(codec.name, codec.oid))
 * 
 *                 for row in records:             # <<<<<<<<<<<<<<
 *                     # Tuple header
 *                     wbuf.write_int16(<int16_t>num_cols)
 */
        if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_records)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_records)) {
          __pyx_t_4 = __pyx_cur_scope->__pyx_v_records; __Pyx_INCREF(__pyx_t_4); __pyx_t_10 = 0;
          __pyx_t_17 = NULL;
        } else {
          __pyx_t_10 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_records); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 418, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_17 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 418, __pyx_L8_error)
        }
        for (;;) {
          if (likely(!__pyx_t_17)) {
            if (likely(PyList_CheckExact(__pyx_t_4))) {
              if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_4)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_10); __Pyx_INCREF(__pyx_t_3); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 418, __pyx_L8_error)
              #else
              __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 418, __pyx_L8_error)
              __Pyx_GOTREF(__pyx_t_3);
              #endif
            } else {
              if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_10); __Pyx_INCREF(__pyx_t_3); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 418, __pyx_L8_error)
              #else
              __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 418, __pyx_L8_error)
              __Pyx_GOTREF(__pyx_t_3);
              #endif
            }
          } else {
            __pyx_t_3 = __pyx_t_17(__pyx_t_4);
            if (unlikely(!__pyx_t_3)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                else __PYX_ERR(0, 418, __pyx_L8_error)
              }
              break;
            }
            __Pyx_GOTREF(__pyx_t_3);
          }
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_row);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_row, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_3);
          __pyx_t_3 = 0;

          /* "asyncpg/protocol/protocol.pyx":420
 *                 for row in records:
 *                     # Tuple header
 *                     wbuf.write_int16(<int16_t>num_cols)             # <<<<<<<<<<<<<<
 *                     # Tuple data
 *                     for i in range(num_cols):
 */
          __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int16(__pyx_cur_scope->__pyx_v_wbuf, ((int16_t)__pyx_cur_scope->__pyx_v_num_cols)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 420, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

          /* "asyncpg/protocol/protocol.pyx":422
 *                     wbuf.write_int16(<int16_t>num_cols)
 *                     # Tuple data
 *                     for i in range(num_cols):             # <<<<<<<<<<<<<<
 *                         item = row[i]
 *                         if item is None:
 */
          __pyx_t_18 = __pyx_cur_scope->__pyx_v_num_cols;
          for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) {
            __pyx_cur_scope->__pyx_v_i = __pyx_t_19;

            /* "asyncpg/protocol/protocol.pyx":423
 *                     # Tuple data
 *                     for i in range(num_cols):
 *                         item = row[i]             # <<<<<<<<<<<<<<
 *                         if item is None:
 *                             wbuf.write_int32(-1)
 */
            __pyx_t_3 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_row, __pyx_cur_scope->__pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 423, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_item);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_item, __pyx_t_3);
            __Pyx_GIVEREF(__pyx_t_3);
            __pyx_t_3 = 0;

            /* "asyncpg/protocol/protocol.pyx":424
 *                     for i in range(num_cols):
 *                         item = row[i]
 *                         if item is None:             # <<<<<<<<<<<<<<
 *                             wbuf.write_int32(-1)
 *                         else:
 */
            __pyx_t_2 = (__pyx_cur_scope->__pyx_v_item == Py_None);
            __pyx_t_11 = (__pyx_t_2 != 0);
            if (__pyx_t_11) {

              /* "asyncpg/protocol/protocol.pyx":425
 *                         item = row[i]
 *                         if item is None:
 *                             wbuf.write_int32(-1)             # <<<<<<<<<<<<<<
 *                         else:
 *                             codec = <Codec>cpython.PyTuple_GET_ITEM(codecs, i)
 */
              __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int32(__pyx_cur_scope->__pyx_v_wbuf, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 425, __pyx_L8_error)
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

              /* "asyncpg/protocol/protocol.pyx":424
 *                     for i in range(num_cols):
 *                         item = row[i]
 *                         if item is None:             # <<<<<<<<<<<<<<
 *                             wbuf.write_int32(-1)
 *                         else:
 */
              goto __pyx_L24;
            }

            /* "asyncpg/protocol/protocol.pyx":427
 *                             wbuf.write_int32(-1)
 *                         else:
 *                             codec = <Codec>cpython.PyTuple_GET_ITEM(codecs, i)             # <<<<<<<<<<<<<<
 *                             codec.encode(settings, wbuf, item)
 * 
 */
            /*else*/ {
              __pyx_t_20 = PyTuple_GET_ITEM(__pyx_cur_scope->__pyx_v_codecs, __pyx_cur_scope->__pyx_v_i);
              __pyx_t_3 = ((PyObject *)__pyx_t_20);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_codec));
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_codec, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *)__pyx_t_3));
              __Pyx_GIVEREF(__pyx_t_3);
              __pyx_t_3 = 0;

              /* "asyncpg/protocol/protocol.pyx":428
 *                         else:
 *                             codec = <Codec>cpython.PyTuple_GET_ITEM(codecs, i)
 *                             codec.encode(settings, wbuf, item)             # <<<<<<<<<<<<<<
 * 
 *                     if wbuf.len() >= _COPY_BUFFER_SIZE:
 */
              __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_5Codec_encode(__pyx_cur_scope->__pyx_v_codec, __pyx_cur_scope->__pyx_v_settings, __pyx_cur_scope->__pyx_v_wbuf, __pyx_cur_scope->__pyx_v_item); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 428, __pyx_L8_error)
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            }
            __pyx_L24:;
          }

          /* "asyncpg/protocol/protocol.pyx":430
 *                             codec.encode(settings, wbuf, item)
 * 
 *                     if wbuf.len() >= _COPY_BUFFER_SIZE:             # <<<<<<<<<<<<<<
 *                         with timer:
 *                             await self.writing_allowed.wait()
 */
          __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_len(__pyx_cur_scope->__pyx_v_wbuf); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 430, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_int_524288, Py_GE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 430, __pyx_L8_error)
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 430, __pyx_L8_error)
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (__pyx_t_11) {

            /* "asyncpg/protocol/protocol.pyx":431
 * 
 *                     if wbuf.len() >= _COPY_BUFFER_SIZE:
 *                         with timer:             # <<<<<<<<<<<<<<
 *                             await self.writing_allowed.wait()
 *                         self._write_copy_data_msg(wbuf)
 */
            /*with:*/ {
              __pyx_t_21 = __Pyx_PyObject_LookupSpecial(__pyx_cur_scope->__pyx_v_timer, __pyx_n_s_exit); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 431, __pyx_L8_error)
              __Pyx_GOTREF(__pyx_t_21);
              __pyx_t_3 = __Pyx_PyObject_LookupSpecial(__pyx_cur_scope->__pyx_v_timer, __pyx_n_s_enter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 431, __pyx_L26_error)
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_16 = NULL;
              if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
                __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_3);
                if (likely(__pyx_t_16)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
                  __Pyx_INCREF(__pyx_t_16);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_3, function);
                }
              }
              if (__pyx_t_16) {
                __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_16); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 431, __pyx_L26_error)
                __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
              } else {
                __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 431, __pyx_L26_error)
              }
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              /*try:*/ {
                {
                  __Pyx_ExceptionSave(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
                  __Pyx_XGOTREF(__pyx_t_22);
                  __Pyx_XGOTREF(__pyx_t_23);
                  __Pyx_XGOTREF(__pyx_t_24);
                  /*try:*/ {

                    /* "asyncpg/protocol/protocol.pyx":432
 *                     if wbuf.len() >= _COPY_BUFFER_SIZE:
 *                         with timer:
 *                             await self.writing_allowed.wait()             # <<<<<<<<<<<<<<
 *                         self._write_copy_data_msg(wbuf)
 *                         wbuf = WriteBuffer.new()
 */
                    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_writing_allowed); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 432, __pyx_L32_error)
                    __Pyx_GOTREF(__pyx_t_3);
                    __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_wait); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 432, __pyx_L32_error)
                    __Pyx_GOTREF(__pyx_t_16);
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __pyx_t_3 = NULL;
                    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_16))) {
                      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_16);
                      if (likely(__pyx_t_3)) {
                        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16);
                        __Pyx_INCREF(__pyx_t_3);
                        __Pyx_INCREF(function);
                        __Pyx_DECREF_SET(__pyx_t_16, function);
                      }
                    }
                    if (__pyx_t_3) {
                      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 432, __pyx_L32_error)
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    } else {
                      __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_16); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 432, __pyx_L32_error)
                    }
                    __Pyx_GOTREF(__pyx_t_5);
                    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                    __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_t_4);
                      __pyx_cur_scope->__pyx_t_0 = __pyx_t_4;
                      __Pyx_XGIVEREF(__pyx_t_7);
                      __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
                      __Pyx_XGIVEREF(__pyx_t_8);
                      __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
                      __Pyx_XGIVEREF(__pyx_t_9);
                      __pyx_cur_scope->__pyx_t_3 = __pyx_t_9;
                      __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                      __pyx_cur_scope->__pyx_t_5 = __pyx_t_17;
                      __Pyx_XGIVEREF(__pyx_t_21);
                      __pyx_cur_scope->__pyx_t_6 = __pyx_t_21;
                      __Pyx_XGIVEREF(__pyx_t_22);
                      __pyx_cur_scope->__pyx_t_7 = __pyx_t_22;
                      __Pyx_XGIVEREF(__pyx_t_23);
                      __pyx_cur_scope->__pyx_t_8 = __pyx_t_23;
                      __Pyx_XGIVEREF(__pyx_t_24);
                      __pyx_cur_scope->__pyx_t_9 = __pyx_t_24;
                      __Pyx_XGIVEREF(__pyx_r);
                      __Pyx_RefNannyFinishContext();
                      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                      /* return from generator, awaiting value */
                      __pyx_generator->resume_label = 3;
                      return __pyx_r;
                      __pyx_L40_resume_from_await:;
                      __pyx_t_4 = __pyx_cur_scope->__pyx_t_0;
                      __pyx_cur_scope->__pyx_t_0 = 0;
                      __Pyx_XGOTREF(__pyx_t_4);
                      __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
                      __pyx_cur_scope->__pyx_t_1 = 0;
                      __Pyx_XGOTREF(__pyx_t_7);
                      __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
                      __pyx_cur_scope->__pyx_t_2 = 0;
                      __Pyx_XGOTREF(__pyx_t_8);
                      __pyx_t_9 = __pyx_cur_scope->__pyx_t_3;
                      __pyx_cur_scope->__pyx_t_3 = 0;
                      __Pyx_XGOTREF(__pyx_t_9);
                      __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                      __pyx_t_17 = __pyx_cur_scope->__pyx_t_5;
                      __pyx_t_21 = __pyx_cur_scope->__pyx_t_6;
                      __pyx_cur_scope->__pyx_t_6 = 0;
                      __Pyx_XGOTREF(__pyx_t_21);
                      __pyx_t_22 = __pyx_cur_scope->__pyx_t_7;
                      __pyx_cur_scope->__pyx_t_7 = 0;
                      __Pyx_XGOTREF(__pyx_t_22);
                      __pyx_t_23 = __pyx_cur_scope->__pyx_t_8;
                      __pyx_cur_scope->__pyx_t_8 = 0;
                      __Pyx_XGOTREF(__pyx_t_23);
                      __pyx_t_24 = __pyx_cur_scope->__pyx_t_9;
                      __pyx_cur_scope->__pyx_t_9 = 0;
                      __Pyx_XGOTREF(__pyx_t_24);
                      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 432, __pyx_L32_error)
                    } else {
                      PyObject* exc_type = __Pyx_PyErr_Occurred();
                      if (exc_type) {
                        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
                        else __PYX_ERR(0, 432, __pyx_L32_error)
                      }
                    }

                    /* "asyncpg/protocol/protocol.pyx":431
 * 
 *                     if wbuf.len() >= _COPY_BUFFER_SIZE:
 *                         with timer:             # <<<<<<<<<<<<<<
 *                             await self.writing_allowed.wait()
 *                         self._write_copy_data_msg(wbuf)
 */
                  }
                  __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                  __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                  goto __pyx_L39_try_end;
                  __pyx_L32_error:;
                  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                  __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                  __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  /*except:*/ {
                    __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.copy_in", __pyx_clineno, __pyx_lineno, __pyx_filename);
                    if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_16, &__pyx_t_3) < 0) __PYX_ERR(0, 431, __pyx_L34_except_error)
                    __Pyx_GOTREF(__pyx_t_5);
                    __Pyx_GOTREF(__pyx_t_16);
                    __Pyx_GOTREF(__pyx_t_3);
                    __pyx_t_6 = PyTuple_Pack(3, __pyx_t_5, __pyx_t_16, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 431, __pyx_L34_except_error)
                    __Pyx_GOTREF(__pyx_t_6);
                    __pyx_t_25 = __Pyx_PyObject_Call(__pyx_t_21, __pyx_t_6, NULL);
                    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 431, __pyx_L34_except_error)
                    __Pyx_GOTREF(__pyx_t_25);
                    __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_25);
                    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                    if (__pyx_t_11 < 0) __PYX_ERR(0, 431, __pyx_L34_except_error)
                    __pyx_t_2 = ((!(__pyx_t_11 != 0)) != 0);
                    if (__pyx_t_2) {
                      __Pyx_GIVEREF(__pyx_t_5);
                      __Pyx_GIVEREF(__pyx_t_16);
                      __Pyx_XGIVEREF(__pyx_t_3);
                      __Pyx_ErrRestoreWithState(__pyx_t_5, __pyx_t_16, __pyx_t_3);
                      __pyx_t_5 = 0; __pyx_t_16 = 0; __pyx_t_3 = 0; 
                      __PYX_ERR(0, 431, __pyx_L34_except_error)
                    }
                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    goto __pyx_L33_exception_handled;
                  }
                  __pyx_L34_except_error:;
                  __Pyx_XGIVEREF(__pyx_t_22);
                  __Pyx_XGIVEREF(__pyx_t_23);
                  __Pyx_XGIVEREF(__pyx_t_24);
                  __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_23, __pyx_t_24);
                  goto __pyx_L8_error;
                  __pyx_L33_exception_handled:;
                  __Pyx_XGIVEREF(__pyx_t_22);
                  __Pyx_XGIVEREF(__pyx_t_23);
                  __Pyx_XGIVEREF(__pyx_t_24);
                  __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_23, __pyx_t_24);
                  __pyx_L39_try_end:;
                }
              }
              /*finally:*/ {
                /*normal exit:*/{
                  if (__pyx_t_21) {
                    __pyx_t_24 = __Pyx_PyObject_Call(__pyx_t_21, __pyx_tuple__96, NULL);
                    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                    if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 431, __pyx_L8_error)
                    __Pyx_GOTREF(__pyx_t_24);
                    __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                  }
                  goto __pyx_L31;
                }
                __pyx_L31:;
              }
              goto __pyx_L44;
              __pyx_L26_error:;
              __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
              goto __pyx_L8_error;
              __pyx_L44:;
            }

            /* "asyncpg/protocol/protocol.pyx":433
 *                         with timer:
 *                             await self.writing_allowed.wait()
 *                         self._write_copy_data_msg(wbuf)             # <<<<<<<<<<<<<<
 *                         wbuf = WriteBuffer.new()
 * 
 */
            __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._write_copy_data_msg(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_cur_scope->__pyx_v_self), ((PyObject *)__pyx_cur_scope->__pyx_v_wbuf)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 433, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

            /* "asyncpg/protocol/protocol.pyx":434
 *                             await self.writing_allowed.wait()
 *                         self._write_copy_data_msg(wbuf)
 *                         wbuf = WriteBuffer.new()             # <<<<<<<<<<<<<<
 * 
 *                 # End of binary copy.
 */
            __pyx_t_3 = ((PyObject *)__pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_new()); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 434, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_GOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_wbuf));
            __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_wbuf, ((struct __pyx_obj_7asyncpg_8protocol_8protocol_WriteBuffer *)__pyx_t_3));
            __Pyx_GIVEREF(__pyx_t_3);
            __pyx_t_3 = 0;

            /* "asyncpg/protocol/protocol.pyx":430
 *                             codec.encode(settings, wbuf, item)
 * 
 *                     if wbuf.len() >= _COPY_BUFFER_SIZE:             # <<<<<<<<<<<<<<
 *                         with timer:
 *                             await self.writing_allowed.wait()
 */
          }

          /* "asyncpg/protocol/protocol.pyx":418
 *                             'type {} (OID {})'.format(codec.name, codec.oid))
 * 
 *                 for row in records:             # <<<<<<<<<<<<<<
 *                     # Tuple header
 *                     wbuf.write_int16(<int16_t>num_cols)
 */
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "asyncpg/protocol/protocol.pyx":437
 * 
 *                 # End of binary copy.
 *                 wbuf.write_int16(-1)             # <<<<<<<<<<<<<<
 *                 self._write_copy_data_msg(wbuf)
 * 
 */
        __pyx_t_4 = __pyx_f_7asyncpg_8protocol_8protocol_11WriteBuffer_write_int16(__pyx_cur_scope->__pyx_v_wbuf, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 437, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "asyncpg/protocol/protocol.pyx":438
 *                 # End of binary copy.
 *                 wbuf.write_int16(-1)
 *                 self._write_copy_data_msg(wbuf)             # <<<<<<<<<<<<<<
 * 
 *             elif reader is not None:
 */
        __pyx_t_4 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._write_copy_data_msg(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_cur_scope->__pyx_v_self), ((PyObject *)__pyx_cur_scope->__pyx_v_wbuf)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 438, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "asyncpg/protocol/protocol.pyx":396
 * 
 *         try:
 *             if record_stmt is not None:             # <<<<<<<<<<<<<<
 *                 # copy_in_records in binary mode
 *                 wbuf = WriteBuffer.new()
 */
        goto __pyx_L14;
      }

      /* "asyncpg/protocol/protocol.pyx":440
 *                 self._write_copy_data_msg(wbuf)
 * 
 *             elif reader is not None:             # <<<<<<<<<<<<<<
 *                 try:
 *                     aiter = reader.__aiter__
 */
      __pyx_t_2 = (__pyx_cur_scope->__pyx_v_reader != Py_None);
      __pyx_t_11 = (__pyx_t_2 != 0);
      if (__pyx_t_11) {

        /* "asyncpg/protocol/protocol.pyx":441
 * 
 *             elif reader is not None:
 *                 try:             # <<<<<<<<<<<<<<
 *                     aiter = reader.__aiter__
 *                 except AttributeError:
 */
        {
          __Pyx_ExceptionSave(&__pyx_t_21, &__pyx_t_24, &__pyx_t_23);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_24);
          __Pyx_XGOTREF(__pyx_t_23);
          /*try:*/ {

            /* "asyncpg/protocol/protocol.pyx":442
 *             elif reader is not None:
 *                 try:
 *                     aiter = reader.__aiter__             # <<<<<<<<<<<<<<
 *                 except AttributeError:
 *                     raise TypeError('reader is not an asynchronous iterable')
 */
            __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_reader, __pyx_n_s_aiter); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 442, __pyx_L45_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_4);
            __pyx_cur_scope->__pyx_v_aiter = __pyx_t_4;
            __pyx_t_4 = 0;

            /* "asyncpg/protocol/protocol.pyx":441
 * 
 *             elif reader is not None:
 *                 try:             # <<<<<<<<<<<<<<
 *                     aiter = reader.__aiter__
 *                 except AttributeError:
 */
          }

          /* "asyncpg/protocol/protocol.pyx":446
 *                     raise TypeError('reader is not an asynchronous iterable')
 *                 else:
 *                     iterator = aiter()             # <<<<<<<<<<<<<<
 * 
 *                 try:
 */
          /*else:*/ {
            __Pyx_INCREF(__pyx_cur_scope->__pyx_v_aiter);
            __pyx_t_3 = __pyx_cur_scope->__pyx_v_aiter; __pyx_t_16 = NULL;
            if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
              __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_3);
              if (likely(__pyx_t_16)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
                __Pyx_INCREF(__pyx_t_16);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_3, function);
              }
            }
            if (__pyx_t_16) {
              __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_16); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 446, __pyx_L47_except_error)
              __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
            } else {
              __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 446, __pyx_L47_except_error)
            }
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GIVEREF(__pyx_t_4);
            __pyx_cur_scope->__pyx_v_iterator = __pyx_t_4;
            __pyx_t_4 = 0;
          }
          __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
          __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
          goto __pyx_L50_try_end;
          __pyx_L45_error:;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

          /* "asyncpg/protocol/protocol.pyx":443
 *                 try:
 *                     aiter = reader.__aiter__
 *                 except AttributeError:             # <<<<<<<<<<<<<<
 *                     raise TypeError('reader is not an asynchronous iterable')
 *                 else:
 */
          __pyx_t_15 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
          if (__pyx_t_15) {
            __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.copy_in", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_3, &__pyx_t_16) < 0) __PYX_ERR(0, 443, __pyx_L47_except_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_GOTREF(__pyx_t_16);

            /* "asyncpg/protocol/protocol.pyx":444
 *                     aiter = reader.__aiter__
 *                 except AttributeError:
 *                     raise TypeError('reader is not an asynchronous iterable')             # <<<<<<<<<<<<<<
 *                 else:
 *                     iterator = aiter()
 */
            __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__97, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 444, __pyx_L47_except_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(0, 444, __pyx_L47_except_error)
          }
          goto __pyx_L47_except_error;
          __pyx_L47_except_error:;

          /* "asyncpg/protocol/protocol.pyx":441
 * 
 *             elif reader is not None:
 *                 try:             # <<<<<<<<<<<<<<
 *                     aiter = reader.__aiter__
 *                 except AttributeError:
 */
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_24);
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_24, __pyx_t_23);
          goto __pyx_L8_error;
          __pyx_L50_try_end:;
        }

        /* "asyncpg/protocol/protocol.pyx":448
 *                     iterator = aiter()
 * 
 *                 try:             # <<<<<<<<<<<<<<
 *                     while True:
 *                         # We rely on protocol flow control to moderate the
 */
        {
          __Pyx_ExceptionSave(&__pyx_t_23, &__pyx_t_24, &__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_23);
          __Pyx_XGOTREF(__pyx_t_24);
          __Pyx_XGOTREF(__pyx_t_21);
          /*try:*/ {

            /* "asyncpg/protocol/protocol.pyx":449
 * 
 *                 try:
 *                     while True:             # <<<<<<<<<<<<<<
 *                         # We rely on protocol flow control to moderate the
 *                         # rate of data messages.
 */
            while (1) {

              /* "asyncpg/protocol/protocol.pyx":452
 *                         # We rely on protocol flow control to moderate the
 *                         # rate of data messages.
 *                         with timer:             # <<<<<<<<<<<<<<
 *                             await self.writing_allowed.wait()
 *                         with timer:
 */
              /*with:*/ {
                __pyx_t_22 = __Pyx_PyObject_LookupSpecial(__pyx_cur_scope->__pyx_v_timer, __pyx_n_s_exit); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 452, __pyx_L53_error)
                __Pyx_GOTREF(__pyx_t_22);
                __pyx_t_3 = __Pyx_PyObject_LookupSpecial(__pyx_cur_scope->__pyx_v_timer, __pyx_n_s_enter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 452, __pyx_L61_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_16 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 452, __pyx_L61_error)
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                } else {
                  __pyx_t_16 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 452, __pyx_L61_error)
                }
                __Pyx_GOTREF(__pyx_t_16);
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                /*try:*/ {
                  {
                    __Pyx_ExceptionSave(&__pyx_t_25, &__pyx_t_26, &__pyx_t_27);
                    __Pyx_XGOTREF(__pyx_t_25);
                    __Pyx_XGOTREF(__pyx_t_26);
                    __Pyx_XGOTREF(__pyx_t_27);
                    /*try:*/ {

                      /* "asyncpg/protocol/protocol.pyx":453
 *                         # rate of data messages.
 *                         with timer:
 *                             await self.writing_allowed.wait()             # <<<<<<<<<<<<<<
 *                         with timer:
 *                             chunk = await asyncio.wait_for(
 */
                      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_writing_allowed); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 453, __pyx_L67_error)
                      __Pyx_GOTREF(__pyx_t_3);
                      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_wait); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 453, __pyx_L67_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_16 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 453, __pyx_L67_error)
                        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                      } else {
                        __pyx_t_16 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 453, __pyx_L67_error)
                      }
                      __Pyx_GOTREF(__pyx_t_16);
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_16);
                      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                      __Pyx_XGOTREF(__pyx_r);
                      if (likely(__pyx_r)) {
                        __Pyx_XGIVEREF(__pyx_t_7);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_7;
                        __Pyx_XGIVEREF(__pyx_t_8);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_8;
                        __Pyx_XGIVEREF(__pyx_t_9);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_21;
                        __Pyx_XGIVEREF(__pyx_t_22);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_22;
                        __Pyx_XGIVEREF(__pyx_t_23);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_23;
                        __Pyx_XGIVEREF(__pyx_t_24);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_24;
                        __Pyx_XGIVEREF(__pyx_t_25);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_25;
                        __Pyx_XGIVEREF(__pyx_t_26);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_26;
                        __Pyx_XGIVEREF(__pyx_t_27);
                        __pyx_cur_scope->__pyx_t_11 = __pyx_t_27;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 4;
                        return __pyx_r;
                        __pyx_L75_resume_from_await:;
                        __pyx_t_7 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_7);
                        __pyx_t_8 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_8);
                        __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_9);
                        __pyx_t_21 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_21);
                        __pyx_t_22 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_22);
                        __pyx_t_23 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_23);
                        __pyx_t_24 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_24);
                        __pyx_t_25 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_25);
                        __pyx_t_26 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_26);
                        __pyx_t_27 = __pyx_cur_scope->__pyx_t_11;
                        __pyx_cur_scope->__pyx_t_11 = 0;
                        __Pyx_XGOTREF(__pyx_t_27);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 453, __pyx_L67_error)
                      } else {
                        PyObject* exc_type = __Pyx_PyErr_Occurred();
                        if (exc_type) {
                          if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
                          else __PYX_ERR(0, 453, __pyx_L67_error)
                        }
                      }

                      /* "asyncpg/protocol/protocol.pyx":452
 *                         # We rely on protocol flow control to moderate the
 *                         # rate of data messages.
 *                         with timer:             # <<<<<<<<<<<<<<
 *                             await self.writing_allowed.wait()
 *                         with timer:
 */
                    }
                    __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                    __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                    __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                    goto __pyx_L74_try_end;
                    __pyx_L67_error:;
                    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                    /*except:*/ {
                      __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.copy_in", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_16, &__pyx_t_4, &__pyx_t_3) < 0) __PYX_ERR(0, 452, __pyx_L69_except_error)
                      __Pyx_GOTREF(__pyx_t_16);
                      __Pyx_GOTREF(__pyx_t_4);
                      __Pyx_GOTREF(__pyx_t_3);
                      __pyx_t_5 = PyTuple_Pack(3, __pyx_t_16, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 452, __pyx_L69_except_error)
                      __Pyx_GOTREF(__pyx_t_5);
                      __pyx_t_28 = __Pyx_PyObject_Call(__pyx_t_22, __pyx_t_5, NULL);
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 452, __pyx_L69_except_error)
                      __Pyx_GOTREF(__pyx_t_28);
                      __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_28);
                      __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
                      if (__pyx_t_11 < 0) __PYX_ERR(0, 452, __pyx_L69_except_error)
                      __pyx_t_2 = ((!(__pyx_t_11 != 0)) != 0);
                      if (__pyx_t_2) {
                        __Pyx_GIVEREF(__pyx_t_16);
                        __Pyx_GIVEREF(__pyx_t_4);
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __Pyx_ErrRestoreWithState(__pyx_t_16, __pyx_t_4, __pyx_t_3);
                        __pyx_t_16 = 0; __pyx_t_4 = 0; __pyx_t_3 = 0; 
                        __PYX_ERR(0, 452, __pyx_L69_except_error)
                      }
                      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                      goto __pyx_L68_exception_handled;
                    }
                    __pyx_L69_except_error:;
                    __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);
                    goto __pyx_L53_error;
                    __pyx_L68_exception_handled:;
                    __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_L74_try_end:;
                  }
                }
                /*finally:*/ {
                  /*normal exit:*/{
                    if (__pyx_t_22) {
                      __pyx_t_27 = __Pyx_PyObject_Call(__pyx_t_22, __pyx_tuple__98, NULL);
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                      if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 452, __pyx_L53_error)
                      __Pyx_GOTREF(__pyx_t_27);
                      __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                    }
                    goto __pyx_L66;
                  }
                  __pyx_L66:;
                }
                goto __pyx_L79;
                __pyx_L61_error:;
                __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                goto __pyx_L53_error;
                __pyx_L79:;
              }

              /* "asyncpg/protocol/protocol.pyx":454
 *                         with timer:
 *                             await self.writing_allowed.wait()
 *                         with timer:             # <<<<<<<<<<<<<<
 *                             chunk = await asyncio.wait_for(
 *                                 iterator.__anext__(),
 */
              /*with:*/ {
                __pyx_t_22 = __Pyx_PyObject_LookupSpecial(__pyx_cur_scope->__pyx_v_timer, __pyx_n_s_exit); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 454, __pyx_L53_error)
                __Pyx_GOTREF(__pyx_t_22);
                __pyx_t_4 = __Pyx_PyObject_LookupSpecial(__pyx_cur_scope->__pyx_v_timer, __pyx_n_s_enter); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 454, __pyx_L80_error)
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_t_16 = NULL;
                if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
                  __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_4);
                  if (likely(__pyx_t_16)) {
                    PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
                    __Pyx_INCREF(__pyx_t_16);
                    __Pyx_INCREF(function);
                    __Pyx_DECREF_SET(__pyx_t_4, function);
                  }
                }
                if (__pyx_t_16) {
                  __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_16); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 454, __pyx_L80_error)
                  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                } else {
                  __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 454, __pyx_L80_error)
                }
                __Pyx_GOTREF(__pyx_t_3);
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                /*try:*/ {
                  {
                    __Pyx_ExceptionSave(&__pyx_t_27, &__pyx_t_26, &__pyx_t_25);
                    __Pyx_XGOTREF(__pyx_t_27);
                    __Pyx_XGOTREF(__pyx_t_26);
                    __Pyx_XGOTREF(__pyx_t_25);
                    /*try:*/ {

                      /* "asyncpg/protocol/protocol.pyx":455
 *                             await self.writing_allowed.wait()
 *                         with timer:
 *                             chunk = await asyncio.wait_for(             # <<<<<<<<<<<<<<
 *                                 iterator.__anext__(),
 *                                 timeout=timer.get_remaining_budget(),
 */
                      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_asyncio); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 455, __pyx_L86_error)
                      __Pyx_GOTREF(__pyx_t_3);
                      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_wait_for); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 455, __pyx_L86_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

                      /* "asyncpg/protocol/protocol.pyx":456
 *                         with timer:
 *                             chunk = await asyncio.wait_for(
 *                                 iterator.__anext__(),             # <<<<<<<<<<<<<<
 *                                 timeout=timer.get_remaining_budget(),
 *                                 loop=self.loop)
 */
                      __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_iterator, __pyx_n_s_anext); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 456, __pyx_L86_error)
                      __Pyx_GOTREF(__pyx_t_16);
                      __pyx_t_5 = NULL;
                      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_16))) {
                        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_16);
                        if (likely(__pyx_t_5)) {
                          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16);
                          __Pyx_INCREF(__pyx_t_5);
                          __Pyx_INCREF(function);
                          __Pyx_DECREF_SET(__pyx_t_16, function);
                        }
                      }
                      if (__pyx_t_5) {
                        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 456, __pyx_L86_error)
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      } else {
                        __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_16); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 456, __pyx_L86_error)
                      }
                      __Pyx_GOTREF(__pyx_t_3);
                      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;

                      /* "asyncpg/protocol/protocol.pyx":455
 *                             await self.writing_allowed.wait()
 *                         with timer:
 *                             chunk = await asyncio.wait_for(             # <<<<<<<<<<<<<<
 *                                 iterator.__anext__(),
 *                                 timeout=timer.get_remaining_budget(),
 */
                      __pyx_t_16 = PyTuple_New(1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 455, __pyx_L86_error)
                      __Pyx_GOTREF(__pyx_t_16);
                      __Pyx_GIVEREF(__pyx_t_3);
                      PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_3);
                      __pyx_t_3 = 0;

                      /* "asyncpg/protocol/protocol.pyx":457
 *                             chunk = await asyncio.wait_for(
 *                                 iterator.__anext__(),
 *                                 timeout=timer.get_remaining_budget(),             # <<<<<<<<<<<<<<
 *                                 loop=self.loop)
 *                         self._write_copy_data_msg(chunk)
 */
                      __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 457, __pyx_L86_error)
                      __Pyx_GOTREF(__pyx_t_3);
                      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_timer, __pyx_n_s_get_remaining_budget); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 457, __pyx_L86_error)
                      __Pyx_GOTREF(__pyx_t_6);
                      __pyx_t_12 = NULL;
                      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
                        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_6);
                        if (likely(__pyx_t_12)) {
                          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
                          __Pyx_INCREF(__pyx_t_12);
                          __Pyx_INCREF(function);
                          __Pyx_DECREF_SET(__pyx_t_6, function);
                        }
                      }
                      if (__pyx_t_12) {
                        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 457, __pyx_L86_error)
                        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                      } else {
                        __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 457, __pyx_L86_error)
                      }
                      __Pyx_GOTREF(__pyx_t_5);
                      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                      if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_timeout, __pyx_t_5) < 0) __PYX_ERR(0, 457, __pyx_L86_error)
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                      /* "asyncpg/protocol/protocol.pyx":458
 *                                 iterator.__anext__(),
 *                                 timeout=timer.get_remaining_budget(),
 *                                 loop=self.loop)             # <<<<<<<<<<<<<<
 *                         self._write_copy_data_msg(chunk)
 *                 except builtins.StopAsyncIteration:
 */
                      if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_loop, __pyx_cur_scope->__pyx_v_self->loop) < 0) __PYX_ERR(0, 457, __pyx_L86_error)

                      /* "asyncpg/protocol/protocol.pyx":455
 *                             await self.writing_allowed.wait()
 *                         with timer:
 *                             chunk = await asyncio.wait_for(             # <<<<<<<<<<<<<<
 *                                 iterator.__anext__(),
 *                                 timeout=timer.get_remaining_budget(),
 */
                      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_16, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 455, __pyx_L86_error)
                      __Pyx_GOTREF(__pyx_t_5);
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                      __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_t_7);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_7;
                        __Pyx_XGIVEREF(__pyx_t_8);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_8;
                        __Pyx_XGIVEREF(__pyx_t_9);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_21;
                        __Pyx_XGIVEREF(__pyx_t_22);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_22;
                        __Pyx_XGIVEREF(__pyx_t_23);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_23;
                        __Pyx_XGIVEREF(__pyx_t_24);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_24;
                        __Pyx_XGIVEREF(__pyx_t_25);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_25;
                        __Pyx_XGIVEREF(__pyx_t_26);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_26;
                        __Pyx_XGIVEREF(__pyx_t_27);
                        __pyx_cur_scope->__pyx_t_11 = __pyx_t_27;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 5;
                        return __pyx_r;
                        __pyx_L94_resume_from_await:;
                        __pyx_t_7 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_7);
                        __pyx_t_8 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_8);
                        __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_9);
                        __pyx_t_21 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_21);
                        __pyx_t_22 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_22);
                        __pyx_t_23 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_23);
                        __pyx_t_24 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_24);
                        __pyx_t_25 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_25);
                        __pyx_t_26 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_26);
                        __pyx_t_27 = __pyx_cur_scope->__pyx_t_11;
                        __pyx_cur_scope->__pyx_t_11 = 0;
                        __Pyx_XGOTREF(__pyx_t_27);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 455, __pyx_L86_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(0, 455, __pyx_L86_error)
                        __Pyx_GOTREF(__pyx_t_5);
                      }
                      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_chunk);
                      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_chunk, __pyx_t_5);
                      __Pyx_GIVEREF(__pyx_t_5);
                      __pyx_t_5 = 0;

                      /* "asyncpg/protocol/protocol.pyx":454
 *                         with timer:
 *                             await self.writing_allowed.wait()
 *                         with timer:             # <<<<<<<<<<<<<<
 *                             chunk = await asyncio.wait_for(
 *                                 iterator.__anext__(),
 */
                    }
                    __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                    __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                    __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                    goto __pyx_L93_try_end;
                    __pyx_L86_error:;
                    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    /*except:*/ {
                      __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.copy_in", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_3, &__pyx_t_16) < 0) __PYX_ERR(0, 454, __pyx_L88_except_error)
                      __Pyx_GOTREF(__pyx_t_5);
                      __Pyx_GOTREF(__pyx_t_3);
                      __Pyx_GOTREF(__pyx_t_16);
                      __pyx_t_4 = PyTuple_Pack(3, __pyx_t_5, __pyx_t_3, __pyx_t_16); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 454, __pyx_L88_except_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      __pyx_t_28 = __Pyx_PyObject_Call(__pyx_t_22, __pyx_t_4, NULL);
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                      if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 454, __pyx_L88_except_error)
                      __Pyx_GOTREF(__pyx_t_28);
                      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_28);
                      __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
                      if (__pyx_t_2 < 0) __PYX_ERR(0, 454, __pyx_L88_except_error)
                      __pyx_t_11 = ((!(__pyx_t_2 != 0)) != 0);
                      if (__pyx_t_11) {
                        __Pyx_GIVEREF(__pyx_t_5);
                        __Pyx_GIVEREF(__pyx_t_3);
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __Pyx_ErrRestoreWithState(__pyx_t_5, __pyx_t_3, __pyx_t_16);
                        __pyx_t_5 = 0; __pyx_t_3 = 0; __pyx_t_16 = 0; 
                        __PYX_ERR(0, 454, __pyx_L88_except_error)
                      }
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                      goto __pyx_L87_exception_handled;
                    }
                    __pyx_L88_except_error:;
                    __Pyx_XGIVEREF(__pyx_t_27);
                    __Pyx_XGIVEREF(__pyx_t_26);
                    __Pyx_XGIVEREF(__pyx_t_25);
                    __Pyx_ExceptionReset(__pyx_t_27, __pyx_t_26, __pyx_t_25);
                    goto __pyx_L53_error;
                    __pyx_L87_exception_handled:;
                    __Pyx_XGIVEREF(__pyx_t_27);
                    __Pyx_XGIVEREF(__pyx_t_26);
                    __Pyx_XGIVEREF(__pyx_t_25);
                    __Pyx_ExceptionReset(__pyx_t_27, __pyx_t_26, __pyx_t_25);
                    __pyx_L93_try_end:;
                  }
                }
                /*finally:*/ {
                  /*normal exit:*/{
                    if (__pyx_t_22) {
                      __pyx_t_25 = __Pyx_PyObject_Call(__pyx_t_22, __pyx_tuple__99, NULL);
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                      if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 454, __pyx_L53_error)
                      __Pyx_GOTREF(__pyx_t_25);
                      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                    }
                    goto __pyx_L85;
                  }
                  __pyx_L85:;
                }
                goto __pyx_L98;
                __pyx_L80_error:;
                __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                goto __pyx_L53_error;
                __pyx_L98:;
              }

              /* "asyncpg/protocol/protocol.pyx":459
 *                                 timeout=timer.get_remaining_budget(),
 *                                 loop=self.loop)
 *                         self._write_copy_data_msg(chunk)             # <<<<<<<<<<<<<<
 *                 except builtins.StopAsyncIteration:
 *                     pass
 */
              if (unlikely(!__pyx_cur_scope->__pyx_v_chunk)) { __Pyx_RaiseUnboundLocalError("chunk"); __PYX_ERR(0, 459, __pyx_L53_error) }
              __pyx_t_16 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._write_copy_data_msg(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_chunk); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 459, __pyx_L53_error)
              __Pyx_GOTREF(__pyx_t_16);
              __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
            }

            /* "asyncpg/protocol/protocol.pyx":448
 *                     iterator = aiter()
 * 
 *                 try:             # <<<<<<<<<<<<<<
 *                     while True:
 *                         # We rely on protocol flow control to moderate the
 */
          }
          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
          __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
          goto __pyx_L58_try_end;
          __pyx_L53_error:;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;

          /* "asyncpg/protocol/protocol.pyx":460
 *                                 loop=self.loop)
 *                         self._write_copy_data_msg(chunk)
 *                 except builtins.StopAsyncIteration:             # <<<<<<<<<<<<<<
 *                     pass
 *             else:
 */
          __pyx_t_16 = __Pyx_GetModuleGlobalName(__pyx_n_s_builtins); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 460, __pyx_L55_except_error)
          __Pyx_GOTREF(__pyx_t_16);
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_StopAsyncIteration); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 460, __pyx_L55_except_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          __pyx_t_15 = __Pyx_PyErr_ExceptionMatches(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (__pyx_t_15) {
            __Pyx_ErrRestore(0,0,0);
            goto __pyx_L54_exception_handled;
          }
          goto __pyx_L55_except_error;
          __pyx_L55_except_error:;

          /* "asyncpg/protocol/protocol.pyx":448
 *                     iterator = aiter()
 * 
 *                 try:             # <<<<<<<<<<<<<<
 *                     while True:
 *                         # We rely on protocol flow control to moderate the
 */
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_XGIVEREF(__pyx_t_24);
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_24, __pyx_t_21);
          goto __pyx_L8_error;
          __pyx_L54_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_XGIVEREF(__pyx_t_24);
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_24, __pyx_t_21);
          __pyx_L58_try_end:;
        }

        /* "asyncpg/protocol/protocol.pyx":440
 *                 self._write_copy_data_msg(wbuf)
 * 
 *             elif reader is not None:             # <<<<<<<<<<<<<<
 *                 try:
 *                     aiter = reader.__aiter__
 */
        goto __pyx_L14;
      }

      /* "asyncpg/protocol/protocol.pyx":464
 *             else:
 *                 # Buffer passed in directly.
 *                 await self.writing_allowed.wait()             # <<<<<<<<<<<<<<
 *                 self._write_copy_data_msg(data)
 * 
 */
      /*else*/ {
        __pyx_t_16 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_writing_allowed); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 464, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_16);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_wait); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 464, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
        __pyx_t_16 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_5);
          if (likely(__pyx_t_16)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_16);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_5, function);
          }
        }
        if (__pyx_t_16) {
          __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_16); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 464, __pyx_L8_error)
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
        } else {
          __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 464, __pyx_L8_error)
        }
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __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_t_7);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_7;
          __Pyx_XGIVEREF(__pyx_t_8);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_8;
          __Pyx_XGIVEREF(__pyx_t_9);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 6;
          return __pyx_r;
          __pyx_L99_resume_from_await:;
          __pyx_t_7 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_7);
          __pyx_t_8 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_8);
          __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_9);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 464, __pyx_L8_error)
        } else {
          PyObject* exc_type = __Pyx_PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
            else __PYX_ERR(0, 464, __pyx_L8_error)
          }
        }

        /* "asyncpg/protocol/protocol.pyx":465
 *                 # Buffer passed in directly.
 *                 await self.writing_allowed.wait()
 *                 self._write_copy_data_msg(data)             # <<<<<<<<<<<<<<
 * 
 *         except asyncio.TimeoutError:
 */
        __pyx_t_3 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._write_copy_data_msg(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 465, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __pyx_L14:;

      /* "asyncpg/protocol/protocol.pyx":395
 *         self._copy_in(copy_stmt)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if record_stmt is not None:
 *                 # copy_in_records in binary mode
 */
    }
    __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_L13_try_end;
    __pyx_L8_error:;
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "asyncpg/protocol/protocol.pyx":467
 *                 self._write_copy_data_msg(data)
 * 
 *         except asyncio.TimeoutError:             # <<<<<<<<<<<<<<
 *             self._write_copy_fail_msg('TimeoutError')
 *             self._on_timeout(self.waiter)
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_asyncio); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 467, __pyx_L10_except_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_TimeoutError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 467, __pyx_L10_except_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_15 = __Pyx_PyErr_ExceptionMatches(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_15) {
      __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.copy_in", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_3, &__pyx_t_16) < 0) __PYX_ERR(0, 467, __pyx_L10_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_16);

      /* "asyncpg/protocol/protocol.pyx":468
 * 
 *         except asyncio.TimeoutError:
 *             self._write_copy_fail_msg('TimeoutError')             # <<<<<<<<<<<<<<
 *             self._on_timeout(self.waiter)
 *             try:
 */
      __pyx_t_4 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._write_copy_fail_msg(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_cur_scope->__pyx_v_self), __pyx_n_u_TimeoutError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 468, __pyx_L10_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "asyncpg/protocol/protocol.pyx":469
 *         except asyncio.TimeoutError:
 *             self._write_copy_fail_msg('TimeoutError')
 *             self._on_timeout(self.waiter)             # <<<<<<<<<<<<<<
 *             try:
 *                 await waiter
 */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_on_timeout); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 469, __pyx_L10_except_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_12 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_12)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
        }
      }
      if (!__pyx_t_12) {
        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_cur_scope->__pyx_v_self->waiter); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 469, __pyx_L10_except_error)
        __Pyx_GOTREF(__pyx_t_4);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_6)) {
          PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_cur_scope->__pyx_v_self->waiter};
          __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 469, __pyx_L10_except_error)
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 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_12, __pyx_cur_scope->__pyx_v_self->waiter};
          __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 469, __pyx_L10_except_error)
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_GOTREF(__pyx_t_4);
        } else
        #endif
        {
          __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 469, __pyx_L10_except_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_cur_scope->__pyx_v_self->waiter);
          __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self->waiter);
          PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_cur_scope->__pyx_v_self->waiter);
          __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_13, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 469, __pyx_L10_except_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "asyncpg/protocol/protocol.pyx":470
 *             self._write_copy_fail_msg('TimeoutError')
 *             self._on_timeout(self.waiter)
 *             try:             # <<<<<<<<<<<<<<
 *                 await waiter
 *             except TimeoutError:
 */
      {
        __Pyx_ExceptionSave(&__pyx_t_21, &__pyx_t_24, &__pyx_t_23);
        __Pyx_XGOTREF(__pyx_t_21);
        __Pyx_XGOTREF(__pyx_t_24);
        __Pyx_XGOTREF(__pyx_t_23);
        /*try:*/ {

          /* "asyncpg/protocol/protocol.pyx":471
 *             self._on_timeout(self.waiter)
 *             try:
 *                 await waiter             # <<<<<<<<<<<<<<
 *             except TimeoutError:
 *                 raise
 */
          __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_t_3);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
            __Pyx_XGIVEREF(__pyx_t_5);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_5;
            __Pyx_XGIVEREF(__pyx_t_7);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_7;
            __Pyx_XGIVEREF(__pyx_t_8);
            __pyx_cur_scope->__pyx_t_3 = __pyx_t_8;
            __Pyx_XGIVEREF(__pyx_t_9);
            __pyx_cur_scope->__pyx_t_6 = __pyx_t_9;
            __Pyx_XGIVEREF(__pyx_t_16);
            __pyx_cur_scope->__pyx_t_7 = __pyx_t_16;
            __Pyx_XGIVEREF(__pyx_t_21);
            __pyx_cur_scope->__pyx_t_8 = __pyx_t_21;
            __Pyx_XGIVEREF(__pyx_t_23);
            __pyx_cur_scope->__pyx_t_9 = __pyx_t_23;
            __Pyx_XGIVEREF(__pyx_t_24);
            __pyx_cur_scope->__pyx_t_10 = __pyx_t_24;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_SwapException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 7;
            return __pyx_r;
            __pyx_L110_resume_from_await:;
            __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_3);
            __pyx_t_5 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_5);
            __pyx_t_7 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_7);
            __pyx_t_8 = __pyx_cur_scope->__pyx_t_3;
            __pyx_cur_scope->__pyx_t_3 = 0;
            __Pyx_XGOTREF(__pyx_t_8);
            __pyx_t_9 = __pyx_cur_scope->__pyx_t_6;
            __pyx_cur_scope->__pyx_t_6 = 0;
            __Pyx_XGOTREF(__pyx_t_9);
            __pyx_t_16 = __pyx_cur_scope->__pyx_t_7;
            __pyx_cur_scope->__pyx_t_7 = 0;
            __Pyx_XGOTREF(__pyx_t_16);
            __pyx_t_21 = __pyx_cur_scope->__pyx_t_8;
            __pyx_cur_scope->__pyx_t_8 = 0;
            __Pyx_XGOTREF(__pyx_t_21);
            __pyx_t_23 = __pyx_cur_scope->__pyx_t_9;
            __pyx_cur_scope->__pyx_t_9 = 0;
            __Pyx_XGOTREF(__pyx_t_23);
            __pyx_t_24 = __pyx_cur_scope->__pyx_t_10;
            __pyx_cur_scope->__pyx_t_10 = 0;
            __Pyx_XGOTREF(__pyx_t_24);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 471, __pyx_L102_error)
          } else {
            PyObject* exc_type = __Pyx_PyErr_Occurred();
            if (exc_type) {
              if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
              else __PYX_ERR(0, 471, __pyx_L102_error)
            }
          }

          /* "asyncpg/protocol/protocol.pyx":470
 *             self._write_copy_fail_msg('TimeoutError')
 *             self._on_timeout(self.waiter)
 *             try:             # <<<<<<<<<<<<<<
 *                 await waiter
 *             except TimeoutError:
 */
        }

        /* "asyncpg/protocol/protocol.pyx":475
 *                 raise
 *             else:
 *                 raise apg_exc.InternalClientError('TimoutError was not raised')             # <<<<<<<<<<<<<<
 * 
 *         except Exception as e:
 */
        /*else:*/ {
          __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 475, __pyx_L104_except_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_InternalClientError); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 475, __pyx_L104_except_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__100, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 475, __pyx_L104_except_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(0, 475, __pyx_L104_except_error)
        }
        __pyx_L102_error:;
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "asyncpg/protocol/protocol.pyx":472
 *             try:
 *                 await waiter
 *             except TimeoutError:             # <<<<<<<<<<<<<<
 *                 raise
 *             else:
 */
        __pyx_t_15 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TimeoutError);
        if (__pyx_t_15) {
          __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.copy_in", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_13) < 0) __PYX_ERR(0, 472, __pyx_L104_except_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_GOTREF(__pyx_t_13);

          /* "asyncpg/protocol/protocol.pyx":473
 *                 await waiter
 *             except TimeoutError:
 *                 raise             # <<<<<<<<<<<<<<
 *             else:
 *                 raise apg_exc.InternalClientError('TimoutError was not raised')
 */
          __Pyx_GIVEREF(__pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_6);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_6, __pyx_t_13);
          __pyx_t_4 = 0; __pyx_t_6 = 0; __pyx_t_13 = 0; 
          __PYX_ERR(0, 473, __pyx_L104_except_error)
        }
        goto __pyx_L104_except_error;
        __pyx_L104_except_error:;

        /* "asyncpg/protocol/protocol.pyx":470
 *             self._write_copy_fail_msg('TimeoutError')
 *             self._on_timeout(self.waiter)
 *             try:             # <<<<<<<<<<<<<<
 *                 await waiter
 *             except TimeoutError:
 */
        __Pyx_XGIVEREF(__pyx_t_21);
        __Pyx_XGIVEREF(__pyx_t_24);
        __Pyx_XGIVEREF(__pyx_t_23);
        __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_24, __pyx_t_23);
        goto __pyx_L10_except_error;
      }
    }

    /* "asyncpg/protocol/protocol.pyx":477
 *                 raise apg_exc.InternalClientError('TimoutError was not raised')
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             self._write_copy_fail_msg(str(e))
 *             self._request_cancel()
 */
    __pyx_t_15 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
    if (__pyx_t_15) {
      __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.copy_in", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_16, &__pyx_t_3, &__pyx_t_5) < 0) __PYX_ERR(0, 477, __pyx_L10_except_error)
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_cur_scope->__pyx_v_e = __pyx_t_3;
      /*try:*/ {

        /* "asyncpg/protocol/protocol.pyx":478
 * 
 *         except Exception as e:
 *             self._write_copy_fail_msg(str(e))             # <<<<<<<<<<<<<<
 *             self._request_cancel()
 *             # Make asyncio shut up about unretrieved QueryCanceledError
 */
        __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 478, __pyx_L118_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_e);
        __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_e);
        PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_cur_scope->__pyx_v_e);
        __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)(&PyUnicode_Type)), __pyx_t_13, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 478, __pyx_L118_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_13 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._write_copy_fail_msg(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_cur_scope->__pyx_v_self), ((PyObject*)__pyx_t_6)); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 478, __pyx_L118_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

        /* "asyncpg/protocol/protocol.pyx":479
 *         except Exception as e:
 *             self._write_copy_fail_msg(str(e))
 *             self._request_cancel()             # <<<<<<<<<<<<<<
 *             # Make asyncio shut up about unretrieved QueryCanceledError
 *             waiter.add_done_callback(lambda f: f.exception())
 */
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_request_cancel); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 479, __pyx_L118_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_6, function);
          }
        }
        if (__pyx_t_4) {
          __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 479, __pyx_L118_error)
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        } else {
          __pyx_t_13 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 479, __pyx_L118_error)
        }
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

        /* "asyncpg/protocol/protocol.pyx":481
 *             self._request_cancel()
 *             # Make asyncio shut up about unretrieved QueryCanceledError
 *             waiter.add_done_callback(lambda f: f.exception())             # <<<<<<<<<<<<<<
 *             raise
 * 
 */
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_waiter, __pyx_n_s_add_done_callback); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 481, __pyx_L118_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_7asyncpg_8protocol_8protocol_12BaseProtocol_7copy_in_lambda2, 0, __pyx_n_s_copy_in_locals_lambda, NULL, __pyx_n_s_asyncpg_protocol_protocol, __pyx_d, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 481, __pyx_L118_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_12 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_6);
          if (likely(__pyx_t_12)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_12);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_6, function);
          }
        }
        if (!__pyx_t_12) {
          __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 481, __pyx_L118_error)
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_13);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_6)) {
            PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_4};
            __pyx_t_13 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 481, __pyx_L118_error)
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
            PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_4};
            __pyx_t_13 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 481, __pyx_L118_error)
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          } else
          #endif
          {
            __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 481, __pyx_L118_error)
            __Pyx_GOTREF(__pyx_t_14);
            __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_12); __pyx_t_12 = NULL;
            __Pyx_GIVEREF(__pyx_t_4);
            PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_4);
            __pyx_t_4 = 0;
            __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_14, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 481, __pyx_L118_error)
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

        /* "asyncpg/protocol/protocol.pyx":482
 *             # Make asyncio shut up about unretrieved QueryCanceledError
 *             waiter.add_done_callback(lambda f: f.exception())
 *             raise             # <<<<<<<<<<<<<<
 * 
 *         self._write_copy_done_msg()
 */
        __Pyx_GIVEREF(__pyx_t_16);
        __Pyx_GIVEREF(__pyx_t_3);
        __Pyx_XGIVEREF(__pyx_t_5);
        __Pyx_ErrRestoreWithState(__pyx_t_16, __pyx_t_3, __pyx_t_5);
        __pyx_t_16 = 0; __pyx_t_3 = 0; __pyx_t_5 = 0; 
        __PYX_ERR(0, 482, __pyx_L118_error)
      }

      /* "asyncpg/protocol/protocol.pyx":477
 *                 raise apg_exc.InternalClientError('TimoutError was not raised')
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             self._write_copy_fail_msg(str(e))
 *             self._request_cancel()
 */
      /*finally:*/ {
        __pyx_L118_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_22, &__pyx_t_25, &__pyx_t_26);
          if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_23, &__pyx_t_24, &__pyx_t_21) < 0)) __Pyx_ErrFetch(&__pyx_t_23, &__pyx_t_24, &__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_23);
          __Pyx_XGOTREF(__pyx_t_24);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_25);
          __Pyx_XGOTREF(__pyx_t_26);
          __pyx_t_15 = __pyx_lineno; __pyx_t_29 = __pyx_clineno; __pyx_t_30 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e);
            __pyx_cur_scope->__pyx_v_e = NULL;
          }
          if (PY_MAJOR_VERSION >= 3) {
            __Pyx_XGIVEREF(__pyx_t_22);
            __Pyx_XGIVEREF(__pyx_t_25);
            __Pyx_XGIVEREF(__pyx_t_26);
            __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_25, __pyx_t_26);
          }
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_XGIVEREF(__pyx_t_24);
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_ErrRestore(__pyx_t_23, __pyx_t_24, __pyx_t_21);
          __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0;
          __pyx_lineno = __pyx_t_15; __pyx_clineno = __pyx_t_29; __pyx_filename = __pyx_t_30;
          goto __pyx_L10_except_error;
        }
      }
    }
    goto __pyx_L10_except_error;
    __pyx_L10_except_error:;

    /* "asyncpg/protocol/protocol.pyx":395
 *         self._copy_in(copy_stmt)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if record_stmt is not None:
 *                 # copy_in_records in binary mode
 */
    __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_L13_try_end:;
  }

  /* "asyncpg/protocol/protocol.pyx":484
 *             raise
 * 
 *         self._write_copy_done_msg()             # <<<<<<<<<<<<<<
 * 
 *         status_msg = await waiter
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._write_copy_done_msg(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_cur_scope->__pyx_v_self)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 484, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "asyncpg/protocol/protocol.pyx":486
 *         self._write_copy_done_msg()
 * 
 *         status_msg = await waiter             # <<<<<<<<<<<<<<
 * 
 *         return status_msg
 */
  __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();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 8;
    return __pyx_r;
    __pyx_L124_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 486, __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(0, 486, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
  }
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_cur_scope->__pyx_v_status_msg = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "asyncpg/protocol/protocol.pyx":488
 *         status_msg = await waiter
 * 
 *         return status_msg             # <<<<<<<<<<<<<<
 * 
 *     async def close_statement(self, PreparedStatementState state, timeout):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_cur_scope->__pyx_v_status_msg);
  goto __pyx_L0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "asyncpg/protocol/protocol.pyx":372
 *         return status_msg
 * 
 *     async def copy_in(self, copy_stmt, reader, data,             # <<<<<<<<<<<<<<
 *                       records, PreparedStatementState record_stmt, timeout):
 *         cdef:
 */

  /* 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_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_AddTraceback("copy_in", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_7asyncpg_8protocol_8protocol_12BaseProtocol_36generator8(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "asyncpg/protocol/protocol.pyx":490
 *         return status_msg
 * 
 *     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_35close_statement(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_35close_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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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;
        CYTHON_FALLTHROUGH;
        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(0, 490, __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(0, 490, __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(0, 490, __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(0, 490, __pyx_L1_error)
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_34close_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_34close_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_9_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_9_close_statement *)__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement(__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 490, __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_36generator8, (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(0, 490, __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_36generator8(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement *__pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_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;
  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;
  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_RefNannyDeclarations
  __Pyx_RefNannySetupContext("close_statement", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L5_resume_from_await;
    case 2: goto __pyx_L7_resume_from_await;
    case 3: goto __pyx_L29_resume_from_await;
    case 4: goto __pyx_L32_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 490, __pyx_L1_error)

  /* "asyncpg/protocol/protocol.pyx":491
 * 
 *     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":492
 *     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();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 1;
      return __pyx_r;
      __pyx_L5_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 492, __pyx_L1_error)
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (exc_type) {
        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
        else __PYX_ERR(0, 492, __pyx_L1_error)
      }
    }

    /* "asyncpg/protocol/protocol.pyx":491
 * 
 *     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":493
 *         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":494
 *             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();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 2;
      return __pyx_r;
      __pyx_L7_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 494, __pyx_L1_error)
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (exc_type) {
        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
        else __PYX_ERR(0, 494, __pyx_L1_error)
      }
    }

    /* "asyncpg/protocol/protocol.pyx":495
 *         if self.cancel_sent_waiter is not None:
 *             await self.cancel_sent_waiter
 *             self.cancel_sent_waiter = None             # <<<<<<<<<<<<<<
 * 
 *         self._check_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":493
 *         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":497
 *             self.cancel_sent_waiter = None
 * 
 *         self._check_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)->_check_state(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 497, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":499
 *         self._check_state()
 * 
 *         if state.refs != 0:             # <<<<<<<<<<<<<<
 *             raise apg_exc.InternalClientError(
 *                 '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":500
 * 
 *         if state.refs != 0:
 *             raise apg_exc.InternalClientError(             # <<<<<<<<<<<<<<
 *                 'cannot close prepared statement; refs == {} != 0'.format(
 *                     state.refs))
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 500, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_InternalClientError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 500, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "asyncpg/protocol/protocol.pyx":501
 *         if state.refs != 0:
 *             raise apg_exc.InternalClientError(
 *                 'cannot close prepared statement; refs == {} != 0'.format(             # <<<<<<<<<<<<<<
 *                     state.refs))
 * 
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_cannot_close_prepared_statement, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 501, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);

    /* "asyncpg/protocol/protocol.pyx":502
 *             raise apg_exc.InternalClientError(
 *                 'cannot close prepared statement; refs == {} != 0'.format(
 *                     state.refs))             # <<<<<<<<<<<<<<
 * 
 *         timeout = self._get_timeout_impl(timeout)
 */
    __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_state->refs); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 502, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = NULL;
    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);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 501, __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_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_7};
        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 501, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 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_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_7};
        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 501, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 501, __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_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_7);
        __pyx_t_7 = 0;
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 501, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __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_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 500, __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_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 500, __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[2] = {__pyx_t_6, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 500, __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_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 500, __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_4);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 500, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 500, __pyx_L1_error)

    /* "asyncpg/protocol/protocol.pyx":499
 *         self._check_state()
 * 
 *         if state.refs != 0:             # <<<<<<<<<<<<<<
 *             raise apg_exc.InternalClientError(
 *                 'cannot close prepared statement; refs == {} != 0'.format(
 */
  }

  /* "asyncpg/protocol/protocol.pyx":504
 *                     state.refs))
 * 
 *         timeout = self._get_timeout_impl(timeout)             # <<<<<<<<<<<<<<
 *         waiter = self._new_waiter(timeout)
 *         try:
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__get_timeout_impl(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_timeout); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 504, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_timeout);
  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_timeout, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":505
 * 
 *         timeout = self._get_timeout_impl(timeout)
 *         waiter = self._new_waiter(timeout)             # <<<<<<<<<<<<<<
 *         try:
 *             self._close(state.name, False)  # network op
 */
  __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(0, 505, __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":506
 *         timeout = self._get_timeout_impl(timeout)
 *         waiter = self._new_waiter(timeout)
 *         try:             # <<<<<<<<<<<<<<
 *             self._close(state.name, False)  # network op
 *             state.closed = True
 */
  /*try:*/ {
    {
      __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/protocol.pyx":507
 *         waiter = self._new_waiter(timeout)
 *         try:
 *             self._close(state.name, False)  # network op             # <<<<<<<<<<<<<<
 *             state.closed = True
 *         except Exception as ex:
 */
        __pyx_t_3 = __pyx_cur_scope->__pyx_v_state->name;
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_5 = ((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_5)) __PYX_ERR(0, 507, __pyx_L12_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "asyncpg/protocol/protocol.pyx":508
 *         try:
 *             self._close(state.name, False)  # network op
 *             state.closed = True             # <<<<<<<<<<<<<<
 *         except Exception as ex:
 *             waiter.set_exception(ex)
 */
        __pyx_cur_scope->__pyx_v_state->closed = 1;

        /* "asyncpg/protocol/protocol.pyx":506
 *         timeout = self._get_timeout_impl(timeout)
 *         waiter = self._new_waiter(timeout)
 *         try:             # <<<<<<<<<<<<<<
 *             self._close(state.name, False)  # network op
 *             state.closed = True
 */
      }
      __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;
      goto __pyx_L17_try_end;
      __pyx_L12_error:;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "asyncpg/protocol/protocol.pyx":509
 *             self._close(state.name, False)  # network op
 *             state.closed = True
 *         except Exception as ex:             # <<<<<<<<<<<<<<
 *             waiter.set_exception(ex)
 *             self._coreproto_error()
 */
      __pyx_t_13 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
      if (__pyx_t_13) {
        __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.close_statement", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_3, &__pyx_t_9) < 0) __PYX_ERR(0, 509, __pyx_L14_except_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_v_ex = __pyx_t_3;
        /*try:*/ {

          /* "asyncpg/protocol/protocol.pyx":510
 *             state.closed = True
 *         except Exception as ex:
 *             waiter.set_exception(ex)             # <<<<<<<<<<<<<<
 *             self._coreproto_error()
 *         finally:
 */
          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_waiter, __pyx_n_s_set_exception); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 510, __pyx_L23_error)
          __Pyx_GOTREF(__pyx_t_6);
          __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_cur_scope->__pyx_v_ex); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 510, __pyx_L23_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_cur_scope->__pyx_v_ex};
              __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 510, __pyx_L23_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_cur_scope->__pyx_v_ex};
              __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 510, __pyx_L23_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(0, 510, __pyx_L23_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_cur_scope->__pyx_v_ex);
              __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_ex);
              PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_cur_scope->__pyx_v_ex);
              __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 510, __pyx_L23_error)
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            }
          }
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

          /* "asyncpg/protocol/protocol.pyx":511
 *         except Exception as ex:
 *             waiter.set_exception(ex)
 *             self._coreproto_error()             # <<<<<<<<<<<<<<
 *         finally:
 *             return await waiter
 */
          __pyx_t_4 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->_coreproto_error(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 511, __pyx_L23_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        }

        /* "asyncpg/protocol/protocol.pyx":509
 *             self._close(state.name, False)  # network op
 *             state.closed = True
 *         except Exception as ex:             # <<<<<<<<<<<<<<
 *             waiter.set_exception(ex)
 *             self._coreproto_error()
 */
        /*finally:*/ {
          /*normal exit:*/{
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_ex);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_ex);
            __pyx_cur_scope->__pyx_v_ex = NULL;
            goto __pyx_L24;
          }
          __pyx_L23_error:;
          /*exception exit:*/{
            __Pyx_PyThreadState_assign
            __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_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 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_13 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_15 = __pyx_filename;
            {
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_ex);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_ex);
              __pyx_cur_scope->__pyx_v_ex = NULL;
            }
            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_13; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_15;
            goto __pyx_L14_except_error;
          }
          __pyx_L24:;
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L13_exception_handled;
      }
      goto __pyx_L14_except_error;
      __pyx_L14_except_error:;

      /* "asyncpg/protocol/protocol.pyx":506
 *         timeout = self._get_timeout_impl(timeout)
 *         waiter = self._new_waiter(timeout)
 *         try:             # <<<<<<<<<<<<<<
 *             self._close(state.name, False)  # network op
 *             state.closed = True
 */
      __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_L10_error;
      __pyx_L13_exception_handled:;
      __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_L17_try_end:;
    }
  }

  /* "asyncpg/protocol/protocol.pyx":513
 *             self._coreproto_error()
 *         finally:
 *             return await waiter             # <<<<<<<<<<<<<<
 * 
 *     def is_closed(self):
 */
  /*finally:*/ {
    /*normal exit:*/{
      __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();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 3;
        return __pyx_r;
        __pyx_L29_resume_from_await:;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 513, __pyx_L1_error)
        __pyx_t_9 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_9);
      } else {
        __pyx_t_9 = NULL;
        if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_9) < 0) __PYX_ERR(0, 513, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
      }
      __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = 0;
      goto __pyx_L0;
    }
    __pyx_L10_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_assign
      __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_21, &__pyx_t_20, &__pyx_t_19);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10) < 0)) __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_21);
      __Pyx_XGOTREF(__pyx_t_20);
      __Pyx_XGOTREF(__pyx_t_19);
      {
        __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_t_10);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_10;
          __Pyx_XGIVEREF(__pyx_t_11);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_11;
          __Pyx_XGIVEREF(__pyx_t_12);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_12;
          __Pyx_XGIVEREF(__pyx_t_19);
          __pyx_cur_scope->__pyx_t_3 = __pyx_t_19;
          __Pyx_XGIVEREF(__pyx_t_20);
          __pyx_cur_scope->__pyx_t_4 = __pyx_t_20;
          __Pyx_XGIVEREF(__pyx_t_21);
          __pyx_cur_scope->__pyx_t_5 = __pyx_t_21;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 4;
          return __pyx_r;
          __pyx_L32_resume_from_await:;
          __pyx_t_10 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_10);
          __pyx_t_11 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_11);
          __pyx_t_12 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_12);
          __pyx_t_19 = __pyx_cur_scope->__pyx_t_3;
          __pyx_cur_scope->__pyx_t_3 = 0;
          __Pyx_XGOTREF(__pyx_t_19);
          __pyx_t_20 = __pyx_cur_scope->__pyx_t_4;
          __pyx_cur_scope->__pyx_t_4 = 0;
          __Pyx_XGOTREF(__pyx_t_20);
          __pyx_t_21 = __pyx_cur_scope->__pyx_t_5;
          __pyx_cur_scope->__pyx_t_5 = 0;
          __Pyx_XGOTREF(__pyx_t_21);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 513, __pyx_L31_error)
          __pyx_t_9 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_9);
        } else {
          __pyx_t_9 = NULL;
          if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_9) < 0) __PYX_ERR(0, 513, __pyx_L31_error)
          __Pyx_GOTREF(__pyx_t_9);
        }
        __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_9 = 0;
        goto __pyx_L30_return;
      }
      __pyx_L30_return:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_21);
        __Pyx_XGIVEREF(__pyx_t_20);
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_20, __pyx_t_19);
      }
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
      goto __pyx_L0;
      __pyx_L31_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_21);
        __Pyx_XGIVEREF(__pyx_t_20);
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_20, __pyx_t_19);
      }
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
      goto __pyx_L1_error;
    }
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "asyncpg/protocol/protocol.pyx":490
 *         return status_msg
 * 
 *     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_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("close_statement", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/protocol.pyx":515
 *             return await waiter
 * 
 *     def is_closed(self):             # <<<<<<<<<<<<<<
 *         return self.closing
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_38is_closed(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_38is_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_37is_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_37is_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":516
 * 
 *     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(0, 516, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "asyncpg/protocol/protocol.pyx":515
 *             return await waiter
 * 
 *     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":518
 *         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_40is_connected(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_40is_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_39is_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_39is_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":519
 * 
 *     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(0, 519, __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(0, 519, __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":518
 *         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":521
 *         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_42abort(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_42abort(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_41abort(((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_41abort(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":522
 * 
 *     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":523
 *     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":522
 * 
 *     def abort(self):
 *         if self.closing:             # <<<<<<<<<<<<<<
 *             return
 *         self.closing = True
 */
  }

  /* "asyncpg/protocol/protocol.pyx":524
 *         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":525
 *             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(0, 525, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/protocol.pyx":526
 *         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(0, 526, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/protocol.pyx":527
 *         self._handle_waiter_on_connection_lost(None)
 *         self._terminate()
 *         self.transport.abort()             # <<<<<<<<<<<<<<
 * 
 *     async def close(self, timeout):
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.transport, __pyx_n_s_abort); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 527, __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(0, 527, __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(0, 527, __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":521
 *         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_45generator9(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "asyncpg/protocol/protocol.pyx":529
 *         self.transport.abort()
 * 
 *     async def close(self, timeout):             # <<<<<<<<<<<<<<
 *         if self.closing:
 *             return
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_44close(PyObject *__pyx_v_self, PyObject *__pyx_v_timeout); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_44close(PyObject *__pyx_v_self, PyObject *__pyx_v_timeout) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("close (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_43close(((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self), ((PyObject *)__pyx_v_timeout));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_43close(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_timeout) {
  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_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_10_close *)__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close(__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 529, __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_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_45generator9, (PyObject *) __pyx_cur_scope, __pyx_n_s_close, __pyx_n_s_BaseProtocol_close, __pyx_n_s_asyncpg_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(0, 529, __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_45generator9(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close *__pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_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;
  PyObject *__pyx_t_6 = NULL;
  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;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("close", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_await;
    case 2: goto __pyx_L8_resume_from_await;
    case 3: goto __pyx_L10_resume_from_await;
    case 4: goto __pyx_L12_resume_from_await;
    case 5: goto __pyx_L22_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 529, __pyx_L1_error)

  /* "asyncpg/protocol/protocol.pyx":530
 * 
 *     async def close(self, timeout):
 *         if self.closing:             # <<<<<<<<<<<<<<
 *             return
 * 
 */
  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_self->closing != 0);
  if (__pyx_t_1) {

    /* "asyncpg/protocol/protocol.pyx":531
 *     async def close(self, timeout):
 *         if self.closing:
 *             return             # <<<<<<<<<<<<<<
 * 
 *         self.closing = True
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = NULL;
    goto __pyx_L0;

    /* "asyncpg/protocol/protocol.pyx":530
 * 
 *     async def close(self, timeout):
 *         if self.closing:             # <<<<<<<<<<<<<<
 *             return
 * 
 */
  }

  /* "asyncpg/protocol/protocol.pyx":533
 *             return
 * 
 *         self.closing = True             # <<<<<<<<<<<<<<
 * 
 *         if self.cancel_sent_waiter is not None:
 */
  __pyx_cur_scope->__pyx_v_self->closing = 1;

  /* "asyncpg/protocol/protocol.pyx":535
 *         self.closing = True
 * 
 *         if self.cancel_sent_waiter is not None:             # <<<<<<<<<<<<<<
 *             await self.cancel_sent_waiter
 *             self.cancel_sent_waiter = None
 */
  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_self->cancel_sent_waiter != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/protocol.pyx":536
 * 
 *         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();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 1;
      return __pyx_r;
      __pyx_L6_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 536, __pyx_L1_error)
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (exc_type) {
        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
        else __PYX_ERR(0, 536, __pyx_L1_error)
      }
    }

    /* "asyncpg/protocol/protocol.pyx":537
 *         if self.cancel_sent_waiter is not None:
 *             await self.cancel_sent_waiter
 *             self.cancel_sent_waiter = None             # <<<<<<<<<<<<<<
 * 
 *         if self.cancel_waiter is not 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":535
 *         self.closing = True
 * 
 *         if self.cancel_sent_waiter is not None:             # <<<<<<<<<<<<<<
 *             await self.cancel_sent_waiter
 *             self.cancel_sent_waiter = None
 */
  }

  /* "asyncpg/protocol/protocol.pyx":539
 *             self.cancel_sent_waiter = None
 * 
 *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
 *             await self.cancel_waiter
 * 
 */
  __pyx_t_2 = (__pyx_cur_scope->__pyx_v_self->cancel_waiter != Py_None);
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "asyncpg/protocol/protocol.pyx":540
 * 
 *         if self.cancel_waiter is not None:
 *             await self.cancel_waiter             # <<<<<<<<<<<<<<
 * 
 *         if self.waiter is not None:
 */
    __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();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 2;
      return __pyx_r;
      __pyx_L8_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 540, __pyx_L1_error)
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (exc_type) {
        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
        else __PYX_ERR(0, 540, __pyx_L1_error)
      }
    }

    /* "asyncpg/protocol/protocol.pyx":539
 *             self.cancel_sent_waiter = None
 * 
 *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
 *             await self.cancel_waiter
 * 
 */
  }

  /* "asyncpg/protocol/protocol.pyx":542
 *             await self.cancel_waiter
 * 
 *         if self.waiter is not None:             # <<<<<<<<<<<<<<
 *             # If there is a query running, cancel it
 *             self._request_cancel()
 */
  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_self->waiter != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/protocol.pyx":544
 *         if self.waiter is not None:
 *             # If there is a query running, cancel it
 *             self._request_cancel()             # <<<<<<<<<<<<<<
 *             await self.cancel_sent_waiter
 *             self.cancel_sent_waiter = None
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_request_cancel); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 544, __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(0, 544, __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(0, 544, __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":545
 *             # If there is a query running, cancel it
 *             self._request_cancel()
 *             await self.cancel_sent_waiter             # <<<<<<<<<<<<<<
 *             self.cancel_sent_waiter = None
 *             if self.cancel_waiter is not 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();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 3;
      return __pyx_r;
      __pyx_L10_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 545, __pyx_L1_error)
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (exc_type) {
        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
        else __PYX_ERR(0, 545, __pyx_L1_error)
      }
    }

    /* "asyncpg/protocol/protocol.pyx":546
 *             self._request_cancel()
 *             await self.cancel_sent_waiter
 *             self.cancel_sent_waiter = None             # <<<<<<<<<<<<<<
 *             if self.cancel_waiter is not None:
 *                 await self.cancel_waiter
 */
    __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":547
 *             await self.cancel_sent_waiter
 *             self.cancel_sent_waiter = None
 *             if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
 *                 await self.cancel_waiter
 * 
 */
    __pyx_t_2 = (__pyx_cur_scope->__pyx_v_self->cancel_waiter != Py_None);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "asyncpg/protocol/protocol.pyx":548
 *             self.cancel_sent_waiter = None
 *             if self.cancel_waiter is not None:
 *                 await self.cancel_waiter             # <<<<<<<<<<<<<<
 * 
 *         assert self.waiter is None
 */
      __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();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 4;
        return __pyx_r;
        __pyx_L12_resume_from_await:;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 548, __pyx_L1_error)
      } else {
        PyObject* exc_type = __Pyx_PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
          else __PYX_ERR(0, 548, __pyx_L1_error)
        }
      }

      /* "asyncpg/protocol/protocol.pyx":547
 *             await self.cancel_sent_waiter
 *             self.cancel_sent_waiter = None
 *             if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
 *                 await self.cancel_waiter
 * 
 */
    }

    /* "asyncpg/protocol/protocol.pyx":542
 *             await self.cancel_waiter
 * 
 *         if self.waiter is not None:             # <<<<<<<<<<<<<<
 *             # If there is a query running, cancel it
 *             self._request_cancel()
 */
  }

  /* "asyncpg/protocol/protocol.pyx":550
 *                 await self.cancel_waiter
 * 
 *         assert self.waiter is None             # <<<<<<<<<<<<<<
 * 
 *         timeout = self._get_timeout_impl(timeout)
 */
  #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(0, 550, __pyx_L1_error)
    }
  }
  #endif

  /* "asyncpg/protocol/protocol.pyx":552
 *         assert self.waiter is None
 * 
 *         timeout = self._get_timeout_impl(timeout)             # <<<<<<<<<<<<<<
 * 
 *         # Ask the server to terminate the connection and wait for it
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__get_timeout_impl(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_timeout); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 552, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_timeout);
  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_timeout, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":556
 *         # Ask the server to terminate the connection and wait for it
 *         # to drop.
 *         self.waiter = self._new_waiter(timeout)             # <<<<<<<<<<<<<<
 *         self._terminate()
 *         try:
 */
  __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(0, 556, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __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":557
 *         # to drop.
 *         self.waiter = self._new_waiter(timeout)
 *         self._terminate()             # <<<<<<<<<<<<<<
 *         try:
 *             await self.waiter
 */
  __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(0, 557, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":558
 *         self.waiter = self._new_waiter(timeout)
 *         self._terminate()
 *         try:             # <<<<<<<<<<<<<<
 *             await self.waiter
 *         except ConnectionResetError:
 */
  /*try:*/ {
    {
      __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":559
 *         self._terminate()
 *         try:
 *             await self.waiter             # <<<<<<<<<<<<<<
 *         except ConnectionResetError:
 *             # There appears to be a difference in behaviour of asyncio
 */
        __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_t_6);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
          __Pyx_XGIVEREF(__pyx_t_7);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
          __Pyx_XGIVEREF(__pyx_t_8);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 5;
          return __pyx_r;
          __pyx_L22_resume_from_await:;
          __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_6);
          __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_7);
          __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_8);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 559, __pyx_L16_error)
        } else {
          PyObject* exc_type = __Pyx_PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
            else __PYX_ERR(0, 559, __pyx_L16_error)
          }
        }

        /* "asyncpg/protocol/protocol.pyx":558
 *         self.waiter = self._new_waiter(timeout)
 *         self._terminate()
 *         try:             # <<<<<<<<<<<<<<
 *             await self.waiter
 *         except ConnectionResetError:
 */
      }
      __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_L21_try_end;
      __pyx_L16_error:;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "asyncpg/protocol/protocol.pyx":560
 *         try:
 *             await self.waiter
 *         except ConnectionResetError:             # <<<<<<<<<<<<<<
 *             # There appears to be a difference in behaviour of asyncio
 *             # in Windows, where, instead of calling protocol.connection_lost()
 */
      __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ConnectionResetError);
      if (__pyx_t_9) {
        __Pyx_ErrRestore(0,0,0);
        goto __pyx_L17_exception_handled;
      }
      goto __pyx_L18_except_error;
      __pyx_L18_except_error:;

      /* "asyncpg/protocol/protocol.pyx":558
 *         self.waiter = self._new_waiter(timeout)
 *         self._terminate()
 *         try:             # <<<<<<<<<<<<<<
 *             await self.waiter
 *         except ConnectionResetError:
 */
      __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_L14_error;
      __pyx_L17_exception_handled:;
      __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_L21_try_end:;
    }
  }

  /* "asyncpg/protocol/protocol.pyx":566
 *             pass
 *         finally:
 *             self.waiter = None             # <<<<<<<<<<<<<<
 *         self.transport.abort()
 * 
 */
  /*finally:*/ {
    /*normal exit:*/{
      __Pyx_INCREF(Py_None);
      __Pyx_GIVEREF(Py_None);
      __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 = Py_None;
      goto __pyx_L15;
    }
    __pyx_L14_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_assign
      __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6) < 0)) __Pyx_ErrFetch(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_14);
      __pyx_t_9 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_11 = __pyx_filename;
      {
        __Pyx_INCREF(Py_None);
        __Pyx_GIVEREF(Py_None);
        __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 = Py_None;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
      }
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_ErrRestore(__pyx_t_8, __pyx_t_7, __pyx_t_6);
      __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
      __pyx_lineno = __pyx_t_9; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_11;
      goto __pyx_L1_error;
    }
    __pyx_L15:;
  }

  /* "asyncpg/protocol/protocol.pyx":567
 *         finally:
 *             self.waiter = None
 *         self.transport.abort()             # <<<<<<<<<<<<<<
 * 
 *     def _request_cancel(self):
 */
  __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(0, 567, __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(0, 567, __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(0, 567, __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;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "asyncpg/protocol/protocol.pyx":529
 *         self.transport.abort()
 * 
 *     async def close(self, timeout):             # <<<<<<<<<<<<<<
 *         if self.closing:
 *             return
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __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_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/protocol.pyx":569
 *         self.transport.abort()
 * 
 *     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_47_request_cancel(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_47_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_46_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_46_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":570
 * 
 *     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(0, 570, __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(0, 570, __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":571
 *     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)
 *         self._set_state(PROTOCOL_CANCELLED)
 */
  __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(0, 571, __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(0, 571, __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":572
 *         self.cancel_waiter = self.create_future()
 *         self.cancel_sent_waiter = self.create_future()
 *         self.connection._cancel_current_command(self.cancel_sent_waiter)             # <<<<<<<<<<<<<<
 *         self._set_state(PROTOCOL_CANCELLED)
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->connection, __pyx_n_s_cancel_current_command); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 572, __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(0, 572, __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(0, 572, __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(0, 572, __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, 572, __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(0, 572, __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":573
 *         self.cancel_sent_waiter = self.create_future()
 *         self.connection._cancel_current_command(self.cancel_sent_waiter)
 *         self._set_state(PROTOCOL_CANCELLED)             # <<<<<<<<<<<<<<
 * 
 *     def _on_timeout(self, fut):
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._set_state(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v_self), __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_CANCELLED); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 573, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/protocol.pyx":569
 *         self.transport.abort()
 * 
 *     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":575
 *         self._set_state(PROTOCOL_CANCELLED)
 * 
 *     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_49_on_timeout(PyObject *__pyx_v_self, PyObject *__pyx_v_fut); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_49_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_48_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_48_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":576
 * 
 *     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(0, 576, __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(0, 576, __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(0, 576, __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(0, 576, __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":577
 *     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":578
 *         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":576
 * 
 *     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":579
 *                 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":576
 * 
 *     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":580
 *                 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(0, 580, __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(0, 580, __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(0, 580, __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":581
 *             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(0, 581, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_asyncio); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 581, __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(0, 581, __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(0, 581, __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(0, 581, __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(0, 581, __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(0, 581, __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(0, 581, __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(0, 581, __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(0, 581, __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":575
 *         self._set_state(PROTOCOL_CANCELLED)
 * 
 *     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":583
 *         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_51_on_waiter_completed(PyObject *__pyx_v_self, PyObject *__pyx_v_fut); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_51_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_50_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_50_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":584
 * 
 *     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":585
 *     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":584
 * 
 *     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":586
 *         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(0, 586, __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(0, 586, __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(0, 586, __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(0, 586, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_1) {

    /* "asyncpg/protocol/protocol.pyx":587
 *             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(0, 587, __pyx_L1_error)
    if (__pyx_t_1) {

      /* "asyncpg/protocol/protocol.pyx":588
 *         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(0, 588, __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(0, 588, __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(0, 588, __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":589
 *             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":587
 *             return
 *         if fut.cancelled():
 *             if self.timeout_handle:             # <<<<<<<<<<<<<<
 *                 self.timeout_handle.cancel()
 *                 self.timeout_handle = None
 */
    }

    /* "asyncpg/protocol/protocol.pyx":590
 *                 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(0, 590, __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(0, 590, __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(0, 590, __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":586
 *         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":583
 *         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":592
 *             self._request_cancel()
 * 
 *     def _create_future_fallback(self):             # <<<<<<<<<<<<<<
 *         return asyncio.Future(loop=self.loop)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_53_create_future_fallback(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_53_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_52_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_52_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":593
 * 
 *     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(0, 593, __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(0, 593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 593, __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(0, 593, __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(0, 593, __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":592
 *             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":595
 *         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":596
 * 
 *     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(0, 596, __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(0, 596, __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(0, 596, __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(0, 596, __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":597
 *     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(0, 597, __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(0, 597, __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__101, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 597, __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":600
 *                 '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":601
 *                 '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(0, 601, __pyx_L1_error)

      /* "asyncpg/protocol/protocol.pyx":600
 *                 '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":602
 *             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(0, 602, __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(0, 602, __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(0, 602, __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(0, 602, __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(0, 602, __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(0, 602, __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":596
 * 
 *     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":603
 *                 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":595
 *         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":605
 *         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":606
 * 
 *     cdef _set_server_parameter(self, name, val):
 *         self.settings.add_setting(name, val)             # <<<<<<<<<<<<<<
 * 
 *     def _get_timeout(self, timeout):
 */
  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(0, 606, __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(0, 606, __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(0, 606, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/protocol.pyx":605
 *         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":608
 *         self.settings.add_setting(name, val)
 * 
 *     def _get_timeout(self, timeout):             # <<<<<<<<<<<<<<
 *         if timeout is not None:
 *             try:
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_55_get_timeout(PyObject *__pyx_v_self, PyObject *__pyx_v_timeout); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_55_get_timeout(PyObject *__pyx_v_self, PyObject *__pyx_v_timeout) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_timeout (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_54_get_timeout(((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self), ((PyObject *)__pyx_v_timeout));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_54_get_timeout(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_timeout) {
  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;
  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;
  __Pyx_RefNannySetupContext("_get_timeout", 0);
  __Pyx_INCREF(__pyx_v_timeout);

  /* "asyncpg/protocol/protocol.pyx":609
 * 
 *     def _get_timeout(self, timeout):
 *         if timeout is not None:             # <<<<<<<<<<<<<<
 *             try:
 *                 if type(timeout) is bool:
 */
  __pyx_t_1 = (__pyx_v_timeout != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/protocol.pyx":610
 *     def _get_timeout(self, timeout):
 *         if timeout is not None:
 *             try:             # <<<<<<<<<<<<<<
 *                 if type(timeout) is bool:
 *                     raise ValueError
 */
    {
      __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/protocol.pyx":611
 *         if timeout is not None:
 *             try:
 *                 if type(timeout) is bool:             # <<<<<<<<<<<<<<
 *                     raise ValueError
 *                 timeout = float(timeout)
 */
        __pyx_t_2 = (((PyObject *)Py_TYPE(__pyx_v_timeout)) == ((PyObject*)&PyBool_Type));
        __pyx_t_1 = (__pyx_t_2 != 0);
        if (__pyx_t_1) {

          /* "asyncpg/protocol/protocol.pyx":612
 *             try:
 *                 if type(timeout) is bool:
 *                     raise ValueError             # <<<<<<<<<<<<<<
 *                 timeout = float(timeout)
 *             except ValueError:
 */
          __Pyx_Raise(__pyx_builtin_ValueError, 0, 0, 0);
          __PYX_ERR(0, 612, __pyx_L4_error)

          /* "asyncpg/protocol/protocol.pyx":611
 *         if timeout is not None:
 *             try:
 *                 if type(timeout) is bool:             # <<<<<<<<<<<<<<
 *                     raise ValueError
 *                 timeout = float(timeout)
 */
        }

        /* "asyncpg/protocol/protocol.pyx":613
 *                 if type(timeout) is bool:
 *                     raise ValueError
 *                 timeout = float(timeout)             # <<<<<<<<<<<<<<
 *             except ValueError:
 *                 raise ValueError(
 */
        __pyx_t_6 = __Pyx_PyNumber_Float(__pyx_v_timeout); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 613, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF_SET(__pyx_v_timeout, __pyx_t_6);
        __pyx_t_6 = 0;

        /* "asyncpg/protocol/protocol.pyx":610
 *     def _get_timeout(self, timeout):
 *         if timeout is not None:
 *             try:             # <<<<<<<<<<<<<<
 *                 if type(timeout) is bool:
 *                     raise ValueError
 */
      }
      __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_L9_try_end;
      __pyx_L4_error:;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "asyncpg/protocol/protocol.pyx":614
 *                     raise ValueError
 *                 timeout = float(timeout)
 *             except ValueError:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     'invalid timeout value: expected non-negative float '
 */
      __pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError);
      if (__pyx_t_7) {
        __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._get_timeout", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_8, &__pyx_t_9) < 0) __PYX_ERR(0, 614, __pyx_L6_except_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GOTREF(__pyx_t_9);

        /* "asyncpg/protocol/protocol.pyx":617
 *                 raise ValueError(
 *                     'invalid timeout value: expected non-negative float '
 *                     '(got {!r})'.format(timeout)) from None             # <<<<<<<<<<<<<<
 * 
 *         return self._get_timeout_impl(timeout)
 */
        __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_invalid_timeout_value_expected_n, __pyx_n_s_format); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 617, __pyx_L6_except_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_12 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
          __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
          if (likely(__pyx_t_12)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
            __Pyx_INCREF(__pyx_t_12);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_11, function);
          }
        }
        if (!__pyx_t_12) {
          __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_v_timeout); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 617, __pyx_L6_except_error)
          __Pyx_GOTREF(__pyx_t_10);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_11)) {
            PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_v_timeout};
            __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 617, __pyx_L6_except_error)
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_GOTREF(__pyx_t_10);
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
            PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_v_timeout};
            __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 617, __pyx_L6_except_error)
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_GOTREF(__pyx_t_10);
          } else
          #endif
          {
            __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 617, __pyx_L6_except_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_timeout);
            __Pyx_GIVEREF(__pyx_v_timeout);
            PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_v_timeout);
            __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_13, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 617, __pyx_L6_except_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

        /* "asyncpg/protocol/protocol.pyx":615
 *                 timeout = float(timeout)
 *             except ValueError:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     'invalid timeout value: expected non-negative float '
 *                     '(got {!r})'.format(timeout)) from None
 */
        __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 615, __pyx_L6_except_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10);
        __pyx_t_10 = 0;
        __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_11, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 615, __pyx_L6_except_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

        /* "asyncpg/protocol/protocol.pyx":617
 *                 raise ValueError(
 *                     'invalid timeout value: expected non-negative float '
 *                     '(got {!r})'.format(timeout)) from None             # <<<<<<<<<<<<<<
 * 
 *         return self._get_timeout_impl(timeout)
 */
        __Pyx_Raise(__pyx_t_10, 0, 0, Py_None);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __PYX_ERR(0, 615, __pyx_L6_except_error)
      }
      goto __pyx_L6_except_error;
      __pyx_L6_except_error:;

      /* "asyncpg/protocol/protocol.pyx":610
 *     def _get_timeout(self, timeout):
 *         if timeout is not None:
 *             try:             # <<<<<<<<<<<<<<
 *                 if type(timeout) is bool:
 *                     raise ValueError
 */
      __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_L9_try_end:;
    }

    /* "asyncpg/protocol/protocol.pyx":609
 * 
 *     def _get_timeout(self, timeout):
 *         if timeout is not None:             # <<<<<<<<<<<<<<
 *             try:
 *                 if type(timeout) is bool:
 */
  }

  /* "asyncpg/protocol/protocol.pyx":619
 *                     '(got {!r})'.format(timeout)) from None
 * 
 *         return self._get_timeout_impl(timeout)             # <<<<<<<<<<<<<<
 * 
 *     cdef inline _get_timeout_impl(self, timeout):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_9 = __pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__get_timeout_impl(__pyx_v_self, __pyx_v_timeout); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 619, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_r = __pyx_t_9;
  __pyx_t_9 = 0;
  goto __pyx_L0;

  /* "asyncpg/protocol/protocol.pyx":608
 *         self.settings.add_setting(name, val)
 * 
 *     def _get_timeout(self, timeout):             # <<<<<<<<<<<<<<
 *         if timeout is not None:
 *             try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __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_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._get_timeout", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_timeout);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/protocol.pyx":621
 *         return self._get_timeout_impl(timeout)
 * 
 *     cdef inline _get_timeout_impl(self, timeout):             # <<<<<<<<<<<<<<
 *         if timeout is None:
 *             timeout = self.connection._config.command_timeout
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__get_timeout_impl(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_timeout) {
  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;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("_get_timeout_impl", 0);
  __Pyx_INCREF(__pyx_v_timeout);

  /* "asyncpg/protocol/protocol.pyx":622
 * 
 *     cdef inline _get_timeout_impl(self, timeout):
 *         if timeout is None:             # <<<<<<<<<<<<<<
 *             timeout = self.connection._config.command_timeout
 *         elif timeout is NO_TIMEOUT:
 */
  __pyx_t_1 = (__pyx_v_timeout == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/protocol.pyx":623
 *     cdef inline _get_timeout_impl(self, timeout):
 *         if timeout is None:
 *             timeout = self.connection._config.command_timeout             # <<<<<<<<<<<<<<
 *         elif timeout is NO_TIMEOUT:
 *             timeout = None
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->connection, __pyx_n_s_config); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 623, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_command_timeout); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 623, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_timeout, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "asyncpg/protocol/protocol.pyx":622
 * 
 *     cdef inline _get_timeout_impl(self, timeout):
 *         if timeout is None:             # <<<<<<<<<<<<<<
 *             timeout = self.connection._config.command_timeout
 *         elif timeout is NO_TIMEOUT:
 */
    goto __pyx_L3;
  }

  /* "asyncpg/protocol/protocol.pyx":624
 *         if timeout is None:
 *             timeout = self.connection._config.command_timeout
 *         elif timeout is NO_TIMEOUT:             # <<<<<<<<<<<<<<
 *             timeout = None
 *         else:
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_NO_TIMEOUT); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = (__pyx_v_timeout == __pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "asyncpg/protocol/protocol.pyx":625
 *             timeout = self.connection._config.command_timeout
 *         elif timeout is NO_TIMEOUT:
 *             timeout = None             # <<<<<<<<<<<<<<
 *         else:
 *             timeout = float(timeout)
 */
    __Pyx_INCREF(Py_None);
    __Pyx_DECREF_SET(__pyx_v_timeout, Py_None);

    /* "asyncpg/protocol/protocol.pyx":624
 *         if timeout is None:
 *             timeout = self.connection._config.command_timeout
 *         elif timeout is NO_TIMEOUT:             # <<<<<<<<<<<<<<
 *             timeout = None
 *         else:
 */
    goto __pyx_L3;
  }

  /* "asyncpg/protocol/protocol.pyx":627
 *             timeout = None
 *         else:
 *             timeout = float(timeout)             # <<<<<<<<<<<<<<
 * 
 *         if timeout is not None and timeout <= 0:
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_PyNumber_Float(__pyx_v_timeout); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 627, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF_SET(__pyx_v_timeout, __pyx_t_4);
    __pyx_t_4 = 0;
  }
  __pyx_L3:;

  /* "asyncpg/protocol/protocol.pyx":629
 *             timeout = float(timeout)
 * 
 *         if timeout is not None and timeout <= 0:             # <<<<<<<<<<<<<<
 *             raise asyncio.TimeoutError()
 *         return timeout
 */
  __pyx_t_2 = (__pyx_v_timeout != Py_None);
  __pyx_t_5 = (__pyx_t_2 != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_1 = __pyx_t_5;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_timeout, __pyx_int_0, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 629, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 629, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_1 = __pyx_t_5;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_1) {

    /* "asyncpg/protocol/protocol.pyx":630
 * 
 *         if timeout is not None and timeout <= 0:
 *             raise asyncio.TimeoutError()             # <<<<<<<<<<<<<<
 *         return timeout
 * 
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_asyncio); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 630, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_TimeoutError); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 630, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (__pyx_t_3) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 630, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 630, __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(0, 630, __pyx_L1_error)

    /* "asyncpg/protocol/protocol.pyx":629
 *             timeout = float(timeout)
 * 
 *         if timeout is not None and timeout <= 0:             # <<<<<<<<<<<<<<
 *             raise asyncio.TimeoutError()
 *         return timeout
 */
  }

  /* "asyncpg/protocol/protocol.pyx":631
 *         if timeout is not None and timeout <= 0:
 *             raise asyncio.TimeoutError()
 *         return timeout             # <<<<<<<<<<<<<<
 * 
 *     cdef _check_state(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_timeout);
  __pyx_r = __pyx_v_timeout;
  goto __pyx_L0;

  /* "asyncpg/protocol/protocol.pyx":621
 *         return self._get_timeout_impl(timeout)
 * 
 *     cdef inline _get_timeout_impl(self, timeout):             # <<<<<<<<<<<<<<
 *         if timeout is None:
 *             timeout = self.connection._config.command_timeout
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._get_timeout_impl", __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":633
 *         return timeout
 * 
 *     cdef _check_state(self):             # <<<<<<<<<<<<<<
 *         if self.cancel_waiter is not None:
 *             raise apg_exc.InterfaceError(
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__check_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("_check_state", 0);

  /* "asyncpg/protocol/protocol.pyx":634
 * 
 *     cdef _check_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":635
 *     cdef _check_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(0, 635, __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(0, 635, __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__102, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 635, __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(0, 635, __pyx_L1_error)

    /* "asyncpg/protocol/protocol.pyx":634
 * 
 *     cdef _check_state(self):
 *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
 *             raise apg_exc.InterfaceError(
 *                 'cannot perform operation: another operation is cancelling')
 */
  }

  /* "asyncpg/protocol/protocol.pyx":637
 *             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":638
 *                 '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(0, 638, __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(0, 638, __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__103, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 638, __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(0, 638, __pyx_L1_error)

    /* "asyncpg/protocol/protocol.pyx":637
 *             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":640
 *             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":641
 *                 '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(0, 641, __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(0, 641, __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__104, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 641, __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(0, 641, __pyx_L1_error)

    /* "asyncpg/protocol/protocol.pyx":640
 *             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":633
 *         return timeout
 * 
 *     cdef _check_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._check_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":644
 *                 'cannot perform operation: another operation is in progress')
 * 
 *     def _is_cancelling(self):             # <<<<<<<<<<<<<<
 *         return (
 *             self.cancel_waiter is not None or
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_57_is_cancelling(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_57_is_cancelling(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_is_cancelling (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_56_is_cancelling(((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_56_is_cancelling(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_cancelling", 0);

  /* "asyncpg/protocol/protocol.pyx":645
 * 
 *     def _is_cancelling(self):
 *         return (             # <<<<<<<<<<<<<<
 *             self.cancel_waiter is not None or
 *             self.cancel_sent_waiter is not None
 */
  __Pyx_XDECREF(__pyx_r);

  /* "asyncpg/protocol/protocol.pyx":646
 *     def _is_cancelling(self):
 *         return (
 *             self.cancel_waiter is not None or             # <<<<<<<<<<<<<<
 *             self.cancel_sent_waiter is not None
 *         )
 */
  __pyx_t_2 = (__pyx_v_self->cancel_waiter != Py_None);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 646, __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/protocol.pyx":647
 *         return (
 *             self.cancel_waiter is not None or
 *             self.cancel_sent_waiter is not None             # <<<<<<<<<<<<<<
 *         )
 * 
 */
  __pyx_t_2 = (__pyx_v_self->cancel_sent_waiter != Py_None);
  __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 647, __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":644
 *                 'cannot perform operation: another operation is in progress')
 * 
 *     def _is_cancelling(self):             # <<<<<<<<<<<<<<
 *         return (
 *             self.cancel_waiter is not None or
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._is_cancelling", __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_60generator10(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "asyncpg/protocol/protocol.pyx":650
 *         )
 * 
 *     async def _wait_for_cancellation(self):             # <<<<<<<<<<<<<<
 *         if self.cancel_sent_waiter is not None:
 *             await self.cancel_sent_waiter
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_59_wait_for_cancellation(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_59_wait_for_cancellation(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_wait_for_cancellation (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_58_wait_for_cancellation(((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_58_wait_for_cancellation(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self) {
  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_wait_for_cancellation", 0);
  __pyx_cur_scope = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation *)__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation(__pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 650, __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_60generator10, (PyObject *) __pyx_cur_scope, __pyx_n_s_wait_for_cancellation, __pyx_n_s_BaseProtocol__wait_for_cancellat, __pyx_n_s_asyncpg_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(0, 650, __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._wait_for_cancellation", __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_60generator10(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation *__pyx_cur_scope = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_wait_for_cancellation", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L5_resume_from_await;
    case 2: goto __pyx_L7_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 650, __pyx_L1_error)

  /* "asyncpg/protocol/protocol.pyx":651
 * 
 *     async def _wait_for_cancellation(self):
 *         if self.cancel_sent_waiter is not None:             # <<<<<<<<<<<<<<
 *             await self.cancel_sent_waiter
 *             self.cancel_sent_waiter = None
 */
  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_self->cancel_sent_waiter != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/protocol.pyx":652
 *     async def _wait_for_cancellation(self):
 *         if self.cancel_sent_waiter is not None:
 *             await self.cancel_sent_waiter             # <<<<<<<<<<<<<<
 *             self.cancel_sent_waiter = None
 *         if self.cancel_waiter is not 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();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 1;
      return __pyx_r;
      __pyx_L5_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 652, __pyx_L1_error)
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (exc_type) {
        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
        else __PYX_ERR(0, 652, __pyx_L1_error)
      }
    }

    /* "asyncpg/protocol/protocol.pyx":653
 *         if self.cancel_sent_waiter is not None:
 *             await self.cancel_sent_waiter
 *             self.cancel_sent_waiter = None             # <<<<<<<<<<<<<<
 *         if self.cancel_waiter is not None:
 *             await self.cancel_waiter
 */
    __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":651
 * 
 *     async def _wait_for_cancellation(self):
 *         if self.cancel_sent_waiter is not None:             # <<<<<<<<<<<<<<
 *             await self.cancel_sent_waiter
 *             self.cancel_sent_waiter = None
 */
  }

  /* "asyncpg/protocol/protocol.pyx":654
 *             await self.cancel_sent_waiter
 *             self.cancel_sent_waiter = None
 *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
 *             await self.cancel_waiter
 * 
 */
  __pyx_t_2 = (__pyx_cur_scope->__pyx_v_self->cancel_waiter != Py_None);
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "asyncpg/protocol/protocol.pyx":655
 *             self.cancel_sent_waiter = None
 *         if self.cancel_waiter is not None:
 *             await self.cancel_waiter             # <<<<<<<<<<<<<<
 * 
 *     cdef _coreproto_error(self):
 */
    __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();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 2;
      return __pyx_r;
      __pyx_L7_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 655, __pyx_L1_error)
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (exc_type) {
        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
        else __PYX_ERR(0, 655, __pyx_L1_error)
      }
    }

    /* "asyncpg/protocol/protocol.pyx":654
 *             await self.cancel_sent_waiter
 *             self.cancel_sent_waiter = None
 *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
 *             await self.cancel_waiter
 * 
 */
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "asyncpg/protocol/protocol.pyx":650
 *         )
 * 
 *     async def _wait_for_cancellation(self):             # <<<<<<<<<<<<<<
 *         if self.cancel_sent_waiter is not None:
 *             await self.cancel_sent_waiter
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("_wait_for_cancellation", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/protocol.pyx":657
 *             await self.cancel_waiter
 * 
 *     cdef _coreproto_error(self):             # <<<<<<<<<<<<<<
 *         try:
 *             if self.waiter is not None:
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__coreproto_error(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;
  int __pyx_t_7;
  char const *__pyx_t_8;
  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;
  PyObject *__pyx_t_14 = NULL;
  __Pyx_RefNannySetupContext("_coreproto_error", 0);

  /* "asyncpg/protocol/protocol.pyx":658
 * 
 *     cdef _coreproto_error(self):
 *         try:             # <<<<<<<<<<<<<<
 *             if self.waiter is not None:
 *                 if not self.waiter.done():
 */
  /*try:*/ {

    /* "asyncpg/protocol/protocol.pyx":659
 *     cdef _coreproto_error(self):
 *         try:
 *             if self.waiter is not None:             # <<<<<<<<<<<<<<
 *                 if not self.waiter.done():
 *                     raise apg_exc.InternalClientError(
 */
    __pyx_t_1 = (__pyx_v_self->waiter != Py_None);
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {

      /* "asyncpg/protocol/protocol.pyx":660
 *         try:
 *             if self.waiter is not None:
 *                 if not self.waiter.done():             # <<<<<<<<<<<<<<
 *                     raise apg_exc.InternalClientError(
 *                         'waiter is not done while handling critical '
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->waiter, __pyx_n_s_done); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 660, __pyx_L4_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(0, 660, __pyx_L4_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(0, 660, __pyx_L4_error)
      }
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 660, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_1 = ((!__pyx_t_2) != 0);
      if (__pyx_t_1) {

        /* "asyncpg/protocol/protocol.pyx":661
 *             if self.waiter is not None:
 *                 if not self.waiter.done():
 *                     raise apg_exc.InternalClientError(             # <<<<<<<<<<<<<<
 *                         'waiter is not done while handling critical '
 *                         'protocol error')
 */
        __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 661, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_InternalClientError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 661, __pyx_L4_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__105, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 661, __pyx_L4_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(0, 661, __pyx_L4_error)

        /* "asyncpg/protocol/protocol.pyx":660
 *         try:
 *             if self.waiter is not None:
 *                 if not self.waiter.done():             # <<<<<<<<<<<<<<
 *                     raise apg_exc.InternalClientError(
 *                         'waiter is not done while handling critical '
 */
      }

      /* "asyncpg/protocol/protocol.pyx":664
 *                         'waiter is not done while handling critical '
 *                         'protocol error')
 *                 self.waiter = None             # <<<<<<<<<<<<<<
 *         finally:
 *             self.abort()
 */
      __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":659
 *     cdef _coreproto_error(self):
 *         try:
 *             if self.waiter is not None:             # <<<<<<<<<<<<<<
 *                 if not self.waiter.done():
 *                     raise apg_exc.InternalClientError(
 */
    }
  }

  /* "asyncpg/protocol/protocol.pyx":666
 *                 self.waiter = None
 *         finally:
 *             self.abort()             # <<<<<<<<<<<<<<
 * 
 *     cdef _new_waiter(self, timeout):
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_abort); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 666, __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(0, 666, __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(0, 666, __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;
      goto __pyx_L5;
    }
    __pyx_L4_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_14);
      __pyx_t_6 = __pyx_lineno; __pyx_t_7 = __pyx_clineno; __pyx_t_8 = __pyx_filename;
      {
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_abort); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 666, __pyx_L9_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(0, 666, __pyx_L9_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(0, 666, __pyx_L9_error)
        }
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
      }
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_ErrRestore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
      __pyx_lineno = __pyx_t_6; __pyx_clineno = __pyx_t_7; __pyx_filename = __pyx_t_8;
      goto __pyx_L1_error;
      __pyx_L9_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
      }
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L5:;
  }

  /* "asyncpg/protocol/protocol.pyx":657
 *             await self.cancel_waiter
 * 
 *     cdef _coreproto_error(self):             # <<<<<<<<<<<<<<
 *         try:
 *             if self.waiter is not 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_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._coreproto_error", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/protocol.pyx":668
 *             self.abort()
 * 
 *     cdef _new_waiter(self, timeout):             # <<<<<<<<<<<<<<
 *         if self.waiter is not None:
 *             raise apg_exc.InterfaceError(
 */

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
  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;
  __Pyx_RefNannySetupContext("_new_waiter", 0);

  /* "asyncpg/protocol/protocol.pyx":669
 * 
 *     cdef _new_waiter(self, timeout):
 *         if self.waiter 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_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/protocol.pyx":670
 *     cdef _new_waiter(self, timeout):
 *         if self.waiter is not None:
 *             raise apg_exc.InterfaceError(             # <<<<<<<<<<<<<<
 *                 'cannot perform operation: another operation is in progress')
 *         self.waiter = self.create_future()
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 670, __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(0, 670, __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__106, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 670, __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(0, 670, __pyx_L1_error)

    /* "asyncpg/protocol/protocol.pyx":669
 * 
 *     cdef _new_waiter(self, timeout):
 *         if self.waiter is not None:             # <<<<<<<<<<<<<<
 *             raise apg_exc.InterfaceError(
 *                 'cannot perform operation: another operation is in progress')
 */
  }

  /* "asyncpg/protocol/protocol.pyx":672
 *             raise apg_exc.InterfaceError(
 *                 'cannot perform operation: another operation is in progress')
 *         self.waiter = self.create_future()             # <<<<<<<<<<<<<<
 *         if timeout is not None:
 *             self.timeout_handle = self.connection._loop.call_later(
 */
  __Pyx_INCREF(__pyx_v_self->create_future);
  __pyx_t_4 = __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(0, 672, __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(0, 672, __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->waiter);
  __Pyx_DECREF(__pyx_v_self->waiter);
  __pyx_v_self->waiter = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":673
 *                 'cannot perform operation: another operation is in progress')
 *         self.waiter = self.create_future()
 *         if timeout is not None:             # <<<<<<<<<<<<<<
 *             self.timeout_handle = self.connection._loop.call_later(
 *                 timeout, self.timeout_callback, self.waiter)
 */
  __pyx_t_2 = (__pyx_v_timeout != Py_None);
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "asyncpg/protocol/protocol.pyx":674
 *         self.waiter = self.create_future()
 *         if timeout is not None:
 *             self.timeout_handle = self.connection._loop.call_later(             # <<<<<<<<<<<<<<
 *                 timeout, self.timeout_callback, self.waiter)
 *         self.waiter.add_done_callback(self.completed_callback)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->connection, __pyx_n_s_loop_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 674, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_call_later); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 674, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "asyncpg/protocol/protocol.pyx":675
 *         if timeout is not None:
 *             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_4 = NULL;
    __pyx_t_6 = 0;
    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);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_timeout, __pyx_v_self->timeout_callback, __pyx_v_self->waiter};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 674, __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[4] = {__pyx_t_4, __pyx_v_timeout, __pyx_v_self->timeout_callback, __pyx_v_self->waiter};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 674, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 674, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_4) {
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __pyx_t_4 = NULL;
      }
      __Pyx_INCREF(__pyx_v_timeout);
      __Pyx_GIVEREF(__pyx_v_timeout);
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_timeout);
      __Pyx_INCREF(__pyx_v_self->timeout_callback);
      __Pyx_GIVEREF(__pyx_v_self->timeout_callback);
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_self->timeout_callback);
      __Pyx_INCREF(__pyx_v_self->waiter);
      __Pyx_GIVEREF(__pyx_v_self->waiter);
      PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_self->waiter);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 674, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "asyncpg/protocol/protocol.pyx":674
 *         self.waiter = self.create_future()
 *         if timeout is not None:
 *             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_3);
    __Pyx_GOTREF(__pyx_v_self->timeout_handle);
    __Pyx_DECREF(__pyx_v_self->timeout_handle);
    __pyx_v_self->timeout_handle = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "asyncpg/protocol/protocol.pyx":673
 *                 'cannot perform operation: another operation is in progress')
 *         self.waiter = self.create_future()
 *         if timeout is not None:             # <<<<<<<<<<<<<<
 *             self.timeout_handle = self.connection._loop.call_later(
 *                 timeout, self.timeout_callback, self.waiter)
 */
  }

  /* "asyncpg/protocol/protocol.pyx":676
 *             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_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->waiter, __pyx_n_s_add_done_callback); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 676, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __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_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_self->completed_callback); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 676, __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_7, __pyx_v_self->completed_callback};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 676, __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_5)) {
      PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_self->completed_callback};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 676, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 676, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_7); __pyx_t_7 = NULL;
      __Pyx_INCREF(__pyx_v_self->completed_callback);
      __Pyx_GIVEREF(__pyx_v_self->completed_callback);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self->completed_callback);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 676, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":677
 *                 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":668
 *             self.abort()
 * 
 *     cdef _new_waiter(self, timeout):             # <<<<<<<<<<<<<<
 *         if self.waiter is not None:
 *             raise apg_exc.InterfaceError(
 */

  /* 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_7);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._new_waiter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/protocol.pyx":679
 *         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":680
 * 
 *     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(0, 680, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__107, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 680, __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":679
 *         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":682
 *         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":683
 * 
 *     cdef _on_result__prepare(self, object waiter):
 *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
 *             if self.statement is None:
 *                 raise apg_exc.InternalClientError(
 */
  __pyx_t_1 = (ASYNCPG_DEBUG != 0);
  if (__pyx_t_1) {

    /* "asyncpg/protocol/protocol.pyx":684
 *     cdef _on_result__prepare(self, object waiter):
 *         if ASYNCPG_DEBUG:
 *             if self.statement is None:             # <<<<<<<<<<<<<<
 *                 raise apg_exc.InternalClientError(
 *                     '_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":685
 *         if ASYNCPG_DEBUG:
 *             if self.statement is None:
 *                 raise apg_exc.InternalClientError(             # <<<<<<<<<<<<<<
 *                     '_on_result__prepare: statement is None')
 * 
 */
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 685, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_InternalClientError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 685, __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__108, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 685, __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(0, 685, __pyx_L1_error)

      /* "asyncpg/protocol/protocol.pyx":684
 *     cdef _on_result__prepare(self, object waiter):
 *         if ASYNCPG_DEBUG:
 *             if self.statement is None:             # <<<<<<<<<<<<<<
 *                 raise apg_exc.InternalClientError(
 *                     '_on_result__prepare: statement is None')
 */
    }

    /* "asyncpg/protocol/protocol.pyx":683
 * 
 *     cdef _on_result__prepare(self, object waiter):
 *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
 *             if self.statement is None:
 *                 raise apg_exc.InternalClientError(
 */
  }

  /* "asyncpg/protocol/protocol.pyx":688
 *                     '_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":689
 * 
 *         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(0, 689, __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":688
 *                     '_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":690
 *         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":691
 *             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(0, 691, __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":690
 *         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":692
 *         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(0, 692, __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(0, 692, __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(0, 692, __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(0, 692, __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(0, 692, __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(0, 692, __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":682
 *         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":694
 *         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":695
 * 
 *     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":696
 *     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(0, 696, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);

    /* "asyncpg/protocol/protocol.pyx":699
 *                 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(0, 699, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);

    /* "asyncpg/protocol/protocol.pyx":697
 *         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(0, 697, __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(0, 696, __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(0, 696, __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(0, 696, __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(0, 696, __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(0, 696, __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":695
 * 
 *     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":701
 *                 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(0, 701, __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(0, 701, __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(0, 701, __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(0, 701, __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(0, 701, __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(0, 701, __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":694
 *         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":703
 *             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":704
 * 
 *     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(0, 704, __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(0, 704, __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(0, 704, __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(0, 704, __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, 704, __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(0, 704, __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":703
 *             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":706
 *         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":707
 * 
 *     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(0, 707, __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(0, 707, __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(0, 707, __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(0, 707, __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, 707, __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(0, 707, __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":706
 *         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":709
 *         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":710
 * 
 *     cdef _on_result__simple_query(self, object waiter):
 *         waiter.set_result(self.result_status_msg.decode(self.encoding))             # <<<<<<<<<<<<<<
 * 
 *     cdef _on_result__copy_out(self, object waiter):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_waiter, __pyx_n_s_set_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 710, __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(0, 710, __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(0, 710, __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(0, 710, __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(0, 710, __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(0, 710, __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(0, 710, __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(0, 710, __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(0, 710, __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(0, 710, __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(0, 710, __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(0, 710, __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":709
 *         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":712
 *         waiter.set_result(self.result_status_msg.decode(self.encoding))
 * 
 *     cdef _on_result__copy_out(self, object waiter):             # <<<<<<<<<<<<<<
 *         cdef bint copy_done = self.state == PROTOCOL_COPY_OUT_DONE
 *         if copy_done:
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_result__copy_out(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_waiter) {
  int __pyx_v_copy_done;
  PyObject *__pyx_v_status_msg = 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;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("_on_result__copy_out", 0);

  /* "asyncpg/protocol/protocol.pyx":713
 * 
 *     cdef _on_result__copy_out(self, object waiter):
 *         cdef bint copy_done = self.state == PROTOCOL_COPY_OUT_DONE             # <<<<<<<<<<<<<<
 *         if copy_done:
 *             status_msg = self.result_status_msg.decode(self.encoding)
 */
  __pyx_v_copy_done = (__pyx_v_self->__pyx_base.state == __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_COPY_OUT_DONE);

  /* "asyncpg/protocol/protocol.pyx":714
 *     cdef _on_result__copy_out(self, object waiter):
 *         cdef bint copy_done = self.state == PROTOCOL_COPY_OUT_DONE
 *         if copy_done:             # <<<<<<<<<<<<<<
 *             status_msg = self.result_status_msg.decode(self.encoding)
 *         else:
 */
  __pyx_t_1 = (__pyx_v_copy_done != 0);
  if (__pyx_t_1) {

    /* "asyncpg/protocol/protocol.pyx":715
 *         cdef bint copy_done = self.state == PROTOCOL_COPY_OUT_DONE
 *         if copy_done:
 *             status_msg = self.result_status_msg.decode(self.encoding)             # <<<<<<<<<<<<<<
 *         else:
 *             status_msg = None
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.result_status_msg, __pyx_n_s_decode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 715, __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->__pyx_base.encoding); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 715, __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->__pyx_base.encoding};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 715, __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->__pyx_base.encoding};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 715, __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(0, 715, __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->__pyx_base.encoding);
        __Pyx_GIVEREF(__pyx_v_self->__pyx_base.encoding);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_self->__pyx_base.encoding);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 715, __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_v_status_msg = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "asyncpg/protocol/protocol.pyx":714
 *     cdef _on_result__copy_out(self, object waiter):
 *         cdef bint copy_done = self.state == PROTOCOL_COPY_OUT_DONE
 *         if copy_done:             # <<<<<<<<<<<<<<
 *             status_msg = self.result_status_msg.decode(self.encoding)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "asyncpg/protocol/protocol.pyx":717
 *             status_msg = self.result_status_msg.decode(self.encoding)
 *         else:
 *             status_msg = None             # <<<<<<<<<<<<<<
 * 
 *         # We need to put some backpressure on Postgres
 */
  /*else*/ {
    __Pyx_INCREF(Py_None);
    __pyx_v_status_msg = Py_None;
  }
  __pyx_L3:;

  /* "asyncpg/protocol/protocol.pyx":721
 *         # We need to put some backpressure on Postgres
 *         # here in case the sink is slow to process the output.
 *         self.pause_reading()             # <<<<<<<<<<<<<<
 * 
 *         waiter.set_result((self.result, copy_done, status_msg))
 */
  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol_pause_reading(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 721, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/protocol.pyx":723
 *         self.pause_reading()
 * 
 *         waiter.set_result((self.result, copy_done, status_msg))             # <<<<<<<<<<<<<<
 * 
 *     cdef _on_result__copy_in(self, object waiter):
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_waiter, __pyx_n_s_set_result); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 723, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_copy_done); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 723, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 723, __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_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
  __Pyx_INCREF(__pyx_v_status_msg);
  __Pyx_GIVEREF(__pyx_v_status_msg);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_status_msg);
  __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_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 723, __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(0, 723, __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(0, 723, __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(0, 723, __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(0, 723, __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":712
 *         waiter.set_result(self.result_status_msg.decode(self.encoding))
 * 
 *     cdef _on_result__copy_out(self, object waiter):             # <<<<<<<<<<<<<<
 *         cdef bint copy_done = self.state == PROTOCOL_COPY_OUT_DONE
 *         if copy_done:
 */

  /* 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__copy_out", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_status_msg);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/protocol.pyx":725
 *         waiter.set_result((self.result, copy_done, status_msg))
 * 
 *     cdef _on_result__copy_in(self, object waiter):             # <<<<<<<<<<<<<<
 *         status_msg = self.result_status_msg.decode(self.encoding)
 *         waiter.set_result(status_msg)
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_result__copy_in(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_waiter) {
  PyObject *__pyx_v_status_msg = 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("_on_result__copy_in", 0);

  /* "asyncpg/protocol/protocol.pyx":726
 * 
 *     cdef _on_result__copy_in(self, object waiter):
 *         status_msg = self.result_status_msg.decode(self.encoding)             # <<<<<<<<<<<<<<
 *         waiter.set_result(status_msg)
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.result_status_msg, __pyx_n_s_decode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 726, __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.encoding); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 726, __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.encoding};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 726, __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.encoding};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 726, __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, 726, __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.encoding);
      __Pyx_GIVEREF(__pyx_v_self->__pyx_base.encoding);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self->__pyx_base.encoding);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 726, __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_status_msg = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "asyncpg/protocol/protocol.pyx":727
 *     cdef _on_result__copy_in(self, object waiter):
 *         status_msg = self.result_status_msg.decode(self.encoding)
 *         waiter.set_result(status_msg)             # <<<<<<<<<<<<<<
 * 
 *     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(0, 727, __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_status_msg); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 727, __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_status_msg};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 727, __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_status_msg};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 727, __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(0, 727, __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_status_msg);
      __Pyx_GIVEREF(__pyx_v_status_msg);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_status_msg);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 727, __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(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/protocol.pyx":725
 *         waiter.set_result((self.result, copy_done, status_msg))
 * 
 *     cdef _on_result__copy_in(self, object waiter):             # <<<<<<<<<<<<<<
 *         status_msg = self.result_status_msg.decode(self.encoding)
 *         waiter.set_result(status_msg)
 */

  /* 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__copy_in", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_status_msg);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/protocol.pyx":729
 *         waiter.set_result(status_msg)
 * 
 *     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;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("_decode_row", 0);

  /* "asyncpg/protocol/protocol.pyx":730
 * 
 *     cdef _decode_row(self, const char* buf, ssize_t buf_len):
 *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
 *             if self.statement is None:
 *                 raise apg_exc.InternalClientError(
 */
  __pyx_t_1 = (ASYNCPG_DEBUG != 0);
  if (__pyx_t_1) {

    /* "asyncpg/protocol/protocol.pyx":731
 *     cdef _decode_row(self, const char* buf, ssize_t buf_len):
 *         if ASYNCPG_DEBUG:
 *             if self.statement is None:             # <<<<<<<<<<<<<<
 *                 raise apg_exc.InternalClientError(
 *                     '_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":732
 *         if ASYNCPG_DEBUG:
 *             if self.statement is None:
 *                 raise apg_exc.InternalClientError(             # <<<<<<<<<<<<<<
 *                     '_decode_row: statement is None')
 * 
 */
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 732, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_InternalClientError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 732, __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__109, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 732, __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(0, 732, __pyx_L1_error)

      /* "asyncpg/protocol/protocol.pyx":731
 *     cdef _decode_row(self, const char* buf, ssize_t buf_len):
 *         if ASYNCPG_DEBUG:
 *             if self.statement is None:             # <<<<<<<<<<<<<<
 *                 raise apg_exc.InternalClientError(
 *                     '_decode_row: statement is None')
 */
    }

    /* "asyncpg/protocol/protocol.pyx":730
 * 
 *     cdef _decode_row(self, const char* buf, ssize_t buf_len):
 *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
 *             if self.statement is None:
 *                 raise apg_exc.InternalClientError(
 */
  }

  /* "asyncpg/protocol/protocol.pyx":735
 *                     '_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(0, 735, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "asyncpg/protocol/protocol.pyx":729
 *         waiter.set_result(status_msg)
 * 
 *     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_XDECREF(__pyx_t_4);
  __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":737
 *         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;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  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":738
 * 
 *     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":739
 *     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":741
 *         self.waiter = None
 * 
 *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
 *             if waiter is None:
 *                 raise apg_exc.InternalClientError('_on_result: waiter is None')
 */
  __pyx_t_2 = (ASYNCPG_DEBUG != 0);
  if (__pyx_t_2) {

    /* "asyncpg/protocol/protocol.pyx":742
 * 
 *         if ASYNCPG_DEBUG:
 *             if waiter is None:             # <<<<<<<<<<<<<<
 *                 raise apg_exc.InternalClientError('_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":743
 *         if ASYNCPG_DEBUG:
 *             if waiter is None:
 *                 raise apg_exc.InternalClientError('_on_result: waiter is None')             # <<<<<<<<<<<<<<
 * 
 *         if waiter.cancelled():
 */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 743, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_InternalClientError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 743, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__110, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 743, __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(0, 743, __pyx_L1_error)

      /* "asyncpg/protocol/protocol.pyx":742
 * 
 *         if ASYNCPG_DEBUG:
 *             if waiter is None:             # <<<<<<<<<<<<<<
 *                 raise apg_exc.InternalClientError('_on_result: waiter is None')
 * 
 */
    }

    /* "asyncpg/protocol/protocol.pyx":741
 *         self.waiter = None
 * 
 *         if ASYNCPG_DEBUG:             # <<<<<<<<<<<<<<
 *             if waiter is None:
 *                 raise apg_exc.InternalClientError('_on_result: waiter is None')
 */
  }

  /* "asyncpg/protocol/protocol.pyx":745
 *                 raise apg_exc.InternalClientError('_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(0, 745, __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(0, 745, __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(0, 745, __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(0, 745, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_3) {

    /* "asyncpg/protocol/protocol.pyx":746
 * 
 *         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":745
 *                 raise apg_exc.InternalClientError('_on_result: waiter is None')
 * 
 *         if waiter.cancelled():             # <<<<<<<<<<<<<<
 *             return
 * 
 */
  }

  /* "asyncpg/protocol/protocol.pyx":748
 *             return
 * 
 *         if waiter.done():             # <<<<<<<<<<<<<<
 *             raise apg_exc.InternalClientError('_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(0, 748, __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(0, 748, __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(0, 748, __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(0, 748, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_3) {

    /* "asyncpg/protocol/protocol.pyx":749
 * 
 *         if waiter.done():
 *             raise apg_exc.InternalClientError('_on_result: waiter is done')             # <<<<<<<<<<<<<<
 * 
 *         if self.result_type == RESULT_FAILED:
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 749, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_InternalClientError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 749, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__111, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 749, __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(0, 749, __pyx_L1_error)

    /* "asyncpg/protocol/protocol.pyx":748
 *             return
 * 
 *         if waiter.done():             # <<<<<<<<<<<<<<
 *             raise apg_exc.InternalClientError('_on_result: waiter is done')
 * 
 */
  }

  /* "asyncpg/protocol/protocol.pyx":751
 *             raise apg_exc.InternalClientError('_on_result: waiter is done')
 * 
 *         if self.result_type == RESULT_FAILED:             # <<<<<<<<<<<<<<
 *             if isinstance(self.result, dict):
 *                 exc = apg_exc_base.PostgresError.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":752
 * 
 *         if self.result_type == RESULT_FAILED:
 *             if isinstance(self.result, dict):             # <<<<<<<<<<<<<<
 *                 exc = apg_exc_base.PostgresError.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":753
 *         if self.result_type == RESULT_FAILED:
 *             if isinstance(self.result, dict):
 *                 exc = apg_exc_base.PostgresError.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(0, 753, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_PostgresError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 753, __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(0, 753, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "asyncpg/protocol/protocol.pyx":754
 *             if isinstance(self.result, dict):
 *                 exc = apg_exc_base.PostgresError.new(
 *                     self.result, query=self.last_query)             # <<<<<<<<<<<<<<
 *             else:
 *                 exc = self.result
 */
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 753, __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 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 754, __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(0, 754, __pyx_L1_error)

      /* "asyncpg/protocol/protocol.pyx":753
 *         if self.result_type == RESULT_FAILED:
 *             if isinstance(self.result, dict):
 *                 exc = apg_exc_base.PostgresError.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(0, 753, __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":752
 * 
 *         if self.result_type == RESULT_FAILED:
 *             if isinstance(self.result, dict):             # <<<<<<<<<<<<<<
 *                 exc = apg_exc_base.PostgresError.new(
 *                     self.result, query=self.last_query)
 */
      goto __pyx_L8;
    }

    /* "asyncpg/protocol/protocol.pyx":756
 *                     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":757
 *             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(0, 757, __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(0, 757, __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(0, 757, __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(0, 757, __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(0, 757, __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(0, 757, __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":758
 *                 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":751
 *             raise apg_exc.InternalClientError('_on_result: waiter is done')
 * 
 *         if self.result_type == RESULT_FAILED:             # <<<<<<<<<<<<<<
 *             if isinstance(self.result, dict):
 *                 exc = apg_exc_base.PostgresError.new(
 */
  }

  /* "asyncpg/protocol/protocol.pyx":760
 *             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":761
 * 
 *         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":762
 *         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(0, 762, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "asyncpg/protocol/protocol.pyx":761
 * 
 *         try:
 *             if self.state == PROTOCOL_AUTH:             # <<<<<<<<<<<<<<
 *                 self._on_result__connect(waiter)
 * 
 */
        break;

        /* "asyncpg/protocol/protocol.pyx":764
 *                 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":765
 * 
 *             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(0, 765, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "asyncpg/protocol/protocol.pyx":764
 *                 self._on_result__connect(waiter)
 * 
 *             elif self.state == PROTOCOL_PREPARE:             # <<<<<<<<<<<<<<
 *                 self._on_result__prepare(waiter)
 * 
 */
        break;

        /* "asyncpg/protocol/protocol.pyx":767
 *                 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":768
 * 
 *             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(0, 768, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "asyncpg/protocol/protocol.pyx":767
 *                 self._on_result__prepare(waiter)
 * 
 *             elif self.state == PROTOCOL_BIND_EXECUTE:             # <<<<<<<<<<<<<<
 *                 self._on_result__bind_and_exec(waiter)
 * 
 */
        break;

        /* "asyncpg/protocol/protocol.pyx":770
 *                 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":771
 * 
 *             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(0, 771, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "asyncpg/protocol/protocol.pyx":770
 *                 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":773
 *                 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":774
 * 
 *             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(0, 774, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "asyncpg/protocol/protocol.pyx":773
 *                 self._on_result__bind_and_exec(waiter)
 * 
 *             elif self.state == PROTOCOL_EXECUTE:             # <<<<<<<<<<<<<<
 *                 self._on_result__bind_and_exec(waiter)
 * 
 */
        break;

        /* "asyncpg/protocol/protocol.pyx":776
 *                 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":777
 * 
 *             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(0, 777, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "asyncpg/protocol/protocol.pyx":776
 *                 self._on_result__bind_and_exec(waiter)
 * 
 *             elif self.state == PROTOCOL_BIND:             # <<<<<<<<<<<<<<
 *                 self._on_result__bind(waiter)
 * 
 */
        break;

        /* "asyncpg/protocol/protocol.pyx":779
 *                 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":780
 * 
 *             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(0, 780, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "asyncpg/protocol/protocol.pyx":779
 *                 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":782
 *                 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":783
 * 
 *             elif self.state == PROTOCOL_SIMPLE_QUERY:
 *                 self._on_result__simple_query(waiter)             # <<<<<<<<<<<<<<
 * 
 *             elif (self.state == PROTOCOL_COPY_OUT_DATA or
 */
        __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(0, 783, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "asyncpg/protocol/protocol.pyx":782
 *                 self._on_result__close_stmt_or_portal(waiter)
 * 
 *             elif self.state == PROTOCOL_SIMPLE_QUERY:             # <<<<<<<<<<<<<<
 *                 self._on_result__simple_query(waiter)
 * 
 */
        break;

        /* "asyncpg/protocol/protocol.pyx":785
 *                 self._on_result__simple_query(waiter)
 * 
 *             elif (self.state == PROTOCOL_COPY_OUT_DATA or             # <<<<<<<<<<<<<<
 *                     self.state == PROTOCOL_COPY_OUT_DONE):
 *                 self._on_result__copy_out(waiter)
 */
        case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_COPY_OUT_DATA:

        /* "asyncpg/protocol/protocol.pyx":786
 * 
 *             elif (self.state == PROTOCOL_COPY_OUT_DATA or
 *                     self.state == PROTOCOL_COPY_OUT_DONE):             # <<<<<<<<<<<<<<
 *                 self._on_result__copy_out(waiter)
 * 
 */
        case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_COPY_OUT_DONE:

        /* "asyncpg/protocol/protocol.pyx":787
 *             elif (self.state == PROTOCOL_COPY_OUT_DATA or
 *                     self.state == PROTOCOL_COPY_OUT_DONE):
 *                 self._on_result__copy_out(waiter)             # <<<<<<<<<<<<<<
 * 
 *             elif self.state == PROTOCOL_COPY_IN_DATA:
 */
        __pyx_t_6 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self->__pyx_base.__pyx_vtab)->_on_result__copy_out(__pyx_v_self, __pyx_v_waiter); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 787, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "asyncpg/protocol/protocol.pyx":785
 *                 self._on_result__simple_query(waiter)
 * 
 *             elif (self.state == PROTOCOL_COPY_OUT_DATA or             # <<<<<<<<<<<<<<
 *                     self.state == PROTOCOL_COPY_OUT_DONE):
 *                 self._on_result__copy_out(waiter)
 */
        break;

        /* "asyncpg/protocol/protocol.pyx":789
 *                 self._on_result__copy_out(waiter)
 * 
 *             elif self.state == PROTOCOL_COPY_IN_DATA:             # <<<<<<<<<<<<<<
 *                 self._on_result__copy_in(waiter)
 * 
 */
        case __pyx_e_7asyncpg_8protocol_8protocol_PROTOCOL_COPY_IN_DATA:

        /* "asyncpg/protocol/protocol.pyx":790
 * 
 *             elif self.state == PROTOCOL_COPY_IN_DATA:
 *                 self._on_result__copy_in(waiter)             # <<<<<<<<<<<<<<
 * 
 *             else:
 */
        __pyx_t_6 = ((struct __pyx_vtabstruct_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self->__pyx_base.__pyx_vtab)->_on_result__copy_in(__pyx_v_self, __pyx_v_waiter); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 790, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "asyncpg/protocol/protocol.pyx":789
 *                 self._on_result__copy_out(waiter)
 * 
 *             elif self.state == PROTOCOL_COPY_IN_DATA:             # <<<<<<<<<<<<<<
 *                 self._on_result__copy_in(waiter)
 * 
 */
        break;
        default:

        /* "asyncpg/protocol/protocol.pyx":793
 * 
 *             else:
 *                 raise apg_exc.InternalClientError(             # <<<<<<<<<<<<<<
 *                     'got result for unknown protocol state {}'.
 *                     format(self.state))
 */
        __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_apg_exc); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 793, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_InternalClientError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 793, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "asyncpg/protocol/protocol.pyx":794
 *             else:
 *                 raise apg_exc.InternalClientError(
 *                     'got result for unknown protocol state {}'.             # <<<<<<<<<<<<<<
 *                     format(self.state))
 * 
 */
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_got_result_for_unknown_protocol, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 794, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_4);

        /* "asyncpg/protocol/protocol.pyx":795
 *                 raise apg_exc.InternalClientError(
 *                     'got result for unknown protocol state {}'.
 *                     format(self.state))             # <<<<<<<<<<<<<<
 * 
 *         except Exception as exc:
 */
        __pyx_t_10 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ProtocolState(__pyx_v_self->__pyx_base.state); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 795, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_11 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_11)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_11);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
          }
        }
        if (!__pyx_t_11) {
          __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 795, __pyx_L9_error)
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_5);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_4)) {
            PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_10};
            __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 795, __pyx_L9_error)
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
            PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_10};
            __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 795, __pyx_L9_error)
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          } else
          #endif
          {
            __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 795, __pyx_L9_error)
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL;
            __Pyx_GIVEREF(__pyx_t_10);
            PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_10);
            __pyx_t_10 = 0;
            __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_12, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 795, __pyx_L9_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_1, function);
          }
        }
        if (!__pyx_t_4) {
          __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 793, __pyx_L9_error)
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_6);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_1)) {
            PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_5};
            __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 793, __pyx_L9_error)
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
            PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_5};
            __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 793, __pyx_L9_error)
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          } else
          #endif
          {
            __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 793, __pyx_L9_error)
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_4); __pyx_t_4 = NULL;
            __Pyx_GIVEREF(__pyx_t_5);
            PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_5);
            __pyx_t_5 = 0;
            __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_12, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 793, __pyx_L9_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_Raise(__pyx_t_6, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __PYX_ERR(0, 793, __pyx_L9_error)
        break;
      }

      /* "asyncpg/protocol/protocol.pyx":760
 *             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_L14_try_end;
    __pyx_L9_error:;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "asyncpg/protocol/protocol.pyx":797
 *                     format(self.state))
 * 
 *         except Exception as exc:             # <<<<<<<<<<<<<<
 *             waiter.set_exception(exc)
 * 
 */
    __pyx_t_13 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
    if (__pyx_t_13) {
      __Pyx_AddTraceback("asyncpg.protocol.protocol.BaseProtocol._dispatch_result", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_1, &__pyx_t_12) < 0) __PYX_ERR(0, 797, __pyx_L11_except_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_v_exc = __pyx_t_1;
      /*try:*/ {

        /* "asyncpg/protocol/protocol.pyx":798
 * 
 *         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(0, 798, __pyx_L20_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_10 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_10)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
          }
        }
        if (!__pyx_t_10) {
          __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_exc); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 798, __pyx_L20_error)
          __Pyx_GOTREF(__pyx_t_5);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_4)) {
            PyObject *__pyx_temp[2] = {__pyx_t_10, __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(0, 798, __pyx_L20_error)
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 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_10, __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(0, 798, __pyx_L20_error)
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_GOTREF(__pyx_t_5);
          } else
          #endif
          {
            __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 798, __pyx_L20_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_INCREF(__pyx_v_exc);
            __Pyx_GIVEREF(__pyx_v_exc);
            PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_exc);
            __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 798, __pyx_L20_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }

      /* "asyncpg/protocol/protocol.pyx":797
 *                     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_L21;
        }
        __pyx_L20_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __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_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 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_13 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_15 = __pyx_filename;
          {
            __Pyx_DECREF(__pyx_v_exc);
            __pyx_v_exc = NULL;
          }
          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_13; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_15;
          goto __pyx_L11_except_error;
        }
        __pyx_L21:;
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      goto __pyx_L10_exception_handled;
    }
    goto __pyx_L11_except_error;
    __pyx_L11_except_error:;

    /* "asyncpg/protocol/protocol.pyx":760
 *             return
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if self.state == PROTOCOL_AUTH:
 *                 self._on_result__connect(waiter)
 */
    __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_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_L14_try_end:;
  }

  /* "asyncpg/protocol/protocol.pyx":737
 *         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_11);
  __Pyx_XDECREF(__pyx_t_12);
  __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":800
 *             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;
  int __pyx_t_7;
  int __pyx_t_8;
  char const *__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("_on_result", 0);

  /* "asyncpg/protocol/protocol.pyx":801
 * 
 *     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":802
 *     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(0, 802, __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(0, 802, __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(0, 802, __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":803
 *         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":801
 * 
 *     cdef _on_result(self):
 *         if self.timeout_handle is not None:             # <<<<<<<<<<<<<<
 *             self.timeout_handle.cancel()
 *             self.timeout_handle = None
 */
  }

  /* "asyncpg/protocol/protocol.pyx":805
 *             self.timeout_handle = None
 * 
 *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
 *             # We have received the result of a cancelled command.
 *             if not self.cancel_waiter.done():
 */
  __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":807
 *         if self.cancel_waiter is not None:
 *             # We have received the result of a cancelled command.
 *             if not self.cancel_waiter.done():             # <<<<<<<<<<<<<<
 *                 # The cancellation future might have been cancelled
 *                 # by the cancellation of the entire task running the query.
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->cancel_waiter, __pyx_n_s_done); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 807, __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(0, 807, __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(0, 807, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 807, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = ((!__pyx_t_1) != 0);
    if (__pyx_t_2) {

      /* "asyncpg/protocol/protocol.pyx":810
 *                 # The cancellation future might have been cancelled
 *                 # by the cancellation of the entire task running the query.
 *                 self.cancel_waiter.set_result(None)             # <<<<<<<<<<<<<<
 *             self.cancel_waiter = None
 *             if self.waiter is not None and self.waiter.done():
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->cancel_waiter, __pyx_n_s_set_result); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 810, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__112, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 810, __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":807
 *         if self.cancel_waiter is not None:
 *             # We have received the result of a cancelled command.
 *             if not self.cancel_waiter.done():             # <<<<<<<<<<<<<<
 *                 # The cancellation future might have been cancelled
 *                 # by the cancellation of the entire task running the query.
 */
    }

    /* "asyncpg/protocol/protocol.pyx":811
 *                 # by the cancellation of the entire task running the query.
 *                 self.cancel_waiter.set_result(None)
 *             self.cancel_waiter = None             # <<<<<<<<<<<<<<
 *             if self.waiter is not None and self.waiter.done():
 *                 self.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":812
 *                 self.cancel_waiter.set_result(None)
 *             self.cancel_waiter = None
 *             if self.waiter is not None and self.waiter.done():             # <<<<<<<<<<<<<<
 *                 self.waiter = None
 *             if self.waiter is None:
 */
    __pyx_t_1 = (__pyx_v_self->waiter != Py_None);
    __pyx_t_6 = (__pyx_t_1 != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_2 = __pyx_t_6;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->waiter, __pyx_n_s_done); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 812, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __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_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 812, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 812, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 812, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_2 = __pyx_t_6;
    __pyx_L7_bool_binop_done:;
    if (__pyx_t_2) {

      /* "asyncpg/protocol/protocol.pyx":813
 *             self.cancel_waiter = None
 *             if self.waiter is not None and self.waiter.done():
 *                 self.waiter = None             # <<<<<<<<<<<<<<
 *             if self.waiter is 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":812
 *                 self.cancel_waiter.set_result(None)
 *             self.cancel_waiter = None
 *             if self.waiter is not None and self.waiter.done():             # <<<<<<<<<<<<<<
 *                 self.waiter = None
 *             if self.waiter is None:
 */
    }

    /* "asyncpg/protocol/protocol.pyx":814
 *             if self.waiter is not None and self.waiter.done():
 *                 self.waiter = None
 *             if self.waiter is None:             # <<<<<<<<<<<<<<
 *                 return
 * 
 */
    __pyx_t_2 = (__pyx_v_self->waiter == Py_None);
    __pyx_t_6 = (__pyx_t_2 != 0);
    if (__pyx_t_6) {

      /* "asyncpg/protocol/protocol.pyx":815
 *                 self.waiter = None
 *             if self.waiter is None:
 *                 return             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;

      /* "asyncpg/protocol/protocol.pyx":814
 *             if self.waiter is not None and self.waiter.done():
 *                 self.waiter = None
 *             if self.waiter is None:             # <<<<<<<<<<<<<<
 *                 return
 * 
 */
    }

    /* "asyncpg/protocol/protocol.pyx":805
 *             self.timeout_handle = None
 * 
 *         if self.cancel_waiter is not None:             # <<<<<<<<<<<<<<
 *             # We have received the result of a cancelled command.
 *             if not self.cancel_waiter.done():
 */
  }

  /* "asyncpg/protocol/protocol.pyx":817
 *                 return
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             self._dispatch_result()
 *         finally:
 */
  /*try:*/ {

    /* "asyncpg/protocol/protocol.pyx":818
 * 
 *         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(0, 818, __pyx_L11_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }

  /* "asyncpg/protocol/protocol.pyx":820
 *             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":821
 *         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":822
 *             self.statement = None
 *             self.last_query = None
 *             self.return_extra = False             # <<<<<<<<<<<<<<
 * 
 *     cdef _on_notice(self, parsed):
 */
      __pyx_v_self->return_extra = 0;
      goto __pyx_L12;
    }
    __pyx_L11_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 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_13, &__pyx_t_14, &__pyx_t_15);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12) < 0)) __Pyx_ErrFetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_10);
      __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_t_7 = __pyx_lineno; __pyx_t_8 = __pyx_clineno; __pyx_t_9 = __pyx_filename;
      {

        /* "asyncpg/protocol/protocol.pyx":820
 *             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":821
 *         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":822
 *             self.statement = None
 *             self.last_query = None
 *             self.return_extra = False             # <<<<<<<<<<<<<<
 * 
 *     cdef _on_notice(self, parsed):
 */
        __pyx_v_self->return_extra = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_XGIVEREF(__pyx_t_15);
        __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
      }
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_ErrRestore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
      __pyx_lineno = __pyx_t_7; __pyx_clineno = __pyx_t_8; __pyx_filename = __pyx_t_9;
      goto __pyx_L1_error;
    }
    __pyx_L12:;
  }

  /* "asyncpg/protocol/protocol.pyx":800
 *             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_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":824
 *             self.return_extra = False
 * 
 *     cdef _on_notice(self, parsed):             # <<<<<<<<<<<<<<
 *         self.connection._process_log_message(parsed, self.last_query)
 * 
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_notice(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v_parsed) {
  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_notice", 0);

  /* "asyncpg/protocol/protocol.pyx":825
 * 
 *     cdef _on_notice(self, parsed):
 *         self.connection._process_log_message(parsed, self.last_query)             # <<<<<<<<<<<<<<
 * 
 *     cdef _on_notification(self, pid, channel, payload):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->connection, __pyx_n_s_process_log_message); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 825, __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, __pyx_v_parsed, __pyx_v_self->last_query};
    __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(0, 825, __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, __pyx_v_parsed, __pyx_v_self->last_query};
    __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(0, 825, __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(0, 825, __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_parsed);
    __Pyx_GIVEREF(__pyx_v_parsed);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_parsed);
    __Pyx_INCREF(__pyx_v_self->last_query);
    __Pyx_GIVEREF(__pyx_v_self->last_query);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_self->last_query);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 825, __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":824
 *             self.return_extra = False
 * 
 *     cdef _on_notice(self, parsed):             # <<<<<<<<<<<<<<
 *         self.connection._process_log_message(parsed, self.last_query)
 * 
 */

  /* 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_notice", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/protocol.pyx":827
 *         self.connection._process_log_message(parsed, self.last_query)
 * 
 *     cdef _on_notification(self, pid, channel, payload):             # <<<<<<<<<<<<<<
 *         self.connection._process_notification(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":828
 * 
 *     cdef _on_notification(self, pid, channel, payload):
 *         self.connection._process_notification(pid, channel, payload)             # <<<<<<<<<<<<<<
 * 
 *     cdef _on_connection_lost(self, exc):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->connection, __pyx_n_s_process_notification); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 828, __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(0, 828, __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(0, 828, __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(0, 828, __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(0, 828, __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":827
 *         self.connection._process_log_message(parsed, self.last_query)
 * 
 *     cdef _on_notification(self, pid, channel, payload):             # <<<<<<<<<<<<<<
 *         self.connection._process_notification(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":830
 *         self.connection._process_notification(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":831
 * 
 *     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":834
 *             # 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(0, 834, __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(0, 834, __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(0, 834, __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(0, 834, __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":835
 *             # 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":836
 *             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(0, 836, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__113, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 836, __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":835
 *             # 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":838
 *                     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(0, 838, __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(0, 838, __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(0, 838, __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(0, 838, __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(0, 838, __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(0, 838, __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":834
 *             # 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":839
 *                 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":831
 * 
 *     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":844
 *             # 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":845
 *             # Throw an error in any awaiting waiter.
 *             self.closing = True
 *             self._handle_waiter_on_connection_lost(exc)             # <<<<<<<<<<<<<<
 * 
 *     def pause_writing(self):
 */
    __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(0, 845, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __pyx_L3:;

  /* "asyncpg/protocol/protocol.pyx":830
 *         self.connection._process_notification(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.pyx":847
 *             self._handle_waiter_on_connection_lost(exc)
 * 
 *     def pause_writing(self):             # <<<<<<<<<<<<<<
 *         self.writing_allowed.clear()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_62pause_writing(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_62pause_writing(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("pause_writing (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_61pause_writing(((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_61pause_writing(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("pause_writing", 0);

  /* "asyncpg/protocol/protocol.pyx":848
 * 
 *     def pause_writing(self):
 *         self.writing_allowed.clear()             # <<<<<<<<<<<<<<
 * 
 *     def resume_writing(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_writing_allowed); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 848, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_clear); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 848, __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_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 848, __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(0, 848, __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/protocol.pyx":847
 *             self._handle_waiter_on_connection_lost(exc)
 * 
 *     def pause_writing(self):             # <<<<<<<<<<<<<<
 *         self.writing_allowed.clear()
 * 
 */

  /* 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.BaseProtocol.pause_writing", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/protocol.pyx":850
 *         self.writing_allowed.clear()
 * 
 *     def resume_writing(self):             # <<<<<<<<<<<<<<
 *         self.writing_allowed.set()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_64resume_writing(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_64resume_writing(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("resume_writing (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_63resume_writing(((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_63resume_writing(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("resume_writing", 0);

  /* "asyncpg/protocol/protocol.pyx":851
 * 
 *     def resume_writing(self):
 *         self.writing_allowed.set()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_writing_allowed); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 851, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_set); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 851, __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_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 851, __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(0, 851, __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/protocol.pyx":850
 *         self.writing_allowed.clear()
 * 
 *     def resume_writing(self):             # <<<<<<<<<<<<<<
 *         self.writing_allowed.set()
 * 
 */

  /* 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.BaseProtocol.resume_writing", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/protocol.pxd":47
 *         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(29, 47, __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;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self._discard_data, self._execute_iter, self._execute_portal_name, self._execute_stmt_name, self._skip_discard, self.address, self.backend_pid, self.backend_secret, self.buffer, self.cancel_sent_waiter, self.cancel_waiter, self.closing, self.completed_callback, self.con_params, self.con_status, self.connection, self.create_future, self.encoding, self.is_reading, self.last_query, self.loop, self.queries_count, self.result, self.result_execute_completed, self.result_param_desc, self.result_row_desc, self.result_status_msg, self.result_type, self.return_extra, self.settings, self.state, self.statement, self.timeout_callback, self.timeout_handle, self.transport, self.waiter, self.writing_paused, self.xact_status)
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_66__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_66__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_65__reduce_cython__(((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_65__reduce_cython__(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = 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;
  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;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  int __pyx_t_17;
  int __pyx_t_18;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     cdef bint use_setstate
 *     state = (self._discard_data, self._execute_iter, self._execute_portal_name, self._execute_stmt_name, self._skip_discard, self.address, self.backend_pid, self.backend_secret, self.buffer, self.cancel_sent_waiter, self.cancel_waiter, self.closing, self.completed_callback, self.con_params, self.con_status, self.connection, self.create_future, self.encoding, self.is_reading, self.last_query, self.loop, self.queries_count, self.result, self.result_execute_completed, self.result_param_desc, self.result_row_desc, self.result_status_msg, self.result_type, self.return_extra, self.settings, self.state, self.statement, self.timeout_callback, self.timeout_handle, self.transport, self.waiter, self.writing_paused, self.xact_status)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->__pyx_base._discard_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->__pyx_base._skip_discard); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_int32_t(__pyx_v_self->__pyx_base.backend_pid); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_From_int32_t(__pyx_v_self->__pyx_base.backend_secret); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_self->closing); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus(__pyx_v_self->__pyx_base.con_status); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_self->is_reading); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyInt_From_uint64_t(__pyx_v_self->queries_count); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __Pyx_PyBool_FromLong(__pyx_v_self->__pyx_base.result_execute_completed); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_10 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ResultType(__pyx_v_self->__pyx_base.result_type); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_11 = __Pyx_PyBool_FromLong(__pyx_v_self->return_extra); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_12 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ProtocolState(__pyx_v_self->__pyx_base.state); if (unlikely(!__pyx_t_12)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = __Pyx_PyBool_FromLong(__pyx_v_self->writing_paused); if (unlikely(!__pyx_t_13)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_14 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus(__pyx_v_self->__pyx_base.xact_status); if (unlikely(!__pyx_t_14)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_15 = PyTuple_New(38); if (unlikely(!__pyx_t_15)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->__pyx_base._execute_iter);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base._execute_iter);
  PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_v_self->__pyx_base._execute_iter);
  __Pyx_INCREF(__pyx_v_self->__pyx_base._execute_portal_name);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base._execute_portal_name);
  PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_v_self->__pyx_base._execute_portal_name);
  __Pyx_INCREF(__pyx_v_self->__pyx_base._execute_stmt_name);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base._execute_stmt_name);
  PyTuple_SET_ITEM(__pyx_t_15, 3, __pyx_v_self->__pyx_base._execute_stmt_name);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_15, 4, __pyx_t_2);
  __Pyx_INCREF(__pyx_v_self->address);
  __Pyx_GIVEREF(__pyx_v_self->address);
  PyTuple_SET_ITEM(__pyx_t_15, 5, __pyx_v_self->address);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_15, 6, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_15, 7, __pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.buffer));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.buffer));
  PyTuple_SET_ITEM(__pyx_t_15, 8, ((PyObject *)__pyx_v_self->__pyx_base.buffer));
  __Pyx_INCREF(__pyx_v_self->cancel_sent_waiter);
  __Pyx_GIVEREF(__pyx_v_self->cancel_sent_waiter);
  PyTuple_SET_ITEM(__pyx_t_15, 9, __pyx_v_self->cancel_sent_waiter);
  __Pyx_INCREF(__pyx_v_self->cancel_waiter);
  __Pyx_GIVEREF(__pyx_v_self->cancel_waiter);
  PyTuple_SET_ITEM(__pyx_t_15, 10, __pyx_v_self->cancel_waiter);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_15, 11, __pyx_t_5);
  __Pyx_INCREF(__pyx_v_self->completed_callback);
  __Pyx_GIVEREF(__pyx_v_self->completed_callback);
  PyTuple_SET_ITEM(__pyx_t_15, 12, __pyx_v_self->completed_callback);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.con_params);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.con_params);
  PyTuple_SET_ITEM(__pyx_t_15, 13, __pyx_v_self->__pyx_base.con_params);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_15, 14, __pyx_t_6);
  __Pyx_INCREF(__pyx_v_self->connection);
  __Pyx_GIVEREF(__pyx_v_self->connection);
  PyTuple_SET_ITEM(__pyx_t_15, 15, __pyx_v_self->connection);
  __Pyx_INCREF(__pyx_v_self->create_future);
  __Pyx_GIVEREF(__pyx_v_self->create_future);
  PyTuple_SET_ITEM(__pyx_t_15, 16, __pyx_v_self->create_future);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.encoding);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.encoding);
  PyTuple_SET_ITEM(__pyx_t_15, 17, __pyx_v_self->__pyx_base.encoding);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_15, 18, __pyx_t_7);
  __Pyx_INCREF(__pyx_v_self->last_query);
  __Pyx_GIVEREF(__pyx_v_self->last_query);
  PyTuple_SET_ITEM(__pyx_t_15, 19, __pyx_v_self->last_query);
  __Pyx_INCREF(__pyx_v_self->loop);
  __Pyx_GIVEREF(__pyx_v_self->loop);
  PyTuple_SET_ITEM(__pyx_t_15, 20, __pyx_v_self->loop);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_15, 21, __pyx_t_8);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.result);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.result);
  PyTuple_SET_ITEM(__pyx_t_15, 22, __pyx_v_self->__pyx_base.result);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_15, 23, __pyx_t_9);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.result_param_desc);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.result_param_desc);
  PyTuple_SET_ITEM(__pyx_t_15, 24, __pyx_v_self->__pyx_base.result_param_desc);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.result_row_desc);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.result_row_desc);
  PyTuple_SET_ITEM(__pyx_t_15, 25, __pyx_v_self->__pyx_base.result_row_desc);
  __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_15, 26, __pyx_v_self->__pyx_base.result_status_msg);
  __Pyx_GIVEREF(__pyx_t_10);
  PyTuple_SET_ITEM(__pyx_t_15, 27, __pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_11);
  PyTuple_SET_ITEM(__pyx_t_15, 28, __pyx_t_11);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->settings));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->settings));
  PyTuple_SET_ITEM(__pyx_t_15, 29, ((PyObject *)__pyx_v_self->settings));
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_15, 30, __pyx_t_12);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->statement));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->statement));
  PyTuple_SET_ITEM(__pyx_t_15, 31, ((PyObject *)__pyx_v_self->statement));
  __Pyx_INCREF(__pyx_v_self->timeout_callback);
  __Pyx_GIVEREF(__pyx_v_self->timeout_callback);
  PyTuple_SET_ITEM(__pyx_t_15, 32, __pyx_v_self->timeout_callback);
  __Pyx_INCREF(__pyx_v_self->timeout_handle);
  __Pyx_GIVEREF(__pyx_v_self->timeout_handle);
  PyTuple_SET_ITEM(__pyx_t_15, 33, __pyx_v_self->timeout_handle);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.transport);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.transport);
  PyTuple_SET_ITEM(__pyx_t_15, 34, __pyx_v_self->__pyx_base.transport);
  __Pyx_INCREF(__pyx_v_self->waiter);
  __Pyx_GIVEREF(__pyx_v_self->waiter);
  PyTuple_SET_ITEM(__pyx_t_15, 35, __pyx_v_self->waiter);
  __Pyx_GIVEREF(__pyx_t_13);
  PyTuple_SET_ITEM(__pyx_t_15, 36, __pyx_t_13);
  __Pyx_GIVEREF(__pyx_t_14);
  PyTuple_SET_ITEM(__pyx_t_15, 37, __pyx_t_14);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __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_t_11 = 0;
  __pyx_t_12 = 0;
  __pyx_t_13 = 0;
  __pyx_t_14 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_15);
  __pyx_t_15 = 0;

  /* "(tree fragment)":4
 *     cdef bint use_setstate
 *     state = (self._discard_data, self._execute_iter, self._execute_portal_name, self._execute_stmt_name, self._skip_discard, self.address, self.backend_pid, self.backend_secret, self.buffer, self.cancel_sent_waiter, self.cancel_waiter, self.closing, self.completed_callback, self.con_params, self.con_status, self.connection, self.create_future, self.encoding, self.is_reading, self.last_query, self.loop, self.queries_count, self.result, self.result_execute_completed, self.result_param_desc, self.result_row_desc, self.result_status_msg, self.result_type, self.return_extra, self.settings, self.state, self.statement, self.timeout_callback, self.timeout_handle, self.transport, self.waiter, self.writing_paused, self.xact_status)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_15 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_15)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_v__dict = __pyx_t_15;
  __pyx_t_15 = 0;

  /* "(tree fragment)":5
 *     state = (self._discard_data, self._execute_iter, self._execute_portal_name, self._execute_stmt_name, self._skip_discard, self.address, self.backend_pid, self.backend_secret, self.buffer, self.cancel_sent_waiter, self.cancel_waiter, self.closing, self.completed_callback, self.con_params, self.con_status, self.connection, self.create_future, self.encoding, self.is_reading, self.last_query, self.loop, self.queries_count, self.result, self.result_execute_completed, self.result_param_desc, self.result_row_desc, self.result_status_msg, self.result_type, self.return_extra, self.settings, self.state, self.statement, self.timeout_callback, self.timeout_handle, self.transport, self.waiter, self.writing_paused, self.xact_status)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_16 = (__pyx_v__dict != Py_None);
  __pyx_t_17 = (__pyx_t_16 != 0);
  if (__pyx_t_17) {

    /* "(tree fragment)":6
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_v__dict);
    __pyx_t_14 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_15); if (unlikely(!__pyx_t_14)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_14));
    __pyx_t_14 = 0;

    /* "(tree fragment)":7
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self._execute_iter is not None or self._execute_portal_name is not None or self._execute_stmt_name is not None or self.address is not None or self.buffer is not None or self.cancel_sent_waiter is not None or self.cancel_waiter is not None or self.completed_callback is not None or self.con_params is not None or self.connection is not None or self.create_future is not None or self.encoding is not None or self.last_query is not None or self.loop is not None or self.result is not None or self.result_param_desc is not None or self.result_row_desc is not None or self.result_status_msg is not None or self.settings is not None or self.statement is not None or self.timeout_callback is not None or self.timeout_handle is not None or self.transport is not None or self.waiter is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":5
 *     state = (self._discard_data, self._execute_iter, self._execute_portal_name, self._execute_stmt_name, self._skip_discard, self.address, self.backend_pid, self.backend_secret, self.buffer, self.cancel_sent_waiter, self.cancel_waiter, self.closing, self.completed_callback, self.con_params, self.con_status, self.connection, self.create_future, self.encoding, self.is_reading, self.last_query, self.loop, self.queries_count, self.result, self.result_execute_completed, self.result_param_desc, self.result_row_desc, self.result_status_msg, self.result_type, self.return_extra, self.settings, self.state, self.statement, self.timeout_callback, self.timeout_handle, self.transport, self.waiter, self.writing_paused, self.xact_status)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         use_setstate = True
 *     else:
 *         use_setstate = self._execute_iter is not None or self._execute_portal_name is not None or self._execute_stmt_name is not None or self.address is not None or self.buffer is not None or self.cancel_sent_waiter is not None or self.cancel_waiter is not None or self.completed_callback is not None or self.con_params is not None or self.connection is not None or self.create_future is not None or self.encoding is not None or self.last_query is not None or self.loop is not None or self.result is not None or self.result_param_desc is not None or self.result_row_desc is not None or self.result_status_msg is not None or self.settings is not None or self.statement is not None or self.timeout_callback is not None or self.timeout_handle is not None or self.transport is not None or self.waiter is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_BaseProtocol, (type(self), 0x30f806c, None), state
 */
  /*else*/ {
    __pyx_t_16 = (__pyx_v_self->__pyx_base._execute_iter != Py_None);
    __pyx_t_18 = (__pyx_t_16 != 0);
    if (!__pyx_t_18) {
    } else {
      __pyx_t_17 = __pyx_t_18;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_18 = (__pyx_v_self->__pyx_base._execute_portal_name != ((PyObject*)Py_None));
    __pyx_t_16 = (__pyx_t_18 != 0);
    if (!__pyx_t_16) {
    } else {
      __pyx_t_17 = __pyx_t_16;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_16 = (__pyx_v_self->__pyx_base._execute_stmt_name != ((PyObject*)Py_None));
    __pyx_t_18 = (__pyx_t_16 != 0);
    if (!__pyx_t_18) {
    } else {
      __pyx_t_17 = __pyx_t_18;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_18 = (__pyx_v_self->address != Py_None);
    __pyx_t_16 = (__pyx_t_18 != 0);
    if (!__pyx_t_16) {
    } else {
      __pyx_t_17 = __pyx_t_16;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_16 = (((PyObject *)__pyx_v_self->__pyx_base.buffer) != Py_None);
    __pyx_t_18 = (__pyx_t_16 != 0);
    if (!__pyx_t_18) {
    } else {
      __pyx_t_17 = __pyx_t_18;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_18 = (__pyx_v_self->cancel_sent_waiter != Py_None);
    __pyx_t_16 = (__pyx_t_18 != 0);
    if (!__pyx_t_16) {
    } else {
      __pyx_t_17 = __pyx_t_16;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_16 = (__pyx_v_self->cancel_waiter != Py_None);
    __pyx_t_18 = (__pyx_t_16 != 0);
    if (!__pyx_t_18) {
    } else {
      __pyx_t_17 = __pyx_t_18;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_18 = (__pyx_v_self->completed_callback != Py_None);
    __pyx_t_16 = (__pyx_t_18 != 0);
    if (!__pyx_t_16) {
    } else {
      __pyx_t_17 = __pyx_t_16;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_16 = (__pyx_v_self->__pyx_base.con_params != Py_None);
    __pyx_t_18 = (__pyx_t_16 != 0);
    if (!__pyx_t_18) {
    } else {
      __pyx_t_17 = __pyx_t_18;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_18 = (__pyx_v_self->connection != Py_None);
    __pyx_t_16 = (__pyx_t_18 != 0);
    if (!__pyx_t_16) {
    } else {
      __pyx_t_17 = __pyx_t_16;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_16 = (__pyx_v_self->create_future != Py_None);
    __pyx_t_18 = (__pyx_t_16 != 0);
    if (!__pyx_t_18) {
    } else {
      __pyx_t_17 = __pyx_t_18;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_18 = (__pyx_v_self->__pyx_base.encoding != ((PyObject*)Py_None));
    __pyx_t_16 = (__pyx_t_18 != 0);
    if (!__pyx_t_16) {
    } else {
      __pyx_t_17 = __pyx_t_16;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_16 = (__pyx_v_self->last_query != ((PyObject*)Py_None));
    __pyx_t_18 = (__pyx_t_16 != 0);
    if (!__pyx_t_18) {
    } else {
      __pyx_t_17 = __pyx_t_18;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_18 = (__pyx_v_self->loop != Py_None);
    __pyx_t_16 = (__pyx_t_18 != 0);
    if (!__pyx_t_16) {
    } else {
      __pyx_t_17 = __pyx_t_16;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_16 = (__pyx_v_self->__pyx_base.result != Py_None);
    __pyx_t_18 = (__pyx_t_16 != 0);
    if (!__pyx_t_18) {
    } else {
      __pyx_t_17 = __pyx_t_18;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_18 = (__pyx_v_self->__pyx_base.result_param_desc != ((PyObject*)Py_None));
    __pyx_t_16 = (__pyx_t_18 != 0);
    if (!__pyx_t_16) {
    } else {
      __pyx_t_17 = __pyx_t_16;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_16 = (__pyx_v_self->__pyx_base.result_row_desc != ((PyObject*)Py_None));
    __pyx_t_18 = (__pyx_t_16 != 0);
    if (!__pyx_t_18) {
    } else {
      __pyx_t_17 = __pyx_t_18;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_18 = (__pyx_v_self->__pyx_base.result_status_msg != ((PyObject*)Py_None));
    __pyx_t_16 = (__pyx_t_18 != 0);
    if (!__pyx_t_16) {
    } else {
      __pyx_t_17 = __pyx_t_16;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_16 = (((PyObject *)__pyx_v_self->settings) != Py_None);
    __pyx_t_18 = (__pyx_t_16 != 0);
    if (!__pyx_t_18) {
    } else {
      __pyx_t_17 = __pyx_t_18;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_18 = (((PyObject *)__pyx_v_self->statement) != Py_None);
    __pyx_t_16 = (__pyx_t_18 != 0);
    if (!__pyx_t_16) {
    } else {
      __pyx_t_17 = __pyx_t_16;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_16 = (__pyx_v_self->timeout_callback != Py_None);
    __pyx_t_18 = (__pyx_t_16 != 0);
    if (!__pyx_t_18) {
    } else {
      __pyx_t_17 = __pyx_t_18;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_18 = (__pyx_v_self->timeout_handle != Py_None);
    __pyx_t_16 = (__pyx_t_18 != 0);
    if (!__pyx_t_16) {
    } else {
      __pyx_t_17 = __pyx_t_16;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_16 = (__pyx_v_self->__pyx_base.transport != Py_None);
    __pyx_t_18 = (__pyx_t_16 != 0);
    if (!__pyx_t_18) {
    } else {
      __pyx_t_17 = __pyx_t_18;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_18 = (__pyx_v_self->waiter != Py_None);
    __pyx_t_16 = (__pyx_t_18 != 0);
    __pyx_t_17 = __pyx_t_16;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_17;
  }
  __pyx_L3:;

  /* "(tree fragment)":10
 *     else:
 *         use_setstate = self._execute_iter is not None or self._execute_portal_name is not None or self._execute_stmt_name is not None or self.address is not None or self.buffer is not None or self.cancel_sent_waiter is not None or self.cancel_waiter is not None or self.completed_callback is not None or self.con_params is not None or self.connection is not None or self.create_future is not None or self.encoding is not None or self.last_query is not None or self.loop is not None or self.result is not None or self.result_param_desc is not None or self.result_row_desc is not None or self.result_status_msg is not None or self.settings is not None or self.statement is not None or self.timeout_callback is not None or self.timeout_handle is not None or self.transport is not None or self.waiter is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_BaseProtocol, (type(self), 0x30f806c, None), state
 *     else:
 */
  __pyx_t_17 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_17) {

    /* "(tree fragment)":11
 *         use_setstate = self._execute_iter is not None or self._execute_portal_name is not None or self._execute_stmt_name is not None or self.address is not None or self.buffer is not None or self.cancel_sent_waiter is not None or self.cancel_waiter is not None or self.completed_callback is not None or self.con_params is not None or self.connection is not None or self.create_future is not None or self.encoding is not None or self.last_query is not None or self.loop is not None or self.result is not None or self.result_param_desc is not None or self.result_row_desc is not None or self.result_status_msg is not None or self.settings is not None or self.statement is not None or self.timeout_callback is not None or self.timeout_handle is not None or self.transport is not None or self.waiter is not None
 *     if use_setstate:
 *         return __pyx_unpickle_BaseProtocol, (type(self), 0x30f806c, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_BaseProtocol, (type(self), 0x30f806c, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_BaseProtocol); if (unlikely(!__pyx_t_14)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_15 = PyTuple_New(3); if (unlikely(!__pyx_t_15)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_15, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_51347564);
    __Pyx_GIVEREF(__pyx_int_51347564);
    PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_int_51347564);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_15, 2, Py_None);
    __pyx_t_13 = PyTuple_New(3); if (unlikely(!__pyx_t_13)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_GIVEREF(__pyx_t_14);
    PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14);
    __Pyx_GIVEREF(__pyx_t_15);
    PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_15);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_v_state);
    __pyx_t_14 = 0;
    __pyx_t_15 = 0;
    __pyx_r = __pyx_t_13;
    __pyx_t_13 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":10
 *     else:
 *         use_setstate = self._execute_iter is not None or self._execute_portal_name is not None or self._execute_stmt_name is not None or self.address is not None or self.buffer is not None or self.cancel_sent_waiter is not None or self.cancel_waiter is not None or self.completed_callback is not None or self.con_params is not None or self.connection is not None or self.create_future is not None or self.encoding is not None or self.last_query is not None or self.loop is not None or self.result is not None or self.result_param_desc is not None or self.result_row_desc is not None or self.result_status_msg is not None or self.settings is not None or self.statement is not None or self.timeout_callback is not None or self.timeout_handle is not None or self.transport is not None or self.waiter is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_BaseProtocol, (type(self), 0x30f806c, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         return __pyx_unpickle_BaseProtocol, (type(self), 0x30f806c, None), state
 *     else:
 *         return __pyx_unpickle_BaseProtocol, (type(self), 0x30f806c, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_BaseProtocol__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_BaseProtocol); if (unlikely(!__pyx_t_13)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_15 = PyTuple_New(3); if (unlikely(!__pyx_t_15)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_15, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_51347564);
    __Pyx_GIVEREF(__pyx_int_51347564);
    PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_int_51347564);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_v_state);
    __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_GIVEREF(__pyx_t_13);
    PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13);
    __Pyx_GIVEREF(__pyx_t_15);
    PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_15);
    __pyx_t_13 = 0;
    __pyx_t_15 = 0;
    __pyx_r = __pyx_t_14;
    __pyx_t_14 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self._discard_data, self._execute_iter, self._execute_portal_name, self._execute_stmt_name, self._skip_discard, self.address, self.backend_pid, self.backend_secret, self.buffer, self.cancel_sent_waiter, self.cancel_waiter, self.closing, self.completed_callback, self.con_params, self.con_status, self.connection, self.create_future, self.encoding, self.is_reading, self.last_query, self.loop, self.queries_count, self.result, self.result_execute_completed, self.result_param_desc, self.result_row_desc, self.result_status_msg, self.result_type, self.return_extra, self.settings, self.state, self.statement, self.timeout_callback, self.timeout_handle, self.transport, self.waiter, self.writing_paused, self.xact_status)
 */

  /* 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_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_AddTraceback("asyncpg.protocol.protocol.BaseProtocol.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_BaseProtocol, (type(self), 0x30f806c, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_BaseProtocol__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_68__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_68__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_67__setstate_cython__(((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_12BaseProtocol_67__setstate_cython__(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":15
 *         return __pyx_unpickle_BaseProtocol, (type(self), 0x30f806c, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_BaseProtocol__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol___pyx_unpickle_BaseProtocol__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_BaseProtocol, (type(self), 0x30f806c, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_BaseProtocol__set_state(self, __pyx_state)
 */

  /* 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.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/protocol.pyx":855
 * 
 * class Timer:
 *     def __init__(self, budget):             # <<<<<<<<<<<<<<
 *         self._budget = budget
 *         self._started = 0
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_5Timer_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_7asyncpg_8protocol_8protocol_5Timer_1__init__ = {"__init__", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_5Timer_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_5Timer_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_budget = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_budget,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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_budget)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 855, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 855, __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_self = values[0];
    __pyx_v_budget = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 855, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("asyncpg.protocol.protocol.Timer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_5Timer___init__(__pyx_self, __pyx_v_self, __pyx_v_budget);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_5Timer___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_budget) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "asyncpg/protocol/protocol.pyx":856
 * class Timer:
 *     def __init__(self, budget):
 *         self._budget = budget             # <<<<<<<<<<<<<<
 *         self._started = 0
 * 
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_budget_2, __pyx_v_budget) < 0) __PYX_ERR(0, 856, __pyx_L1_error)

  /* "asyncpg/protocol/protocol.pyx":857
 *     def __init__(self, budget):
 *         self._budget = budget
 *         self._started = 0             # <<<<<<<<<<<<<<
 * 
 *     def __enter__(self):
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_started, __pyx_int_0) < 0) __PYX_ERR(0, 857, __pyx_L1_error)

  /* "asyncpg/protocol/protocol.pyx":855
 * 
 * class Timer:
 *     def __init__(self, budget):             # <<<<<<<<<<<<<<
 *         self._budget = budget
 *         self._started = 0
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("asyncpg.protocol.protocol.Timer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/protocol.pyx":859
 *         self._started = 0
 * 
 *     def __enter__(self):             # <<<<<<<<<<<<<<
 *         if self._budget is not None:
 *             self._started = time.monotonic()
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_5Timer_3__enter__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_7asyncpg_8protocol_8protocol_5Timer_3__enter__ = {"__enter__", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_5Timer_3__enter__, METH_O, 0};
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_5Timer_3__enter__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__enter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_5Timer_2__enter__(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_5Timer_2__enter__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  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;
  __Pyx_RefNannySetupContext("__enter__", 0);

  /* "asyncpg/protocol/protocol.pyx":860
 * 
 *     def __enter__(self):
 *         if self._budget is not None:             # <<<<<<<<<<<<<<
 *             self._started = time.monotonic()
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_budget_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 860, __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_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "asyncpg/protocol/protocol.pyx":861
 *     def __enter__(self):
 *         if self._budget is not None:
 *             self._started = time.monotonic()             # <<<<<<<<<<<<<<
 * 
 *     def __exit__(self, et, e, tb):
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_time); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 861, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_monotonic); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 861, __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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 861, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 861, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_started, __pyx_t_1) < 0) __PYX_ERR(0, 861, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "asyncpg/protocol/protocol.pyx":860
 * 
 *     def __enter__(self):
 *         if self._budget is not None:             # <<<<<<<<<<<<<<
 *             self._started = time.monotonic()
 * 
 */
  }

  /* "asyncpg/protocol/protocol.pyx":859
 *         self._started = 0
 * 
 *     def __enter__(self):             # <<<<<<<<<<<<<<
 *         if self._budget is not None:
 *             self._started = time.monotonic()
 */

  /* 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.Timer.__enter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/protocol.pyx":863
 *             self._started = time.monotonic()
 * 
 *     def __exit__(self, et, e, tb):             # <<<<<<<<<<<<<<
 *         if self._budget is not None:
 *             self._budget -= time.monotonic() - self._started
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_5Timer_5__exit__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_7asyncpg_8protocol_8protocol_5Timer_5__exit__ = {"__exit__", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_5Timer_5__exit__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_5Timer_5__exit__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  CYTHON_UNUSED PyObject *__pyx_v_et = 0;
  CYTHON_UNUSED PyObject *__pyx_v_e = 0;
  CYTHON_UNUSED PyObject *__pyx_v_tb = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__exit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_et,&__pyx_n_s_e,&__pyx_n_s_tb,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);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_et)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__exit__", 1, 4, 4, 1); __PYX_ERR(0, 863, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_e)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__exit__", 1, 4, 4, 2); __PYX_ERR(0, 863, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_tb)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__exit__", 1, 4, 4, 3); __PYX_ERR(0, 863, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__exit__") < 0)) __PYX_ERR(0, 863, __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_self = values[0];
    __pyx_v_et = values[1];
    __pyx_v_e = values[2];
    __pyx_v_tb = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__exit__", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 863, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("asyncpg.protocol.protocol.Timer.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_5Timer_4__exit__(__pyx_self, __pyx_v_self, __pyx_v_et, __pyx_v_e, __pyx_v_tb);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_5Timer_4__exit__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_et, CYTHON_UNUSED PyObject *__pyx_v_e, CYTHON_UNUSED PyObject *__pyx_v_tb) {
  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;
  __Pyx_RefNannySetupContext("__exit__", 0);

  /* "asyncpg/protocol/protocol.pyx":864
 * 
 *     def __exit__(self, et, e, tb):
 *         if self._budget is not None:             # <<<<<<<<<<<<<<
 *             self._budget -= time.monotonic() - self._started
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_budget_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 864, __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_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "asyncpg/protocol/protocol.pyx":865
 *     def __exit__(self, et, e, tb):
 *         if self._budget is not None:
 *             self._budget -= time.monotonic() - self._started             # <<<<<<<<<<<<<<
 * 
 *     def get_remaining_budget(self):
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_budget_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 865, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_time); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 865, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_monotonic); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 865, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 865, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 865, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_started); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 865, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = PyNumber_Subtract(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 865, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyNumber_InPlaceSubtract(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 865, __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;
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_budget_2, __pyx_t_6) < 0) __PYX_ERR(0, 865, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "asyncpg/protocol/protocol.pyx":864
 * 
 *     def __exit__(self, et, e, tb):
 *         if self._budget is not None:             # <<<<<<<<<<<<<<
 *             self._budget -= time.monotonic() - self._started
 * 
 */
  }

  /* "asyncpg/protocol/protocol.pyx":863
 *             self._started = time.monotonic()
 * 
 *     def __exit__(self, et, e, tb):             # <<<<<<<<<<<<<<
 *         if self._budget is not None:
 *             self._budget -= time.monotonic() - self._started
 */

  /* 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.Timer.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/protocol.pyx":867
 *             self._budget -= time.monotonic() - self._started
 * 
 *     def get_remaining_budget(self):             # <<<<<<<<<<<<<<
 *         return self._budget
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_5Timer_7get_remaining_budget(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_7asyncpg_8protocol_8protocol_5Timer_7get_remaining_budget = {"get_remaining_budget", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_5Timer_7get_remaining_budget, METH_O, 0};
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_5Timer_7get_remaining_budget(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_remaining_budget (wrapper)", 0);
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_5Timer_6get_remaining_budget(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_5Timer_6get_remaining_budget(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("get_remaining_budget", 0);

  /* "asyncpg/protocol/protocol.pyx":868
 * 
 *     def get_remaining_budget(self):
 *         return self._budget             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_budget_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 868, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "asyncpg/protocol/protocol.pyx":867
 *             self._budget -= time.monotonic() - self._started
 * 
 *     def get_remaining_budget(self):             # <<<<<<<<<<<<<<
 *         return self._budget
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.Timer.get_remaining_budget", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "asyncpg/protocol/protocol.pyx":875
 * 
 * 
 * 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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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;
        CYTHON_FALLTHROUGH;
        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(0, 875, __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(0, 875, __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(0, 875, __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(0, 875, __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":882
 *         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":883
 * 
 *     if mapping is None:
 *         desc = record.ApgRecordDesc_New({}, ())             # <<<<<<<<<<<<<<
 *     else:
 *         desc = record.ApgRecordDesc_New(
 */
    __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 883, __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(0, 883, __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":882
 *         int32_t i
 * 
 *     if mapping is None:             # <<<<<<<<<<<<<<
 *         desc = record.ApgRecordDesc_New({}, ())
 *     else:
 */
    goto __pyx_L3;
  }

  /* "asyncpg/protocol/protocol.pyx":885
 *         desc = record.ApgRecordDesc_New({}, ())
 *     else:
 *         desc = record.ApgRecordDesc_New(             # <<<<<<<<<<<<<<
 *             mapping, tuple(mapping) if mapping else ())
 * 
 */
  /*else*/ {

    /* "asyncpg/protocol/protocol.pyx":886
 *     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(0, 886, __pyx_L1_error)
    if (__pyx_t_2) {
      __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_v_mapping); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 886, __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":885
 *         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(0, 885, __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":888
 *             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(0, 888, __pyx_L1_error)
  }
  __pyx_t_5 = PyTuple_GET_SIZE(__pyx_v_elems); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 888, __pyx_L1_error)
  __pyx_t_3 = ApgRecord_New(__pyx_v_desc, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 888, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_rec = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":889
 * 
 *     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(0, 889, __pyx_L1_error)
  }
  __pyx_t_5 = PyTuple_GET_SIZE(__pyx_v_elems); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 889, __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":890
 *     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(0, 890, __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(0, 890, __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":891
 *     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":892
 *         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":893
 *         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":875
 * 
 * 
 * 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;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_Memory(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xe0abff4:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_3__pyx_unpickle_Memory(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_7asyncpg_8protocol_8protocol_3__pyx_unpickle_Memory = {"__pyx_unpickle_Memory", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_3__pyx_unpickle_Memory, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_3__pyx_unpickle_Memory(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_Memory (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Memory", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Memory", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Memory") < 0)) __PYX_ERR(2, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Memory", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("asyncpg.protocol.protocol.__pyx_unpickle_Memory", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_2__pyx_unpickle_Memory(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_2__pyx_unpickle_Memory(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = NULL;
  PyObject *__pyx_v___pyx_result = 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;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Memory", 0);

  /* "(tree fragment)":2
 * def __pyx_unpickle_Memory(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xe0abff4:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xe0abff4 = (buf, length, owner))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xe0abff4) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_Memory(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xe0abff4:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xe0abff4 = (buf, length, owner))" % __pyx_checksum)
 *     __pyx_result = Memory.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0xe0abff4:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xe0abff4 = (buf, length, owner))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = Memory.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xe0, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(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_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __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_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __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[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __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_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 4, __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_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __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(2, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_Memory(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xe0abff4:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xe0abff4 = (buf, length, owner))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xe0abff4 = (buf, length, owner))" % __pyx_checksum)
 *     __pyx_result = Memory.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Memory__set_state(<Memory> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_Memory), __pyx_n_s_new_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __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_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 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_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xe0abff4 = (buf, length, owner))" % __pyx_checksum)
 *     __pyx_result = Memory.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Memory__set_state(<Memory> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = Memory.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Memory__set_state(<Memory> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_Memory__set_state(Memory __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol___pyx_unpickle_Memory__set_state(((struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xe0abff4 = (buf, length, owner))" % __pyx_checksum)
 *     __pyx_result = Memory.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Memory__set_state(<Memory> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Memory__set_state(<Memory> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_Memory__set_state(Memory __pyx_result, tuple __pyx_state):
 *     __pyx_result.buf = __pyx_state[0]; __pyx_result.length = __pyx_state[1]; __pyx_result.owner = __pyx_state[2]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Memory(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xe0abff4:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* 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_AddTraceback("asyncpg.protocol.protocol.__pyx_unpickle_Memory", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":9
 *         __pyx_unpickle_Memory__set_state(<Memory> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Memory__set_state(Memory __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.buf = __pyx_state[0]; __pyx_result.length = __pyx_state[1]; __pyx_result.owner = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol___pyx_unpickle_Memory__set_state(struct __pyx_obj_7asyncpg_8protocol_8protocol_Memory *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char const *__pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  Py_ssize_t __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;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Memory__set_state", 0);

  /* "(tree fragment)":10
 *     return __pyx_result
 * cdef __pyx_unpickle_Memory__set_state(Memory __pyx_result, tuple __pyx_state):
 *     __pyx_result.buf = __pyx_state[0]; __pyx_result.length = __pyx_state[1]; __pyx_result.owner = __pyx_state[2]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[3])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_AsString(__pyx_t_1); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(2, 10, __pyx_L1_error)
  __pyx_v___pyx_result->buf = __pyx_t_2;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyInt_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->length = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->owner);
  __Pyx_DECREF(__pyx_v___pyx_result->owner);
  __pyx_v___pyx_result->owner = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":11
 * cdef __pyx_unpickle_Memory__set_state(Memory __pyx_result, tuple __pyx_state):
 *     __pyx_result.buf = __pyx_state[0]; __pyx_result.length = __pyx_state[1]; __pyx_result.owner = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[3])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 11, __pyx_L1_error)
  }
  __pyx_t_5 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_6 = ((__pyx_t_5 > 3) != 0);
  if (__pyx_t_6) {
  } else {
    __pyx_t_4 = __pyx_t_6;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_6 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_7 = (__pyx_t_6 != 0);
  __pyx_t_4 = __pyx_t_7;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_4) {

    /* "(tree fragment)":12
 *     __pyx_result.buf = __pyx_state[0]; __pyx_result.length = __pyx_state[1]; __pyx_result.owner = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[3])             # <<<<<<<<<<<<<<
 */
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_update); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 12, __pyx_L1_error)
    }
    __pyx_t_8 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_10 = NULL;
    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);
      }
    }
    if (!__pyx_t_10) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __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_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_8};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 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_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_8};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 12, __pyx_L1_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_8);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_8);
        __pyx_t_8 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * cdef __pyx_unpickle_Memory__set_state(Memory __pyx_result, tuple __pyx_state):
 *     __pyx_result.buf = __pyx_state[0]; __pyx_result.length = __pyx_state[1]; __pyx_result.owner = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[3])
 */
  }

  /* "(tree fragment)":9
 *         __pyx_unpickle_Memory__set_state(<Memory> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Memory__set_state(Memory __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.buf = __pyx_state[0]; __pyx_result.length = __pyx_state[1]; __pyx_result.owner = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 */

  /* 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_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.__pyx_unpickle_Memory__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_FastReadBuffer(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x7ea5e72:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_5__pyx_unpickle_FastReadBuffer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_7asyncpg_8protocol_8protocol_5__pyx_unpickle_FastReadBuffer = {"__pyx_unpickle_FastReadBuffer", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_5__pyx_unpickle_FastReadBuffer, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_5__pyx_unpickle_FastReadBuffer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_FastReadBuffer (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_FastReadBuffer", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_FastReadBuffer", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_FastReadBuffer") < 0)) __PYX_ERR(2, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_FastReadBuffer", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("asyncpg.protocol.protocol.__pyx_unpickle_FastReadBuffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_4__pyx_unpickle_FastReadBuffer(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_4__pyx_unpickle_FastReadBuffer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = NULL;
  PyObject *__pyx_v___pyx_result = 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;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("__pyx_unpickle_FastReadBuffer", 0);

  /* "(tree fragment)":2
 * def __pyx_unpickle_FastReadBuffer(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x7ea5e72:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7ea5e72 = (buf, len))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x7ea5e72) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_FastReadBuffer(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x7ea5e72:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7ea5e72 = (buf, len))" % __pyx_checksum)
 *     __pyx_result = FastReadBuffer.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0x7ea5e72:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7ea5e72 = (buf, len))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = FastReadBuffer.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x7e, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(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_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __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_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __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[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __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_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 4, __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_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __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(2, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_FastReadBuffer(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x7ea5e72:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7ea5e72 = (buf, len))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7ea5e72 = (buf, len))" % __pyx_checksum)
 *     __pyx_result = FastReadBuffer.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_FastReadBuffer__set_state(<FastReadBuffer> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_FastReadBuffer), __pyx_n_s_new_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __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_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 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_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7ea5e72 = (buf, len))" % __pyx_checksum)
 *     __pyx_result = FastReadBuffer.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_FastReadBuffer__set_state(<FastReadBuffer> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = FastReadBuffer.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_FastReadBuffer__set_state(<FastReadBuffer> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_FastReadBuffer__set_state(FastReadBuffer __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol___pyx_unpickle_FastReadBuffer__set_state(((struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7ea5e72 = (buf, len))" % __pyx_checksum)
 *     __pyx_result = FastReadBuffer.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_FastReadBuffer__set_state(<FastReadBuffer> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_FastReadBuffer__set_state(<FastReadBuffer> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_FastReadBuffer__set_state(FastReadBuffer __pyx_result, tuple __pyx_state):
 *     __pyx_result.buf = __pyx_state[0]; __pyx_result.len = __pyx_state[1]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_FastReadBuffer(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x7ea5e72:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* 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_AddTraceback("asyncpg.protocol.protocol.__pyx_unpickle_FastReadBuffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":9
 *         __pyx_unpickle_FastReadBuffer__set_state(<FastReadBuffer> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_FastReadBuffer__set_state(FastReadBuffer __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.buf = __pyx_state[0]; __pyx_result.len = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol___pyx_unpickle_FastReadBuffer__set_state(struct __pyx_obj_7asyncpg_8protocol_8protocol_FastReadBuffer *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char const *__pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  Py_ssize_t __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;
  __Pyx_RefNannySetupContext("__pyx_unpickle_FastReadBuffer__set_state", 0);

  /* "(tree fragment)":10
 *     return __pyx_result
 * cdef __pyx_unpickle_FastReadBuffer__set_state(FastReadBuffer __pyx_result, tuple __pyx_state):
 *     __pyx_result.buf = __pyx_state[0]; __pyx_result.len = __pyx_state[1]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_AsString(__pyx_t_1); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(2, 10, __pyx_L1_error)
  __pyx_v___pyx_result->buf = __pyx_t_2;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyInt_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->len = __pyx_t_3;

  /* "(tree fragment)":11
 * cdef __pyx_unpickle_FastReadBuffer__set_state(FastReadBuffer __pyx_result, tuple __pyx_state):
 *     __pyx_result.buf = __pyx_state[0]; __pyx_result.len = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 11, __pyx_L1_error)
  }
  __pyx_t_5 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_6 = ((__pyx_t_5 > 2) != 0);
  if (__pyx_t_6) {
  } else {
    __pyx_t_4 = __pyx_t_6;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_6 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_7 = (__pyx_t_6 != 0);
  __pyx_t_4 = __pyx_t_7;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_4) {

    /* "(tree fragment)":12
 *     __pyx_result.buf = __pyx_state[0]; __pyx_result.len = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[2])             # <<<<<<<<<<<<<<
 */
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_update); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 12, __pyx_L1_error)
    }
    __pyx_t_8 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_10 = NULL;
    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);
      }
    }
    if (!__pyx_t_10) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __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_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_8};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 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_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_8};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 12, __pyx_L1_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_8);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_8);
        __pyx_t_8 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * cdef __pyx_unpickle_FastReadBuffer__set_state(FastReadBuffer __pyx_result, tuple __pyx_state):
 *     __pyx_result.buf = __pyx_state[0]; __pyx_result.len = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  }

  /* "(tree fragment)":9
 *         __pyx_unpickle_FastReadBuffer__set_state(<FastReadBuffer> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_FastReadBuffer__set_state(FastReadBuffer __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.buf = __pyx_state[0]; __pyx_result.len = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */

  /* 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_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.__pyx_unpickle_FastReadBuffer__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_DataCodecConfig(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xb75bfc9:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_7__pyx_unpickle_DataCodecConfig(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_7asyncpg_8protocol_8protocol_7__pyx_unpickle_DataCodecConfig = {"__pyx_unpickle_DataCodecConfig", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_7__pyx_unpickle_DataCodecConfig, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_7__pyx_unpickle_DataCodecConfig(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_DataCodecConfig (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_DataCodecConfig", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_DataCodecConfig", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_DataCodecConfig") < 0)) __PYX_ERR(2, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_DataCodecConfig", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("asyncpg.protocol.protocol.__pyx_unpickle_DataCodecConfig", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_6__pyx_unpickle_DataCodecConfig(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_6__pyx_unpickle_DataCodecConfig(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = NULL;
  PyObject *__pyx_v___pyx_result = 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;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("__pyx_unpickle_DataCodecConfig", 0);

  /* "(tree fragment)":2
 * def __pyx_unpickle_DataCodecConfig(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xb75bfc9:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb75bfc9 = (_local_type_codecs, _type_codecs_cache))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xb75bfc9) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_DataCodecConfig(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xb75bfc9:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb75bfc9 = (_local_type_codecs, _type_codecs_cache))" % __pyx_checksum)
 *     __pyx_result = DataCodecConfig.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0xb75bfc9:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb75bfc9 = (_local_type_codecs, _type_codecs_cache))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = DataCodecConfig.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xb7, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(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_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __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_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __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[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __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_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 4, __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_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __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(2, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_DataCodecConfig(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xb75bfc9:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb75bfc9 = (_local_type_codecs, _type_codecs_cache))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb75bfc9 = (_local_type_codecs, _type_codecs_cache))" % __pyx_checksum)
 *     __pyx_result = DataCodecConfig.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_DataCodecConfig__set_state(<DataCodecConfig> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_DataCodecConfig), __pyx_n_s_new_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __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_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 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_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb75bfc9 = (_local_type_codecs, _type_codecs_cache))" % __pyx_checksum)
 *     __pyx_result = DataCodecConfig.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_DataCodecConfig__set_state(<DataCodecConfig> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = DataCodecConfig.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_DataCodecConfig__set_state(<DataCodecConfig> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_DataCodecConfig__set_state(DataCodecConfig __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol___pyx_unpickle_DataCodecConfig__set_state(((struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb75bfc9 = (_local_type_codecs, _type_codecs_cache))" % __pyx_checksum)
 *     __pyx_result = DataCodecConfig.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_DataCodecConfig__set_state(<DataCodecConfig> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_DataCodecConfig__set_state(<DataCodecConfig> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_DataCodecConfig__set_state(DataCodecConfig __pyx_result, tuple __pyx_state):
 *     __pyx_result._local_type_codecs = __pyx_state[0]; __pyx_result._type_codecs_cache = __pyx_state[1]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_DataCodecConfig(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xb75bfc9:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* 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_AddTraceback("asyncpg.protocol.protocol.__pyx_unpickle_DataCodecConfig", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":9
 *         __pyx_unpickle_DataCodecConfig__set_state(<DataCodecConfig> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_DataCodecConfig__set_state(DataCodecConfig __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._local_type_codecs = __pyx_state[0]; __pyx_result._type_codecs_cache = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol___pyx_unpickle_DataCodecConfig__set_state(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __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;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_DataCodecConfig__set_state", 0);

  /* "(tree fragment)":10
 *     return __pyx_result
 * cdef __pyx_unpickle_DataCodecConfig__set_state(DataCodecConfig __pyx_result, tuple __pyx_state):
 *     __pyx_result._local_type_codecs = __pyx_state[0]; __pyx_result._type_codecs_cache = __pyx_state[1]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_local_type_codecs);
  __Pyx_DECREF(__pyx_v___pyx_result->_local_type_codecs);
  __pyx_v___pyx_result->_local_type_codecs = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_type_codecs_cache);
  __Pyx_DECREF(__pyx_v___pyx_result->_type_codecs_cache);
  __pyx_v___pyx_result->_type_codecs_cache = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":11
 * cdef __pyx_unpickle_DataCodecConfig__set_state(DataCodecConfig __pyx_result, tuple __pyx_state):
 *     __pyx_result._local_type_codecs = __pyx_state[0]; __pyx_result._type_codecs_cache = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 11, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 2) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":12
 *     __pyx_result._local_type_codecs = __pyx_state[0]; __pyx_result._type_codecs_cache = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[2])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 12, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 12, __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_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * cdef __pyx_unpickle_DataCodecConfig__set_state(DataCodecConfig __pyx_result, tuple __pyx_state):
 *     __pyx_result._local_type_codecs = __pyx_state[0]; __pyx_result._type_codecs_cache = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  }

  /* "(tree fragment)":9
 *         __pyx_unpickle_DataCodecConfig__set_state(<DataCodecConfig> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_DataCodecConfig__set_state(DataCodecConfig __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._local_type_codecs = __pyx_state[0]; __pyx_result._type_codecs_cache = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */

  /* 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_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.__pyx_unpickle_DataCodecConfig__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_CoreProtocol(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x197884c:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_9__pyx_unpickle_CoreProtocol(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_7asyncpg_8protocol_8protocol_9__pyx_unpickle_CoreProtocol = {"__pyx_unpickle_CoreProtocol", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_9__pyx_unpickle_CoreProtocol, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_9__pyx_unpickle_CoreProtocol(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_CoreProtocol (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_CoreProtocol", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_CoreProtocol", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_CoreProtocol") < 0)) __PYX_ERR(2, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_CoreProtocol", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("asyncpg.protocol.protocol.__pyx_unpickle_CoreProtocol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_8__pyx_unpickle_CoreProtocol(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_8__pyx_unpickle_CoreProtocol(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = NULL;
  PyObject *__pyx_v___pyx_result = 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;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("__pyx_unpickle_CoreProtocol", 0);

  /* "(tree fragment)":2
 * def __pyx_unpickle_CoreProtocol(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x197884c:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x197884c = (_discard_data, _execute_iter, _execute_portal_name, _execute_stmt_name, _skip_discard, backend_pid, backend_secret, buffer, con_params, con_status, encoding, result, result_execute_completed, result_param_desc, result_row_desc, result_status_msg, result_type, state, transport, xact_status))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x197884c) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_CoreProtocol(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x197884c:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x197884c = (_discard_data, _execute_iter, _execute_portal_name, _execute_stmt_name, _skip_discard, backend_pid, backend_secret, buffer, con_params, con_status, encoding, result, result_execute_completed, result_param_desc, result_row_desc, result_status_msg, result_type, state, transport, xact_status))" % __pyx_checksum)
 *     __pyx_result = CoreProtocol.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0x197884c:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x197884c = (_discard_data, _execute_iter, _execute_portal_name, _execute_stmt_name, _skip_discard, backend_pid, backend_secret, buffer, con_params, con_status, encoding, result, result_execute_completed, result_param_desc, result_row_desc, result_status_msg, result_type, state, transport, xact_status))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = CoreProtocol.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x19, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(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_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __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_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __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[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __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_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 4, __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_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __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(2, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_CoreProtocol(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x197884c:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x197884c = (_discard_data, _execute_iter, _execute_portal_name, _execute_stmt_name, _skip_discard, backend_pid, backend_secret, buffer, con_params, con_status, encoding, result, result_execute_completed, result_param_desc, result_row_desc, result_status_msg, result_type, state, transport, xact_status))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x197884c = (_discard_data, _execute_iter, _execute_portal_name, _execute_stmt_name, _skip_discard, backend_pid, backend_secret, buffer, con_params, con_status, encoding, result, result_execute_completed, result_param_desc, result_row_desc, result_status_msg, result_type, state, transport, xact_status))" % __pyx_checksum)
 *     __pyx_result = CoreProtocol.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_CoreProtocol__set_state(<CoreProtocol> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_CoreProtocol), __pyx_n_s_new_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __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_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 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_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x197884c = (_discard_data, _execute_iter, _execute_portal_name, _execute_stmt_name, _skip_discard, backend_pid, backend_secret, buffer, con_params, con_status, encoding, result, result_execute_completed, result_param_desc, result_row_desc, result_status_msg, result_type, state, transport, xact_status))" % __pyx_checksum)
 *     __pyx_result = CoreProtocol.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_CoreProtocol__set_state(<CoreProtocol> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = CoreProtocol.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_CoreProtocol__set_state(<CoreProtocol> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_CoreProtocol__set_state(CoreProtocol __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol___pyx_unpickle_CoreProtocol__set_state(((struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x197884c = (_discard_data, _execute_iter, _execute_portal_name, _execute_stmt_name, _skip_discard, backend_pid, backend_secret, buffer, con_params, con_status, encoding, result, result_execute_completed, result_param_desc, result_row_desc, result_status_msg, result_type, state, transport, xact_status))" % __pyx_checksum)
 *     __pyx_result = CoreProtocol.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_CoreProtocol__set_state(<CoreProtocol> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_CoreProtocol__set_state(<CoreProtocol> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_CoreProtocol__set_state(CoreProtocol __pyx_result, tuple __pyx_state):
 *     __pyx_result._discard_data = __pyx_state[0]; __pyx_result._execute_iter = __pyx_state[1]; __pyx_result._execute_portal_name = __pyx_state[2]; __pyx_result._execute_stmt_name = __pyx_state[3]; __pyx_result._skip_discard = __pyx_state[4]; __pyx_result.backend_pid = __pyx_state[5]; __pyx_result.backend_secret = __pyx_state[6]; __pyx_result.buffer = __pyx_state[7]; __pyx_result.con_params = __pyx_state[8]; __pyx_result.con_status = __pyx_state[9]; __pyx_result.encoding = __pyx_state[10]; __pyx_result.result = __pyx_state[11]; __pyx_result.result_execute_completed = __pyx_state[12]; __pyx_result.result_param_desc = __pyx_state[13]; __pyx_result.result_row_desc = __pyx_state[14]; __pyx_result.result_status_msg = __pyx_state[15]; __pyx_result.result_type = __pyx_state[16]; __pyx_result.state = __pyx_state[17]; __pyx_result.transport = __pyx_state[18]; __pyx_result.xact_status = __pyx_state[19]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_CoreProtocol(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x197884c:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* 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_AddTraceback("asyncpg.protocol.protocol.__pyx_unpickle_CoreProtocol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":9
 *         __pyx_unpickle_CoreProtocol__set_state(<CoreProtocol> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_CoreProtocol__set_state(CoreProtocol __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._discard_data = __pyx_state[0]; __pyx_result._execute_iter = __pyx_state[1]; __pyx_result._execute_portal_name = __pyx_state[2]; __pyx_result._execute_stmt_name = __pyx_state[3]; __pyx_result._skip_discard = __pyx_state[4]; __pyx_result.backend_pid = __pyx_state[5]; __pyx_result.backend_secret = __pyx_state[6]; __pyx_result.buffer = __pyx_state[7]; __pyx_result.con_params = __pyx_state[8]; __pyx_result.con_status = __pyx_state[9]; __pyx_result.encoding = __pyx_state[10]; __pyx_result.result = __pyx_state[11]; __pyx_result.result_execute_completed = __pyx_state[12]; __pyx_result.result_param_desc = __pyx_state[13]; __pyx_result.result_row_desc = __pyx_state[14]; __pyx_result.result_status_msg = __pyx_state[15]; __pyx_result.result_type = __pyx_state[16]; __pyx_result.state = __pyx_state[17]; __pyx_result.transport = __pyx_state[18]; __pyx_result.xact_status = __pyx_state[19]
 *     if len(__pyx_state) > 20 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol___pyx_unpickle_CoreProtocol__set_state(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int32_t __pyx_t_3;
  enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus __pyx_t_4;
  enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType __pyx_t_5;
  enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState __pyx_t_6;
  enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_CoreProtocol__set_state", 0);

  /* "(tree fragment)":10
 *     return __pyx_result
 * cdef __pyx_unpickle_CoreProtocol__set_state(CoreProtocol __pyx_result, tuple __pyx_state):
 *     __pyx_result._discard_data = __pyx_state[0]; __pyx_result._execute_iter = __pyx_state[1]; __pyx_result._execute_portal_name = __pyx_state[2]; __pyx_result._execute_stmt_name = __pyx_state[3]; __pyx_result._skip_discard = __pyx_state[4]; __pyx_result.backend_pid = __pyx_state[5]; __pyx_result.backend_secret = __pyx_state[6]; __pyx_result.buffer = __pyx_state[7]; __pyx_result.con_params = __pyx_state[8]; __pyx_result.con_status = __pyx_state[9]; __pyx_result.encoding = __pyx_state[10]; __pyx_result.result = __pyx_state[11]; __pyx_result.result_execute_completed = __pyx_state[12]; __pyx_result.result_param_desc = __pyx_state[13]; __pyx_result.result_row_desc = __pyx_state[14]; __pyx_result.result_status_msg = __pyx_state[15]; __pyx_result.result_type = __pyx_state[16]; __pyx_result.state = __pyx_state[17]; __pyx_result.transport = __pyx_state[18]; __pyx_result.xact_status = __pyx_state[19]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 20 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[20])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->_discard_data = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_execute_iter);
  __Pyx_DECREF(__pyx_v___pyx_result->_execute_iter);
  __pyx_v___pyx_result->_execute_iter = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __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(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_execute_portal_name);
  __Pyx_DECREF(__pyx_v___pyx_result->_execute_portal_name);
  __pyx_v___pyx_result->_execute_portal_name = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __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(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_execute_stmt_name);
  __Pyx_DECREF(__pyx_v___pyx_result->_execute_stmt_name);
  __pyx_v___pyx_result->_execute_stmt_name = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->_skip_discard = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __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(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->backend_pid = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 6, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __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(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->backend_secret = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 7, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7asyncpg_8protocol_8protocol_ReadBuffer))))) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->buffer);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->buffer));
  __pyx_v___pyx_result->buffer = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 8, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->con_params);
  __Pyx_DECREF(__pyx_v___pyx_result->con_params);
  __pyx_v___pyx_result->con_params = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 9, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = ((enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)__Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus(__pyx_t_1)); if (unlikely(PyErr_Occurred())) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->con_status = __pyx_t_4;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 10, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __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(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->encoding);
  __Pyx_DECREF(__pyx_v___pyx_result->encoding);
  __pyx_v___pyx_result->encoding = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 11, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->result);
  __Pyx_DECREF(__pyx_v___pyx_result->result);
  __pyx_v___pyx_result->result = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 12, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->result_execute_completed = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 13, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __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(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->result_param_desc);
  __Pyx_DECREF(__pyx_v___pyx_result->result_param_desc);
  __pyx_v___pyx_result->result_param_desc = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 14, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __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(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->result_row_desc);
  __Pyx_DECREF(__pyx_v___pyx_result->result_row_desc);
  __pyx_v___pyx_result->result_row_desc = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 15, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __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(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->result_status_msg);
  __Pyx_DECREF(__pyx_v___pyx_result->result_status_msg);
  __pyx_v___pyx_result->result_status_msg = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 16, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = ((enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)__Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ResultType(__pyx_t_1)); if (unlikely(PyErr_Occurred())) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->result_type = __pyx_t_5;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 17, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = ((enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)__Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ProtocolState(__pyx_t_1)); if (unlikely(PyErr_Occurred())) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->state = __pyx_t_6;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 18, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->transport);
  __Pyx_DECREF(__pyx_v___pyx_result->transport);
  __pyx_v___pyx_result->transport = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 19, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = ((enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)__Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus(__pyx_t_1)); if (unlikely(PyErr_Occurred())) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->xact_status = __pyx_t_7;

  /* "(tree fragment)":11
 * cdef __pyx_unpickle_CoreProtocol__set_state(CoreProtocol __pyx_result, tuple __pyx_state):
 *     __pyx_result._discard_data = __pyx_state[0]; __pyx_result._execute_iter = __pyx_state[1]; __pyx_result._execute_portal_name = __pyx_state[2]; __pyx_result._execute_stmt_name = __pyx_state[3]; __pyx_result._skip_discard = __pyx_state[4]; __pyx_result.backend_pid = __pyx_state[5]; __pyx_result.backend_secret = __pyx_state[6]; __pyx_result.buffer = __pyx_state[7]; __pyx_result.con_params = __pyx_state[8]; __pyx_result.con_status = __pyx_state[9]; __pyx_result.encoding = __pyx_state[10]; __pyx_result.result = __pyx_state[11]; __pyx_result.result_execute_completed = __pyx_state[12]; __pyx_result.result_param_desc = __pyx_state[13]; __pyx_result.result_row_desc = __pyx_state[14]; __pyx_result.result_status_msg = __pyx_state[15]; __pyx_result.result_type = __pyx_state[16]; __pyx_result.state = __pyx_state[17]; __pyx_result.transport = __pyx_state[18]; __pyx_result.xact_status = __pyx_state[19]
 *     if len(__pyx_state) > 20 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[20])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 11, __pyx_L1_error)
  }
  __pyx_t_8 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_9 = ((__pyx_t_8 > 20) != 0);
  if (__pyx_t_9) {
  } else {
    __pyx_t_2 = __pyx_t_9;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_9 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_10 = (__pyx_t_9 != 0);
  __pyx_t_2 = __pyx_t_10;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":12
 *     __pyx_result._discard_data = __pyx_state[0]; __pyx_result._execute_iter = __pyx_state[1]; __pyx_result._execute_portal_name = __pyx_state[2]; __pyx_result._execute_stmt_name = __pyx_state[3]; __pyx_result._skip_discard = __pyx_state[4]; __pyx_result.backend_pid = __pyx_state[5]; __pyx_result.backend_secret = __pyx_state[6]; __pyx_result.buffer = __pyx_state[7]; __pyx_result.con_params = __pyx_state[8]; __pyx_result.con_status = __pyx_state[9]; __pyx_result.encoding = __pyx_state[10]; __pyx_result.result = __pyx_state[11]; __pyx_result.result_execute_completed = __pyx_state[12]; __pyx_result.result_param_desc = __pyx_state[13]; __pyx_result.result_row_desc = __pyx_state[14]; __pyx_result.result_status_msg = __pyx_state[15]; __pyx_result.result_type = __pyx_state[16]; __pyx_result.state = __pyx_state[17]; __pyx_result.transport = __pyx_state[18]; __pyx_result.xact_status = __pyx_state[19]
 *     if len(__pyx_state) > 20 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[20])             # <<<<<<<<<<<<<<
 */
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_update); if (unlikely(!__pyx_t_12)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 12, __pyx_L1_error)
    }
    __pyx_t_11 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 20, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_13 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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);
      }
    }
    if (!__pyx_t_13) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_11};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_11};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      } else
      #endif
      {
        __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL;
        __Pyx_GIVEREF(__pyx_t_11);
        PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_11);
        __pyx_t_11 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_14, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * cdef __pyx_unpickle_CoreProtocol__set_state(CoreProtocol __pyx_result, tuple __pyx_state):
 *     __pyx_result._discard_data = __pyx_state[0]; __pyx_result._execute_iter = __pyx_state[1]; __pyx_result._execute_portal_name = __pyx_state[2]; __pyx_result._execute_stmt_name = __pyx_state[3]; __pyx_result._skip_discard = __pyx_state[4]; __pyx_result.backend_pid = __pyx_state[5]; __pyx_result.backend_secret = __pyx_state[6]; __pyx_result.buffer = __pyx_state[7]; __pyx_result.con_params = __pyx_state[8]; __pyx_result.con_status = __pyx_state[9]; __pyx_result.encoding = __pyx_state[10]; __pyx_result.result = __pyx_state[11]; __pyx_result.result_execute_completed = __pyx_state[12]; __pyx_result.result_param_desc = __pyx_state[13]; __pyx_result.result_row_desc = __pyx_state[14]; __pyx_result.result_status_msg = __pyx_state[15]; __pyx_result.result_type = __pyx_state[16]; __pyx_result.state = __pyx_state[17]; __pyx_result.transport = __pyx_state[18]; __pyx_result.xact_status = __pyx_state[19]
 *     if len(__pyx_state) > 20 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[20])
 */
  }

  /* "(tree fragment)":9
 *         __pyx_unpickle_CoreProtocol__set_state(<CoreProtocol> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_CoreProtocol__set_state(CoreProtocol __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._discard_data = __pyx_state[0]; __pyx_result._execute_iter = __pyx_state[1]; __pyx_result._execute_portal_name = __pyx_state[2]; __pyx_result._execute_stmt_name = __pyx_state[3]; __pyx_result._skip_discard = __pyx_state[4]; __pyx_result.backend_pid = __pyx_state[5]; __pyx_result.backend_secret = __pyx_state[6]; __pyx_result.buffer = __pyx_state[7]; __pyx_result.con_params = __pyx_state[8]; __pyx_result.con_status = __pyx_state[9]; __pyx_result.encoding = __pyx_state[10]; __pyx_result.result = __pyx_state[11]; __pyx_result.result_execute_completed = __pyx_state[12]; __pyx_result.result_param_desc = __pyx_state[13]; __pyx_result.result_row_desc = __pyx_state[14]; __pyx_result.result_status_msg = __pyx_state[15]; __pyx_result.result_type = __pyx_state[16]; __pyx_result.state = __pyx_state[17]; __pyx_result.transport = __pyx_state[18]; __pyx_result.xact_status = __pyx_state[19]
 *     if len(__pyx_state) > 20 and hasattr(__pyx_result, '__dict__'):
 */

  /* 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_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.__pyx_unpickle_CoreProtocol__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_BaseProtocol(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x30f806c:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* Python wrapper */
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_11__pyx_unpickle_BaseProtocol(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_7asyncpg_8protocol_8protocol_11__pyx_unpickle_BaseProtocol = {"__pyx_unpickle_BaseProtocol", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_11__pyx_unpickle_BaseProtocol, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_7asyncpg_8protocol_8protocol_11__pyx_unpickle_BaseProtocol(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_BaseProtocol (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_BaseProtocol", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_BaseProtocol", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_BaseProtocol") < 0)) __PYX_ERR(2, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_BaseProtocol", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("asyncpg.protocol.protocol.__pyx_unpickle_BaseProtocol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7asyncpg_8protocol_8protocol_10__pyx_unpickle_BaseProtocol(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7asyncpg_8protocol_8protocol_10__pyx_unpickle_BaseProtocol(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = NULL;
  PyObject *__pyx_v___pyx_result = 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;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("__pyx_unpickle_BaseProtocol", 0);

  /* "(tree fragment)":2
 * def __pyx_unpickle_BaseProtocol(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x30f806c:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x30f806c = (_discard_data, _execute_iter, _execute_portal_name, _execute_stmt_name, _skip_discard, address, backend_pid, backend_secret, buffer, cancel_sent_waiter, cancel_waiter, closing, completed_callback, con_params, con_status, connection, create_future, encoding, is_reading, last_query, loop, queries_count, result, result_execute_completed, result_param_desc, result_row_desc, result_status_msg, result_type, return_extra, settings, state, statement, timeout_callback, timeout_handle, transport, waiter, writing_paused, xact_status))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x30f806c) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_BaseProtocol(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x30f806c:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x30f806c = (_discard_data, _execute_iter, _execute_portal_name, _execute_stmt_name, _skip_discard, address, backend_pid, backend_secret, buffer, cancel_sent_waiter, cancel_waiter, closing, completed_callback, con_params, con_status, connection, create_future, encoding, is_reading, last_query, loop, queries_count, result, result_execute_completed, result_param_desc, result_row_desc, result_status_msg, result_type, return_extra, settings, state, statement, timeout_callback, timeout_handle, transport, waiter, writing_paused, xact_status))" % __pyx_checksum)
 *     __pyx_result = BaseProtocol.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0x30f806c:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x30f806c = (_discard_data, _execute_iter, _execute_portal_name, _execute_stmt_name, _skip_discard, address, backend_pid, backend_secret, buffer, cancel_sent_waiter, cancel_waiter, closing, completed_callback, con_params, con_status, connection, create_future, encoding, is_reading, last_query, loop, queries_count, result, result_execute_completed, result_param_desc, result_row_desc, result_status_msg, result_type, return_extra, settings, state, statement, timeout_callback, timeout_handle, transport, waiter, writing_paused, xact_status))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = BaseProtocol.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x30, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(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_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __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_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __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[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __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_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 4, __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_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __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(2, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_BaseProtocol(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x30f806c:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x30f806c = (_discard_data, _execute_iter, _execute_portal_name, _execute_stmt_name, _skip_discard, address, backend_pid, backend_secret, buffer, cancel_sent_waiter, cancel_waiter, closing, completed_callback, con_params, con_status, connection, create_future, encoding, is_reading, last_query, loop, queries_count, result, result_execute_completed, result_param_desc, result_row_desc, result_status_msg, result_type, return_extra, settings, state, statement, timeout_callback, timeout_handle, transport, waiter, writing_paused, xact_status))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x30f806c = (_discard_data, _execute_iter, _execute_portal_name, _execute_stmt_name, _skip_discard, address, backend_pid, backend_secret, buffer, cancel_sent_waiter, cancel_waiter, closing, completed_callback, con_params, con_status, connection, create_future, encoding, is_reading, last_query, loop, queries_count, result, result_execute_completed, result_param_desc, result_row_desc, result_status_msg, result_type, return_extra, settings, state, statement, timeout_callback, timeout_handle, transport, waiter, writing_paused, xact_status))" % __pyx_checksum)
 *     __pyx_result = BaseProtocol.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_BaseProtocol__set_state(<BaseProtocol> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_BaseProtocol), __pyx_n_s_new_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __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_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 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_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x30f806c = (_discard_data, _execute_iter, _execute_portal_name, _execute_stmt_name, _skip_discard, address, backend_pid, backend_secret, buffer, cancel_sent_waiter, cancel_waiter, closing, completed_callback, con_params, con_status, connection, create_future, encoding, is_reading, last_query, loop, queries_count, result, result_execute_completed, result_param_desc, result_row_desc, result_status_msg, result_type, return_extra, settings, state, statement, timeout_callback, timeout_handle, transport, waiter, writing_paused, xact_status))" % __pyx_checksum)
 *     __pyx_result = BaseProtocol.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_BaseProtocol__set_state(<BaseProtocol> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = BaseProtocol.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_BaseProtocol__set_state(<BaseProtocol> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_BaseProtocol__set_state(BaseProtocol __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol___pyx_unpickle_BaseProtocol__set_state(((struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x30f806c = (_discard_data, _execute_iter, _execute_portal_name, _execute_stmt_name, _skip_discard, address, backend_pid, backend_secret, buffer, cancel_sent_waiter, cancel_waiter, closing, completed_callback, con_params, con_status, connection, create_future, encoding, is_reading, last_query, loop, queries_count, result, result_execute_completed, result_param_desc, result_row_desc, result_status_msg, result_type, return_extra, settings, state, statement, timeout_callback, timeout_handle, transport, waiter, writing_paused, xact_status))" % __pyx_checksum)
 *     __pyx_result = BaseProtocol.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_BaseProtocol__set_state(<BaseProtocol> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_BaseProtocol__set_state(<BaseProtocol> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_BaseProtocol__set_state(BaseProtocol __pyx_result, tuple __pyx_state):
 *     __pyx_result._discard_data = __pyx_state[0]; __pyx_result._execute_iter = __pyx_state[1]; __pyx_result._execute_portal_name = __pyx_state[2]; __pyx_result._execute_stmt_name = __pyx_state[3]; __pyx_result._skip_discard = __pyx_state[4]; __pyx_result.address = __pyx_state[5]; __pyx_result.backend_pid = __pyx_state[6]; __pyx_result.backend_secret = __pyx_state[7]; __pyx_result.buffer = __pyx_state[8]; __pyx_result.cancel_sent_waiter = __pyx_state[9]; __pyx_result.cancel_waiter = __pyx_state[10]; __pyx_result.closing = __pyx_state[11]; __pyx_result.completed_callback = __pyx_state[12]; __pyx_result.con_params = __pyx_state[13]; __pyx_result.con_status = __pyx_state[14]; __pyx_result.connection = __pyx_state[15]; __pyx_result.create_future = __pyx_state[16]; __pyx_result.encoding = __pyx_state[17]; __pyx_result.is_reading = __pyx_state[18]; __pyx_result.last_query = __pyx_state[19]; __pyx_result.loop = __pyx_state[20]; __pyx_result.queries_count = __pyx_state[21]; __pyx_result.result = __pyx_state[22]; __pyx_result.result_execute_completed = __pyx_state[23]; __pyx_result.result_param_desc = __pyx_state[24]; __pyx_result.result_row_desc = __pyx_state[25]; __pyx_result.result_status_msg = __pyx_state[26]; __pyx_result.result_type = __pyx_state[27]; __pyx_result.return_extra = __pyx_state[28]; __pyx_result.settings = __pyx_state[29]; __pyx_result.state = __pyx_state[30]; __pyx_result.statement = __pyx_state[31]; __pyx_result.timeout_callback = __pyx_state[32]; __pyx_result.timeout_handle = __pyx_state[33]; __pyx_result.transport = __pyx_state[34]; __pyx_result.waiter = __pyx_state[35]; __pyx_result.writing_paused = __pyx_state[36]; __pyx_result.xact_status = __pyx_state[37]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_BaseProtocol(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x30f806c:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* 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_AddTraceback("asyncpg.protocol.protocol.__pyx_unpickle_BaseProtocol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":9
 *         __pyx_unpickle_BaseProtocol__set_state(<BaseProtocol> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_BaseProtocol__set_state(BaseProtocol __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._discard_data = __pyx_state[0]; __pyx_result._execute_iter = __pyx_state[1]; __pyx_result._execute_portal_name = __pyx_state[2]; __pyx_result._execute_stmt_name = __pyx_state[3]; __pyx_result._skip_discard = __pyx_state[4]; __pyx_result.address = __pyx_state[5]; __pyx_result.backend_pid = __pyx_state[6]; __pyx_result.backend_secret = __pyx_state[7]; __pyx_result.buffer = __pyx_state[8]; __pyx_result.cancel_sent_waiter = __pyx_state[9]; __pyx_result.cancel_waiter = __pyx_state[10]; __pyx_result.closing = __pyx_state[11]; __pyx_result.completed_callback = __pyx_state[12]; __pyx_result.con_params = __pyx_state[13]; __pyx_result.con_status = __pyx_state[14]; __pyx_result.connection = __pyx_state[15]; __pyx_result.create_future = __pyx_state[16]; __pyx_result.encoding = __pyx_state[17]; __pyx_result.is_reading = __pyx_state[18]; __pyx_result.last_query = __pyx_state[19]; __pyx_result.loop = __pyx_state[20]; __pyx_result.queries_count = __pyx_state[21]; __pyx_result.result = __pyx_state[22]; __pyx_result.result_execute_completed = __pyx_state[23]; __pyx_result.result_param_desc = __pyx_state[24]; __pyx_result.result_row_desc = __pyx_state[25]; __pyx_result.result_status_msg = __pyx_state[26]; __pyx_result.result_type = __pyx_state[27]; __pyx_result.return_extra = __pyx_state[28]; __pyx_result.settings = __pyx_state[29]; __pyx_result.state = __pyx_state[30]; __pyx_result.statement = __pyx_state[31]; __pyx_result.timeout_callback = __pyx_state[32]; __pyx_result.timeout_handle = __pyx_state[33]; __pyx_result.transport = __pyx_state[34]; __pyx_result.waiter = __pyx_state[35]; __pyx_result.writing_paused = __pyx_state[36]; __pyx_result.xact_status = __pyx_state[37]
 *     if len(__pyx_state) > 38 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_7asyncpg_8protocol_8protocol___pyx_unpickle_BaseProtocol__set_state(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int32_t __pyx_t_3;
  enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus __pyx_t_4;
  uint64_t __pyx_t_5;
  enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType __pyx_t_6;
  enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState __pyx_t_7;
  enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_BaseProtocol__set_state", 0);

  /* "(tree fragment)":10
 *     return __pyx_result
 * cdef __pyx_unpickle_BaseProtocol__set_state(BaseProtocol __pyx_result, tuple __pyx_state):
 *     __pyx_result._discard_data = __pyx_state[0]; __pyx_result._execute_iter = __pyx_state[1]; __pyx_result._execute_portal_name = __pyx_state[2]; __pyx_result._execute_stmt_name = __pyx_state[3]; __pyx_result._skip_discard = __pyx_state[4]; __pyx_result.address = __pyx_state[5]; __pyx_result.backend_pid = __pyx_state[6]; __pyx_result.backend_secret = __pyx_state[7]; __pyx_result.buffer = __pyx_state[8]; __pyx_result.cancel_sent_waiter = __pyx_state[9]; __pyx_result.cancel_waiter = __pyx_state[10]; __pyx_result.closing = __pyx_state[11]; __pyx_result.completed_callback = __pyx_state[12]; __pyx_result.con_params = __pyx_state[13]; __pyx_result.con_status = __pyx_state[14]; __pyx_result.connection = __pyx_state[15]; __pyx_result.create_future = __pyx_state[16]; __pyx_result.encoding = __pyx_state[17]; __pyx_result.is_reading = __pyx_state[18]; __pyx_result.last_query = __pyx_state[19]; __pyx_result.loop = __pyx_state[20]; __pyx_result.queries_count = __pyx_state[21]; __pyx_result.result = __pyx_state[22]; __pyx_result.result_execute_completed = __pyx_state[23]; __pyx_result.result_param_desc = __pyx_state[24]; __pyx_result.result_row_desc = __pyx_state[25]; __pyx_result.result_status_msg = __pyx_state[26]; __pyx_result.result_type = __pyx_state[27]; __pyx_result.return_extra = __pyx_state[28]; __pyx_result.settings = __pyx_state[29]; __pyx_result.state = __pyx_state[30]; __pyx_result.statement = __pyx_state[31]; __pyx_result.timeout_callback = __pyx_state[32]; __pyx_result.timeout_handle = __pyx_state[33]; __pyx_result.transport = __pyx_state[34]; __pyx_result.waiter = __pyx_state[35]; __pyx_result.writing_paused = __pyx_state[36]; __pyx_result.xact_status = __pyx_state[37]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 38 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[38])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base._discard_data = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base._execute_iter);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base._execute_iter);
  __pyx_v___pyx_result->__pyx_base._execute_iter = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __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(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base._execute_portal_name);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base._execute_portal_name);
  __pyx_v___pyx_result->__pyx_base._execute_portal_name = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __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(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base._execute_stmt_name);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base._execute_stmt_name);
  __pyx_v___pyx_result->__pyx_base._execute_stmt_name = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base._skip_discard = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->address);
  __Pyx_DECREF(__pyx_v___pyx_result->address);
  __pyx_v___pyx_result->address = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 6, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __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(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.backend_pid = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 7, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __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(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.backend_secret = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 8, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7asyncpg_8protocol_8protocol_ReadBuffer))))) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.buffer);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.buffer));
  __pyx_v___pyx_result->__pyx_base.buffer = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 9, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->cancel_sent_waiter);
  __Pyx_DECREF(__pyx_v___pyx_result->cancel_sent_waiter);
  __pyx_v___pyx_result->cancel_sent_waiter = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 10, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->cancel_waiter);
  __Pyx_DECREF(__pyx_v___pyx_result->cancel_waiter);
  __pyx_v___pyx_result->cancel_waiter = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 11, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->closing = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 12, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->completed_callback);
  __Pyx_DECREF(__pyx_v___pyx_result->completed_callback);
  __pyx_v___pyx_result->completed_callback = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 13, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.con_params);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.con_params);
  __pyx_v___pyx_result->__pyx_base.con_params = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 14, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = ((enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)__Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus(__pyx_t_1)); if (unlikely(PyErr_Occurred())) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.con_status = __pyx_t_4;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 15, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->connection);
  __Pyx_DECREF(__pyx_v___pyx_result->connection);
  __pyx_v___pyx_result->connection = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 16, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->create_future);
  __Pyx_DECREF(__pyx_v___pyx_result->create_future);
  __pyx_v___pyx_result->create_future = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 17, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __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(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.encoding);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.encoding);
  __pyx_v___pyx_result->__pyx_base.encoding = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 18, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->is_reading = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 19, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __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(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->last_query);
  __Pyx_DECREF(__pyx_v___pyx_result->last_query);
  __pyx_v___pyx_result->last_query = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 20, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->loop);
  __Pyx_DECREF(__pyx_v___pyx_result->loop);
  __pyx_v___pyx_result->loop = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 21, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyInt_As_uint64_t(__pyx_t_1); if (unlikely((__pyx_t_5 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->queries_count = __pyx_t_5;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 22, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.result);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.result);
  __pyx_v___pyx_result->__pyx_base.result = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 23, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.result_execute_completed = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 24, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __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(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.result_param_desc);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.result_param_desc);
  __pyx_v___pyx_result->__pyx_base.result_param_desc = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 25, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __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(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.result_row_desc);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.result_row_desc);
  __pyx_v___pyx_result->__pyx_base.result_row_desc = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 26, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __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(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.result_status_msg);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.result_status_msg);
  __pyx_v___pyx_result->__pyx_base.result_status_msg = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 27, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = ((enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)__Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ResultType(__pyx_t_1)); if (unlikely(PyErr_Occurred())) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.result_type = __pyx_t_6;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 28, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->return_extra = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 29, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7asyncpg_8protocol_8protocol_ConnectionSettings))))) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->settings);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->settings));
  __pyx_v___pyx_result->settings = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 30, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = ((enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)__Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ProtocolState(__pyx_t_1)); if (unlikely(PyErr_Occurred())) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.state = __pyx_t_7;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 31, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7asyncpg_8protocol_8protocol_PreparedStatementState))))) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->statement);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->statement));
  __pyx_v___pyx_result->statement = ((struct __pyx_obj_7asyncpg_8protocol_8protocol_PreparedStatementState *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 32, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->timeout_callback);
  __Pyx_DECREF(__pyx_v___pyx_result->timeout_callback);
  __pyx_v___pyx_result->timeout_callback = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 33, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->timeout_handle);
  __Pyx_DECREF(__pyx_v___pyx_result->timeout_handle);
  __pyx_v___pyx_result->timeout_handle = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 34, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.transport);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.transport);
  __pyx_v___pyx_result->__pyx_base.transport = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 35, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->waiter);
  __Pyx_DECREF(__pyx_v___pyx_result->waiter);
  __pyx_v___pyx_result->waiter = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 36, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->writing_paused = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 37, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = ((enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)__Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus(__pyx_t_1)); if (unlikely(PyErr_Occurred())) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.xact_status = __pyx_t_8;

  /* "(tree fragment)":11
 * cdef __pyx_unpickle_BaseProtocol__set_state(BaseProtocol __pyx_result, tuple __pyx_state):
 *     __pyx_result._discard_data = __pyx_state[0]; __pyx_result._execute_iter = __pyx_state[1]; __pyx_result._execute_portal_name = __pyx_state[2]; __pyx_result._execute_stmt_name = __pyx_state[3]; __pyx_result._skip_discard = __pyx_state[4]; __pyx_result.address = __pyx_state[5]; __pyx_result.backend_pid = __pyx_state[6]; __pyx_result.backend_secret = __pyx_state[7]; __pyx_result.buffer = __pyx_state[8]; __pyx_result.cancel_sent_waiter = __pyx_state[9]; __pyx_result.cancel_waiter = __pyx_state[10]; __pyx_result.closing = __pyx_state[11]; __pyx_result.completed_callback = __pyx_state[12]; __pyx_result.con_params = __pyx_state[13]; __pyx_result.con_status = __pyx_state[14]; __pyx_result.connection = __pyx_state[15]; __pyx_result.create_future = __pyx_state[16]; __pyx_result.encoding = __pyx_state[17]; __pyx_result.is_reading = __pyx_state[18]; __pyx_result.last_query = __pyx_state[19]; __pyx_result.loop = __pyx_state[20]; __pyx_result.queries_count = __pyx_state[21]; __pyx_result.result = __pyx_state[22]; __pyx_result.result_execute_completed = __pyx_state[23]; __pyx_result.result_param_desc = __pyx_state[24]; __pyx_result.result_row_desc = __pyx_state[25]; __pyx_result.result_status_msg = __pyx_state[26]; __pyx_result.result_type = __pyx_state[27]; __pyx_result.return_extra = __pyx_state[28]; __pyx_result.settings = __pyx_state[29]; __pyx_result.state = __pyx_state[30]; __pyx_result.statement = __pyx_state[31]; __pyx_result.timeout_callback = __pyx_state[32]; __pyx_result.timeout_handle = __pyx_state[33]; __pyx_result.transport = __pyx_state[34]; __pyx_result.waiter = __pyx_state[35]; __pyx_result.writing_paused = __pyx_state[36]; __pyx_result.xact_status = __pyx_state[37]
 *     if len(__pyx_state) > 38 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[38])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 11, __pyx_L1_error)
  }
  __pyx_t_9 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_10 = ((__pyx_t_9 > 38) != 0);
  if (__pyx_t_10) {
  } else {
    __pyx_t_2 = __pyx_t_10;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_10 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_11 = (__pyx_t_10 != 0);
  __pyx_t_2 = __pyx_t_11;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":12
 *     __pyx_result._discard_data = __pyx_state[0]; __pyx_result._execute_iter = __pyx_state[1]; __pyx_result._execute_portal_name = __pyx_state[2]; __pyx_result._execute_stmt_name = __pyx_state[3]; __pyx_result._skip_discard = __pyx_state[4]; __pyx_result.address = __pyx_state[5]; __pyx_result.backend_pid = __pyx_state[6]; __pyx_result.backend_secret = __pyx_state[7]; __pyx_result.buffer = __pyx_state[8]; __pyx_result.cancel_sent_waiter = __pyx_state[9]; __pyx_result.cancel_waiter = __pyx_state[10]; __pyx_result.closing = __pyx_state[11]; __pyx_result.completed_callback = __pyx_state[12]; __pyx_result.con_params = __pyx_state[13]; __pyx_result.con_status = __pyx_state[14]; __pyx_result.connection = __pyx_state[15]; __pyx_result.create_future = __pyx_state[16]; __pyx_result.encoding = __pyx_state[17]; __pyx_result.is_reading = __pyx_state[18]; __pyx_result.last_query = __pyx_state[19]; __pyx_result.loop = __pyx_state[20]; __pyx_result.queries_count = __pyx_state[21]; __pyx_result.result = __pyx_state[22]; __pyx_result.result_execute_completed = __pyx_state[23]; __pyx_result.result_param_desc = __pyx_state[24]; __pyx_result.result_row_desc = __pyx_state[25]; __pyx_result.result_status_msg = __pyx_state[26]; __pyx_result.result_type = __pyx_state[27]; __pyx_result.return_extra = __pyx_state[28]; __pyx_result.settings = __pyx_state[29]; __pyx_result.state = __pyx_state[30]; __pyx_result.statement = __pyx_state[31]; __pyx_result.timeout_callback = __pyx_state[32]; __pyx_result.timeout_handle = __pyx_state[33]; __pyx_result.transport = __pyx_state[34]; __pyx_result.waiter = __pyx_state[35]; __pyx_result.writing_paused = __pyx_state[36]; __pyx_result.xact_status = __pyx_state[37]
 *     if len(__pyx_state) > 38 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[38])             # <<<<<<<<<<<<<<
 */
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_12)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_update); if (unlikely(!__pyx_t_13)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 12, __pyx_L1_error)
    }
    __pyx_t_12 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 38, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_14 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
      __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
      if (likely(__pyx_t_14)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
        __Pyx_INCREF(__pyx_t_14);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_13, function);
      }
    }
    if (!__pyx_t_14) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_13)) {
        PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_12};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
        PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_12};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      } else
      #endif
      {
        __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_14); __pyx_t_14 = NULL;
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_t_12);
        __pyx_t_12 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_15, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * cdef __pyx_unpickle_BaseProtocol__set_state(BaseProtocol __pyx_result, tuple __pyx_state):
 *     __pyx_result._discard_data = __pyx_state[0]; __pyx_result._execute_iter = __pyx_state[1]; __pyx_result._execute_portal_name = __pyx_state[2]; __pyx_result._execute_stmt_name = __pyx_state[3]; __pyx_result._skip_discard = __pyx_state[4]; __pyx_result.address = __pyx_state[5]; __pyx_result.backend_pid = __pyx_state[6]; __pyx_result.backend_secret = __pyx_state[7]; __pyx_result.buffer = __pyx_state[8]; __pyx_result.cancel_sent_waiter = __pyx_state[9]; __pyx_result.cancel_waiter = __pyx_state[10]; __pyx_result.closing = __pyx_state[11]; __pyx_result.completed_callback = __pyx_state[12]; __pyx_result.con_params = __pyx_state[13]; __pyx_result.con_status = __pyx_state[14]; __pyx_result.connection = __pyx_state[15]; __pyx_result.create_future = __pyx_state[16]; __pyx_result.encoding = __pyx_state[17]; __pyx_result.is_reading = __pyx_state[18]; __pyx_result.last_query = __pyx_state[19]; __pyx_result.loop = __pyx_state[20]; __pyx_result.queries_count = __pyx_state[21]; __pyx_result.result = __pyx_state[22]; __pyx_result.result_execute_completed = __pyx_state[23]; __pyx_result.result_param_desc = __pyx_state[24]; __pyx_result.result_row_desc = __pyx_state[25]; __pyx_result.result_status_msg = __pyx_state[26]; __pyx_result.result_type = __pyx_state[27]; __pyx_result.return_extra = __pyx_state[28]; __pyx_result.settings = __pyx_state[29]; __pyx_result.state = __pyx_state[30]; __pyx_result.statement = __pyx_state[31]; __pyx_result.timeout_callback = __pyx_state[32]; __pyx_result.timeout_handle = __pyx_state[33]; __pyx_result.transport = __pyx_state[34]; __pyx_result.waiter = __pyx_state[35]; __pyx_result.writing_paused = __pyx_state[36]; __pyx_result.xact_status = __pyx_state[37]
 *     if len(__pyx_state) > 38 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[38])
 */
  }

  /* "(tree fragment)":9
 *         __pyx_unpickle_BaseProtocol__set_state(<BaseProtocol> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_BaseProtocol__set_state(BaseProtocol __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._discard_data = __pyx_state[0]; __pyx_result._execute_iter = __pyx_state[1]; __pyx_result._execute_portal_name = __pyx_state[2]; __pyx_result._execute_stmt_name = __pyx_state[3]; __pyx_result._skip_discard = __pyx_state[4]; __pyx_result.address = __pyx_state[5]; __pyx_result.backend_pid = __pyx_state[6]; __pyx_result.backend_secret = __pyx_state[7]; __pyx_result.buffer = __pyx_state[8]; __pyx_result.cancel_sent_waiter = __pyx_state[9]; __pyx_result.cancel_waiter = __pyx_state[10]; __pyx_result.closing = __pyx_state[11]; __pyx_result.completed_callback = __pyx_state[12]; __pyx_result.con_params = __pyx_state[13]; __pyx_result.con_status = __pyx_state[14]; __pyx_result.connection = __pyx_state[15]; __pyx_result.create_future = __pyx_state[16]; __pyx_result.encoding = __pyx_state[17]; __pyx_result.is_reading = __pyx_state[18]; __pyx_result.last_query = __pyx_state[19]; __pyx_result.loop = __pyx_state[20]; __pyx_result.queries_count = __pyx_state[21]; __pyx_result.result = __pyx_state[22]; __pyx_result.result_execute_completed = __pyx_state[23]; __pyx_result.result_param_desc = __pyx_state[24]; __pyx_result.result_row_desc = __pyx_state[25]; __pyx_result.result_status_msg = __pyx_state[26]; __pyx_result.result_type = __pyx_state[27]; __pyx_result.return_extra = __pyx_state[28]; __pyx_result.settings = __pyx_state[29]; __pyx_result.state = __pyx_state[30]; __pyx_result.statement = __pyx_state[31]; __pyx_result.timeout_callback = __pyx_state[32]; __pyx_result.timeout_handle = __pyx_state[33]; __pyx_result.transport = __pyx_state[34]; __pyx_result.waiter = __pyx_state[35]; __pyx_result.writing_paused = __pyx_state[36]; __pyx_result.xact_status = __pyx_state[37]
 *     if len(__pyx_state) > 38 and hasattr(__pyx_result, '__dict__'):
 */

  /* 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_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("asyncpg.protocol.protocol.__pyx_unpickle_BaseProtocol__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __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 PyMethodDef __pyx_methods_7asyncpg_8protocol_8protocol_Memory[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_6Memory_1__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_6Memory_3__setstate_cython__, METH_O, 0},
  {0, 0, 0, 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*/
  __pyx_methods_7asyncpg_8protocol_8protocol_Memory, /*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[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_11WriteBuffer_9__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_11WriteBuffer_11__setstate_cython__, METH_O, 0},
  {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[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_10ReadBuffer_3__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_10ReadBuffer_5__setstate_cython__, METH_O, 0},
  {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 PyMethodDef __pyx_methods_7asyncpg_8protocol_8protocol_FastReadBuffer[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_14FastReadBuffer_1__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_14FastReadBuffer_3__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

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*/
  __pyx_methods_7asyncpg_8protocol_8protocol_FastReadBuffer, /*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[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_5Codec_5__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_5Codec_7__setstate_cython__, METH_O, 0},
  {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 CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && 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},
  {"remove_python_codec", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_7remove_python_codec, METH_VARARGS|METH_KEYWORDS, 0},
  {"_set_builtin_type_codec", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_9_set_builtin_type_codec, METH_VARARGS|METH_KEYWORDS, 0},
  {"set_builtin_type_codec", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_11set_builtin_type_codec, METH_VARARGS|METH_KEYWORDS, 0},
  {"clear_type_cache", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_13clear_type_cache, METH_NOARGS, 0},
  {"declare_fallback_codec", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_15declare_fallback_codec, METH_VARARGS|METH_KEYWORDS, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_17__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_15DataCodecConfig_19__setstate_cython__, METH_O, 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_17__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},
  {"remove_python_codec", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_9remove_python_codec, METH_VARARGS|METH_KEYWORDS, 0},
  {"clear_type_cache", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_11clear_type_cache, METH_NOARGS, 0},
  {"set_builtin_type_codec", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_13set_builtin_type_codec, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_data_codec", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_15get_data_codec, METH_VARARGS|METH_KEYWORDS, 0},
  {"__getattr__", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_17__getattr__, METH_O|METH_COEXIST, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_21__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_23__setstate_cython__, METH_O, 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
  __pyx_pw_7asyncpg_8protocol_8protocol_18ConnectionSettings_19__repr__, /*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_params = 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 CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && 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_params);
  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_params) {
    e = (*v)(p->con_params, 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_params);
  p->con_params = 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},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12CoreProtocol_9__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12CoreProtocol_11__setstate_cython__, 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},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_15__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_22PreparedStatementState_17__setstate_cython__, METH_O, 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 CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && 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},
  {"is_in_transaction", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_9is_in_transaction, METH_NOARGS, 0},
  {"prepare", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_11prepare, METH_VARARGS|METH_KEYWORDS, 0},
  {"bind_execute", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_14bind_execute, METH_VARARGS|METH_KEYWORDS, 0},
  {"bind_execute_many", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_17bind_execute_many, METH_VARARGS|METH_KEYWORDS, 0},
  {"bind", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_20bind, METH_VARARGS|METH_KEYWORDS, 0},
  {"execute", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_23execute, METH_VARARGS|METH_KEYWORDS, 0},
  {"query", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_26query, METH_VARARGS|METH_KEYWORDS, 0},
  {"copy_out", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_29copy_out, METH_VARARGS|METH_KEYWORDS, 0},
  {"copy_in", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_32copy_in, METH_VARARGS|METH_KEYWORDS, 0},
  {"close_statement", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_35close_statement, METH_VARARGS|METH_KEYWORDS, 0},
  {"is_closed", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_38is_closed, METH_NOARGS, 0},
  {"is_connected", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_40is_connected, METH_NOARGS, 0},
  {"abort", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_42abort, METH_NOARGS, 0},
  {"close", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_44close, METH_O, 0},
  {"_request_cancel", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_47_request_cancel, METH_NOARGS, 0},
  {"_on_timeout", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_49_on_timeout, METH_O, 0},
  {"_on_waiter_completed", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_51_on_waiter_completed, METH_O, 0},
  {"_create_future_fallback", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_53_create_future_fallback, METH_NOARGS, 0},
  {"_get_timeout", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_55_get_timeout, METH_O, 0},
  {"_is_cancelling", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_57_is_cancelling, METH_NOARGS, 0},
  {"_wait_for_cancellation", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_59_wait_for_cancellation, METH_NOARGS, 0},
  {"pause_writing", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_62pause_writing, METH_NOARGS, 0},
  {"resume_writing", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_64resume_writing, METH_NOARGS, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_66__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_7asyncpg_8protocol_8protocol_12BaseProtocol_68__setstate_cython__, METH_O, 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_ex);
  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);
  Py_CLEAR(p->__pyx_v_waiter);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  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_ex) {
    e = (*v)(p->__pyx_v_ex, a); if (e) return e;
  }
  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;
  }
  if (p->__pyx_v_waiter) {
    e = (*v)(p->__pyx_v_waiter, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  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*/
  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___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_args_buf);
  Py_CLEAR(p->__pyx_v_ex);
  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);
  Py_CLEAR(p->__pyx_v_waiter);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  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_args_buf) {
    e = (*v)(p->__pyx_v_args_buf, a); if (e) return e;
  }
  if (p->__pyx_v_ex) {
    e = (*v)(p->__pyx_v_ex, 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;
  }
  if (p->__pyx_v_waiter) {
    e = (*v)(p->__pyx_v_waiter, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  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*/
  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___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_ex);
  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);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  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_ex) {
    e = (*v)(p->__pyx_v_ex, 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;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  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*/
  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___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 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*/
  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___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_args_buf);
  Py_CLEAR(p->__pyx_v_ex);
  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);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  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_args_buf) {
    e = (*v)(p->__pyx_v_args_buf, a); if (e) return e;
  }
  if (p->__pyx_v_ex) {
    e = (*v)(p->__pyx_v_ex, 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;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  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*/
  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___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_ex);
  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);
  Py_CLEAR(p->__pyx_v_waiter);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  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_ex) {
    e = (*v)(p->__pyx_v_ex, 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;
  }
  if (p->__pyx_v_waiter) {
    e = (*v)(p->__pyx_v_waiter, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  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*/
  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___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_ex);
  Py_CLEAR(p->__pyx_v_query);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_timeout);
  Py_CLEAR(p->__pyx_v_waiter);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  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_ex) {
    e = (*v)(p->__pyx_v_ex, a); if (e) return e;
  }
  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;
  }
  if (p->__pyx_v_waiter) {
    e = (*v)(p->__pyx_v_waiter, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  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*/
  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___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_copy_out *__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out[8];
static int __pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out = 0;

static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out(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_copy_out > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out)))) {
    o = (PyObject*)__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out[--__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out];
    memset(o, 0, sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out));
    (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_copy_out(PyObject *o) {
  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_buffer);
  Py_CLEAR(p->__pyx_v_copy_stmt);
  Py_CLEAR(p->__pyx_v_done);
  Py_CLEAR(p->__pyx_v_ex);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_sink);
  Py_CLEAR(p->__pyx_v_status_msg);
  Py_CLEAR(p->__pyx_v_timeout);
  Py_CLEAR(p->__pyx_v_timer);
  Py_CLEAR(p->__pyx_v_waiter);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  Py_CLEAR(p->__pyx_t_6);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out)))) {
    __pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out[__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out++] = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out *)o;
  if (p->__pyx_v_buffer) {
    e = (*v)(p->__pyx_v_buffer, a); if (e) return e;
  }
  if (p->__pyx_v_copy_stmt) {
    e = (*v)(p->__pyx_v_copy_stmt, a); if (e) return e;
  }
  if (p->__pyx_v_done) {
    e = (*v)(p->__pyx_v_done, a); if (e) return e;
  }
  if (p->__pyx_v_ex) {
    e = (*v)(p->__pyx_v_ex, 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_sink) {
    e = (*v)(p->__pyx_v_sink, a); if (e) return e;
  }
  if (p->__pyx_v_status_msg) {
    e = (*v)(p->__pyx_v_status_msg, 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_timer) {
    e = (*v)(p->__pyx_v_timer, a); if (e) return e;
  }
  if (p->__pyx_v_waiter) {
    e = (*v)(p->__pyx_v_waiter, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  if (p->__pyx_t_6) {
    e = (*v)(p->__pyx_t_6, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out = {
  PyVarObject_HEAD_INIT(0, 0)
  "asyncpg.protocol.protocol.__pyx_scope_struct_7_copy_out", /*tp_name*/
  sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out, /*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_copy_out, /*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___pyx_scope_struct_7_copy_out, /*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_copy_in *__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in[8];
static int __pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in = 0;

static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in(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_copy_in > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in)))) {
    o = (PyObject*)__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in[--__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in];
    memset(o, 0, sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in));
    (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_copy_in(PyObject *o) {
  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_aiter);
  Py_CLEAR(p->__pyx_v_chunk);
  Py_CLEAR(p->__pyx_v_codec);
  Py_CLEAR(p->__pyx_v_codecs);
  Py_CLEAR(p->__pyx_v_copy_stmt);
  Py_CLEAR(p->__pyx_v_data);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_item);
  Py_CLEAR(p->__pyx_v_iterator);
  Py_CLEAR(p->__pyx_v_reader);
  Py_CLEAR(p->__pyx_v_record_stmt);
  Py_CLEAR(p->__pyx_v_records);
  Py_CLEAR(p->__pyx_v_row);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_settings);
  Py_CLEAR(p->__pyx_v_status_msg);
  Py_CLEAR(p->__pyx_v_timeout);
  Py_CLEAR(p->__pyx_v_timer);
  Py_CLEAR(p->__pyx_v_waiter);
  Py_CLEAR(p->__pyx_v_wbuf);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_6);
  Py_CLEAR(p->__pyx_t_7);
  Py_CLEAR(p->__pyx_t_8);
  Py_CLEAR(p->__pyx_t_9);
  Py_CLEAR(p->__pyx_t_10);
  Py_CLEAR(p->__pyx_t_11);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in)))) {
    __pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in[__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in++] = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in *)o;
  if (p->__pyx_v_aiter) {
    e = (*v)(p->__pyx_v_aiter, a); if (e) return e;
  }
  if (p->__pyx_v_chunk) {
    e = (*v)(p->__pyx_v_chunk, a); if (e) return e;
  }
  if (p->__pyx_v_codec) {
    e = (*v)(((PyObject *)p->__pyx_v_codec), a); if (e) return e;
  }
  if (p->__pyx_v_codecs) {
    e = (*v)(p->__pyx_v_codecs, a); if (e) return e;
  }
  if (p->__pyx_v_copy_stmt) {
    e = (*v)(p->__pyx_v_copy_stmt, a); if (e) return e;
  }
  if (p->__pyx_v_data) {
    e = (*v)(p->__pyx_v_data, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_item) {
    e = (*v)(p->__pyx_v_item, a); if (e) return e;
  }
  if (p->__pyx_v_iterator) {
    e = (*v)(p->__pyx_v_iterator, a); if (e) return e;
  }
  if (p->__pyx_v_reader) {
    e = (*v)(p->__pyx_v_reader, a); if (e) return e;
  }
  if (p->__pyx_v_record_stmt) {
    e = (*v)(((PyObject *)p->__pyx_v_record_stmt), a); if (e) return e;
  }
  if (p->__pyx_v_records) {
    e = (*v)(p->__pyx_v_records, a); if (e) return e;
  }
  if (p->__pyx_v_row) {
    e = (*v)(p->__pyx_v_row, 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_settings) {
    e = (*v)(((PyObject *)p->__pyx_v_settings), a); if (e) return e;
  }
  if (p->__pyx_v_status_msg) {
    e = (*v)(p->__pyx_v_status_msg, 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_timer) {
    e = (*v)(p->__pyx_v_timer, a); if (e) return e;
  }
  if (p->__pyx_v_waiter) {
    e = (*v)(p->__pyx_v_waiter, a); if (e) return e;
  }
  if (p->__pyx_v_wbuf) {
    e = (*v)(((PyObject *)p->__pyx_v_wbuf), a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_6) {
    e = (*v)(p->__pyx_t_6, a); if (e) return e;
  }
  if (p->__pyx_t_7) {
    e = (*v)(p->__pyx_t_7, a); if (e) return e;
  }
  if (p->__pyx_t_8) {
    e = (*v)(p->__pyx_t_8, a); if (e) return e;
  }
  if (p->__pyx_t_9) {
    e = (*v)(p->__pyx_t_9, a); if (e) return e;
  }
  if (p->__pyx_t_10) {
    e = (*v)(p->__pyx_t_10, a); if (e) return e;
  }
  if (p->__pyx_t_11) {
    e = (*v)(p->__pyx_t_11, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in = {
  PyVarObject_HEAD_INIT(0, 0)
  "asyncpg.protocol.protocol.__pyx_scope_struct_8_copy_in", /*tp_name*/
  sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in, /*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_copy_in, /*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___pyx_scope_struct_8_copy_in, /*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_9_close_statement *__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement[8];
static int __pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement = 0;

static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_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_9_close_statement > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement)))) {
    o = (PyObject*)__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement[--__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement];
    memset(o, 0, sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_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_9_close_statement(PyObject *o) {
  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_ex);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_state);
  Py_CLEAR(p->__pyx_v_timeout);
  Py_CLEAR(p->__pyx_v_waiter);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement)))) {
    __pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement[__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement++] = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement *)o;
  if (p->__pyx_v_ex) {
    e = (*v)(p->__pyx_v_ex, 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;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement = {
  PyVarObject_HEAD_INIT(0, 0)
  "asyncpg.protocol.protocol.__pyx_scope_struct_9_close_statement", /*tp_name*/
  sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_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_9_close_statement, /*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___pyx_scope_struct_9_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_10_close *__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close[8];
static int __pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close = 0;

static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_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_10_close > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close)))) {
    o = (PyObject*)__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close[--__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close];
    memset(o, 0, sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_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_10_close(PyObject *o) {
  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_timeout);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close)))) {
    __pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close[__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close++] = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close *)o;
  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;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close = {
  PyVarObject_HEAD_INIT(0, 0)
  "asyncpg.protocol.protocol.__pyx_scope_struct_10_close", /*tp_name*/
  sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_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_10_close, /*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___pyx_scope_struct_10_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 struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation *__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation[8];
static int __pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation = 0;

static PyObject *__pyx_tp_new_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation(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_11__wait_for_cancellation > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation)))) {
    o = (PyObject*)__pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation[--__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation];
    memset(o, 0, sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation));
    (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_11__wait_for_cancellation(PyObject *o) {
  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation)))) {
    __pyx_freelist_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation[__pyx_freecount_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation++] = ((struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation *p = (struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation = {
  PyVarObject_HEAD_INIT(0, 0)
  "asyncpg.protocol.protocol.__pyx_scope_struct_11__wait_for_cancellation", /*tp_name*/
  sizeof(struct __pyx_obj_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation, /*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_11__wait_for_cancellation, /*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___pyx_scope_struct_11__wait_for_cancellation, /*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
#if CYTHON_PEP489_MULTI_PHASE_INIT
static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
static int __pyx_pymod_exec_protocol(PyObject* module); /*proto*/
static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  {Py_mod_create, (void*)__pyx_pymod_create},
  {Py_mod_exec, (void*)__pyx_pymod_exec_protocol},
  {0, NULL}
};
#endif

static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    "protocol",
    0, /* m_doc */
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    0, /* m_size */
  #else
    -1, /* m_size */
  #endif
    __pyx_methods /* m_methods */,
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    __pyx_moduledef_slots, /* m_slots */
  #else
    NULL, /* m_reload */
  #endif
    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__wait_for_cancellat, __pyx_k_BaseProtocol__wait_for_cancellat, sizeof(__pyx_k_BaseProtocol__wait_for_cancellat), 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_copy_in, __pyx_k_BaseProtocol_copy_in, sizeof(__pyx_k_BaseProtocol_copy_in), 0, 0, 1, 1},
  {&__pyx_n_s_BaseProtocol_copy_out, __pyx_k_BaseProtocol_copy_out, sizeof(__pyx_k_BaseProtocol_copy_out), 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_kp_u_Check_the_query_against_the_pass, __pyx_k_Check_the_query_against_the_pass, sizeof(__pyx_k_Check_the_query_against_the_pass), 0, 1, 0, 0},
  {&__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_ConnectionResetError, __pyx_k_ConnectionResetError, sizeof(__pyx_k_ConnectionResetError), 0, 0, 1, 1},
  {&__pyx_kp_u_ConnectionSettings_r, __pyx_k_ConnectionSettings_r, sizeof(__pyx_k_ConnectionSettings_r), 0, 1, 0, 0},
  {&__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_Event, __pyx_k_Event, sizeof(__pyx_k_Event), 0, 0, 1, 1},
  {&__pyx_n_u_F, __pyx_k_F, sizeof(__pyx_k_F), 0, 1, 0, 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_kp_s_Incompatible_checksums_s_vs_0x19, __pyx_k_Incompatible_checksums_s_vs_0x19, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x19), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x30, __pyx_k_Incompatible_checksums_s_vs_0x30, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x30), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x7e, __pyx_k_Incompatible_checksums_s_vs_0x7e, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x7e), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0xb7, __pyx_k_Incompatible_checksums_s_vs_0xb7, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xb7), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0xe0, __pyx_k_Incompatible_checksums_s_vs_0xe0, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xe0), 0, 0, 1, 0},
  {&__pyx_n_s_InterfaceError, __pyx_k_InterfaceError, sizeof(__pyx_k_InterfaceError), 0, 0, 1, 1},
  {&__pyx_n_s_InternalClientError, __pyx_k_InternalClientError, sizeof(__pyx_k_InternalClientError), 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_N, __pyx_k_N, sizeof(__pyx_k_N), 0, 1, 0, 1},
  {&__pyx_n_u_NA, __pyx_k_NA, sizeof(__pyx_k_NA), 0, 1, 0, 1},
  {&__pyx_n_s_NO_TIMEOUT, __pyx_k_NO_TIMEOUT, sizeof(__pyx_k_NO_TIMEOUT), 0, 0, 1, 1},
  {&__pyx_n_b_NULL, __pyx_k_NULL, sizeof(__pyx_k_NULL), 0, 0, 0, 1},
  {&__pyx_kp_b_NULL_2, __pyx_k_NULL_2, sizeof(__pyx_k_NULL_2), 0, 0, 0, 0},
  {&__pyx_n_u_NaN, __pyx_k_NaN, sizeof(__pyx_k_NaN), 0, 1, 0, 1},
  {&__pyx_n_s_NotImplementedError, __pyx_k_NotImplementedError, sizeof(__pyx_k_NotImplementedError), 0, 0, 1, 1},
  {&__pyx_kp_u_Note_that_parameters_are_suppor, __pyx_k_Note_that_parameters_are_suppor, sizeof(__pyx_k_Note_that_parameters_are_suppor), 0, 1, 0, 0},
  {&__pyx_n_s_OrderedDict, __pyx_k_OrderedDict, sizeof(__pyx_k_OrderedDict), 0, 0, 1, 1},
  {&__pyx_n_s_OutdatedSchemaCacheError, __pyx_k_OutdatedSchemaCacheError, sizeof(__pyx_k_OutdatedSchemaCacheError), 0, 0, 1, 1},
  {&__pyx_n_s_OverflowError, __pyx_k_OverflowError, sizeof(__pyx_k_OverflowError), 0, 0, 1, 1},
  {&__pyx_kp_b_PGCOPY, __pyx_k_PGCOPY, sizeof(__pyx_k_PGCOPY), 0, 0, 0, 0},
  {&__pyx_n_s_Path, __pyx_k_Path, sizeof(__pyx_k_Path), 0, 0, 1, 1},
  {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 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_PostgresError, __pyx_k_PostgresError, sizeof(__pyx_k_PostgresError), 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_Record, __pyx_k_Record, sizeof(__pyx_k_Record), 0, 0, 1, 1},
  {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
  {&__pyx_n_s_StopAsyncIteration, __pyx_k_StopAsyncIteration, sizeof(__pyx_k_StopAsyncIteration), 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_u_TimeoutError, __pyx_k_TimeoutError, sizeof(__pyx_k_TimeoutError), 0, 1, 0, 1},
  {&__pyx_n_s_Timer, __pyx_k_Timer, sizeof(__pyx_k_Timer), 0, 0, 1, 1},
  {&__pyx_n_s_Timer___enter, __pyx_k_Timer___enter, sizeof(__pyx_k_Timer___enter), 0, 0, 1, 1},
  {&__pyx_n_s_Timer___exit, __pyx_k_Timer___exit, sizeof(__pyx_k_Timer___exit), 0, 0, 1, 1},
  {&__pyx_n_s_Timer___init, __pyx_k_Timer___init, sizeof(__pyx_k_Timer___init), 0, 0, 1, 1},
  {&__pyx_n_s_Timer_get_remaining_budget, __pyx_k_Timer_get_remaining_budget, sizeof(__pyx_k_Timer_get_remaining_budget), 0, 0, 1, 1},
  {&__pyx_kp_u_TimoutError_was_not_raised, __pyx_k_TimoutError_was_not_raised, sizeof(__pyx_k_TimoutError_was_not_raised), 0, 1, 0, 0},
  {&__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__22, __pyx_k__22, sizeof(__pyx_k__22), 0, 0, 0, 0},
  {&__pyx_kp_u__22, __pyx_k__22, sizeof(__pyx_k__22), 0, 1, 0, 0},
  {&__pyx_kp_b__23, __pyx_k__23, sizeof(__pyx_k__23), 0, 0, 0, 0},
  {&__pyx_n_u__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 1, 0, 1},
  {&__pyx_kp_u__36, __pyx_k__36, sizeof(__pyx_k__36), 0, 1, 0, 0},
  {&__pyx_kp_b__64, __pyx_k__64, sizeof(__pyx_k__64), 0, 0, 0, 0},
  {&__pyx_kp_u__87, __pyx_k__87, sizeof(__pyx_k__87), 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_aiter, __pyx_k_aiter, sizeof(__pyx_k_aiter), 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_s_anext, __pyx_k_anext, sizeof(__pyx_k_anext), 0, 0, 1, 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_s_as_tuple, __pyx_k_as_tuple, sizeof(__pyx_k_as_tuple), 0, 0, 1, 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_kp_s_asyncpg_protocol_protocol_pyx, __pyx_k_asyncpg_protocol_protocol_pyx, sizeof(__pyx_k_asyncpg_protocol_protocol_pyx), 0, 0, 1, 0},
  {&__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_u_binary, __pyx_k_binary, sizeof(__pyx_k_binary), 0, 1, 0, 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_n_s_budget, __pyx_k_budget, sizeof(__pyx_k_budget), 0, 0, 1, 1},
  {&__pyx_n_s_budget_2, __pyx_k_budget_2, sizeof(__pyx_k_budget_2), 0, 0, 1, 1},
  {&__pyx_kp_u_buffer_overread, __pyx_k_buffer_overread, sizeof(__pyx_k_buffer_overread), 0, 1, 0, 0},
  {&__pyx_n_s_builtins, __pyx_k_builtins, sizeof(__pyx_k_builtins), 0, 0, 1, 1},
  {&__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_encode_Decimal_value_into, __pyx_k_cannot_encode_Decimal_value_into, sizeof(__pyx_k_cannot_encode_Decimal_value_into), 0, 1, 0, 0},
  {&__pyx_kp_u_cannot_encode_Decimal_value_into_2, __pyx_k_cannot_encode_Decimal_value_into_2, sizeof(__pyx_k_cannot_encode_Decimal_value_into_2), 0, 1, 0, 0},
  {&__pyx_kp_u_cannot_encode_Decimal_value_into_3, __pyx_k_cannot_encode_Decimal_value_into_3, sizeof(__pyx_k_cannot_encode_Decimal_value_into_3), 0, 1, 0, 0},
  {&__pyx_kp_u_cannot_encode_type_text_encoding, __pyx_k_cannot_encode_type_text_encoding, sizeof(__pyx_k_cannot_encode_type_text_encoding), 0, 1, 0, 0},
  {&__pyx_kp_u_cannot_encode_type_text_encoding_2, __pyx_k_cannot_encode_type_text_encoding_2, sizeof(__pyx_k_cannot_encode_type_text_encoding_2), 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_s_clear, __pyx_k_clear, sizeof(__pyx_k_clear), 0, 0, 1, 1},
  {&__pyx_n_s_clear_type_cache, __pyx_k_clear_type_cache, sizeof(__pyx_k_clear_type_cache), 0, 0, 1, 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_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 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_s_compat, __pyx_k_compat, sizeof(__pyx_k_compat), 0, 0, 1, 1},
  {&__pyx_n_u_composite, __pyx_k_composite, sizeof(__pyx_k_composite), 0, 1, 0, 1},
  {&__pyx_n_s_con_params, __pyx_k_con_params, sizeof(__pyx_k_con_params), 0, 0, 1, 1},
  {&__pyx_n_s_config, __pyx_k_config, sizeof(__pyx_k_config), 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_s_copy_in, __pyx_k_copy_in, sizeof(__pyx_k_copy_in), 0, 0, 1, 1},
  {&__pyx_n_s_copy_in_locals_lambda, __pyx_k_copy_in_locals_lambda, sizeof(__pyx_k_copy_in_locals_lambda), 0, 0, 1, 1},
  {&__pyx_n_s_copy_out, __pyx_k_copy_out, sizeof(__pyx_k_copy_out), 0, 0, 1, 1},
  {&__pyx_n_s_copy_out_locals_lambda, __pyx_k_copy_out_locals_lambda, sizeof(__pyx_k_copy_out_locals_lambda), 0, 0, 1, 1},
  {&__pyx_n_s_copy_stmt, __pyx_k_copy_stmt, sizeof(__pyx_k_copy_stmt), 0, 0, 1, 1},
  {&__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_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
  {&__pyx_n_s_data_type, __pyx_k_data_type, sizeof(__pyx_k_data_type), 0, 0, 1, 1},
  {&__pyx_n_s_database, __pyx_k_database, sizeof(__pyx_k_database), 0, 0, 1, 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_kp_u_date_tuple_encoder_expecting_1_e, __pyx_k_date_tuple_encoder_expecting_1_e, sizeof(__pyx_k_date_tuple_encoder_expecting_1_e), 0, 1, 0, 0},
  {&__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_declare_fallback_codec, __pyx_k_declare_fallback_codec, sizeof(__pyx_k_declare_fallback_codec), 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_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
  {&__pyx_n_s_digits, __pyx_k_digits, sizeof(__pyx_k_digits), 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_b_e, __pyx_k_e, sizeof(__pyx_k_e), 0, 0, 0, 1},
  {&__pyx_n_s_e, __pyx_k_e, sizeof(__pyx_k_e), 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_enter, __pyx_k_enter, sizeof(__pyx_k_enter), 0, 0, 1, 1},
  {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
  {&__pyx_n_s_et, __pyx_k_et, sizeof(__pyx_k_et), 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_exception, __pyx_k_exception, sizeof(__pyx_k_exception), 0, 0, 1, 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_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 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_kp_u_expected_str_got, __pyx_k_expected_str_got, sizeof(__pyx_k_expected_str_got), 0, 1, 0, 0},
  {&__pyx_n_s_exponent, __pyx_k_exponent, sizeof(__pyx_k_exponent), 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_get_remaining_budget, __pyx_k_get_remaining_budget, sizeof(__pyx_k_get_remaining_budget), 0, 0, 1, 1},
  {&__pyx_n_s_get_timeout, __pyx_k_get_timeout, sizeof(__pyx_k_get_timeout), 0, 0, 1, 1},
  {&__pyx_n_s_getattr, __pyx_k_getattr, sizeof(__pyx_k_getattr), 0, 0, 1, 1},
  {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 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_n_s_hint, __pyx_k_hint, sizeof(__pyx_k_hint), 0, 0, 1, 1},
  {&__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_index_am_handler, __pyx_k_index_am_handler, sizeof(__pyx_k_index_am_handler), 0, 1, 0, 1},
  {&__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_int_too_big_to_be_encoded_as_INT, __pyx_k_int_too_big_to_be_encoded_as_INT, sizeof(__pyx_k_int_too_big_to_be_encoded_as_INT), 0, 1, 0, 0},
  {&__pyx_kp_u_int_too_big_to_be_encoded_as_INT_2, __pyx_k_int_too_big_to_be_encoded_as_INT_2, sizeof(__pyx_k_int_too_big_to_be_encoded_as_INT_2), 0, 1, 0, 0},
  {&__pyx_kp_u_int_too_big_to_be_encoded_as_INT_3, __pyx_k_int_too_big_to_be_encoded_as_INT_3, sizeof(__pyx_k_int_too_big_to_be_encoded_as_INT_3), 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_interval_tuple_encoder_expecting, __pyx_k_interval_tuple_encoder_expecting, sizeof(__pyx_k_interval_tuple_encoder_expecting), 0, 1, 0, 0},
  {&__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_address_length_in_value, __pyx_k_invalid_address_length_in_value, sizeof(__pyx_k_invalid_address_length_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_data_format, __pyx_k_invalid_data_format, sizeof(__pyx_k_invalid_data_format), 0, 1, 0, 0},
  {&__pyx_kp_u_invalid_format_argument_expected, __pyx_k_invalid_format_argument_expected, sizeof(__pyx_k_invalid_format_argument_expected), 0, 1, 0, 0},
  {&__pyx_kp_u_invalid_network_prefix_length_in, __pyx_k_invalid_network_prefix_length_in, sizeof(__pyx_k_invalid_network_prefix_length_in), 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_timeout_value_expected_n, __pyx_k_invalid_timeout_value_expected_n, sizeof(__pyx_k_invalid_timeout_value_expected_n), 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_u_macaddr8, __pyx_k_macaddr8, sizeof(__pyx_k_macaddr8), 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_monotonic, __pyx_k_monotonic, sizeof(__pyx_k_monotonic), 0, 0, 1, 1},
  {&__pyx_n_u_n, __pyx_k_n, sizeof(__pyx_k_n), 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_2, __pyx_k_new_2, sizeof(__pyx_k_new_2), 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_binary_format_encoder_for_typ, __pyx_k_no_binary_format_encoder_for_typ, sizeof(__pyx_k_no_binary_format_encoder_for_typ), 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_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_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 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_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_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_kp_u_numeric_type_does_not_support_in, __pyx_k_numeric_type_does_not_support_in, sizeof(__pyx_k_numeric_type_does_not_support_in), 0, 1, 0, 0},
  {&__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_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_s_pause_reading, __pyx_k_pause_reading, sizeof(__pyx_k_pause_reading), 0, 0, 1, 1},
  {&__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_u_pg_dependencies, __pyx_k_pg_dependencies, sizeof(__pyx_k_pg_dependencies), 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_ndistinct, __pyx_k_pg_ndistinct, sizeof(__pyx_k_pg_ndistinct), 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_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 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_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 0, 0, 1, 1},
  {&__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_position, __pyx_k_position, sizeof(__pyx_k_position), 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_process_log_message, __pyx_k_process_log_message, sizeof(__pyx_k_process_log_message), 0, 0, 1, 1},
  {&__pyx_n_s_process_notification, __pyx_k_process_notification, sizeof(__pyx_k_process_notification), 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_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_capi, __pyx_k_pyx_capi, sizeof(__pyx_k_pyx_capi), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_BaseProtocol, __pyx_k_pyx_unpickle_BaseProtocol, sizeof(__pyx_k_pyx_unpickle_BaseProtocol), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_CoreProtocol, __pyx_k_pyx_unpickle_CoreProtocol, sizeof(__pyx_k_pyx_unpickle_CoreProtocol), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_DataCodecConfig, __pyx_k_pyx_unpickle_DataCodecConfig, sizeof(__pyx_k_pyx_unpickle_DataCodecConfig), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_FastReadBuffer, __pyx_k_pyx_unpickle_FastReadBuffer, sizeof(__pyx_k_pyx_unpickle_FastReadBuffer), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_Memory, __pyx_k_pyx_unpickle_Memory, sizeof(__pyx_k_pyx_unpickle_Memory), 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_reader, __pyx_k_reader, sizeof(__pyx_k_reader), 0, 0, 1, 1},
  {&__pyx_kp_u_reader_is_not_an_asynchronous_it, __pyx_k_reader_is_not_an_asynchronous_it, sizeof(__pyx_k_reader_is_not_an_asynchronous_it), 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_s_record_stmt, __pyx_k_record_stmt, sizeof(__pyx_k_record_stmt), 0, 0, 1, 1},
  {&__pyx_n_s_records, __pyx_k_records, sizeof(__pyx_k_records), 0, 0, 1, 1},
  {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 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_s_release, __pyx_k_release, sizeof(__pyx_k_release), 0, 0, 1, 1},
  {&__pyx_n_u_reltime, __pyx_k_reltime, sizeof(__pyx_k_reltime), 0, 1, 0, 1},
  {&__pyx_n_s_remove_python_codec, __pyx_k_remove_python_codec, sizeof(__pyx_k_remove_python_codec), 0, 0, 1, 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_resume_reading, __pyx_k_resume_reading, sizeof(__pyx_k_resume_reading), 0, 0, 1, 1},
  {&__pyx_n_s_return_extra, __pyx_k_return_extra, sizeof(__pyx_k_return_extra), 0, 0, 1, 1},
  {&__pyx_n_s_reversed, __pyx_k_reversed, sizeof(__pyx_k_reversed), 0, 0, 1, 1},
  {&__pyx_n_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 1},
  {&__pyx_n_u_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 1, 0, 1},
  {&__pyx_n_u_scalar, __pyx_k_scalar, sizeof(__pyx_k_scalar), 0, 1, 0, 1},
  {&__pyx_n_s_schema, __pyx_k_schema, sizeof(__pyx_k_schema), 0, 0, 1, 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_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
  {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1},
  {&__pyx_n_s_server_settings, __pyx_k_server_settings, sizeof(__pyx_k_server_settings), 0, 0, 1, 1},
  {&__pyx_n_s_set, __pyx_k_set, sizeof(__pyx_k_set), 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_builtin_type_codec_2, __pyx_k_set_builtin_type_codec_2, sizeof(__pyx_k_set_builtin_type_codec_2), 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_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
  {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 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_s_sign, __pyx_k_sign, sizeof(__pyx_k_sign), 0, 0, 1, 1},
  {&__pyx_n_s_sink, __pyx_k_sink, sizeof(__pyx_k_sink), 0, 0, 1, 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_started, __pyx_k_started, sizeof(__pyx_k_started), 0, 0, 1, 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_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_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
  {&__pyx_n_s_supernet, __pyx_k_supernet, sizeof(__pyx_k_supernet), 0, 0, 1, 1},
  {&__pyx_n_s_tb, __pyx_k_tb, sizeof(__pyx_k_tb), 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_text_binary_or_tuple, __pyx_k_text_binary_or_tuple, sizeof(__pyx_k_text_binary_or_tuple), 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_kp_u_the_number_of_query_arguments_ca, __pyx_k_the_number_of_query_arguments_ca, sizeof(__pyx_k_the_number_of_query_arguments_ca), 0, 1, 0, 0},
  {&__pyx_kp_u_the_server_expects_x_argument_s, __pyx_k_the_server_expects_x_argument_s, sizeof(__pyx_k_the_server_expects_x_argument_s), 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_kp_u_time_tuple_encoder_expecting_1_e, __pyx_k_time_tuple_encoder_expecting_1_e, sizeof(__pyx_k_time_tuple_encoder_expecting_1_e), 0, 1, 0, 0},
  {&__pyx_kp_u_time_tuple_encoder_expecting_2_e, __pyx_k_time_tuple_encoder_expecting_2_e, sizeof(__pyx_k_time_tuple_encoder_expecting_2_e), 0, 1, 0, 0},
  {&__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_kp_u_timestamp_tuple_encoder_expectin, __pyx_k_timestamp_tuple_encoder_expectin, sizeof(__pyx_k_timestamp_tuple_encoder_expectin), 0, 1, 0, 0},
  {&__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_tuple, __pyx_k_tuple, sizeof(__pyx_k_tuple), 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_does_not_support_tuple_exc, __pyx_k_type_does_not_support_tuple_exc, sizeof(__pyx_k_type_does_not_support_tuple_exc), 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_format, __pyx_k_unexpected_data_format, sizeof(__pyx_k_unexpected_data_format), 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_exchange_format, __pyx_k_unexpected_exchange_format, sizeof(__pyx_k_unexpected_exchange_format), 0, 1, 0, 0},
  {&__pyx_kp_u_unexpected_instance_of_anyarray, __pyx_k_unexpected_instance_of_anyarray, sizeof(__pyx_k_unexpected_instance_of_anyarray), 0, 1, 0, 0},
  {&__pyx_kp_u_unexpected_ndims_value, __pyx_k_unexpected_ndims_value, sizeof(__pyx_k_unexpected_ndims_value), 0, 1, 0, 0},
  {&__pyx_kp_u_unexpected_number_of_attributes, __pyx_k_unexpected_number_of_attributes, sizeof(__pyx_k_unexpected_number_of_attributes), 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_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
  {&__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_s_w, __pyx_k_w, sizeof(__pyx_k_w), 0, 0, 1, 1},
  {&__pyx_n_s_wait, __pyx_k_wait, sizeof(__pyx_k_wait), 0, 0, 1, 1},
  {&__pyx_n_s_wait_for, __pyx_k_wait_for, sizeof(__pyx_k_wait_for), 0, 0, 1, 1},
  {&__pyx_n_s_wait_for_cancellation, __pyx_k_wait_for_cancellation, sizeof(__pyx_k_wait_for_cancellation), 0, 0, 1, 1},
  {&__pyx_kp_u_waiter_is_not_done_while_handlin, __pyx_k_waiter_is_not_done_while_handlin, sizeof(__pyx_k_waiter_is_not_done_while_handlin), 0, 1, 0, 0},
  {&__pyx_n_u_was, __pyx_k_was, sizeof(__pyx_k_was), 0, 1, 0, 1},
  {&__pyx_n_u_were, __pyx_k_were, sizeof(__pyx_k_were), 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_s_writing_allowed, __pyx_k_writing_allowed, sizeof(__pyx_k_writing_allowed), 0, 0, 1, 1},
  {&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1},
  {&__pyx_n_s_xformat, __pyx_k_xformat, sizeof(__pyx_k_xformat), 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},
  {&__pyx_n_s_y, __pyx_k_y, sizeof(__pyx_k_y), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) __PYX_ERR(0, 88, __pyx_L1_error)
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(1, 51, __pyx_L1_error)
  __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) __PYX_ERR(1, 85, __pyx_L1_error)
  __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(1, 86, __pyx_L1_error)
  __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(2, 2, __pyx_L1_error)
  __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(3, 52, __pyx_L1_error)
  __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(3, 94, __pyx_L1_error)
  __pyx_builtin_chr = __Pyx_GetBuiltinName(__pyx_n_s_chr); if (!__pyx_builtin_chr) __PYX_ERR(3, 593, __pyx_L1_error)
  __pyx_builtin_print = __Pyx_GetBuiltinName(__pyx_n_s_print); if (!__pyx_builtin_print) __PYX_ERR(3, 598, __pyx_L1_error)
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(4, 208, __pyx_L1_error)
  __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(4, 464, __pyx_L1_error)
  __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s_NotImplementedError); if (!__pyx_builtin_NotImplementedError) __PYX_ERR(4, 606, __pyx_L1_error)
  __pyx_builtin_OverflowError = __Pyx_GetBuiltinName(__pyx_n_s_OverflowError); if (!__pyx_builtin_OverflowError) __PYX_ERR(5, 27, __pyx_L1_error)
  __pyx_builtin_reversed = __Pyx_GetBuiltinName(__pyx_n_s_reversed); if (!__pyx_builtin_reversed) __PYX_ERR(6, 357, __pyx_L1_error)
  __pyx_builtin_memoryview = __Pyx_GetBuiltinName(__pyx_n_s_memoryview); if (!__pyx_builtin_memoryview) __PYX_ERR(7, 36, __pyx_L1_error)
  __pyx_builtin_StopIteration = __Pyx_GetBuiltinName(__pyx_n_s_StopIteration); if (!__pyx_builtin_StopIteration) __PYX_ERR(7, 264, __pyx_L1_error)
  __pyx_builtin_TimeoutError = __Pyx_GetBuiltinName(__pyx_n_s_TimeoutError); if (!__pyx_builtin_TimeoutError) __PYX_ERR(0, 472, __pyx_L1_error)
  __pyx_builtin_ConnectionResetError = __Pyx_GetBuiltinName(__pyx_n_s_ConnectionResetError); if (!__pyx_builtin_ConnectionResetError) __PYX_ERR(0, 560, __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(1, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple_);
  __Pyx_GIVEREF(__pyx_tuple_);

  /* "asyncpg/protocol/settings.pyx":82
 * 
 *     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(1, 82, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__5);
  __Pyx_GIVEREF(__pyx_tuple__5);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);

  /* "asyncpg/protocol/buffer.pyx":52
 * 
 *         if self._view_count:
 *             raise RuntimeError(             # <<<<<<<<<<<<<<
 *                 'Deallocating buffer with attached memoryviews')
 * 
 */
  __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_u_Deallocating_buffer_with_attache); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(3, 52, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__7);
  __Pyx_GIVEREF(__pyx_tuple__7);

  /* "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__8 = PyTuple_Pack(1, __pyx_kp_u_the_buffer_is_in_read_only_mode); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(3, 68, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__8);
  __Pyx_GIVEREF(__pyx_tuple__8);

  /* "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__9 = PyTuple_Pack(1, __pyx_kp_u_cannot_start_message_for_a_non_e); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(3, 112, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__9);
  __Pyx_GIVEREF(__pyx_tuple__9);

  /* "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__10 = PyTuple_Pack(1, __pyx_kp_u_end_message_can_only_be_called_w); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(3, 124, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__10);
  __Pyx_GIVEREF(__pyx_tuple__10);

  /* "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__11 = PyTuple_Pack(1, __pyx_kp_u_end_message_buffer_is_too_small); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(3, 127, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__11);
  __Pyx_GIVEREF(__pyx_tuple__11);

  /* "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__12 = PyTuple_Pack(1, __pyx_kp_u_end_message_message_is_too_large); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(3, 129, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__13);
  __Pyx_GIVEREF(__pyx_tuple__13);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__14);
  __Pyx_GIVEREF(__pyx_tuple__14);

  /* "asyncpg/protocol/buffer.pyx":255
 * 
 *         if not cpython.PyBytes_CheckExact(data):
 *             raise BufferError('feed_data: bytes object expected')             # <<<<<<<<<<<<<<
 *         data_bytes = <bytes>data
 * 
 */
  __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_u_feed_data_bytes_object_expected); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(3, 255, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);

  /* "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__16 = PyTuple_Pack(1, __pyx_kp_u_empty_first_buffer); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(3, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__16);
  __Pyx_GIVEREF(__pyx_tuple__16);

  /* "asyncpg/protocol/buffer.pyx":295
 *         if ASYNCPG_DEBUG:
 *             if self._len0 < 1:
 *                 raise RuntimeError(             # <<<<<<<<<<<<<<
 *                     'debug: second buffer of ReadBuffer is empty')
 * 
 */
  __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_u_debug_second_buffer_of_ReadBuffe); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(3, 295, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__17);
  __Pyx_GIVEREF(__pyx_tuple__17);

  /* "asyncpg/protocol/buffer.pyx":371
 *             self._current_message_len_unread -= nbytes
 *             if self._current_message_len_unread < 0:
 *                 raise BufferError('buffer overread')             # <<<<<<<<<<<<<<
 * 
 *         result = PyByteArray_FromStringAndSize(NULL, nbytes)
 */
  __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_u_buffer_overread); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(3, 371, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__18);
  __Pyx_GIVEREF(__pyx_tuple__18);

  /* "asyncpg/protocol/buffer.pyx":384
 *         if ASYNCPG_DEBUG:
 *             if not self._buf0:
 *                 raise RuntimeError(             # <<<<<<<<<<<<<<
 *                     'debug: first buffer of ReadBuffer is empty')
 * 
 */
  __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_u_debug_first_buffer_of_ReadBuffer); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(3, 384, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__19);
  __Pyx_GIVEREF(__pyx_tuple__19);

  /* "asyncpg/protocol/buffer.pyx":390
 *         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__20 = PyTuple_Pack(1, __pyx_kp_u_not_enough_data_to_read_one_byte); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(3, 390, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__20);
  __Pyx_GIVEREF(__pyx_tuple__20);

  /* "asyncpg/protocol/buffer.pyx":435
 *     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__21 = PyTuple_Pack(1, __pyx_kp_u_read_cstr_only_works_when_the_me); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(3, 435, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__21);
  __Pyx_GIVEREF(__pyx_tuple__21);

  /* "asyncpg/protocol/buffer.pyx":473
 *                 self._current_message_len_unread -= nread
 *                 if self._current_message_len_unread < 0:
 *                     raise BufferError('read_cstr: buffer overread')             # <<<<<<<<<<<<<<
 * 
 *                 return result
 */
  __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_u_read_cstr_buffer_overread); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(3, 473, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__24);
  __Pyx_GIVEREF(__pyx_tuple__24);

  /* "asyncpg/protocol/buffer.pyx":485
 *                 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__25 = PyTuple_Pack(1, __pyx_kp_u_read_cstr_buffer_overread); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(3, 485, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__25);
  __Pyx_GIVEREF(__pyx_tuple__25);

  /* "asyncpg/protocol/buffer.pyx":502
 *             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__26 = PyTuple_Pack(1, __pyx_kp_u_failed_to_read_one_byte_on_a_non); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(3, 502, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);

  /* "asyncpg/protocol/buffer.pyx":546
 *     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__27 = PyTuple_Pack(1, __pyx_kp_u_no_message_to_consume); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(3, 546, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__27);
  __Pyx_GIVEREF(__pyx_tuple__27);

  /* "asyncpg/protocol/buffer.pyx":589
 * 
 *         if not self._current_message_ready:
 *             raise BufferError('no message to discard')             # <<<<<<<<<<<<<<
 * 
 *         if self._current_message_len_unread:
 */
  __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_u_no_message_to_discard); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(3, 589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__28);
  __Pyx_GIVEREF(__pyx_tuple__28);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__29);
  __Pyx_GIVEREF(__pyx_tuple__29);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__30);
  __Pyx_GIVEREF(__pyx_tuple__30);

  /* "asyncpg/protocol/codecs/base.pyx":131
 *         count = len(obj)
 *         if count > _MAXINT32:
 *             raise ValueError('too many elements in composite type record')             # <<<<<<<<<<<<<<
 * 
 *         elem_data = WriteBuffer.new()
 */
  __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_u_too_many_elements_in_composite_t); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(4, 131, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__31);
  __Pyx_GIVEREF(__pyx_tuple__31);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__32);
  __Pyx_GIVEREF(__pyx_tuple__32);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__33 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__33);
  __Pyx_GIVEREF(__pyx_tuple__33);

  /* "asyncpg/protocol/codecs/base.pyx":421
 * 
 *                 # Canonicalize type name to "elemtype[]"
 *                 if name.startswith('_'):             # <<<<<<<<<<<<<<
 *                     name = name[1:]
 *                 name = '{}[]'.format(name)
 */
  __pyx_tuple__34 = PyTuple_Pack(1, __pyx_n_u__3); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(4, 421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__34);
  __Pyx_GIVEREF(__pyx_tuple__34);

  /* "asyncpg/protocol/codecs/base.pyx":422
 *                 # Canonicalize type name to "elemtype[]"
 *                 if name.startswith('_'):
 *                     name = name[1:]             # <<<<<<<<<<<<<<
 *                 name = '{}[]'.format(name)
 * 
 */
  __pyx_slice__35 = PySlice_New(__pyx_int_1, Py_None, Py_None); if (unlikely(!__pyx_slice__35)) __PYX_ERR(4, 422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__35);
  __Pyx_GIVEREF(__pyx_slice__35);

  /* "asyncpg/protocol/codecs/base.pyx":731
 *     kind = 'scalar'
 * 
 *     codec = Codec(INVALIDOID)             # <<<<<<<<<<<<<<
 *     codec.init(name, None, kind, CODEC_C, format, PG_XFORMAT_OBJECT,
 *                encode, decode, None, None, None, None, None, None, 0)
 */
  __pyx_tuple__42 = PyTuple_Pack(1, __pyx_int_0); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(4, 731, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__42);
  __Pyx_GIVEREF(__pyx_tuple__42);

  /* "asyncpg/protocol/codecs/text.pyx":21
 * 
 *     if size[0] > 0x7fffffff:
 *         raise ValueError('string too long')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__43 = PyTuple_Pack(1, __pyx_kp_u_string_too_long); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(10, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__43);
  __Pyx_GIVEREF(__pyx_tuple__43);

  /* "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__44 = PyTuple_Pack(1, __pyx_kp_u_bit_value_too_long); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(11, 35, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__44);
  __Pyx_GIVEREF(__pyx_tuple__44);

  /* "asyncpg/protocol/codecs/datetime.pyx":275
 * 
 * cdef timetz_encode(ConnectionSettings settings, WriteBuffer buf, obj):
 *     offset = obj.tzinfo.utcoffset(None)             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
  __pyx_tuple__45 = PyTuple_Pack(1, Py_None); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(12, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__45);
  __Pyx_GIVEREF(__pyx_tuple__45);

  /* "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__46 = PyTuple_Pack(1, __pyx_kp_u_float_value_too_large_to_be_enco); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(13, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__46);
  __Pyx_GIVEREF(__pyx_tuple__46);

  /* "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__47 = PyTuple_Pack(1, __pyx_kp_u_path_value_too_long); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(14, 115, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__47);
  __Pyx_GIVEREF(__pyx_tuple__47);

  /* "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__48 = PyTuple_Pack(1, __pyx_kp_u_polygon_value_too_long); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(14, 141, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__48);
  __Pyx_GIVEREF(__pyx_tuple__48);

  /* "asyncpg/protocol/codecs/json.pyx":16
 * 
 *     if size > 0x7fffffff - 1:
 *         raise ValueError('string too long')             # <<<<<<<<<<<<<<
 * 
 *     buf.write_int32(<int32_t>size + 1)
 */
  __pyx_tuple__49 = PyTuple_Pack(1, __pyx_kp_u_string_too_long); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(15, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__49);
  __Pyx_GIVEREF(__pyx_tuple__49);

  /* "asyncpg/protocol/codecs/numeric.pyx":57
 *     dt = dec.as_tuple()
 *     if dt.exponent == 'F':
 *         raise ValueError('numeric type does not support infinite values')             # <<<<<<<<<<<<<<
 * 
 *     if dt.exponent == 'n' or dt.exponent == 'N':
 */
  __pyx_tuple__50 = PyTuple_Pack(1, __pyx_kp_u_numeric_type_does_not_support_in); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(18, 57, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__50);
  __Pyx_GIVEREF(__pyx_tuple__50);

  /* "asyncpg/protocol/codecs/numeric.pyx":68
 *         exponent = dt.exponent
 *         if exponent < 0 and -exponent > MAX_DSCALE:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 'cannot encode Decimal value into numeric: '
 *                 'exponent is too small')
 */
  __pyx_tuple__51 = PyTuple_Pack(1, __pyx_kp_u_cannot_encode_Decimal_value_into); if (unlikely(!__pyx_tuple__51)) __PYX_ERR(18, 68, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__51);
  __Pyx_GIVEREF(__pyx_tuple__51);

  /* "asyncpg/protocol/codecs/numeric.pyx":87
 * 
 *         if weight > 2 ** 16 - 1:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                     'cannot encode Decimal value into numeric: '
 *                     'exponent is too large')
 */
  __pyx_tuple__52 = PyTuple_Pack(1, __pyx_kp_u_cannot_encode_Decimal_value_into_2); if (unlikely(!__pyx_tuple__52)) __PYX_ERR(18, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__52);
  __Pyx_GIVEREF(__pyx_tuple__52);

  /* "asyncpg/protocol/codecs/numeric.pyx":97
 * 
 *         if num_pgdigits > 2 ** 16 - 1:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                     'cannot encode Decimal value into numeric: '
 *                     'number of digits is too large')
 */
  __pyx_tuple__53 = PyTuple_Pack(1, __pyx_kp_u_cannot_encode_Decimal_value_into_3); if (unlikely(!__pyx_tuple__53)) __PYX_ERR(18, 97, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__53);
  __Pyx_GIVEREF(__pyx_tuple__53);

  /* "asyncpg/protocol/codecs/numeric.pyx":103
 *         # Pad decimal digits to provide room for correct Postgres
 *         # digit alignment in the digit computation loop.
 *         pydigits = (0,) * DEC_DIGITS + pydigits + (0,) * DEC_DIGITS             # <<<<<<<<<<<<<<
 * 
 *         if exponent < 0:
 */
  __pyx_tuple__54 = PyTuple_New(1 * 4); if (unlikely(!__pyx_tuple__54)) __PYX_ERR(18, 103, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__54);
  { Py_ssize_t __pyx_temp;
    for (__pyx_temp=0; __pyx_temp < 4; __pyx_temp++) {
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_tuple__54, __pyx_temp, __pyx_int_0);
    }
  }
  __Pyx_GIVEREF(__pyx_tuple__54);
  __pyx_tuple__55 = PyTuple_New(1 * 4); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(18, 103, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__55);
  { Py_ssize_t __pyx_temp;
    for (__pyx_temp=0; __pyx_temp < 4; __pyx_temp++) {
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_tuple__55, __pyx_temp, __pyx_int_0);
    }
  }
  __Pyx_GIVEREF(__pyx_tuple__55);

  /* "asyncpg/protocol/codecs/numeric.pyx":107
 *         if exponent < 0:
 *             if -exponent > MAX_DSCALE:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     'cannot encode Decimal value into numeric: '
 *                     'exponent is too small')
 */
  __pyx_tuple__56 = PyTuple_Pack(1, __pyx_kp_u_cannot_encode_Decimal_value_into); if (unlikely(!__pyx_tuple__56)) __PYX_ERR(18, 107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__56);
  __Pyx_GIVEREF(__pyx_tuple__56);

  /* "asyncpg/protocol/codecs/numeric.pyx":160
 *     if sign == NUMERIC_NAN:
 *         # Not-a-number
 *         return _Dec('NaN')             # <<<<<<<<<<<<<<
 * 
 *     if num_pgdigits == 0:
 */
  __pyx_tuple__57 = PyTuple_Pack(1, __pyx_n_u_NaN); if (unlikely(!__pyx_tuple__57)) __PYX_ERR(18, 160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__57);
  __Pyx_GIVEREF(__pyx_tuple__57);

  /* "asyncpg/protocol/codecs/txid.pyx":21
 * 
 *     if len(obj) != 3:
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             'invalid number of elements in txid_snapshot tuple, expecting 4')
 * 
 */
  __pyx_tuple__58 = PyTuple_Pack(1, __pyx_kp_u_invalid_number_of_elements_in_tx); if (unlikely(!__pyx_tuple__58)) __PYX_ERR(20, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__58);
  __Pyx_GIVEREF(__pyx_tuple__58);

  /* "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__59 = PyTuple_Pack(1, __pyx_kp_u_txid_snapshot_value_is_too_long); if (unlikely(!__pyx_tuple__59)) __PYX_ERR(20, 26, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__59);
  __Pyx_GIVEREF(__pyx_tuple__59);

  /* "asyncpg/protocol/codecs/array.pyx":49
 * 
 *     if mylen > _MAXINT32:
 *         raise ValueError('too many elements in array value')             # <<<<<<<<<<<<<<
 * 
 *     if ndims[0] > ARRAY_MAXDIM:
 */
  __pyx_tuple__60 = PyTuple_Pack(1, __pyx_kp_u_too_many_elements_in_array_value); if (unlikely(!__pyx_tuple__60)) __PYX_ERR(6, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__60);
  __Pyx_GIVEREF(__pyx_tuple__60);

  /* "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__61 = PyTuple_Pack(1, __pyx_kp_u_too_many_elements_in_array_value); if (unlikely(!__pyx_tuple__61)) __PYX_ERR(6, 63, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__61);
  __Pyx_GIVEREF(__pyx_tuple__61);

  /* "asyncpg/protocol/codecs/array.pyx":68
 *             else:
 *                 if len(elem) != elemlen:
 *                     raise ValueError('non-homogeneous array')             # <<<<<<<<<<<<<<
 *         else:
 *             if elemlen >= 0:
 */
  __pyx_tuple__62 = PyTuple_Pack(1, __pyx_kp_u_non_homogeneous_array); if (unlikely(!__pyx_tuple__62)) __PYX_ERR(6, 68, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__62);
  __Pyx_GIVEREF(__pyx_tuple__62);

  /* "asyncpg/protocol/codecs/array.pyx":71
 *         else:
 *             if elemlen >= 0:
 *                 raise ValueError('non-homogeneous array')             # <<<<<<<<<<<<<<
 *             else:
 *                 elemlen = -1
 */
  __pyx_tuple__63 = PyTuple_Pack(1, __pyx_kp_u_non_homogeneous_array); if (unlikely(!__pyx_tuple__63)) __PYX_ERR(6, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__63);
  __Pyx_GIVEREF(__pyx_tuple__63);

  /* "asyncpg/protocol/codecs/array.pyx":470
 *         ptr = apg_parse_int32(ptr, &ubound)
 *         if ptr == NULL:
 *             raise ValueError('missing array dimension value')             # <<<<<<<<<<<<<<
 * 
 *         if ptr[0] == ':':
 */
  __pyx_tuple__65 = PyTuple_Pack(1, __pyx_kp_u_missing_array_dimension_value); if (unlikely(!__pyx_tuple__65)) __PYX_ERR(6, 470, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__65);
  __Pyx_GIVEREF(__pyx_tuple__65);

  /* "asyncpg/protocol/codecs/array.pyx":479
 *             ptr = apg_parse_int32(ptr, &ubound)
 *             if ptr == NULL:
 *                 raise ValueError('missing array dimension value')             # <<<<<<<<<<<<<<
 *         else:
 *             lbound = 1
 */
  __pyx_tuple__66 = PyTuple_Pack(1, __pyx_kp_u_missing_array_dimension_value); if (unlikely(!__pyx_tuple__66)) __PYX_ERR(6, 479, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__66);
  __Pyx_GIVEREF(__pyx_tuple__66);

  /* "asyncpg/protocol/codecs/array.pyx":484
 * 
 *         if ptr[0] != ']':
 *             raise ValueError('missing \']\' after array dimensions')             # <<<<<<<<<<<<<<
 * 
 *         ptr += 1  # ']'
 */
  __pyx_tuple__67 = PyTuple_Pack(1, __pyx_kp_u_missing_after_array_dimensions); if (unlikely(!__pyx_tuple__67)) __PYX_ERR(6, 484, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__67);
  __Pyx_GIVEREF(__pyx_tuple__67);

  /* "asyncpg/protocol/codecs/array.pyx":494
 *         # If dimensions were given, the '=' token is expected.
 *         if ptr[0] != '=':
 *             raise ValueError('missing \'=\' after array dimensions')             # <<<<<<<<<<<<<<
 * 
 *         ptr += 1  # '='
 */
  __pyx_tuple__68 = PyTuple_Pack(1, __pyx_kp_u_missing_after_array_dimensions_2); if (unlikely(!__pyx_tuple__68)) __PYX_ERR(6, 494, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__68);
  __Pyx_GIVEREF(__pyx_tuple__68);

  /* "asyncpg/protocol/codecs/array.pyx":509
 * 
 *         if inferred_ndims != ndims:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 'specified array dimensions do not match array content')
 * 
 */
  __pyx_tuple__69 = PyTuple_Pack(1, __pyx_kp_u_specified_array_dimensions_do_no); if (unlikely(!__pyx_tuple__69)) __PYX_ERR(6, 509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__69);
  __Pyx_GIVEREF(__pyx_tuple__69);

  /* "asyncpg/protocol/codecs/array.pyx":514
 *         for i in range(ndims):
 *             if inferred_dims[i] != dims[i]:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     'specified array dimensions do not match array content')
 *     else:
 */
  __pyx_tuple__70 = PyTuple_Pack(1, __pyx_kp_u_specified_array_dimensions_do_no); if (unlikely(!__pyx_tuple__70)) __PYX_ERR(6, 514, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__70);
  __Pyx_GIVEREF(__pyx_tuple__70);

  /* "asyncpg/protocol/codecs/array.pyx":687
 *         while not end_of_item:
 *             if ptr[0] == '\0':
 *                 raise ValueError('unexpected end of string')             # <<<<<<<<<<<<<<
 * 
 *             elif ptr[0] == '"':
 */
  __pyx_tuple__71 = PyTuple_Pack(1, __pyx_kp_u_unexpected_end_of_string); if (unlikely(!__pyx_tuple__71)) __PYX_ERR(6, 687, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__71);
  __Pyx_GIVEREF(__pyx_tuple__71);

  /* "asyncpg/protocol/codecs/array.pyx":712
 *                     ptr += 1
 *                 else:
 *                     raise ValueError('unexpected end of string')             # <<<<<<<<<<<<<<
 * 
 *             elif in_quotes:
 */
  __pyx_tuple__72 = PyTuple_Pack(1, __pyx_kp_u_unexpected_end_of_string); if (unlikely(!__pyx_tuple__72)) __PYX_ERR(6, 712, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__72);
  __Pyx_GIVEREF(__pyx_tuple__72);

  /* "asyncpg/protocol/codecs/array.pyx":843
 *     # Instances of anyarray (or any other polymorphic pseudotype) are
 *     # never supposed to be returned from actual queries.
 *     raise RuntimeError('unexpected instance of \'anyarray\' type')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__73 = PyTuple_Pack(1, __pyx_kp_u_unexpected_instance_of_anyarray); if (unlikely(!__pyx_tuple__73)) __PYX_ERR(6, 843, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__73);
  __Pyx_GIVEREF(__pyx_tuple__73);

  /* "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__74 = PyTuple_Pack(1, __pyx_kp_u_hstore_value_is_too_large); if (unlikely(!__pyx_tuple__74)) __PYX_ERR(25, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__74);
  __Pyx_GIVEREF(__pyx_tuple__74);

  /* "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__75 = PyTuple_Pack(1, __pyx_kp_u_null_value_not_allowed_in_hstore); if (unlikely(!__pyx_tuple__75)) __PYX_ERR(25, 28, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__75);
  __Pyx_GIVEREF(__pyx_tuple__75);

  /* "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__76 = PyTuple_Pack(1, __pyx_kp_u_null_value_not_allowed_in_hstore); if (unlikely(!__pyx_tuple__76)) __PYX_ERR(25, 61, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__76);
  __Pyx_GIVEREF(__pyx_tuple__76);

  /* "asyncpg/protocol/coreproto.pyx":119
 *                         if self.result_type != RESULT_FAILED:
 *                             self.result_type = RESULT_FAILED
 *                             self.result = RuntimeError(             # <<<<<<<<<<<<<<
 *                                 'unknown error in protocol implementation')
 * 
 */
  __pyx_tuple__77 = PyTuple_Pack(1, __pyx_kp_u_unknown_error_in_protocol_implem); if (unlikely(!__pyx_tuple__77)) __PYX_ERR(7, 119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__77);
  __Pyx_GIVEREF(__pyx_tuple__77);

  /* "asyncpg/protocol/coreproto.pyx":475
 *         if ASYNCPG_DEBUG:
 *             if buf.get_message_type() != b'D':
 *                 raise apg_exc.InternalClientError(             # <<<<<<<<<<<<<<
 *                     '_parse_data_msgs: first message is not "D"')
 * 
 */
  __pyx_tuple__78 = PyTuple_Pack(1, __pyx_kp_u_parse_data_msgs_first_message_i); if (unlikely(!__pyx_tuple__78)) __PYX_ERR(7, 475, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__78);
  __Pyx_GIVEREF(__pyx_tuple__78);

  /* "asyncpg/protocol/coreproto.pyx":569
 * 
 *         msg = WriteBuffer.new_message(b'p')
 *         msg.write_bytestring(self.password.encode('ascii'))             # <<<<<<<<<<<<<<
 *         msg.end_message()
 * 
 */
  __pyx_tuple__79 = PyTuple_Pack(1, __pyx_n_u_ascii); if (unlikely(!__pyx_tuple__79)) __PYX_ERR(7, 569, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__79);
  __Pyx_GIVEREF(__pyx_tuple__79);

  /* "asyncpg/protocol/coreproto.pyx":581
 * 
 *         # '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__80 = PyTuple_Pack(1, __pyx_n_u_ascii); if (unlikely(!__pyx_tuple__80)) __PYX_ERR(7, 581, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__80);
  __Pyx_GIVEREF(__pyx_tuple__80);

  /* "asyncpg/protocol/coreproto.pyx":583
 *         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__81 = PyTuple_Pack(1, __pyx_n_u_ascii); if (unlikely(!__pyx_tuple__81)) __PYX_ERR(7, 583, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__81);
  __Pyx_GIVEREF(__pyx_tuple__81);
  __pyx_tuple__82 = PyTuple_Pack(1, __pyx_n_u_ascii); if (unlikely(!__pyx_tuple__82)) __PYX_ERR(7, 583, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__82);
  __Pyx_GIVEREF(__pyx_tuple__82);

  /* "asyncpg/protocol/coreproto.pyx":642
 *         if new_state == PROTOCOL_IDLE:
 *             if self.state == PROTOCOL_FAILED:
 *                 raise apg_exc.InternalClientError(             # <<<<<<<<<<<<<<
 *                     'cannot switch to "idle" state; '
 *                     'protocol is in the "failed" state')
 */
  __pyx_tuple__83 = PyTuple_Pack(1, __pyx_kp_u_cannot_switch_to_idle_state_prot); if (unlikely(!__pyx_tuple__83)) __PYX_ERR(7, 642, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__83);
  __Pyx_GIVEREF(__pyx_tuple__83);

  /* "asyncpg/protocol/coreproto.pyx":646
 *                     'protocol is in the "failed" state')
 *             elif self.state == PROTOCOL_IDLE:
 *                 raise apg_exc.InternalClientError(             # <<<<<<<<<<<<<<
 *                     'protocol is already in the "idle" state')
 *             else:
 */
  __pyx_tuple__84 = PyTuple_Pack(1, __pyx_kp_u_protocol_is_already_in_the_idle); if (unlikely(!__pyx_tuple__84)) __PYX_ERR(7, 646, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__84);
  __Pyx_GIVEREF(__pyx_tuple__84);

  /* "asyncpg/protocol/coreproto.pyx":685
 *     cdef _ensure_connected(self):
 *         if self.con_status != CONNECTION_OK:
 *             raise apg_exc.InternalClientError('not connected')             # <<<<<<<<<<<<<<
 * 
 *     cdef WriteBuffer _build_bind_message(self, str portal_name,
 */
  __pyx_tuple__85 = PyTuple_Pack(1, __pyx_kp_u_not_connected); if (unlikely(!__pyx_tuple__85)) __PYX_ERR(7, 685, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__85);
  __Pyx_GIVEREF(__pyx_tuple__85);

  /* "asyncpg/protocol/coreproto.pyx":710
 * 
 *         if self.con_status != CONNECTION_BAD:
 *             raise apg_exc.InternalClientError('already connected')             # <<<<<<<<<<<<<<
 * 
 *         self._set_state(PROTOCOL_AUTH)
 */
  __pyx_tuple__86 = PyTuple_Pack(1, __pyx_kp_u_already_connected); if (unlikely(!__pyx_tuple__86)) __PYX_ERR(7, 710, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__86);
  __Pyx_GIVEREF(__pyx_tuple__86);

  /* "asyncpg/protocol/coreproto.pyx":723
 * 
 *         buf.write_bytestring(b'client_encoding')
 *         buf.write_bytestring("'{}'".format(self.encoding).encode('ascii'))             # <<<<<<<<<<<<<<
 * 
 *         buf.write_str('user', self.encoding)
 */
  __pyx_tuple__88 = PyTuple_Pack(1, __pyx_n_u_ascii); if (unlikely(!__pyx_tuple__88)) __PYX_ERR(7, 723, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__88);
  __Pyx_GIVEREF(__pyx_tuple__88);

  /* "asyncpg/protocol/coreproto.pyx":936
 *         self.transport = transport
 * 
 *         sock = transport.get_extra_info('socket')             # <<<<<<<<<<<<<<
 *         if (sock is not None and
 *               (not hasattr(socket, 'AF_UNIX')
 */
  __pyx_tuple__89 = PyTuple_Pack(1, __pyx_n_u_socket); if (unlikely(!__pyx_tuple__89)) __PYX_ERR(7, 936, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__89);
  __Pyx_GIVEREF(__pyx_tuple__89);

  /* "asyncpg/protocol/prepared_stmt.pyx":101
 * 
 *         if len(args) > 32767:
 *             raise exceptions.InterfaceError(             # <<<<<<<<<<<<<<
 *                 'the number of query arguments cannot exceed 32767')
 * 
 */
  __pyx_tuple__90 = PyTuple_Pack(1, __pyx_kp_u_the_number_of_query_arguments_ca); if (unlikely(!__pyx_tuple__90)) __PYX_ERR(27, 101, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__90);
  __Pyx_GIVEREF(__pyx_tuple__90);

  /* "asyncpg/protocol/prepared_stmt.pyx":253
 *             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__91 = PyTuple_Pack(1, __pyx_kp_u_invalid_rows_codecs); if (unlikely(!__pyx_tuple__91)) __PYX_ERR(27, 253, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__91);
  __Pyx_GIVEREF(__pyx_tuple__91);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__92 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__92)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__92);
  __Pyx_GIVEREF(__pyx_tuple__92);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__93 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__93)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__93);
  __Pyx_GIVEREF(__pyx_tuple__93);

  /* "asyncpg/protocol/protocol.pyx":340
 *                 self.resume_reading()
 * 
 *                 with timer:             # <<<<<<<<<<<<<<
 *                     buffer, done, status_msg = await waiter
 * 
 */
  __pyx_tuple__94 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__94)) __PYX_ERR(0, 340, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__94);
  __Pyx_GIVEREF(__pyx_tuple__94);

  /* "asyncpg/protocol/protocol.pyx":347
 *                 if buffer:
 *                     try:
 *                         with timer:             # <<<<<<<<<<<<<<
 *                             await asyncio.wait_for(
 *                                 sink(buffer),
 */
  __pyx_tuple__95 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__95)) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__95);
  __Pyx_GIVEREF(__pyx_tuple__95);

  /* "asyncpg/protocol/protocol.pyx":431
 * 
 *                     if wbuf.len() >= _COPY_BUFFER_SIZE:
 *                         with timer:             # <<<<<<<<<<<<<<
 *                             await self.writing_allowed.wait()
 *                         self._write_copy_data_msg(wbuf)
 */
  __pyx_tuple__96 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__96)) __PYX_ERR(0, 431, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__96);
  __Pyx_GIVEREF(__pyx_tuple__96);

  /* "asyncpg/protocol/protocol.pyx":444
 *                     aiter = reader.__aiter__
 *                 except AttributeError:
 *                     raise TypeError('reader is not an asynchronous iterable')             # <<<<<<<<<<<<<<
 *                 else:
 *                     iterator = aiter()
 */
  __pyx_tuple__97 = PyTuple_Pack(1, __pyx_kp_u_reader_is_not_an_asynchronous_it); if (unlikely(!__pyx_tuple__97)) __PYX_ERR(0, 444, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__97);
  __Pyx_GIVEREF(__pyx_tuple__97);

  /* "asyncpg/protocol/protocol.pyx":452
 *                         # We rely on protocol flow control to moderate the
 *                         # rate of data messages.
 *                         with timer:             # <<<<<<<<<<<<<<
 *                             await self.writing_allowed.wait()
 *                         with timer:
 */
  __pyx_tuple__98 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__98)) __PYX_ERR(0, 452, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__98);
  __Pyx_GIVEREF(__pyx_tuple__98);

  /* "asyncpg/protocol/protocol.pyx":454
 *                         with timer:
 *                             await self.writing_allowed.wait()
 *                         with timer:             # <<<<<<<<<<<<<<
 *                             chunk = await asyncio.wait_for(
 *                                 iterator.__anext__(),
 */
  __pyx_tuple__99 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__99)) __PYX_ERR(0, 454, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__99);
  __Pyx_GIVEREF(__pyx_tuple__99);

  /* "asyncpg/protocol/protocol.pyx":475
 *                 raise
 *             else:
 *                 raise apg_exc.InternalClientError('TimoutError was not raised')             # <<<<<<<<<<<<<<
 * 
 *         except Exception as e:
 */
  __pyx_tuple__100 = PyTuple_Pack(1, __pyx_kp_u_TimoutError_was_not_raised); if (unlikely(!__pyx_tuple__100)) __PYX_ERR(0, 475, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__100);
  __Pyx_GIVEREF(__pyx_tuple__100);

  /* "asyncpg/protocol/protocol.pyx":597
 *     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__101 = PyTuple_Pack(1, __pyx_kp_u_connection_was_closed_in_the_mid); if (unlikely(!__pyx_tuple__101)) __PYX_ERR(0, 597, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__101);
  __Pyx_GIVEREF(__pyx_tuple__101);

  /* "asyncpg/protocol/protocol.pyx":635
 *     cdef _check_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__102 = PyTuple_Pack(1, __pyx_kp_u_cannot_perform_operation_another); if (unlikely(!__pyx_tuple__102)) __PYX_ERR(0, 635, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__102);
  __Pyx_GIVEREF(__pyx_tuple__102);

  /* "asyncpg/protocol/protocol.pyx":638
 *                 '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__103 = PyTuple_Pack(1, __pyx_kp_u_cannot_perform_operation_connect); if (unlikely(!__pyx_tuple__103)) __PYX_ERR(0, 638, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__103);
  __Pyx_GIVEREF(__pyx_tuple__103);

  /* "asyncpg/protocol/protocol.pyx":641
 *                 '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__104 = PyTuple_Pack(1, __pyx_kp_u_cannot_perform_operation_another_2); if (unlikely(!__pyx_tuple__104)) __PYX_ERR(0, 641, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__104);
  __Pyx_GIVEREF(__pyx_tuple__104);

  /* "asyncpg/protocol/protocol.pyx":661
 *             if self.waiter is not None:
 *                 if not self.waiter.done():
 *                     raise apg_exc.InternalClientError(             # <<<<<<<<<<<<<<
 *                         'waiter is not done while handling critical '
 *                         'protocol error')
 */
  __pyx_tuple__105 = PyTuple_Pack(1, __pyx_kp_u_waiter_is_not_done_while_handlin); if (unlikely(!__pyx_tuple__105)) __PYX_ERR(0, 661, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__105);
  __Pyx_GIVEREF(__pyx_tuple__105);

  /* "asyncpg/protocol/protocol.pyx":670
 *     cdef _new_waiter(self, timeout):
 *         if self.waiter is not None:
 *             raise apg_exc.InterfaceError(             # <<<<<<<<<<<<<<
 *                 'cannot perform operation: another operation is in progress')
 *         self.waiter = self.create_future()
 */
  __pyx_tuple__106 = PyTuple_Pack(1, __pyx_kp_u_cannot_perform_operation_another_2); if (unlikely(!__pyx_tuple__106)) __PYX_ERR(0, 670, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__106);
  __Pyx_GIVEREF(__pyx_tuple__106);

  /* "asyncpg/protocol/protocol.pyx":680
 * 
 *     cdef _on_result__connect(self, object waiter):
 *         waiter.set_result(True)             # <<<<<<<<<<<<<<
 * 
 *     cdef _on_result__prepare(self, object waiter):
 */
  __pyx_tuple__107 = PyTuple_Pack(1, Py_True); if (unlikely(!__pyx_tuple__107)) __PYX_ERR(0, 680, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__107);
  __Pyx_GIVEREF(__pyx_tuple__107);

  /* "asyncpg/protocol/protocol.pyx":685
 *         if ASYNCPG_DEBUG:
 *             if self.statement is None:
 *                 raise apg_exc.InternalClientError(             # <<<<<<<<<<<<<<
 *                     '_on_result__prepare: statement is None')
 * 
 */
  __pyx_tuple__108 = PyTuple_Pack(1, __pyx_kp_u_on_result__prepare_statement_is); if (unlikely(!__pyx_tuple__108)) __PYX_ERR(0, 685, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__108);
  __Pyx_GIVEREF(__pyx_tuple__108);

  /* "asyncpg/protocol/protocol.pyx":732
 *         if ASYNCPG_DEBUG:
 *             if self.statement is None:
 *                 raise apg_exc.InternalClientError(             # <<<<<<<<<<<<<<
 *                     '_decode_row: statement is None')
 * 
 */
  __pyx_tuple__109 = PyTuple_Pack(1, __pyx_kp_u_decode_row_statement_is_None); if (unlikely(!__pyx_tuple__109)) __PYX_ERR(0, 732, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__109);
  __Pyx_GIVEREF(__pyx_tuple__109);

  /* "asyncpg/protocol/protocol.pyx":743
 *         if ASYNCPG_DEBUG:
 *             if waiter is None:
 *                 raise apg_exc.InternalClientError('_on_result: waiter is None')             # <<<<<<<<<<<<<<
 * 
 *         if waiter.cancelled():
 */
  __pyx_tuple__110 = PyTuple_Pack(1, __pyx_kp_u_on_result_waiter_is_None); if (unlikely(!__pyx_tuple__110)) __PYX_ERR(0, 743, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__110);
  __Pyx_GIVEREF(__pyx_tuple__110);

  /* "asyncpg/protocol/protocol.pyx":749
 * 
 *         if waiter.done():
 *             raise apg_exc.InternalClientError('_on_result: waiter is done')             # <<<<<<<<<<<<<<
 * 
 *         if self.result_type == RESULT_FAILED:
 */
  __pyx_tuple__111 = PyTuple_Pack(1, __pyx_kp_u_on_result_waiter_is_done); if (unlikely(!__pyx_tuple__111)) __PYX_ERR(0, 749, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__111);
  __Pyx_GIVEREF(__pyx_tuple__111);

  /* "asyncpg/protocol/protocol.pyx":810
 *                 # The cancellation future might have been cancelled
 *                 # by the cancellation of the entire task running the query.
 *                 self.cancel_waiter.set_result(None)             # <<<<<<<<<<<<<<
 *             self.cancel_waiter = None
 *             if self.waiter is not None and self.waiter.done():
 */
  __pyx_tuple__112 = PyTuple_Pack(1, Py_None); if (unlikely(!__pyx_tuple__112)) __PYX_ERR(0, 810, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__112);
  __Pyx_GIVEREF(__pyx_tuple__112);

  /* "asyncpg/protocol/protocol.pyx":836
 *             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__113 = PyTuple_Pack(1, Py_None); if (unlikely(!__pyx_tuple__113)) __PYX_ERR(0, 836, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__113);
  __Pyx_GIVEREF(__pyx_tuple__113);

  /* "asyncpg/protocol/pgtypes.pxi":102
 * DEF REGROLEOID = 4096
 * 
 * cdef ARRAY_TYPES = (_TEXTOID, _OIDOID,)             # <<<<<<<<<<<<<<
 * 
 * TYPEMAP = {
 */
  __pyx_tuple__114 = PyTuple_Pack(2, __pyx_int_1009, __pyx_int_1028); if (unlikely(!__pyx_tuple__114)) __PYX_ERR(33, 102, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__114);
  __Pyx_GIVEREF(__pyx_tuple__114);

  /* "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__115 = PyTuple_Pack(3, __pyx_int_2000, __pyx_int_1, __pyx_int_1); if (unlikely(!__pyx_tuple__115)) __PYX_ERR(12, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__115);
  __Pyx_GIVEREF(__pyx_tuple__115);

  /* "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__116 = PyTuple_Pack(3, __pyx_int_2000, __pyx_int_1, __pyx_int_1); if (unlikely(!__pyx_tuple__116)) __PYX_ERR(12, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__116);
  __Pyx_GIVEREF(__pyx_tuple__116);

  /* "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__117 = PyTuple_Pack(3, __pyx_int_2000, __pyx_int_1, __pyx_int_1); if (unlikely(!__pyx_tuple__117)) __PYX_ERR(12, 22, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__117);
  __Pyx_GIVEREF(__pyx_tuple__117);

  /* "asyncpg/protocol/protocol.pyx":855
 * 
 * class Timer:
 *     def __init__(self, budget):             # <<<<<<<<<<<<<<
 *         self._budget = budget
 *         self._started = 0
 */
  __pyx_tuple__118 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_budget); if (unlikely(!__pyx_tuple__118)) __PYX_ERR(0, 855, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__118);
  __Pyx_GIVEREF(__pyx_tuple__118);
  __pyx_codeobj__119 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__118, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_asyncpg_protocol_protocol_pyx, __pyx_n_s_init, 855, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__119)) __PYX_ERR(0, 855, __pyx_L1_error)

  /* "asyncpg/protocol/protocol.pyx":859
 *         self._started = 0
 * 
 *     def __enter__(self):             # <<<<<<<<<<<<<<
 *         if self._budget is not None:
 *             self._started = time.monotonic()
 */
  __pyx_tuple__120 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__120)) __PYX_ERR(0, 859, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__120);
  __Pyx_GIVEREF(__pyx_tuple__120);
  __pyx_codeobj__121 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__120, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_asyncpg_protocol_protocol_pyx, __pyx_n_s_enter, 859, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__121)) __PYX_ERR(0, 859, __pyx_L1_error)

  /* "asyncpg/protocol/protocol.pyx":863
 *             self._started = time.monotonic()
 * 
 *     def __exit__(self, et, e, tb):             # <<<<<<<<<<<<<<
 *         if self._budget is not None:
 *             self._budget -= time.monotonic() - self._started
 */
  __pyx_tuple__122 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_et, __pyx_n_s_e, __pyx_n_s_tb); if (unlikely(!__pyx_tuple__122)) __PYX_ERR(0, 863, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__122);
  __Pyx_GIVEREF(__pyx_tuple__122);
  __pyx_codeobj__123 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__122, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_asyncpg_protocol_protocol_pyx, __pyx_n_s_exit, 863, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__123)) __PYX_ERR(0, 863, __pyx_L1_error)

  /* "asyncpg/protocol/protocol.pyx":867
 *             self._budget -= time.monotonic() - self._started
 * 
 *     def get_remaining_budget(self):             # <<<<<<<<<<<<<<
 *         return self._budget
 * 
 */
  __pyx_tuple__124 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__124)) __PYX_ERR(0, 867, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__124);
  __Pyx_GIVEREF(__pyx_tuple__124);
  __pyx_codeobj__125 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__124, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_asyncpg_protocol_protocol_pyx, __pyx_n_s_get_remaining_budget, 867, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__125)) __PYX_ERR(0, 867, __pyx_L1_error)

  /* "asyncpg/protocol/protocol.pyx":875
 * 
 * 
 * def _create_record(object mapping, tuple elems):             # <<<<<<<<<<<<<<
 *     # Exposed only for testing purposes.
 * 
 */
  __pyx_tuple__126 = 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__126)) __PYX_ERR(0, 875, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__126);
  __Pyx_GIVEREF(__pyx_tuple__126);
  __pyx_codeobj__127 = (PyObject*)__Pyx_PyCode_New(2, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__126, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_asyncpg_protocol_protocol_pyx, __pyx_n_s_create_record, 875, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__127)) __PYX_ERR(0, 875, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __pyx_unpickle_Memory(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xe0abff4:
 *         from pickle import PickleError as __pyx_PickleError
 */
  __pyx_tuple__128 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__128)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__128);
  __Pyx_GIVEREF(__pyx_tuple__128);
  __pyx_codeobj__129 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__128, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Memory, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__129)) __PYX_ERR(2, 1, __pyx_L1_error)
  __pyx_tuple__130 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__130)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__130);
  __Pyx_GIVEREF(__pyx_tuple__130);
  __pyx_codeobj__131 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__130, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_FastReadBuffer, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__131)) __PYX_ERR(2, 1, __pyx_L1_error)
  __pyx_tuple__132 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__132)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__132);
  __Pyx_GIVEREF(__pyx_tuple__132);
  __pyx_codeobj__133 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__132, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_DataCodecConfig, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__133)) __PYX_ERR(2, 1, __pyx_L1_error)
  __pyx_tuple__134 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__134)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__134);
  __Pyx_GIVEREF(__pyx_tuple__134);
  __pyx_codeobj__135 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__134, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_CoreProtocol, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__135)) __PYX_ERR(2, 1, __pyx_L1_error)
  __pyx_tuple__136 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__136)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__136);
  __Pyx_GIVEREF(__pyx_tuple__136);
  __pyx_codeobj__137 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__136, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_BaseProtocol, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__137)) __PYX_ERR(2, 1, __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(0, 1, __pyx_L1_error);
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_6 = PyInt_FromLong(6); if (unlikely(!__pyx_int_6)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_10 = PyInt_FromLong(10); if (unlikely(!__pyx_int_10)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_12 = PyInt_FromLong(12); if (unlikely(!__pyx_int_12)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_16 = PyInt_FromLong(16); if (unlikely(!__pyx_int_16)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_17 = PyInt_FromLong(17); if (unlikely(!__pyx_int_17)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_18 = PyInt_FromLong(18); if (unlikely(!__pyx_int_18)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_19 = PyInt_FromLong(19); if (unlikely(!__pyx_int_19)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_20 = PyInt_FromLong(20); if (unlikely(!__pyx_int_20)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_21 = PyInt_FromLong(21); if (unlikely(!__pyx_int_21)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_23 = PyInt_FromLong(23); if (unlikely(!__pyx_int_23)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_24 = PyInt_FromLong(24); if (unlikely(!__pyx_int_24)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_25 = PyInt_FromLong(25); if (unlikely(!__pyx_int_25)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_26 = PyInt_FromLong(26); if (unlikely(!__pyx_int_26)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_27 = PyInt_FromLong(27); if (unlikely(!__pyx_int_27)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_28 = PyInt_FromLong(28); if (unlikely(!__pyx_int_28)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_29 = PyInt_FromLong(29); if (unlikely(!__pyx_int_29)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_31 = PyInt_FromLong(31); if (unlikely(!__pyx_int_31)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_32 = PyInt_FromLong(32); if (unlikely(!__pyx_int_32)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_59 = PyInt_FromLong(59); if (unlikely(!__pyx_int_59)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_100 = PyInt_FromLong(100); if (unlikely(!__pyx_int_100)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_114 = PyInt_FromLong(114); if (unlikely(!__pyx_int_114)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_142 = PyInt_FromLong(142); if (unlikely(!__pyx_int_142)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_194 = PyInt_FromLong(194); if (unlikely(!__pyx_int_194)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_210 = PyInt_FromLong(210); if (unlikely(!__pyx_int_210)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_325 = PyInt_FromLong(325); if (unlikely(!__pyx_int_325)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_600 = PyInt_FromLong(600); if (unlikely(!__pyx_int_600)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_601 = PyInt_FromLong(601); if (unlikely(!__pyx_int_601)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_602 = PyInt_FromLong(602); if (unlikely(!__pyx_int_602)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_603 = PyInt_FromLong(603); if (unlikely(!__pyx_int_603)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_604 = PyInt_FromLong(604); if (unlikely(!__pyx_int_604)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_628 = PyInt_FromLong(628); if (unlikely(!__pyx_int_628)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_650 = PyInt_FromLong(650); if (unlikely(!__pyx_int_650)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_700 = PyInt_FromLong(700); if (unlikely(!__pyx_int_700)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_701 = PyInt_FromLong(701); if (unlikely(!__pyx_int_701)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_702 = PyInt_FromLong(702); if (unlikely(!__pyx_int_702)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_703 = PyInt_FromLong(703); if (unlikely(!__pyx_int_703)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_704 = PyInt_FromLong(704); if (unlikely(!__pyx_int_704)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_705 = PyInt_FromLong(705); if (unlikely(!__pyx_int_705)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_718 = PyInt_FromLong(718); if (unlikely(!__pyx_int_718)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_774 = PyInt_FromLong(774); if (unlikely(!__pyx_int_774)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_790 = PyInt_FromLong(790); if (unlikely(!__pyx_int_790)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_829 = PyInt_FromLong(829); if (unlikely(!__pyx_int_829)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_869 = PyInt_FromLong(869); if (unlikely(!__pyx_int_869)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1000 = PyInt_FromLong(1000); if (unlikely(!__pyx_int_1000)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1009 = PyInt_FromLong(1009); if (unlikely(!__pyx_int_1009)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1028 = PyInt_FromLong(1028); if (unlikely(!__pyx_int_1028)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1033 = PyInt_FromLong(1033); if (unlikely(!__pyx_int_1033)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1042 = PyInt_FromLong(1042); if (unlikely(!__pyx_int_1042)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1043 = PyInt_FromLong(1043); if (unlikely(!__pyx_int_1043)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1082 = PyInt_FromLong(1082); if (unlikely(!__pyx_int_1082)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1083 = PyInt_FromLong(1083); if (unlikely(!__pyx_int_1083)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1114 = PyInt_FromLong(1114); if (unlikely(!__pyx_int_1114)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1184 = PyInt_FromLong(1184); if (unlikely(!__pyx_int_1184)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1186 = PyInt_FromLong(1186); if (unlikely(!__pyx_int_1186)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1266 = PyInt_FromLong(1266); if (unlikely(!__pyx_int_1266)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1560 = PyInt_FromLong(1560); if (unlikely(!__pyx_int_1560)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1562 = PyInt_FromLong(1562); if (unlikely(!__pyx_int_1562)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1700 = PyInt_FromLong(1700); if (unlikely(!__pyx_int_1700)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1790 = PyInt_FromLong(1790); if (unlikely(!__pyx_int_1790)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2000 = PyInt_FromLong(2000); if (unlikely(!__pyx_int_2000)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2202 = PyInt_FromLong(2202); if (unlikely(!__pyx_int_2202)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2203 = PyInt_FromLong(2203); if (unlikely(!__pyx_int_2203)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2204 = PyInt_FromLong(2204); if (unlikely(!__pyx_int_2204)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2205 = PyInt_FromLong(2205); if (unlikely(!__pyx_int_2205)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2206 = PyInt_FromLong(2206); if (unlikely(!__pyx_int_2206)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2249 = PyInt_FromLong(2249); if (unlikely(!__pyx_int_2249)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2275 = PyInt_FromLong(2275); if (unlikely(!__pyx_int_2275)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2276 = PyInt_FromLong(2276); if (unlikely(!__pyx_int_2276)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2277 = PyInt_FromLong(2277); if (unlikely(!__pyx_int_2277)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2278 = PyInt_FromLong(2278); if (unlikely(!__pyx_int_2278)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2279 = PyInt_FromLong(2279); if (unlikely(!__pyx_int_2279)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2280 = PyInt_FromLong(2280); if (unlikely(!__pyx_int_2280)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2281 = PyInt_FromLong(2281); if (unlikely(!__pyx_int_2281)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2282 = PyInt_FromLong(2282); if (unlikely(!__pyx_int_2282)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2283 = PyInt_FromLong(2283); if (unlikely(!__pyx_int_2283)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2776 = PyInt_FromLong(2776); if (unlikely(!__pyx_int_2776)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2950 = PyInt_FromLong(2950); if (unlikely(!__pyx_int_2950)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2970 = PyInt_FromLong(2970); if (unlikely(!__pyx_int_2970)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_3115 = PyInt_FromLong(3115); if (unlikely(!__pyx_int_3115)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_3220 = PyInt_FromLong(3220); if (unlikely(!__pyx_int_3220)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_3310 = PyInt_FromLong(3310); if (unlikely(!__pyx_int_3310)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_3361 = PyInt_FromLong(3361); if (unlikely(!__pyx_int_3361)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_3402 = PyInt_FromLong(3402); if (unlikely(!__pyx_int_3402)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_3500 = PyInt_FromLong(3500); if (unlikely(!__pyx_int_3500)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_3614 = PyInt_FromLong(3614); if (unlikely(!__pyx_int_3614)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_3615 = PyInt_FromLong(3615); if (unlikely(!__pyx_int_3615)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_3642 = PyInt_FromLong(3642); if (unlikely(!__pyx_int_3642)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_3734 = PyInt_FromLong(3734); if (unlikely(!__pyx_int_3734)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_3769 = PyInt_FromLong(3769); if (unlikely(!__pyx_int_3769)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_3802 = PyInt_FromLong(3802); if (unlikely(!__pyx_int_3802)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_3831 = PyInt_FromLong(3831); if (unlikely(!__pyx_int_3831)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_3838 = PyInt_FromLong(3838); if (unlikely(!__pyx_int_3838)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_4089 = PyInt_FromLong(4089); if (unlikely(!__pyx_int_4089)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_4096 = PyInt_FromLong(4096); if (unlikely(!__pyx_int_4096)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_524288 = PyInt_FromLong(524288L); if (unlikely(!__pyx_int_524288)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_999999 = PyInt_FromLong(999999L); if (unlikely(!__pyx_int_999999)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_26708044 = PyInt_FromLong(26708044L); if (unlikely(!__pyx_int_26708044)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_51347564 = PyInt_FromLong(51347564L); if (unlikely(!__pyx_int_51347564)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_132800114 = PyInt_FromLong(132800114L); if (unlikely(!__pyx_int_132800114)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_192266185 = PyInt_FromLong(192266185L); if (unlikely(!__pyx_int_192266185)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_235585524 = PyInt_FromLong(235585524L); if (unlikely(!__pyx_int_235585524)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_9223372036854775807 = PyInt_FromString((char *)"9223372036854775807", 0, 0); if (unlikely(!__pyx_int_9223372036854775807)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_neg_9223372036854775808 = PyInt_FromString((char *)"-9223372036854775808", 0, 0); if (unlikely(!__pyx_int_neg_9223372036854775808)) __PYX_ERR(0, 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)
#if CYTHON_PEP489_MULTI_PHASE_INIT
{
  return PyModuleDef_Init(&__pyx_moduledef);
}
static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) {
    PyObject *value = PyObject_GetAttrString(spec, from_name);
    int result = 0;
    if (likely(value)) {
        result = PyDict_SetItemString(moddict, to_name, value);
        Py_DECREF(value);
    } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Clear();
    } else {
        result = -1;
    }
    return result;
}
static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
    PyObject *module = NULL, *moddict, *modname;
    if (__pyx_m)
        return __Pyx_NewRef(__pyx_m);
    modname = PyObject_GetAttrString(spec, "name");
    if (unlikely(!modname)) goto bad;
    module = PyModule_NewObject(modname);
    Py_DECREF(modname);
    if (unlikely(!module)) goto bad;
    moddict = PyModule_GetDict(module);
    if (unlikely(!moddict)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad;
    return module;
bad:
    Py_XDECREF(module);
    return NULL;
}


static int __pyx_pymod_exec_protocol(PyObject *__pyx_pyinit_module)
#endif
#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];
  PyTypeObject *__pyx_t_9;
  __Pyx_RefNannyDeclarations
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0;
  #endif
  #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(0, 1, __pyx_L1_error)
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pyx_CyFunction_USED
  if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Coroutine_USED
  if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_AsyncGen_USED
  if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_StopAsyncIteration_USED
  if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 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 CYTHON_PEP489_MULTI_PHASE_INIT
  __pyx_m = __pyx_pyinit_module;
  Py_INCREF(__pyx_m);
  #else
  #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(0, 1, __pyx_L1_error)
  #endif
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 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(0, 1, __pyx_L1_error);
  /*--- Initialize various global constants etc. ---*/
  if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 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(0, 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(0, 1, __pyx_L1_error)
  }
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
    if (!PyDict_GetItemString(modules, "asyncpg.protocol.protocol")) {
      if (unlikely(PyDict_SetItemString(modules, "asyncpg.protocol.protocol", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Constants init code ---*/
  if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 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(0, 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 const *, PyObject *, Py_ssize_t))__pyx_f_7asyncpg_8protocol_8protocol_6Memory_new;
  if (PyType_Ready(&__pyx_type_7asyncpg_8protocol_8protocol_Memory) < 0) __PYX_ERR(3, 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(3, 18, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Memory", (PyObject *)&__pyx_type_7asyncpg_8protocol_8protocol_Memory) < 0) __PYX_ERR(3, 18, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_7asyncpg_8protocol_8protocol_Memory) < 0) __PYX_ERR(3, 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 const *, 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(3, 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(3, 36, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "WriteBuffer", (PyObject *)&__pyx_type_7asyncpg_8protocol_8protocol_WriteBuffer) < 0) __PYX_ERR(3, 36, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_7asyncpg_8protocol_8protocol_WriteBuffer) < 0) __PYX_ERR(3, 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 const *(*)(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 *, char *, Py_ssize_t))__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer__read;
  __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 = (char const *(*)(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.has_message_type = (int32_t (*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *, char))__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_has_message_type;
  __pyx_vtable_7asyncpg_8protocol_8protocol_ReadBuffer.try_consume_message = (char const *(*)(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.consume_messages = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ReadBuffer *, char))__pyx_f_7asyncpg_8protocol_8protocol_10ReadBuffer_consume_messages;
  __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(3, 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(3, 231, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "ReadBuffer", (PyObject *)&__pyx_type_7asyncpg_8protocol_8protocol_ReadBuffer) < 0) __PYX_ERR(3, 231, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_7asyncpg_8protocol_8protocol_ReadBuffer) < 0) __PYX_ERR(3, 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(3, 632, __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(3, 632, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "FastReadBuffer", (PyObject *)&__pyx_type_7asyncpg_8protocol_8protocol_FastReadBuffer) < 0) __PYX_ERR(3, 632, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_7asyncpg_8protocol_8protocol_FastReadBuffer) < 0) __PYX_ERR(3, 632, __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_ServerDataFormat, enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat, __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_array_text = (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_text;
  __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 *, enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat, 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 *, __pyx_t_7asyncpg_8protocol_8protocol_encode_func, __pyx_t_7asyncpg_8protocol_8protocol_decode_func, enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat, enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat))__pyx_f_7asyncpg_8protocol_8protocol_5Codec_new_python_codec;
  if (PyType_Ready(&__pyx_type_7asyncpg_8protocol_8protocol_Codec) < 0) __PYX_ERR(4, 18, __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(4, 18, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Codec", (PyObject *)&__pyx_type_7asyncpg_8protocol_8protocol_Codec) < 0) __PYX_ERR(4, 18, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_7asyncpg_8protocol_8protocol_Codec) < 0) __PYX_ERR(4, 18, __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_ServerDataFormat))__pyx_f_7asyncpg_8protocol_8protocol_15DataCodecConfig_get_codec;
  __pyx_vtable_7asyncpg_8protocol_8protocol_DataCodecConfig.get_local_codec = (struct __pyx_obj_7asyncpg_8protocol_8protocol_Codec *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_DataCodecConfig *, uint32_t))__pyx_f_7asyncpg_8protocol_8protocol_15DataCodecConfig_get_local_codec;
  if (PyType_Ready(&__pyx_type_7asyncpg_8protocol_8protocol_DataCodecConfig) < 0) __PYX_ERR(4, 376, __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(4, 376, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "DataCodecConfig", (PyObject *)&__pyx_type_7asyncpg_8protocol_8protocol_DataCodecConfig) < 0) __PYX_ERR(4, 376, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_7asyncpg_8protocol_8protocol_DataCodecConfig) < 0) __PYX_ERR(4, 376, __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.remove_python_codec = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_remove_python_codec;
  __pyx_vtable_7asyncpg_8protocol_8protocol_ConnectionSettings.clear_type_cache = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_ConnectionSettings *, int __pyx_skip_dispatch))__pyx_f_7asyncpg_8protocol_8protocol_18ConnectionSettings_clear_type_cache;
  __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(1, 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(1, 9, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "ConnectionSettings", (PyObject *)&__pyx_type_7asyncpg_8protocol_8protocol_ConnectionSettings) < 0) __PYX_ERR(1, 9, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_7asyncpg_8protocol_8protocol_ConnectionSettings) < 0) __PYX_ERR(1, 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._process__copy_out = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, char))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__copy_out;
  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._process__copy_out_data = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, char))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__copy_out_data;
  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._process__copy_in = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, char))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__copy_in;
  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._process__copy_in_data = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, char))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__process__copy_in_data;
  __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_copy_data_msgs = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__parse_copy_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._write_copy_data_msg = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__write_copy_data_msg;
  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._write_copy_done_msg = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__write_copy_done_msg;
  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._write_copy_fail_msg = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__write_copy_fail_msg;
  __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._copy_out = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__copy_out;
  __pyx_vtable_7asyncpg_8protocol_8protocol_CoreProtocol._copy_in = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__copy_in;
  __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._on_notice = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12CoreProtocol__on_notice;
  __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(7, 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(7, 11, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "CoreProtocol", (PyObject *)&__pyx_type_7asyncpg_8protocol_8protocol_CoreProtocol) < 0) __PYX_ERR(7, 11, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_7asyncpg_8protocol_8protocol_CoreProtocol) < 0) __PYX_ERR(7, 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(27, 12, __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(27, 12, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "PreparedStatementState", (PyObject *)&__pyx_type_7asyncpg_8protocol_8protocol_PreparedStatementState) < 0) __PYX_ERR(27, 12, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_7asyncpg_8protocol_8protocol_PreparedStatementState) < 0) __PYX_ERR(27, 12, __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._on_notice = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_CoreProtocol *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_notice;
  __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._get_timeout_impl = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__get_timeout_impl;
  __pyx_vtable_7asyncpg_8protocol_8protocol_BaseProtocol._check_state = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *))__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__check_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._coreproto_error = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *))__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__coreproto_error;
  __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._on_result__copy_out = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_result__copy_out;
  __pyx_vtable_7asyncpg_8protocol_8protocol_BaseProtocol._on_result__copy_in = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *, PyObject *))__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol__on_result__copy_in;
  __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_vtable_7asyncpg_8protocol_8protocol_BaseProtocol.resume_reading = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *))__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol_resume_reading;
  __pyx_vtable_7asyncpg_8protocol_8protocol_BaseProtocol.pause_reading = (PyObject *(*)(struct __pyx_obj_7asyncpg_8protocol_8protocol_BaseProtocol *))__pyx_f_7asyncpg_8protocol_8protocol_12BaseProtocol_pause_reading;
  __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(0, 91, __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(0, 91, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "BaseProtocol", (PyObject *)&__pyx_type_7asyncpg_8protocol_8protocol_BaseProtocol) < 0) __PYX_ERR(0, 91, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_7asyncpg_8protocol_8protocol_BaseProtocol) < 0) __PYX_ERR(0, 91, __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(0, 149, __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(0, 170, __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(0, 202, __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(0, 217, __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(0, 237, __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(0, 265, __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(0, 294, __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_copy_out) < 0) __PYX_ERR(0, 318, __pyx_L1_error)
  __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out.tp_print = 0;
  __pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out = &__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_7_copy_out;
  if (PyType_Ready(&__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in) < 0) __PYX_ERR(0, 372, __pyx_L1_error)
  __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in.tp_print = 0;
  __pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in = &__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_8_copy_in;
  if (PyType_Ready(&__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement) < 0) __PYX_ERR(0, 490, __pyx_L1_error)
  __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement.tp_print = 0;
  __pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement = &__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_9_close_statement;
  if (PyType_Ready(&__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close) < 0) __PYX_ERR(0, 529, __pyx_L1_error)
  __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close.tp_print = 0;
  __pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close = &__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_10_close;
  if (PyType_Ready(&__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation) < 0) __PYX_ERR(0, 650, __pyx_L1_error)
  __pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation.tp_print = 0;
  __pyx_ptype_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation = &__pyx_type_7asyncpg_8protocol_8protocol___pyx_scope_struct_11__wait_for_cancellation;
  /*--- 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(30, 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(31, 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(32, 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(0, 1, __pyx_L1_error)
  #endif

  /* "asyncpg/protocol/protocol.pyx":13
 * cimport cpython
 * 
 * import asyncio             # <<<<<<<<<<<<<<
 * import builtins
 * import codecs
 */
  __pyx_t_1 = __Pyx_patch_asyncio(__Pyx_Import(__pyx_n_s_asyncio, 0, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_asyncio, __pyx_t_1) < 0) __PYX_ERR(0, 13, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/protocol.pyx":14
 * 
 * import asyncio
 * import builtins             # <<<<<<<<<<<<<<
 * import codecs
 * import collections
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_builtins, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_builtins, __pyx_t_1) < 0) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/protocol.pyx":15
 * import asyncio
 * import builtins
 * import codecs             # <<<<<<<<<<<<<<
 * import collections
 * import socket
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_codecs, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_codecs, __pyx_t_1) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/protocol.pyx":16
 * import builtins
 * import codecs
 * import collections             # <<<<<<<<<<<<<<
 * import socket
 * import time
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_collections, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_collections, __pyx_t_1) < 0) __PYX_ERR(0, 16, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/protocol.pyx":17
 * import codecs
 * import collections
 * import socket             # <<<<<<<<<<<<<<
 * import time
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_socket, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_socket, __pyx_t_1) < 0) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/protocol.pyx":18
 * import collections
 * import socket
 * import time             # <<<<<<<<<<<<<<
 * 
 * from libc.stdint cimport int8_t, uint8_t, int16_t, uint16_t, \
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_time, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_time, __pyx_t_1) < 0) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/protocol.pyx":37
 * from cpython cimport PyBuffer_FillInfo, PyBytes_AsString
 * 
 * from asyncpg.exceptions import _base as apg_exc_base             # <<<<<<<<<<<<<<
 * from asyncpg import compat
 * from asyncpg import types as apg_types
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __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(0, 37, __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(0, 37, __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(0, 37, __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":38
 * 
 * from asyncpg.exceptions import _base as apg_exc_base
 * from asyncpg import compat             # <<<<<<<<<<<<<<
 * 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(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_compat);
  __Pyx_GIVEREF(__pyx_n_s_compat);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_compat);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_asyncpg, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __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_compat); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_compat, __pyx_t_2) < 0) __PYX_ERR(0, 38, __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":39
 * from asyncpg.exceptions import _base as apg_exc_base
 * from asyncpg import compat
 * 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(0, 39, __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_2 = __Pyx_Import(__pyx_n_s_asyncpg, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 39, __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_types); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_apg_types, __pyx_t_1) < 0) __PYX_ERR(0, 39, __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":40
 * from asyncpg import compat
 * from asyncpg import types as apg_types
 * from asyncpg import exceptions as apg_exc             # <<<<<<<<<<<<<<
 * 
 * from asyncpg.protocol cimport hton
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_exceptions);
  __Pyx_GIVEREF(__pyx_n_s_exceptions);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_exceptions);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_asyncpg, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __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_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_apg_exc, __pyx_t_2) < 0) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/pgtypes.pxi":102
 * DEF REGROLEOID = 4096
 * 
 * cdef ARRAY_TYPES = (_TEXTOID, _OIDOID,)             # <<<<<<<<<<<<<<
 * 
 * TYPEMAP = {
 */
  __Pyx_INCREF(__pyx_tuple__114);
  __Pyx_XGOTREF(__pyx_v_7asyncpg_8protocol_8protocol_ARRAY_TYPES);
  __Pyx_DECREF_SET(__pyx_v_7asyncpg_8protocol_8protocol_ARRAY_TYPES, __pyx_tuple__114);
  __Pyx_GIVEREF(__pyx_tuple__114);

  /* "asyncpg/protocol/pgtypes.pxi":105
 * 
 * TYPEMAP = {
 *     ABSTIMEOID: 'abstime',             # <<<<<<<<<<<<<<
 *     ACLITEMOID: 'aclitem',
 *     ANYARRAYOID: 'anyarray',
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(86); if (unlikely(!__pyx_t_1)) __PYX_ERR(33, 105, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_702, __pyx_n_u_abstime) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_1033, __pyx_n_u_aclitem) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_2277, __pyx_n_u_anyarray) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_2283, __pyx_n_u_anyelement) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_3500, __pyx_n_u_anyenum) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_2776, __pyx_n_u_anynonarray) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_2276, __pyx_n_u_any) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_3831, __pyx_n_u_anyrange) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_1560, __pyx_n_u_bit) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_16, __pyx_n_u_bool) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_603, __pyx_n_u_box) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_1042, __pyx_n_u_bpchar) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_17, __pyx_n_u_bytea) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_18, __pyx_n_u_char) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_29, __pyx_n_u_cid) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_650, __pyx_n_u_cidr) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_718, __pyx_n_u_circle) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_2275, __pyx_n_u_cstring) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_1082, __pyx_n_u_date) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_3838, __pyx_n_u_event_trigger) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_3115, __pyx_n_u_fdw_handler) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_700, __pyx_n_u_float4) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_701, __pyx_n_u_float8) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_3642, __pyx_n_u_gtsvector) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_325, __pyx_n_u_index_am_handler) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_869, __pyx_n_u_inet) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_21, __pyx_n_u_int2) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_23, __pyx_n_u_int4) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_20, __pyx_n_u_int8) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_2281, __pyx_n_u_internal) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_1186, __pyx_n_u_interval) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_3802, __pyx_n_u_jsonb) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_114, __pyx_n_u_json) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_2280, __pyx_n_u_language_handler) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_628, __pyx_n_u_line) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_601, __pyx_n_u_lseg) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_774, __pyx_n_u_macaddr8) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_829, __pyx_n_u_macaddr) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_790, __pyx_n_u_money) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_19, __pyx_n_u_name) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_1700, __pyx_n_u_numeric) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_26, __pyx_n_u_oid) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_2282, __pyx_n_u_opaque) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_602, __pyx_n_u_path) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_32, __pyx_n_u_pg_ddl_command) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_3402, __pyx_n_u_pg_dependencies) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_3220, __pyx_n_u_pg_lsn) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_3361, __pyx_n_u_pg_ndistinct) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_194, __pyx_n_u_pg_node_tree) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_600, __pyx_n_u_point) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_604, __pyx_n_u_polygon) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_2249, __pyx_n_u_record) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_1790, __pyx_n_u_refcursor) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_2205, __pyx_n_u_regclass) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_3734, __pyx_n_u_regconfig) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_3769, __pyx_n_u_regdictionary) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_4089, __pyx_n_u_regnamespace) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_2204, __pyx_n_u_regoperator) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_2203, __pyx_n_u_regoper) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_2202, __pyx_n_u_regprocedure) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_24, __pyx_n_u_regproc) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_4096, __pyx_n_u_regrole) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_2206, __pyx_n_u_regtype) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_703, __pyx_n_u_reltime) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_210, __pyx_n_u_smgr) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_25, __pyx_n_u_text) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_27, __pyx_n_u_tid) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_1083, __pyx_n_u_time) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_1114, __pyx_n_u_timestamp) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_1184, __pyx_n_u_timestamptz) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_1266, __pyx_n_u_timetz) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_704, __pyx_n_u_tinterval) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_2279, __pyx_n_u_trigger) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_3310, __pyx_n_u_tsm_handler) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_3615, __pyx_n_u_tsquery) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_3614, __pyx_n_u_tsvector) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_2970, __pyx_n_u_txid_snapshot) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_705, __pyx_n_u_unknown) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_2950, __pyx_n_u_uuid) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_1562, __pyx_n_u_varbit) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_1043, __pyx_n_u_varchar) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_2278, __pyx_n_u_void) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_28, __pyx_n_u_xid) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_142, __pyx_n_u_xml) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_1028, __pyx_kp_u_oid_2) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_1009, __pyx_kp_u_text_2) < 0) __PYX_ERR(33, 105, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_TYPEMAP, __pyx_t_1) < 0) __PYX_ERR(33, 104, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/encodings.pyx":14
 * 
 * cdef dict ENCODINGS_MAP = {
 *     'abc': 'cp1258',             # <<<<<<<<<<<<<<
 *     'alt': 'cp866',
 *     'euc_cn': 'euccn',
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(45); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_abc, __pyx_n_u_cp1258) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_alt, __pyx_n_u_cp866) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_euc_cn, __pyx_n_u_euccn) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_euc_jp, __pyx_n_u_eucjp) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_euc_kr, __pyx_n_u_euckr) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_koi8r, __pyx_n_u_koi8_r) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_koi8u, __pyx_n_u_koi8_u) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_shift_jis_2004, __pyx_n_u_euc_jis_2004) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_sjis, __pyx_n_u_shift_jis) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_sql_ascii, __pyx_n_u_ascii) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_vscii, __pyx_n_u_cp1258) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_tcvn, __pyx_n_u_cp1258) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_tcvn5712, __pyx_n_u_cp1258) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_unicode, __pyx_n_u_utf_8_2) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_win, __pyx_n_u_cp1521) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_win1250, __pyx_n_u_cp1250) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_win1251, __pyx_n_u_cp1251) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_win1252, __pyx_n_u_cp1252) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_win1253, __pyx_n_u_cp1253) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_win1254, __pyx_n_u_cp1254) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_win1255, __pyx_n_u_cp1255) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_win1256, __pyx_n_u_cp1256) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_win1257, __pyx_n_u_cp1257) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_win1258, __pyx_n_u_cp1258) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_win866, __pyx_n_u_cp866) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_win874, __pyx_n_u_cp874) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_win932, __pyx_n_u_cp932) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_win936, __pyx_n_u_cp936) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_win949, __pyx_n_u_cp949) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_win950, __pyx_n_u_cp950) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_windows1250, __pyx_n_u_cp1250) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_windows1251, __pyx_n_u_cp1251) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_windows1252, __pyx_n_u_cp1252) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_windows1253, __pyx_n_u_cp1253) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_windows1254, __pyx_n_u_cp1254) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_windows1255, __pyx_n_u_cp1255) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_windows1256, __pyx_n_u_cp1256) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_windows1257, __pyx_n_u_cp1257) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_windows1258, __pyx_n_u_cp1258) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_windows866, __pyx_n_u_cp866) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_windows874, __pyx_n_u_cp874) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_windows932, __pyx_n_u_cp932) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_windows936, __pyx_n_u_cp936) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_windows949, __pyx_n_u_cp949) < 0) __PYX_ERR(8, 14, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_windows950, __pyx_n_u_cp950) < 0) __PYX_ERR(8, 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_1));
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "asyncpg/protocol/settings.pyx":72
 * 
 *     cpdef inline Codec get_data_codec(self, uint32_t oid,
 *                                       ServerDataFormat 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":71
 *                                           typekind, alias_to)
 * 
 *     cpdef inline Codec get_data_codec(self, uint32_t oid,             # <<<<<<<<<<<<<<
 *                                       ServerDataFormat 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_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
  __Pyx_GIVEREF(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
  __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_1, __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(3, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_BufferError, __pyx_t_1, __pyx_t_3, NULL, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_BufferError, __pyx_t_4) < 0) __PYX_ERR(3, 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_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/base.pyx":8
 * 
 * 
 * from asyncpg.exceptions import OutdatedSchemaCacheError             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_OutdatedSchemaCacheError);
  __Pyx_GIVEREF(__pyx_n_s_OutdatedSchemaCacheError);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_OutdatedSchemaCacheError);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_asyncpg_exceptions, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 8, __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_OutdatedSchemaCacheError); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_OutdatedSchemaCacheError, __pyx_t_1) < 0) __PYX_ERR(4, 8, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/codecs/base.pyx":13
 * cdef void* binary_codec_map[(MAXSUPPORTEDOID + 1) * 2]
 * cdef void* text_codec_map[(MAXSUPPORTEDOID + 1) * 2]
 * cdef dict TYPE_CODECS_CACHE = {}             # <<<<<<<<<<<<<<
 * cdef dict EXTRA_CODECS = {}
 * 
 */
  __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 13, __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":14
 * cdef void* text_codec_map[(MAXSUPPORTEDOID + 1) * 2]
 * cdef dict TYPE_CODECS_CACHE = {}
 * cdef dict EXTRA_CODECS = {}             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 14, __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/base.pyx":550
 * 
 *     def _set_builtin_type_codec(self, typeoid, typename, typeschema, typekind,
 *                                 alias_to, format=PG_FORMAT_ANY):             # <<<<<<<<<<<<<<
 *         cdef:
 *             Codec codec
 */
  __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(__pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_ANY); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 550, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k__37 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "asyncpg/protocol/codecs/base.pyx":585
 * 
 *     def set_builtin_type_codec(self, typeoid, typename, typeschema, typekind,
 *                                alias_to, format=PG_FORMAT_ANY):             # <<<<<<<<<<<<<<
 *         self._set_builtin_type_codec(typeoid, typename, typeschema, typekind,
 *                                      alias_to, format)
 */
  __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(__pyx_e_7asyncpg_8protocol_8protocol_PG_FORMAT_ANY); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 585, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k__38 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "asyncpg/protocol/codecs/base.pyx":651
 * cdef inline Codec get_core_codec(
 *         uint32_t oid, ServerDataFormat format,
 *         ClientExchangeFormat xformat=PG_XFORMAT_OBJECT):             # <<<<<<<<<<<<<<
 *     cdef:
 *         void *ptr = NULL
 */
  __pyx_k__39 = __pyx_e_7asyncpg_8protocol_8protocol_PG_XFORMAT_OBJECT;

  /* "asyncpg/protocol/codecs/base.pyx":670
 * cdef inline Codec get_any_core_codec(
 *         uint32_t oid, ServerDataFormat format,
 *         ClientExchangeFormat xformat=PG_XFORMAT_OBJECT):             # <<<<<<<<<<<<<<
 *     """A version of get_core_codec that accepts PG_FORMAT_ANY."""
 *     cdef:
 */
  __pyx_k__40 = __pyx_e_7asyncpg_8protocol_8protocol_PG_XFORMAT_OBJECT;

  /* "asyncpg/protocol/codecs/base.pyx":693
 *                          decode_func decode,
 *                          ServerDataFormat format,
 *                          ClientExchangeFormat xformat=PG_XFORMAT_OBJECT):             # <<<<<<<<<<<<<<
 * 
 *     if oid > MAXSUPPORTEDOID:
 */
  __pyx_k__41 = __pyx_e_7asyncpg_8protocol_8protocol_PG_XFORMAT_OBJECT;

  /* "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(9, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "asyncpg/protocol/codecs/text.pyx":71
 *                             PG_FORMAT_TEXT)
 * 
 * init_text_codecs()             # <<<<<<<<<<<<<<
 */
  __pyx_t_2 = __pyx_f_7asyncpg_8protocol_8protocol_init_text_codecs(); if (unlikely(!__pyx_t_2)) __PYX_ERR(10, 71, __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(11, 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(11, 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(11, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_BitString, __pyx_t_2) < 0) __PYX_ERR(11, 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(11, 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(12, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_datetime, __pyx_t_1) < 0) __PYX_ERR(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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__115, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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 == ((long)-1L) && PyErr_Occurred())) __PYX_ERR(12, 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(12, 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(12, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(12, 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(12, 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(12, 18, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__116, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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 == ((long)-1L) && PyErr_Occurred())) __PYX_ERR(12, 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(12, 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(12, 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__117, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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 == ((long)-1L) && PyErr_Occurred())) __PYX_ERR(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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 == ((long)-1L) && PyErr_Occurred())) __PYX_ERR(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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 == ((long)-1L) && PyErr_Occurred())) __PYX_ERR(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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 == ((long)-1L) && PyErr_Occurred())) __PYX_ERR(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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(12, 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 == ((long)-1L) && PyErr_Occurred())) __PYX_ERR(12, 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":484
 *                         PG_FORMAT_TEXT)
 * 
 * init_datetime_codecs()             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_init_datetime_codecs(); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 484, __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(13, 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(14, 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(14, 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(14, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Box, __pyx_t_1) < 0) __PYX_ERR(14, 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(14, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Line, __pyx_t_1) < 0) __PYX_ERR(14, 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(14, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_LineSegment, __pyx_t_1) < 0) __PYX_ERR(14, 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(14, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Path, __pyx_t_1) < 0) __PYX_ERR(14, 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(14, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Point, __pyx_t_1) < 0) __PYX_ERR(14, 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(14, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Polygon, __pyx_t_1) < 0) __PYX_ERR(14, 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(14, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Circle, __pyx_t_1) < 0) __PYX_ERR(14, 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(14, 205, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/codecs/int.pyx":111
 * 
 * 
 * init_int_codecs()             # <<<<<<<<<<<<<<
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_init_int_codecs(); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 111, __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(15, 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(16, 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(17, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ipaddress, __pyx_t_3) < 0) __PYX_ERR(17, 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(17, 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(17, 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(17, 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(17, 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(17, 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(17, 18, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/codecs/network.pyx":144
 * 
 * 
 * init_network_codecs()             # <<<<<<<<<<<<<<
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_init_network_codecs(); if (unlikely(!__pyx_t_3)) __PYX_ERR(17, 144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/codecs/numeric.pyx":11
 * from libc.stdio cimport snprintf
 * 
 * import decimal             # <<<<<<<<<<<<<<
 * 
 * from asyncpg.protocol cimport python
 */
  __pyx_t_3 = __Pyx_Import(__pyx_n_s_decimal, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(18, 11, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_decimal, __pyx_t_3) < 0) __PYX_ERR(18, 11, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/codecs/numeric.pyx":22
 * DEF NUMERIC_NAN = 0xC000
 * 
 * _Dec = decimal.Decimal             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_decimal); if (unlikely(!__pyx_t_3)) __PYX_ERR(18, 22, __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(18, 22, __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(18, 22, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/codecs/numeric.pyx":323
 *                         PG_FORMAT_BINARY)
 * 
 * init_numeric_codecs()             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_init_numeric_codecs(); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 323, __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(19, 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(20, 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(21, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_uuid, __pyx_t_1) < 0) __PYX_ERR(21, 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(21, 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(21, 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(21, 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(21, 31, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/codecs/misc.pyx":120
 *                         PG_FORMAT_TEXT)
 * 
 * init_pseudo_codecs()             # <<<<<<<<<<<<<<
 */
  __pyx_t_3 = __pyx_f_7asyncpg_8protocol_8protocol_init_pseudo_codecs(); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 120, __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(6, 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(6, 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(6, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ContainerABC, __pyx_t_3) < 0) __PYX_ERR(6, 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":865
 *                         PG_FORMAT_BINARY)
 * 
 * init_array_codecs()             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __pyx_f_7asyncpg_8protocol_8protocol_init_array_codecs(); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 865, __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(23, 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(23, 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(23, 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(23, 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(23, 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(24, 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(25, 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(7, 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(7, 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(7, 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(7, 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":957
 * 
 * 
 * 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(7, 957, __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(7, 957, __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(7, 957, __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(7, 957, __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/prepared_stmt.pyx":8
 * 
 * 
 * from asyncpg import exceptions             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_n_s_exceptions);
  __Pyx_GIVEREF(__pyx_n_s_exceptions);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_exceptions);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_asyncpg, __pyx_t_3, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(27, 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_exceptions); if (unlikely(!__pyx_t_3)) __PYX_ERR(27, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_exceptions, __pyx_t_3) < 0) __PYX_ERR(27, 8, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/protocol.pyx":88
 * 
 * 
 * NO_TIMEOUT = object()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_builtin_object); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_NO_TIMEOUT, __pyx_t_1) < 0) __PYX_ERR(0, 88, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/protocol.pyx":854
 * 
 * 
 * class Timer:             # <<<<<<<<<<<<<<
 *     def __init__(self, budget):
 *         self._budget = budget
 */
  __pyx_t_1 = __Pyx_Py3MetaclassPrepare((PyObject *) NULL, __pyx_empty_tuple, __pyx_n_s_Timer, __pyx_n_s_Timer, (PyObject *) NULL, __pyx_n_s_asyncpg_protocol_protocol, (PyObject *) NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 854, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "asyncpg/protocol/protocol.pyx":855
 * 
 * class Timer:
 *     def __init__(self, budget):             # <<<<<<<<<<<<<<
 *         self._budget = budget
 *         self._started = 0
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_7asyncpg_8protocol_8protocol_5Timer_1__init__, 0, __pyx_n_s_Timer___init, NULL, __pyx_n_s_asyncpg_protocol_protocol, __pyx_d, ((PyObject *)__pyx_codeobj__119)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 855, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s_init, __pyx_t_3) < 0) __PYX_ERR(0, 855, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":859
 *         self._started = 0
 * 
 *     def __enter__(self):             # <<<<<<<<<<<<<<
 *         if self._budget is not None:
 *             self._started = time.monotonic()
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_7asyncpg_8protocol_8protocol_5Timer_3__enter__, 0, __pyx_n_s_Timer___enter, NULL, __pyx_n_s_asyncpg_protocol_protocol, __pyx_d, ((PyObject *)__pyx_codeobj__121)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 859, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s_enter, __pyx_t_3) < 0) __PYX_ERR(0, 859, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":863
 *             self._started = time.monotonic()
 * 
 *     def __exit__(self, et, e, tb):             # <<<<<<<<<<<<<<
 *         if self._budget is not None:
 *             self._budget -= time.monotonic() - self._started
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_7asyncpg_8protocol_8protocol_5Timer_5__exit__, 0, __pyx_n_s_Timer___exit, NULL, __pyx_n_s_asyncpg_protocol_protocol, __pyx_d, ((PyObject *)__pyx_codeobj__123)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 863, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s_exit, __pyx_t_3) < 0) __PYX_ERR(0, 863, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":867
 *             self._budget -= time.monotonic() - self._started
 * 
 *     def get_remaining_budget(self):             # <<<<<<<<<<<<<<
 *         return self._budget
 * 
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_7asyncpg_8protocol_8protocol_5Timer_7get_remaining_budget, 0, __pyx_n_s_Timer_get_remaining_budget, NULL, __pyx_n_s_asyncpg_protocol_protocol, __pyx_d, ((PyObject *)__pyx_codeobj__125)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 867, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s_get_remaining_budget, __pyx_t_3) < 0) __PYX_ERR(0, 867, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "asyncpg/protocol/protocol.pyx":854
 * 
 * 
 * class Timer:             # <<<<<<<<<<<<<<
 *     def __init__(self, budget):
 *         self._budget = budget
 */
  __pyx_t_3 = __Pyx_Py3ClassCreate(((PyObject*)&__Pyx_DefaultClassType), __pyx_n_s_Timer, __pyx_empty_tuple, __pyx_t_1, NULL, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 854, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Timer, __pyx_t_3) < 0) __PYX_ERR(0, 854, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/protocol.pyx":871
 * 
 * 
 * class Protocol(BaseProtocol, asyncio.Protocol):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_asyncio); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 871, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Protocol); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 871, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 871, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_BaseProtocol));
  __Pyx_GIVEREF(((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_BaseProtocol));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_ptype_7asyncpg_8protocol_8protocol_BaseProtocol));
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 871, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_3, __pyx_t_1, __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(0, 871, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_3, __pyx_n_s_Protocol, __pyx_t_1, __pyx_t_2, NULL, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 871, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Protocol, __pyx_t_4) < 0) __PYX_ERR(0, 871, __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_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/protocol.pyx":875
 * 
 * 
 * def _create_record(object mapping, tuple elems):             # <<<<<<<<<<<<<<
 *     # Exposed only for testing purposes.
 * 
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7asyncpg_8protocol_8protocol_1_create_record, NULL, __pyx_n_s_asyncpg_protocol_protocol); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 875, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_create_record, __pyx_t_1) < 0) __PYX_ERR(0, 875, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/protocol.pyx":896
 * 
 * 
 * Record = <object>record.ApgRecord_InitTypes()             # <<<<<<<<<<<<<<
 */
  __pyx_t_9 = ApgRecord_InitTypes(); if (unlikely(__pyx_t_9 == ((PyTypeObject *)NULL))) __PYX_ERR(0, 896, __pyx_L1_error)
  __pyx_t_1 = ((PyObject *)__pyx_t_9);
  __Pyx_INCREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Record, __pyx_t_1) < 0) __PYX_ERR(0, 896, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Memory(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xe0abff4:
 *         from pickle import PickleError as __pyx_PickleError
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7asyncpg_8protocol_8protocol_3__pyx_unpickle_Memory, NULL, __pyx_n_s_asyncpg_protocol_protocol); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Memory, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":9
 *         __pyx_unpickle_Memory__set_state(<Memory> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Memory__set_state(Memory __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.buf = __pyx_state[0]; __pyx_result.length = __pyx_state[1]; __pyx_result.owner = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7asyncpg_8protocol_8protocol_5__pyx_unpickle_FastReadBuffer, NULL, __pyx_n_s_asyncpg_protocol_protocol); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_FastReadBuffer, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_DataCodecConfig(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xb75bfc9:
 *         from pickle import PickleError as __pyx_PickleError
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7asyncpg_8protocol_8protocol_7__pyx_unpickle_DataCodecConfig, NULL, __pyx_n_s_asyncpg_protocol_protocol); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_DataCodecConfig, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":9
 *         __pyx_unpickle_DataCodecConfig__set_state(<DataCodecConfig> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_DataCodecConfig__set_state(DataCodecConfig __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._local_type_codecs = __pyx_state[0]; __pyx_result._type_codecs_cache = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7asyncpg_8protocol_8protocol_9__pyx_unpickle_CoreProtocol, NULL, __pyx_n_s_asyncpg_protocol_protocol); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_CoreProtocol, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_BaseProtocol(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x30f806c:
 *         from pickle import PickleError as __pyx_PickleError
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7asyncpg_8protocol_8protocol_11__pyx_unpickle_BaseProtocol, NULL, __pyx_n_s_asyncpg_protocol_protocol); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_BaseProtocol, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "asyncpg/protocol/protocol.pyx":1
 * # Copyright (C) 2016-present the asyncpg authors and contributors             # <<<<<<<<<<<<<<
 * # <see AUTHORS file>
 * #
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /*--- 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", 0, __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 CYTHON_PEP489_MULTI_PHASE_INIT
  return (__pyx_m != NULL) ? 0 : -1;
  #elif PY_MAJOR_VERSION >= 3
  return __pyx_m;
  #else
  return;
  #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);
    int flags = PyCFunction_GET_FLAGS(func);
    assert(PyCFunction_Check(func));
    assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)));
    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());
    if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
        return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL);
    } else {
        return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs);
    }
}
#endif

/* 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 = __Pyx_PyThreadState_Current;
    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
#endif

/* 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
    if (likely(PyCFunction_Check(func))) {
        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) || __Pyx_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;
#if CYTHON_USE_UNICODE_INTERNALS
            Py_hash_t hash1, hash2;
            hash1 = ((PyBytesObject*)s1)->ob_shash;
            hash2 = ((PyBytesObject*)s2)->ob_shash;
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                return (equals == Py_NE);
            }
#endif
            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;
        }
#if CYTHON_USE_UNICODE_INTERNALS
        {
            Py_hash_t hash1, hash2;
        #if CYTHON_PEP393_ENABLED
            hash1 = ((PyASCIIObject*)s1)->hash;
            hash2 = ((PyASCIIObject*)s2)->hash;
        #else
            hash1 = ((PyUnicodeObject*)s1)->hash;
            hash2 = ((PyUnicodeObject*)s2)->hash;
        #endif
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                goto return_ne;
            }
        }
#endif
        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
}

/* 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 (cause) {
        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 = __Pyx_PyThreadState_Current;
        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

/* SaveResetException */
    #if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    #if PY_VERSION_HEX >= 0x030700A2
    *type = tstate->exc_state.exc_type;
    *value = tstate->exc_state.exc_value;
    *tb = tstate->exc_state.exc_traceback;
    #else
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    #endif
    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;
    #if PY_VERSION_HEX >= 0x030700A2
    tmp_type = tstate->exc_state.exc_type;
    tmp_value = tstate->exc_state.exc_value;
    tmp_tb = tstate->exc_state.exc_traceback;
    tstate->exc_state.exc_type = type;
    tstate->exc_state.exc_value = value;
    tstate->exc_state.exc_traceback = tb;
    #else
    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;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
#endif

/* PyErrExceptionMatches */
    #if CYTHON_FAST_THREAD_STATE
static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
    }
    return 0;
}
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;
    if (unlikely(PyTuple_Check(err)))
        return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
    return __Pyx_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
    #if PY_VERSION_HEX >= 0x030700A2
    tmp_type = tstate->exc_state.exc_type;
    tmp_value = tstate->exc_state.exc_value;
    tmp_tb = tstate->exc_state.exc_traceback;
    tstate->exc_state.exc_type = local_type;
    tstate->exc_state.exc_value = local_value;
    tstate->exc_state.exc_traceback = local_tb;
    #else
    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;
    #endif
    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;
}

/* 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(__Pyx_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

/* GetAttr */
      static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
#if CYTHON_USE_TYPE_SLOTS
#if PY_MAJOR_VERSION >= 3
    if (likely(PyUnicode_Check(n)))
#else
    if (likely(PyString_Check(n)))
#endif
        return __Pyx_PyObject_GetAttrStr(o, n);
#endif
    return PyObject_GetAttr(o, n);
}

/* GetAttr3 */
      static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
        return NULL;
    __Pyx_PyErr_Clear();
    Py_INCREF(d);
    return d;
}
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
    PyObject *r = __Pyx_GetAttr(o, n);
    return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
}

/* KeywordStringCheck */
      static 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_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 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
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyList_GET_SIZE(o);
    }
    if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, wrapped_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
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyTuple_GET_SIZE(o);
    }
    if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, wrapped_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

/* ArgTypeTest */
      static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
{
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    else if (exact) {
        #if PY_MAJOR_VERSION == 2
        if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
        #endif
    }
    else {
        if (likely(__Pyx_TypeCheck(obj, type))) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

/* 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;
    #if PY_VERSION_HEX >= 0x030700A2
    tmp_type = tstate->exc_state.exc_type;
    tmp_value = tstate->exc_state.exc_value;
    tmp_tb = tstate->exc_state.exc_traceback;
    tstate->exc_state.exc_type = *type;
    tstate->exc_state.exc_value = *value;
    tstate->exc_state.exc_traceback = *tb;
    #else
    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;
    #endif
    *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;
}

/* None */
      static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
    long q = a / b;
    long r = a - q*b;
    q -= ((r != 0) & ((r ^ b) < 0));
    return q;
}

/* None */
      static CYTHON_INLINE long __Pyx_mod_long(long a, long b) {
    long r = a % b;
    r += ((r != 0) & ((r ^ b) < 0)) * b;
    return r;
}

/* None */
      static CYTHON_INLINE int64_t __Pyx_div_int64_t(int64_t a, int64_t b) {
    int64_t q = a / b;
    int64_t r = a - q*b;
    q -= ((r != 0) & ((r ^ b) < 0));
    return q;
}

/* 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

/* PyIntBinop */
      #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_SubtractObjC(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_subtract(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_subtract(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("subtract", return NULL)
            result = ((double)a) - (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceSubtract : PyNumber_Subtract)(op1, op2);
}
#endif

/* HasAttr */
      static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
    PyObject *r;
    if (unlikely(!__Pyx_PyBaseString_Check(n))) {
        PyErr_SetString(PyExc_TypeError,
                        "hasattr(): attribute name must be string");
        return -1;
    }
    r = __Pyx_GetAttr(o, n);
    if (unlikely(!r)) {
        PyErr_Clear();
        return 0;
    } else {
        Py_DECREF(r);
        return 1;
    }
}

/* 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 = __Pyx_PyThreadState_Current;
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(__Pyx_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 PyObject *__Pyx_PyIter_Next2Default(PyObject* defval) {
    PyObject* exc_type;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    exc_type = __Pyx_PyErr_Occurred();
    if (unlikely(exc_type)) {
        if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))
            return NULL;
        if (defval) {
            __Pyx_PyErr_Clear();
            Py_INCREF(defval);
        }
        return defval;
    }
    if (defval) {
        Py_INCREF(defval);
        return defval;
    }
    __Pyx_PyErr_SetNone(PyExc_StopIteration);
    return NULL;
}
static void __Pyx_PyIter_Next_ErrorNoIterator(PyObject *iterator) {
    PyErr_Format(PyExc_TypeError,
        "%.200s object is not an iterator", Py_TYPE(iterator)->tp_name);
}
static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) {
    PyObject* next;
    iternextfunc iternext = Py_TYPE(iterator)->tp_iternext;
    if (likely(iternext)) {
#if CYTHON_USE_TYPE_SLOTS
        next = iternext(iterator);
        if (likely(next))
            return next;
        #if PY_VERSION_HEX >= 0x02070000
        if (unlikely(iternext == &_PyObject_NextNotImplemented))
            return NULL;
        #endif
#else
        next = PyIter_Next(iterator);
        if (likely(next))
            return next;
#endif
    } else if (CYTHON_USE_TYPE_SLOTS || !PyIter_Check(iterator)) {
        __Pyx_PyIter_Next_ErrorNoIterator(iterator);
        return NULL;
    }
    return __Pyx_PyIter_Next2Default(defval);
}

/* 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_exact(
        PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, int decref_tuple) {
    PyObject *value1 = NULL, *value2 = NULL;
#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);  Py_INCREF(value1);
    value2 = PyTuple_GET_ITEM(tuple, 1);  Py_INCREF(value2);
#endif
    if (decref_tuple) {
        Py_DECREF(tuple);
    }
    *pvalue1 = value1;
    *pvalue2 = value2;
    return 0;
#if CYTHON_COMPILING_IN_PYPY
bad:
    Py_XDECREF(value1);
    Py_XDECREF(value2);
    if (decref_tuple) { Py_XDECREF(tuple); }
    return -1;
#endif
}
static int __Pyx_unpack_tuple2_generic(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2,
                                       int has_known_size, int decref_tuple) {
    Py_ssize_t index;
    PyObject *value1 = NULL, *value2 = NULL, *iter = NULL;
    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);
    *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 (is_dict) {
#if !CYTHON_COMPILING_IN_PYPY
        *p_orig_length = PyDict_Size(iterable);
        Py_INCREF(iterable);
        return iterable;
#elif PY_MAJOR_VERSION >= 3
        static PyObject *py_items = NULL, *py_keys = NULL, *py_values = NULL;
        PyObject **pp = NULL;
        if (method_name) {
            const char *name = PyUnicode_AsUTF8(method_name);
            if (strcmp(name, "iteritems") == 0) pp = &py_items;
            else if (strcmp(name, "iterkeys") == 0) pp = &py_keys;
            else if (strcmp(name, "itervalues") == 0) pp = &py_values;
            if (pp) {
                if (!*pp) {
                    *pp = PyUnicode_FromString(name + 4);
                    if (!*pp)
                        return NULL;
                }
                method_name = *pp;
            }
        }
#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;
}

/* 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* method, PyObject* arg) {
    PyObject *result = NULL;
#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);
            result = __Pyx_PyObject_Call(function, args, NULL);
            Py_DECREF(args);
            Py_DECREF(function);
            return result;
        }
    }
#endif
    result = __Pyx_PyObject_CallOneArg(method, arg);
    goto done;
done:
    return result;
}
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;
    result = __Pyx__PyObject_CallMethod1(method, arg);
done:
    Py_XDECREF(method);
    return result;
}

/* CoroutineBase */
      #include <structmember.h>
#include <frameobject.h>
#define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom)
static int __Pyx_PyGen__FetchStopIterationValue(CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject **pvalue) {
    PyObject *et, *ev, *tb;
    PyObject *value = NULL;
    __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 (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
            value = ev;
        }
        if (likely(value)) {
            Py_XDECREF(tb);
            Py_DECREF(et);
            *pvalue = value;
            return 0;
        }
    } else if (!__Pyx_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;
}
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);
}
#define __Pyx_Coroutine_AlreadyRunningError(gen)  (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
static void __Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_CoroutineObject *gen) {
    const char *msg;
    if (0) {
    #ifdef __Pyx_Coroutine_USED
    } else if (__Pyx_Coroutine_CheckExact((PyObject*)gen)) {
        msg = "coroutine already executing";
    #endif
    #ifdef __Pyx_AsyncGen_USED
    } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) {
        msg = "async generator already executing";
    #endif
    } else {
        msg = "generator already executing";
    }
    PyErr_SetString(PyExc_ValueError, msg);
}
#define __Pyx_Coroutine_NotStartedError(gen)  (__Pyx__Coroutine_NotStartedError(gen), (PyObject*)NULL)
static void __Pyx__Coroutine_NotStartedError(CYTHON_UNUSED PyObject *gen) {
    const char *msg;
    if (0) {
    #ifdef __Pyx_Coroutine_USED
    } else if (__Pyx_Coroutine_CheckExact(gen)) {
        msg = "can't send non-None value to a just-started coroutine";
    #endif
    #ifdef __Pyx_AsyncGen_USED
    } else if (__Pyx_AsyncGen_CheckExact(gen)) {
        msg = "can't send non-None value to a just-started async generator";
    #endif
    } else {
        msg = "can't send non-None value to a just-started generator";
    }
    PyErr_SetString(PyExc_TypeError, msg);
}
#define __Pyx_Coroutine_AlreadyTerminatedError(gen, value, closing)  (__Pyx__Coroutine_AlreadyTerminatedError(gen, value, closing), (PyObject*)NULL)
static void __Pyx__Coroutine_AlreadyTerminatedError(CYTHON_UNUSED PyObject *gen, PyObject *value, CYTHON_UNUSED int closing) {
    #ifdef __Pyx_Coroutine_USED
    if (!closing && __Pyx_Coroutine_CheckExact(gen)) {
        PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine");
    } else
    #endif
    if (value) {
        #ifdef __Pyx_AsyncGen_USED
        if (__Pyx_AsyncGen_CheckExact(gen))
            PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration);
        else
        #endif
        PyErr_SetNone(PyExc_StopIteration);
    }
}
static
PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, int closing) {
    __Pyx_PyThreadState_declare
    PyThreadState *tstate;
    PyObject *retval;
    assert(!self->is_running);
    if (unlikely(self->resume_label == 0)) {
        if (unlikely(value && value != Py_None)) {
            return __Pyx_Coroutine_NotStartedError((PyObject*)self);
        }
    }
    if (unlikely(self->resume_label == -1)) {
        return __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing);
    }
#if CYTHON_FAST_THREAD_STATE
    __Pyx_PyThreadState_assign
    tstate = __pyx_tstate;
#else
    tstate = __Pyx_PyThreadState_Current;
#endif
    if (self->exc_type) {
#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(tstate->frame);
            assert(f->f_back == NULL);
            f->f_back = tstate->frame;
        }
#endif
        __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
                            &self->exc_traceback);
    } else {
        __Pyx_Coroutine_ExceptionClear(self);
        __Pyx_ExceptionSave(&self->exc_type, &self->exc_value, &self->exc_traceback);
    }
    self->is_running = 1;
    retval = self->body((PyObject *) self, tstate, value);
    self->is_running = 0;
    return retval;
}
static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__pyx_CoroutineObject *self) {
    if (likely(self->exc_traceback)) {
#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
#else
        PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
        PyFrameObject *f = tb->tb_frame;
        Py_CLEAR(f->f_back);
#endif
    }
}
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_MethodReturn(CYTHON_UNUSED PyObject* gen, PyObject *retval) {
    if (unlikely(!retval)) {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        if (!__Pyx_PyErr_Occurred()) {
            PyObject *exc = PyExc_StopIteration;
            #ifdef __Pyx_AsyncGen_USED
            if (__Pyx_AsyncGen_CheckExact(gen))
                exc = __Pyx_PyExc_StopAsyncIteration;
            #endif
            __Pyx_PyErr_SetNone(exc);
        }
    }
    return retval;
}
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) {
    PyObject *ret;
    PyObject *val = NULL;
    __Pyx_Coroutine_Undelegate(gen);
    __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val);
    ret = __Pyx_Coroutine_SendEx(gen, val, 0);
    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(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    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
        #ifdef __Pyx_AsyncGen_USED
        if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
            ret = __Pyx_async_gen_asend_send(yf, value);
        } else
        #endif
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
        if (PyGen_CheckExact(yf)) {
            ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
        } else
        #endif
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03050000 && defined(PyCoro_CheckExact) && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
        if (PyCoro_CheckExact(yf)) {
            ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : 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, 0);
    }
    return __Pyx_Coroutine_MethodReturn(self, 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
    if (__Pyx_CoroutineAwait_CheckExact(yf)) {
        retval = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf);
        if (!retval)
            return -1;
    } else
    #endif
    #ifdef __Pyx_AsyncGen_USED
    if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
        retval = __Pyx_async_gen_asend_close(yf, NULL);
    } else
    if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) {
        retval = __Pyx_async_gen_athrow_close(yf, NULL);
    } 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(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        PyObject *ret;
        gen->is_running = 1;
        #ifdef __Pyx_Generator_USED
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Generator_Next(yf);
        } else
        #endif
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
        if (PyGen_CheckExact(yf)) {
            ret = _PyGen_Send((PyGenObject*)yf, NULL);
        } 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, 0);
}
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(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    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, 1);
    if (unlikely(retval)) {
        const char *msg;
        Py_DECREF(retval);
        if ((0)) {
        #ifdef __Pyx_Coroutine_USED
        } else if (__Pyx_Coroutine_CheckExact(self)) {
            msg = "coroutine ignored GeneratorExit";
        #endif
        #ifdef __Pyx_AsyncGen_USED
        } else if (__Pyx_AsyncGen_CheckExact(self)) {
#if PY_VERSION_HEX < 0x03060000
            msg = "async generator ignored GeneratorExit - might require Python 3.6+ finalisation (PEP 525)";
#else
            msg = "async generator ignored GeneratorExit";
#endif
        #endif
        } else {
            msg = "generator ignored GeneratorExit";
        }
        PyErr_SetString(PyExc_RuntimeError, msg);
        return NULL;
    }
    raised_exception = PyErr_Occurred();
    if (likely(!raised_exception || __Pyx_PyErr_GivenExceptionMatches2(raised_exception, PyExc_GeneratorExit, PyExc_StopIteration))) {
        if (raised_exception) PyErr_Clear();
        Py_INCREF(Py_None);
        return Py_None;
    }
    return NULL;
}
static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb,
                                        PyObject *args, int close_on_genexit) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        PyObject *ret;
        Py_INCREF(yf);
        if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) {
            int err = __Pyx_Coroutine_CloseIter(gen, yf);
            Py_DECREF(yf);
            __Pyx_Coroutine_Undelegate(gen);
            if (err < 0)
                return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
            goto throw_here;
        }
        gen->is_running = 1;
        if (0
        #ifdef __Pyx_Generator_USED
            || __Pyx_Generator_CheckExact(yf)
        #endif
        #ifdef __Pyx_Coroutine_USED
            || __Pyx_Coroutine_CheckExact(yf)
        #endif
            ) {
            ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit);
        #ifdef __Pyx_Coroutine_USED
        } else if (__Pyx_CoroutineAwait_CheckExact(yf)) {
            ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit);
        #endif
        } else {
            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;
            }
            if (likely(args)) {
                ret = PyObject_CallObject(meth, args);
            } else {
                ret = PyObject_CallFunctionObjArgs(meth, typ, val, tb, NULL);
            }
            Py_DECREF(meth);
        }
        gen->is_running = 0;
        Py_DECREF(yf);
        if (!ret) {
            ret = __Pyx_Coroutine_FinishDelegation(gen);
        }
        return __Pyx_Coroutine_MethodReturn(self, ret);
    }
throw_here:
    __Pyx_Raise(typ, val, tb, NULL);
    return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
}
static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
    PyObject *typ;
    PyObject *val = NULL;
    PyObject *tb = NULL;
    if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))
        return NULL;
    return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1);
}
static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) {
    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);
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer);
    }
#endif
    Py_CLEAR(gen->gi_name);
    Py_CLEAR(gen->gi_qualname);
    Py_CLEAR(gen->gi_modulename);
    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 && CYTHON_USE_TP_FINALIZE
        if (PyObject_CallFinalizerFromDealloc(self))
#else
        Py_TYPE(gen)->tp_del(self);
        if (self->ob_refcnt > 0)
#endif
        {
            return;
        }
        PyObject_GC_UnTrack(self);
    }
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        /* We have to handle this case for asynchronous generators
           right here, because this code has to be between UNTRACK
           and GC_Del. */
        Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer);
    }
#endif
    __Pyx_Coroutine_clear(self);
    PyObject_GC_Del(gen);
}
static void __Pyx_Coroutine_del(PyObject *self) {
    PyObject *error_type, *error_value, *error_traceback;
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    __Pyx_PyThreadState_declare
    if (gen->resume_label < 0) {
        return;
    }
#if !CYTHON_USE_TP_FINALIZE
    assert(self->ob_refcnt == 0);
    self->ob_refcnt = 1;
#endif
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self;
        PyObject *finalizer = agen->ag_finalizer;
        if (finalizer && !agen->ag_closed) {
            PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self);
            if (unlikely(!res)) {
                PyErr_WriteUnraisable(self);
            } else {
                Py_DECREF(res);
            }
            __Pyx_ErrRestore(error_type, error_value, error_traceback);
            return;
        }
    }
#endif
    if (unlikely(gen->resume_label == 0 && !error_value)) {
#ifdef __Pyx_Coroutine_USED
#ifdef __Pyx_Generator_USED
    if (!__Pyx_Generator_CheckExact(self))
#endif
        {
        PyObject_GC_UnTrack(self);
#if PY_MAJOR_VERSION >= 3  || defined(PyErr_WarnFormat)
        if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0))
            PyErr_WriteUnraisable(self);
#else
        {PyObject *msg;
        char *cmsg;
        #if CYTHON_COMPILING_IN_PYPY
        msg = NULL;
        cmsg = (char*) "coroutine was never awaited";
        #else
        char *cname;
        PyObject *qualname;
        qualname = gen->gi_qualname;
        cname = PyString_AS_STRING(qualname);
        msg = PyString_FromFormat("coroutine '%.50s' was never awaited", cname);
        if (unlikely(!msg)) {
            PyErr_Clear();
            cmsg = (char*) "coroutine was never awaited";
        } else {
            cmsg = PyString_AS_STRING(msg);
        }
        #endif
        if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0))
            PyErr_WriteUnraisable(self);
        Py_XDECREF(msg);}
#endif
        PyObject_GC_Track(self);
        }
#endif
    } else {
        PyObject *res = __Pyx_Coroutine_Close(self);
        if (unlikely(!res)) {
            if (PyErr_Occurred())
                PyErr_WriteUnraisable(self);
        } else {
            Py_DECREF(res);
        }
    }
    __Pyx_ErrRestore(error_type, error_value, error_traceback);
#if !CYTHON_USE_TP_FINALIZE
    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 (unlikely(!gen))
        return NULL;
    return __Pyx__Coroutine_NewInit(gen, body, closure, name, qualname, module_name);
}
static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
            __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name) {
    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 */
          #ifndef CYTHON_REGISTER_ABCS
#define CYTHON_REGISTER_ABCS 1
#endif
#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 (CYTHON_REGISTER_ABCS && !abc_patched) {
        PyObject *module;
        module = PyImport_ImportModule((PY_MAJOR_VERSION >= 3) ? "collections.abc" : "collections");
        if (!module) {
            PyErr_WriteUnraisable(NULL);
            if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning,
                    ((PY_MAJOR_VERSION >= 3) ?
                        "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 */
          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) {
    __pyx_CoroutineAwaitObject *await = PyObject_GC_New(__pyx_CoroutineAwaitObject, __pyx_CoroutineAwaitType);
    if (unlikely(!await)) return NULL;
    Py_INCREF(coroutine);
    await->coroutine = coroutine;
    PyObject_GC_Track(await);
    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);
}
#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_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_USE_ASYNC_SLOTS && 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 CYTHON_USE_TP_FINALIZE
    0,
#else
    __Pyx_Coroutine_del,
#endif
    0,
#if CYTHON_USE_TP_FINALIZE
    __Pyx_Coroutine_del,
#elif PY_VERSION_HEX >= 0x030400a1
    0,
#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)) {
        return __Pyx_NewRef(o);
    }
#endif
    return __Pyx__Coroutine_GetAwaitableIter(o);
}
static void __Pyx_Coroutine_AwaitableIterError(PyObject *source) {
#if PY_VERSION_HEX >= 0x030600B3 || defined(_PyErr_FormatFromCause)
    _PyErr_FormatFromCause(
        PyExc_TypeError,
        "'async for' received an invalid object "
        "from __anext__: %.100s",
        Py_TYPE(source)->tp_name);
#elif PY_MAJOR_VERSION >= 3
    PyObject *exc, *val, *val2, *tb;
    assert(PyErr_Occurred());
    PyErr_Fetch(&exc, &val, &tb);
    PyErr_NormalizeException(&exc, &val, &tb);
    if (tb != NULL) {
        PyException_SetTraceback(val, tb);
        Py_DECREF(tb);
    }
    Py_DECREF(exc);
    assert(!PyErr_Occurred());
    PyErr_Format(
        PyExc_TypeError,
        "'async for' received an invalid object "
        "from __anext__: %.100s",
        Py_TYPE(source)->tp_name);
    PyErr_Fetch(&exc, &val2, &tb);
    PyErr_NormalizeException(&exc, &val2, &tb);
    Py_INCREF(val);
    PyException_SetCause(val2, val);
    PyException_SetContext(val2, val);
    PyErr_Restore(exc, val2, tb);
#else
    source++;
#endif
}
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)) {
        return __Pyx_NewRef(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) {
        return __Pyx_NewRef(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)) {
        __Pyx_Coroutine_AwaitableIterError(obj);
        goto bad;
    }
    if (unlikely(!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 PyObject* __Pyx__Coroutine_Yield_From_Generic(__pyx_CoroutineObject *gen, PyObject *source) {
    PyObject *retval;
    PyObject *source_gen = __Pyx__Coroutine_GetAwaitableIter(source);
    if (unlikely(!source_gen)) {
        return NULL;
    }
    if (__Pyx_Coroutine_CheckExact(source_gen)) {
        retval = __Pyx_Generator_Next(source_gen);
    } else {
#if CYTHON_USE_TYPE_SLOTS
        retval = Py_TYPE(source_gen)->tp_iternext(source_gen);
#else
        retval = PyIter_Next(source_gen);
#endif
    }
    if (retval) {
        gen->yieldfrom = source_gen;
        return retval;
    }
    Py_DECREF(source_gen);
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_Coroutine_Yield_From(__pyx_CoroutineObject *gen, PyObject *source) {
    PyObject *retval;
    if (__Pyx_Coroutine_CheckExact(source)) {
        if (unlikely(((__pyx_CoroutineObject*)source)->yieldfrom)) {
            PyErr_SetString(
                PyExc_RuntimeError,
                "coroutine is being awaited already");
            return NULL;
        }
        retval = __Pyx_Generator_Next(source);
#ifdef __Pyx_AsyncGen_USED
    } else if (__pyx_PyAsyncGenASend_CheckExact(source)) {
        retval = __Pyx_async_gen_asend_iternext(source);
#endif
    } else {
        return __Pyx__Coroutine_Yield_From_Generic(gen, source);
    }
    if (retval) {
        Py_INCREF(source);
        gen->yieldfrom = source;
    }
    return retval;
}

/* 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) || PyExceptionInstance_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;
    }
    #if CYTHON_FAST_THREAD_STATE
    __Pyx_PyThreadState_assign
    #if PY_VERSION_HEX >= 0x030700A2
    if (!__pyx_tstate->exc_state.exc_type)
    #else
    if (!__pyx_tstate->exc_type)
    #endif
    {
        Py_INCREF(PyExc_StopIteration);
        __Pyx_ErrRestore(PyExc_StopIteration, exc, NULL);
        return;
    }
    #endif
#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);
}

/* CythonFunction */
          static PyObject *
__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
{
    if (unlikely(op->func_doc == NULL)) {
        if (op->func.m_ml->ml_doc) {
#if PY_MAJOR_VERSION >= 3
            op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
#else
            op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
#endif
            if (unlikely(op->func_doc == NULL))
                return NULL;
        } else {
            Py_INCREF(Py_None);
            return Py_None;
        }
    }
    Py_INCREF(op->func_doc);
    return op->func_doc;
}
static int
__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp = op->func_doc;
    if (value == NULL) {
        value = Py_None;
    }
    Py_INCREF(value);
    op->func_doc = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
{
    if (unlikely(op->func_name == NULL)) {
#if PY_MAJOR_VERSION >= 3
        op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
#else
        op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
#endif
        if (unlikely(op->func_name == NULL))
            return NULL;
    }
    Py_INCREF(op->func_name);
    return op->func_name;
}
static int
__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, 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 = op->func_name;
    Py_INCREF(value);
    op->func_name = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
{
    Py_INCREF(op->func_qualname);
    return op->func_qualname;
}
static int
__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, 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 = op->func_qualname;
    Py_INCREF(value);
    op->func_qualname = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
{
    PyObject *self;
    self = m->func_closure;
    if (self == NULL)
        self = Py_None;
    Py_INCREF(self);
    return self;
}
static PyObject *
__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
{
    if (unlikely(op->func_dict == NULL)) {
        op->func_dict = PyDict_New();
        if (unlikely(op->func_dict == NULL))
            return NULL;
    }
    Py_INCREF(op->func_dict);
    return op->func_dict;
}
static int
__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
    if (unlikely(value == NULL)) {
        PyErr_SetString(PyExc_TypeError,
               "function's dictionary may not be deleted");
        return -1;
    }
    if (unlikely(!PyDict_Check(value))) {
        PyErr_SetString(PyExc_TypeError,
               "setting function's dictionary to a non-dict");
        return -1;
    }
    tmp = op->func_dict;
    Py_INCREF(value);
    op->func_dict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
{
    Py_INCREF(op->func_globals);
    return op->func_globals;
}
static PyObject *
__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
{
    Py_INCREF(Py_None);
    return Py_None;
}
static PyObject *
__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
{
    PyObject* result = (op->func_code) ? op->func_code : Py_None;
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
    int result = 0;
    PyObject *res = op->defaults_getter((PyObject *) op);
    if (unlikely(!res))
        return -1;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
    Py_INCREF(op->defaults_tuple);
    op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
    Py_INCREF(op->defaults_kwdict);
    #else
    op->defaults_tuple = PySequence_ITEM(res, 0);
    if (unlikely(!op->defaults_tuple)) result = -1;
    else {
        op->defaults_kwdict = PySequence_ITEM(res, 1);
        if (unlikely(!op->defaults_kwdict)) result = -1;
    }
    #endif
    Py_DECREF(res);
    return result;
}
static int
__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyTuple_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__defaults__ must be set to a tuple object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_tuple;
    op->defaults_tuple = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
    PyObject* result = op->defaults_tuple;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_tuple;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__kwdefaults__ must be set to a dict object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_kwdict;
    op->defaults_kwdict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
    PyObject* result = op->defaults_kwdict;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_kwdict;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
    PyObject* tmp;
    if (!value || value == Py_None) {
        value = NULL;
    } else if (!PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__annotations__ must be set to a dict object");
        return -1;
    }
    Py_XINCREF(value);
    tmp = op->func_annotations;
    op->func_annotations = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
    PyObject* result = op->func_annotations;
    if (unlikely(!result)) {
        result = PyDict_New();
        if (unlikely(!result)) return NULL;
        op->func_annotations = result;
    }
    Py_INCREF(result);
    return result;
}
static PyGetSetDef __pyx_CyFunction_getsets[] = {
    {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "__doc__",  (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
    {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
    {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
    {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
    {0, 0, 0, 0, 0}
};
static PyMemberDef __pyx_CyFunction_members[] = {
    {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
    {0, 0, 0,  0, 0}
};
static PyObject *
__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromString(m->func.m_ml->ml_name);
#else
    return PyString_FromString(m->func.m_ml->ml_name);
#endif
}
static PyMethodDef __pyx_CyFunction_methods[] = {
    {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
    {0, 0, 0, 0}
};
#if PY_VERSION_HEX < 0x030500A0
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
#else
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
#endif
static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
                                      PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
    __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
    if (op == NULL)
        return NULL;
    op->flags = flags;
    __Pyx_CyFunction_weakreflist(op) = NULL;
    op->func.m_ml = ml;
    op->func.m_self = (PyObject *) op;
    Py_XINCREF(closure);
    op->func_closure = closure;
    Py_XINCREF(module);
    op->func.m_module = module;
    op->func_dict = NULL;
    op->func_name = NULL;
    Py_INCREF(qualname);
    op->func_qualname = qualname;
    op->func_doc = NULL;
    op->func_classobj = NULL;
    op->func_globals = globals;
    Py_INCREF(op->func_globals);
    Py_XINCREF(code);
    op->func_code = code;
    op->defaults_pyobjects = 0;
    op->defaults = NULL;
    op->defaults_tuple = NULL;
    op->defaults_kwdict = NULL;
    op->defaults_getter = NULL;
    op->func_annotations = NULL;
    PyObject_GC_Track(op);
    return (PyObject *) op;
}
static int
__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
{
    Py_CLEAR(m->func_closure);
    Py_CLEAR(m->func.m_module);
    Py_CLEAR(m->func_dict);
    Py_CLEAR(m->func_name);
    Py_CLEAR(m->func_qualname);
    Py_CLEAR(m->func_doc);
    Py_CLEAR(m->func_globals);
    Py_CLEAR(m->func_code);
    Py_CLEAR(m->func_classobj);
    Py_CLEAR(m->defaults_tuple);
    Py_CLEAR(m->defaults_kwdict);
    Py_CLEAR(m->func_annotations);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_XDECREF(pydefaults[i]);
        PyObject_Free(m->defaults);
        m->defaults = NULL;
    }
    return 0;
}
static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    if (__Pyx_CyFunction_weakreflist(m) != NULL)
        PyObject_ClearWeakRefs((PyObject *) m);
    __Pyx_CyFunction_clear(m);
    PyObject_GC_Del(m);
}
static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    PyObject_GC_UnTrack(m);
    __Pyx__CyFunction_dealloc(m);
}
static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
{
    Py_VISIT(m->func_closure);
    Py_VISIT(m->func.m_module);
    Py_VISIT(m->func_dict);
    Py_VISIT(m->func_name);
    Py_VISIT(m->func_qualname);
    Py_VISIT(m->func_doc);
    Py_VISIT(m->func_globals);
    Py_VISIT(m->func_code);
    Py_VISIT(m->func_classobj);
    Py_VISIT(m->defaults_tuple);
    Py_VISIT(m->defaults_kwdict);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_VISIT(pydefaults[i]);
    }
    return 0;
}
static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
{
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
        Py_INCREF(func);
        return func;
    }
    if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
        if (type == NULL)
            type = (PyObject *)(Py_TYPE(obj));
        return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
    }
    if (obj == Py_None)
        obj = NULL;
    return __Pyx_PyMethod_New(func, obj, type);
}
static PyObject*
__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromFormat("<cyfunction %U at %p>",
                                op->func_qualname, (void *)op);
#else
    return PyString_FromFormat("<cyfunction %s at %p>",
                               PyString_AsString(op->func_qualname), (void *)op);
#endif
}
static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
    PyCFunctionObject* f = (PyCFunctionObject*)func;
    PyCFunction meth = f->m_ml->ml_meth;
    Py_ssize_t size;
    switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
    case METH_VARARGS:
        if (likely(kw == NULL || PyDict_Size(kw) == 0))
            return (*meth)(self, arg);
        break;
    case METH_VARARGS | METH_KEYWORDS:
        return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
    case METH_NOARGS:
        if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
            size = PyTuple_GET_SIZE(arg);
            if (likely(size == 0))
                return (*meth)(self, NULL);
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    case METH_O:
        if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
            size = PyTuple_GET_SIZE(arg);
            if (likely(size == 1)) {
                PyObject *result, *arg0;
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                arg0 = PyTuple_GET_ITEM(arg, 0);
                #else
                arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
                #endif
                result = (*meth)(self, arg0);
                #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
                Py_DECREF(arg0);
                #endif
                return result;
            }
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    default:
        PyErr_SetString(PyExc_SystemError, "Bad call flags in "
                        "__Pyx_CyFunction_Call. METH_OLDARGS is no "
                        "longer supported!");
        return NULL;
    }
    PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
                 f->m_ml->ml_name);
    return NULL;
}
static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
}
static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
    PyObject *result;
    __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
    if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
        Py_ssize_t argc;
        PyObject *new_args;
        PyObject *self;
        argc = PyTuple_GET_SIZE(args);
        new_args = PyTuple_GetSlice(args, 1, argc);
        if (unlikely(!new_args))
            return NULL;
        self = PyTuple_GetItem(args, 0);
        if (unlikely(!self)) {
            Py_DECREF(new_args);
            return NULL;
        }
        result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
        Py_DECREF(new_args);
    } else {
        result = __Pyx_CyFunction_Call(func, args, kw);
    }
    return result;
}
static PyTypeObject __pyx_CyFunctionType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    "cython_function_or_method",
    sizeof(__pyx_CyFunctionObject),
    0,
    (destructor) __Pyx_CyFunction_dealloc,
    0,
    0,
    0,
#if PY_MAJOR_VERSION < 3
    0,
#else
    0,
#endif
    (reprfunc) __Pyx_CyFunction_repr,
    0,
    0,
    0,
    0,
    __Pyx_CyFunction_CallAsMethod,
    0,
    0,
    0,
    0,
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
    0,
    (traverseproc) __Pyx_CyFunction_traverse,
    (inquiry) __Pyx_CyFunction_clear,
    0,
#if PY_VERSION_HEX < 0x030500A0
    offsetof(__pyx_CyFunctionObject, func_weakreflist),
#else
    offsetof(PyCFunctionObject, m_weakreflist),
#endif
    0,
    0,
    __pyx_CyFunction_methods,
    __pyx_CyFunction_members,
    __pyx_CyFunction_getsets,
    0,
    0,
    __Pyx_CyFunction_descr_get,
    0,
    offsetof(__pyx_CyFunctionObject, func_dict),
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
#if PY_VERSION_HEX >= 0x030400a1
    0,
#endif
};
static int __pyx_CyFunction_init(void) {
    __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
    if (unlikely(__pyx_CyFunctionType == NULL)) {
        return -1;
    }
    return 0;
}
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults = PyObject_Malloc(size);
    if (unlikely(!m->defaults))
        return PyErr_NoMemory();
    memset(m->defaults, 0, size);
    m->defaults_pyobjects = pyobjects;
    return m->defaults;
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_tuple = tuple;
    Py_INCREF(tuple);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_kwdict = dict;
    Py_INCREF(dict);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->func_annotations = dict;
    Py_INCREF(dict);
}

/* 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_MAJOR_VERSION < 3
    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, '.')) {
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        #endif
        if (!module) {
            #if PY_MAJOR_VERSION < 3
            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_MAJOR_VERSION < 3
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    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;
}

/* 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;
}

/* SetupReduce */
              static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
  int ret;
  PyObject *name_attr;
  name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name_2);
  if (likely(name_attr)) {
      ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
  } else {
      ret = -1;
  }
  if (unlikely(ret < 0)) {
      PyErr_Clear();
      ret = 0;
  }
  Py_XDECREF(name_attr);
  return ret;
}
static int __Pyx_setup_reduce(PyObject* type_obj) {
    int ret = 0;
    PyObject *object_reduce = NULL;
    PyObject *object_reduce_ex = NULL;
    PyObject *reduce = NULL;
    PyObject *reduce_ex = NULL;
    PyObject *reduce_cython = NULL;
    PyObject *setstate = NULL;
    PyObject *setstate_cython = NULL;
#if CYTHON_USE_PYTYPE_LOOKUP
    if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD;
#else
    if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD;
#endif
#if CYTHON_USE_PYTYPE_LOOKUP
    object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
#else
    object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
#endif
    reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD;
    if (reduce_ex == object_reduce_ex) {
#if CYTHON_USE_PYTYPE_LOOKUP
        object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
#else
        object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
#endif
        reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD;
        if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
            reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD;
            ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD;
            ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD;
            setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
            if (!setstate) PyErr_Clear();
            if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
                setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD;
                ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD;
                ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD;
            }
            PyType_Modified((PyTypeObject*)type_obj);
        }
    }
    goto GOOD;
BAD:
    if (!PyErr_Occurred())
        PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
    ret = -1;
GOOD:
#if !CYTHON_USE_PYTYPE_LOOKUP
    Py_XDECREF(object_reduce);
    Py_XDECREF(object_reduce_ex);
#endif
    Py_XDECREF(reduce);
    Py_XDECREF(reduce_ex);
    Py_XDECREF(reduce_cython);
    Py_XDECREF(setstate);
    Py_XDECREF(setstate_cython);
    return ret;
}

/* 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();
            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"
            );
        }
        Py_DECREF(package);
        if (unlikely(!patch_module)) goto ignore;
asyncio_done:
        PyErr_Clear();
        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;
}

/* 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;
}

/* CLineInTraceback */
              #ifndef CYTHON_CLINE_IN_TRACEBACK
static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
    PyObject *use_cline;
    PyObject *ptype, *pvalue, *ptraceback;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject **cython_runtime_dict;
#endif
    __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
#if CYTHON_COMPILING_IN_CPYTHON
    cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
    if (likely(cython_runtime_dict)) {
      use_cline = PyDict_GetItem(*cython_runtime_dict, __pyx_n_s_cline_in_traceback);
    } else
#endif
    {
      PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
      if (use_cline_obj) {
        use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
        Py_DECREF(use_cline_obj);
      } else {
        PyErr_Clear();
        use_cline = NULL;
      }
    }
    if (!use_cline) {
        c_line = 0;
        PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
    }
    else if (PyObject_Not(use_cline) != 0) {
        c_line = 0;
    }
    __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
    return c_line;
}
#endif

/* 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;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    if (c_line) {
        c_line = __Pyx_CLineForTraceback(tstate, c_line);
    }
    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(
        tstate,            /*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);
    }
}

/* 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);
    }
}

/* 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_enum____pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus value) {
    const enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus neg_one = (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) -1, const_zero = (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) <= 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_ConnectionStatus),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
              static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ResultType(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType value) {
    const enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType neg_one = (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) -1, const_zero = (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) <= 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_ResultType),
                                     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_enum____pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus value) {
    const enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus neg_one = (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) -1, const_zero = (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) <= 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_TransactionStatus),
                                     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);
    }
}

/* CIntToPy */
              static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat value) {
    const enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat neg_one = (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) -1, const_zero = (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) <= 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_ServerDataFormat),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
              static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat value) {
    const enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat neg_one = (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) -1, const_zero = (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) <= 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_ClientExchangeFormat),
                                     little, !is_unsigned);
    }
}

/* 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_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_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_PY_LONG_LONG(PY_LONG_LONG value) {
    const PY_LONG_LONG neg_one = (PY_LONG_LONG) -1, const_zero = (PY_LONG_LONG) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(PY_LONG_LONG) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(PY_LONG_LONG) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(PY_LONG_LONG) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(PY_LONG_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(PY_LONG_LONG),
                                     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_uint16_t(uint16_t value) {
    const uint16_t neg_one = (uint16_t) -1, const_zero = (uint16_t) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(uint16_t) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(uint16_t) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(uint16_t) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(uint16_t) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(uint16_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(uint16_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);
    }
}

/* 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 enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus __Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus(PyObject *x) {
    const enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus neg_one = (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) -1, const_zero = (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) 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_ConnectionStatus) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus, 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_ConnectionStatus) 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_ConnectionStatus) 0;
                case  1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus, digit, digits[0])
                case 2:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) >= 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) (((((enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus, 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_ConnectionStatus) >= 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) (((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus, 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_ConnectionStatus) >= 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) (((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)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_ConnectionStatus) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus, 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_ConnectionStatus) 0;
                case -1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) - 1 > 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) (((enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)-1)*(((((enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) - 1 > 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) ((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus, 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_ConnectionStatus) - 1 > 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) (((enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)-1)*(((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus, 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_ConnectionStatus) - 1 > 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) ((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus, 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_ConnectionStatus) - 1 > 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) (((enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)-1)*(((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus, 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_ConnectionStatus) - 1 > 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) ((((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus, 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_ConnectionStatus 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_ConnectionStatus) -1;
        }
    } else {
        enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) -1;
        val = __Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus");
    return (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus");
    return (enum __pyx_t_7asyncpg_8protocol_8protocol_ConnectionStatus) -1;
}

/* CIntFromPy */
              static CYTHON_INLINE enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType __Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ResultType(PyObject *x) {
    const enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType neg_one = (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) -1, const_zero = (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) 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_ResultType) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType, 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_ResultType) 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_ResultType) 0;
                case  1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType, digit, digits[0])
                case 2:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) >= 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) (((((enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType, 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_ResultType) >= 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) (((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType, 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_ResultType) >= 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) (((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)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_ResultType) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType, 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_ResultType) 0;
                case -1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) - 1 > 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) (((enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)-1)*(((((enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) - 1 > 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) ((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType, 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_ResultType) - 1 > 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) (((enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)-1)*(((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType, 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_ResultType) - 1 > 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) ((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType, 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_ResultType) - 1 > 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) (((enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)-1)*(((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType, 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_ResultType) - 1 > 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) ((((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType, 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_ResultType 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_ResultType) -1;
        }
    } else {
        enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) -1;
        val = __Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ResultType(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType");
    return (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType");
    return (enum __pyx_t_7asyncpg_8protocol_8protocol_ResultType) -1;
}

/* CIntFromPy */
              static CYTHON_INLINE enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState __Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ProtocolState(PyObject *x) {
    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 PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState, 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_ProtocolState) 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_ProtocolState) 0;
                case  1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState, digit, digits[0])
                case 2:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) >= 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) (((((enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState, 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_ProtocolState) >= 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) (((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState, 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_ProtocolState) >= 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) (((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)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_ProtocolState) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState, 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_ProtocolState) 0;
                case -1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) - 1 > 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) (((enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)-1)*(((((enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) - 1 > 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) ((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState, 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_ProtocolState) - 1 > 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) (((enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)-1)*(((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState, 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_ProtocolState) - 1 > 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) ((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState, 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_ProtocolState) - 1 > 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) (((enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)-1)*(((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState, 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_ProtocolState) - 1 > 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) ((((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState, 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_ProtocolState 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_ProtocolState) -1;
        }
    } else {
        enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) -1;
        val = __Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ProtocolState(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState");
    return (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState");
    return (enum __pyx_t_7asyncpg_8protocol_8protocol_ProtocolState) -1;
}

/* CIntFromPy */
              static CYTHON_INLINE enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus __Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus(PyObject *x) {
    const enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus neg_one = (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) -1, const_zero = (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) 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_TransactionStatus) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus, 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_TransactionStatus) 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_TransactionStatus) 0;
                case  1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus, digit, digits[0])
                case 2:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) >= 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) (((((enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus, 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_TransactionStatus) >= 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) (((((((enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus, 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_TransactionStatus) >= 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) (((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)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_TransactionStatus) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus, 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_TransactionStatus) 0;
                case -1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) - 1 > 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) (((enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)-1)*(((((enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) - 1 > 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) ((((((enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus, 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_TransactionStatus) - 1 > 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) (((enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)-1)*(((((((enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus, 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_TransactionStatus) - 1 > 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) ((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus, 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_TransactionStatus) - 1 > 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) (((enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)-1)*(((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus, 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_TransactionStatus) - 1 > 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) ((((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus, 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_TransactionStatus 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_TransactionStatus) -1;
        }
    } else {
        enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) -1;
        val = __Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus");
    return (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus");
    return (enum __pyx_t_7asyncpg_8protocol_8protocol_TransactionStatus) -1;
}

/* CIntFromPy */
              static CYTHON_INLINE uint64_t __Pyx_PyInt_As_uint64_t(PyObject *x) {
    const uint64_t neg_one = (uint64_t) -1, const_zero = (uint64_t) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(uint64_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(uint64_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (uint64_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 (uint64_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(uint64_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(uint64_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint64_t) >= 2 * PyLong_SHIFT) {
                            return (uint64_t) (((((uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(uint64_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint64_t) >= 3 * PyLong_SHIFT) {
                            return (uint64_t) (((((((uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(uint64_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_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(uint64_t) >= 4 * PyLong_SHIFT) {
                            return (uint64_t) (((((((((uint64_t)digits[3]) << PyLong_SHIFT) | (uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_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 (uint64_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(uint64_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint64_t, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(uint64_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint64_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 (uint64_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(uint64_t, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(uint64_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(uint64_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint64_t) - 1 > 2 * PyLong_SHIFT) {
                            return (uint64_t) (((uint64_t)-1)*(((((uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(uint64_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint64_t) - 1 > 2 * PyLong_SHIFT) {
                            return (uint64_t) ((((((uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(uint64_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint64_t) - 1 > 3 * PyLong_SHIFT) {
                            return (uint64_t) (((uint64_t)-1)*(((((((uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(uint64_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint64_t) - 1 > 3 * PyLong_SHIFT) {
                            return (uint64_t) ((((((((uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(uint64_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_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(uint64_t) - 1 > 4 * PyLong_SHIFT) {
                            return (uint64_t) (((uint64_t)-1)*(((((((((uint64_t)digits[3]) << PyLong_SHIFT) | (uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(uint64_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_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(uint64_t) - 1 > 4 * PyLong_SHIFT) {
                            return (uint64_t) ((((((((((uint64_t)digits[3]) << PyLong_SHIFT) | (uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(uint64_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint64_t, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(uint64_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint64_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
            uint64_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 (uint64_t) -1;
        }
    } else {
        uint64_t val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (uint64_t) -1;
        val = __Pyx_PyInt_As_uint64_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to uint64_t");
    return (uint64_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to uint64_t");
    return (uint64_t) -1;
}

/* 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_ServerDataFormat __Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(PyObject *x) {
    const enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat neg_one = (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) -1, const_zero = (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) 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_ServerDataFormat) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat, 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_ServerDataFormat) 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_ServerDataFormat) 0;
                case  1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat, digit, digits[0])
                case 2:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) >= 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) (((((enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat, 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_ServerDataFormat) >= 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) (((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat, 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_ServerDataFormat) >= 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) (((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)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_ServerDataFormat) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat, 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_ServerDataFormat) 0;
                case -1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) - 1 > 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) (((enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)-1)*(((((enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) - 1 > 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) ((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat, 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_ServerDataFormat) - 1 > 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) (((enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)-1)*(((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat, 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_ServerDataFormat) - 1 > 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) ((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat, 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_ServerDataFormat) - 1 > 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) (((enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)-1)*(((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat, 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_ServerDataFormat) - 1 > 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) ((((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat, 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_ServerDataFormat 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_ServerDataFormat) -1;
        }
    } else {
        enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) -1;
        val = __Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat");
    return (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat");
    return (enum __pyx_t_7asyncpg_8protocol_8protocol_ServerDataFormat) -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 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;
}

/* CIntFromPy */
              static CYTHON_INLINE enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat __Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat(PyObject *x) {
    const enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat neg_one = (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) -1, const_zero = (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) 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_ClientExchangeFormat) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat, 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_ClientExchangeFormat) 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_ClientExchangeFormat) 0;
                case  1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat, digit, digits[0])
                case 2:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) >= 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) (((((enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat, 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_ClientExchangeFormat) >= 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) (((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat, 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_ClientExchangeFormat) >= 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) (((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)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_ClientExchangeFormat) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat, 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_ClientExchangeFormat) 0;
                case -1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) - 1 > 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) (((enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)-1)*(((((enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) - 1 > 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) ((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat, 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_ClientExchangeFormat) - 1 > 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) (((enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)-1)*(((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat, 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_ClientExchangeFormat) - 1 > 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) ((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat, 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_ClientExchangeFormat) - 1 > 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) (((enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)-1)*(((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat, 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_ClientExchangeFormat) - 1 > 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) ((((((((((enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat, 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_ClientExchangeFormat 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_ClientExchangeFormat) -1;
        }
    } else {
        enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) -1;
        val = __Pyx_PyInt_As_enum____pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat");
    return (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat");
    return (enum __pyx_t_7asyncpg_8protocol_8protocol_ClientExchangeFormat) -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 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;
}

/* 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;
}

/* 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;
}

/* FastTypeChecks */
              #if CYTHON_COMPILING_IN_CPYTHON
static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
    while (a) {
        a = a->tp_base;
        if (a == b)
            return 1;
    }
    return b == &PyBaseObject_Type;
}
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
    PyObject *mro;
    if (a == b) return 1;
    mro = a->tp_mro;
    if (likely(mro)) {
        Py_ssize_t i, n;
        n = PyTuple_GET_SIZE(mro);
        for (i = 0; i < n; i++) {
            if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
                return 1;
        }
        return 0;
    }
    return __Pyx_InBases(a, b);
}
#if PY_MAJOR_VERSION == 2
static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
    PyObject *exception, *value, *tb;
    int res;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&exception, &value, &tb);
    res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
    if (unlikely(res == -1)) {
        PyErr_WriteUnraisable(err);
        res = 0;
    }
    if (!res) {
        res = PyObject_IsSubclass(err, exc_type2);
        if (unlikely(res == -1)) {
            PyErr_WriteUnraisable(err);
            res = 0;
        }
    }
    __Pyx_ErrRestore(exception, value, tb);
    return res;
}
#else
static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
    int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
    if (!res) {
        res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
    }
    return res;
}
#endif
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
    if (likely(err == exc_type)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
    }
    return PyErr_GivenExceptionMatches(err, exc_type);
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
    if (likely(err == exc_type1 || err == exc_type2)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
    }
    return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
}
#endif

/* 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 CYTHON_USE_TP_FINALIZE
    0,
#else
    __Pyx_Coroutine_del,
#endif
    0,
#if CYTHON_USE_TP_FINALIZE
    __Pyx_Coroutine_del,
#elif PY_VERSION_HEX >= 0x030400a1
    0,
#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;
        if (PyObject_Hash(*t->p) == -1)
            PyErr_Clear();
        ++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 const char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
#if !CYTHON_PEP393_ENABLED
static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    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
static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    if (likely(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
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if __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)) {
        return __Pyx_PyUnicode_AsStringAndSize(o, length);
    } 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 PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
#if PY_MAJOR_VERSION >= 3
    if (PyLong_Check(result)) {
        if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
                "__int__ returned non-int (type %.200s).  "
                "The ability to return an instance of a strict subclass of int "
                "is deprecated, and may be removed in a future version of Python.",
                Py_TYPE(result)->tp_name)) {
            Py_DECREF(result);
            return NULL;
        }
        return result;
    }
#endif
    PyErr_Format(PyExc_TypeError,
                 "__%.4s__ returned non-%.4s (type %.200s)",
                 type_name, type_name, Py_TYPE(result)->tp_name);
    Py_DECREF(result);
    return NULL;
}
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 (likely(PyInt_Check(x) || PyLong_Check(x)))
#else
  if (likely(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 = m->nb_int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = m->nb_long(x);
  }
  #else
  if (likely(m && m->nb_int)) {
    name = "int";
    res = m->nb_int(x);
  }
  #endif
#else
  if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
    res = PyNumber_Int(x);
  }
#endif
  if (likely(res)) {
#if PY_MAJOR_VERSION < 3
    if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
#else
    if (unlikely(!PyLong_CheckExact(res))) {
#endif
        return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
    }
  }
  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 */
