23
23
* License for more details.
26
#define PY_SSIZE_T_CLEAN
30
26
#define PSYCOPG_MODULE
31
#include "psycopg/config.h"
32
27
#include "psycopg/psycopg.h"
33
29
#include "psycopg/cursor.h"
34
30
#include "psycopg/pqpath.h"
31
#include "psycopg/typecast.h"
33
/* curs_get_cast - return the type caster for an oid.
35
* Return the most specific type caster, from cursor to connection to global.
36
* If no type caster is found, return the default one.
38
* Return a borrowed reference.
42
curs_get_cast(cursorObject *self, PyObject *oid)
47
if (self->string_types != NULL && self->string_types != Py_None) {
48
cast = PyDict_GetItem(self->string_types, oid);
49
Dprintf("curs_get_cast: per-cursor dict: %p", cast);
50
if (cast) { return cast; }
53
/* connection lookup */
54
cast = PyDict_GetItem(self->conn->string_types, oid);
55
Dprintf("curs_get_cast: per-connection dict: %p", cast);
56
if (cast) { return cast; }
59
cast = PyDict_GetItem(psyco_types, oid);
60
Dprintf("curs_get_cast: global dict: %p", cast);
61
if (cast) { return cast; }
64
return psyco_default_cast;
36
70
/* curs_reset - reset the cursor to a clean state */