Ejemplo n.º 1
0
static PyObject *
psyco_lobj_truncate(lobjectObject *self, PyObject *args)
{
    long len = 0;

    if (!PyArg_ParseTuple(args, "|l", &len))
        return NULL;

    EXC_IF_LOBJ_CLOSED(self);
    EXC_IF_LOBJ_LEVEL0(self);
    EXC_IF_LOBJ_UNMARKED(self);

#ifdef HAVE_LO64
    if (len > INT_MAX && self->conn->server_version < 90300) {
        PyErr_Format(NotSupportedError,
            "len out of range (%ld): server version %d "
            "does not support the lobject 64 API",
            len, self->conn->server_version);
        return NULL;
    }
#else
    if (len > INT_MAX) {
        PyErr_Format(InterfaceError,
            "len out of range (%ld): this psycopg version was not built "
            "with lobject 64 API support",
            len);
        return NULL;
    }
#endif

    if (lobject_truncate(self, len) < 0)
        return NULL;

    Py_RETURN_NONE;
}
Ejemplo n.º 2
0
static PyObject *
psyco_lobj_truncate(lobjectObject *self, PyObject *args)
{
    int len = 0;

    if (!PyArg_ParseTuple(args, "|i", &len))
        return NULL;

    EXC_IF_LOBJ_CLOSED(self);
    EXC_IF_LOBJ_LEVEL0(self);
    EXC_IF_LOBJ_UNMARKED(self);

    if (lobject_truncate(self, len) < 0)
        return NULL;

    Py_RETURN_NONE;
}