Several function names shortened

There's not so much need for a strict convention for static functions.
Leaving some 'psyco_' prefix when the internal function and the
python-exposed function clashed.
This commit is contained in:
Daniele Varrazzo 2019-03-17 18:33:15 +00:00
parent a5c0a2215e
commit e4d365705a
18 changed files with 231 additions and 234 deletions

View File

@ -36,7 +36,7 @@
RAISES_NEG int RAISES_NEG int
psyco_adapter_datetime_init(void) adapter_datetime_init(void)
{ {
PyDateTime_IMPORT; PyDateTime_IMPORT;

View File

@ -45,7 +45,7 @@ typedef struct {
} pydatetimeObject; } pydatetimeObject;
RAISES_NEG HIDDEN int psyco_adapter_datetime_init(void); RAISES_NEG HIDDEN int adapter_datetime_init(void);
HIDDEN PyObject *psyco_Date(PyObject *module, PyObject *args); HIDDEN PyObject *psyco_Date(PyObject *module, PyObject *args);
#define psyco_Date_doc \ #define psyco_Date_doc \

View File

@ -112,10 +112,10 @@ psyco_conn_cursor(connectionObject *self, PyObject *args, PyObject *kwargs)
goto exit; goto exit;
} }
if (0 > psyco_curs_withhold_set((cursorObject *)obj, withhold)) { if (0 > curs_withhold_set((cursorObject *)obj, withhold)) {
goto exit; goto exit;
} }
if (0 > psyco_curs_scrollable_set((cursorObject *)obj, scrollable)) { if (0 > curs_scrollable_set((cursorObject *)obj, scrollable)) {
goto exit; goto exit;
} }

View File

@ -93,9 +93,9 @@ struct cursorObject {
/* C-callable functions in cursor_int.c and cursor_type.c */ /* C-callable functions in cursor_int.c and cursor_type.c */
BORROWED HIDDEN PyObject *curs_get_cast(cursorObject *self, PyObject *oid); BORROWED HIDDEN PyObject *curs_get_cast(cursorObject *self, PyObject *oid);
HIDDEN void curs_reset(cursorObject *self); HIDDEN void curs_reset(cursorObject *self);
RAISES_NEG HIDDEN int psyco_curs_withhold_set(cursorObject *self, PyObject *pyvalue); RAISES_NEG HIDDEN int curs_withhold_set(cursorObject *self, PyObject *pyvalue);
RAISES_NEG HIDDEN int psyco_curs_scrollable_set(cursorObject *self, PyObject *pyvalue); RAISES_NEG HIDDEN int curs_scrollable_set(cursorObject *self, PyObject *pyvalue);
HIDDEN PyObject *psyco_curs_validate_sql_basic(cursorObject *self, PyObject *sql); HIDDEN PyObject *curs_validate_sql_basic(cursorObject *self, PyObject *sql);
HIDDEN void curs_set_result(cursorObject *self, PGresult *pgres); HIDDEN void curs_set_result(cursorObject *self, PGresult *pgres);
/* exception-raising macros */ /* exception-raising macros */

View File

@ -108,7 +108,7 @@ exit:
* after having set an exception. * after having set an exception.
*/ */
PyObject * PyObject *
psyco_curs_validate_sql_basic(cursorObject *self, PyObject *sql) curs_validate_sql_basic(cursorObject *self, PyObject *sql)
{ {
PyObject *rv = NULL; PyObject *rv = NULL;
PyObject *comp = NULL; PyObject *comp = NULL;

View File

@ -43,11 +43,11 @@
/* close method - close the cursor */ /* close method - close the cursor */
#define psyco_curs_close_doc \ #define curs_close_doc \
"close() -- Close the cursor." "close() -- Close the cursor."
static PyObject * static PyObject *
psyco_curs_close(cursorObject *self, PyObject *dummy) curs_close(cursorObject *self, PyObject *dummy)
{ {
PyObject *rv = NULL; PyObject *rv = NULL;
char *lname = NULL; char *lname = NULL;
@ -110,7 +110,7 @@ close:
CLEARPGRES(self->pgres); CLEARPGRES(self->pgres);
self->closed = 1; self->closed = 1;
Dprintf("psyco_curs_close: cursor at %p closed", self); Dprintf("curs_close: cursor at %p closed", self);
rv = Py_None; rv = Py_None;
Py_INCREF(rv); Py_INCREF(rv);
@ -335,7 +335,7 @@ _psyco_curs_merge_query_args(cursorObject *self,
PyErr_Fetch(&err, &arg, &trace); PyErr_Fetch(&err, &arg, &trace);
if (err && PyErr_GivenExceptionMatches(err, PyExc_TypeError)) { if (err && PyErr_GivenExceptionMatches(err, PyExc_TypeError)) {
Dprintf("psyco_curs_execute: TypeError exception caught"); Dprintf("curs_execute: TypeError exception caught");
PyErr_NormalizeException(&err, &arg, &trace); PyErr_NormalizeException(&err, &arg, &trace);
if (PyObject_HasAttrString(arg, "args")) { if (PyObject_HasAttrString(arg, "args")) {
@ -343,11 +343,11 @@ _psyco_curs_merge_query_args(cursorObject *self,
PyObject *str = PySequence_GetItem(args, 0); PyObject *str = PySequence_GetItem(args, 0);
const char *s = Bytes_AS_STRING(str); const char *s = Bytes_AS_STRING(str);
Dprintf("psyco_curs_execute: -> %s", s); Dprintf("curs_execute: -> %s", s);
if (!strcmp(s, "not enough arguments for format string") if (!strcmp(s, "not enough arguments for format string")
|| !strcmp(s, "not all arguments converted")) { || !strcmp(s, "not all arguments converted")) {
Dprintf("psyco_curs_execute: -> got a match"); Dprintf("curs_execute: -> got a match");
psyco_set_error(ProgrammingError, self, s); psyco_set_error(ProgrammingError, self, s);
pe = 1; pe = 1;
} }
@ -369,7 +369,7 @@ _psyco_curs_merge_query_args(cursorObject *self,
return fquery; return fquery;
} }
#define psyco_curs_execute_doc \ #define curs_execute_doc \
"execute(query, vars=None) -- Execute query with bound vars." "execute(query, vars=None) -- Execute query with bound vars."
RAISES_NEG static int RAISES_NEG static int
@ -382,13 +382,13 @@ _psyco_curs_execute(cursorObject *self,
PyObject *fquery = NULL, *cvt = NULL; PyObject *fquery = NULL, *cvt = NULL;
/* query becomes NULL or refcount +1, so good to XDECREF at the end */ /* query becomes NULL or refcount +1, so good to XDECREF at the end */
if (!(query = psyco_curs_validate_sql_basic(self, query))) { if (!(query = curs_validate_sql_basic(self, query))) {
goto exit; goto exit;
} }
CLEARPGRES(self->pgres); CLEARPGRES(self->pgres);
Py_CLEAR(self->query); Py_CLEAR(self->query);
Dprintf("psyco_curs_execute: starting execution of new query"); Dprintf("curs_execute: starting execution of new query");
/* here we are, and we have a sequence or a dictionary filled with /* here we are, and we have a sequence or a dictionary filled with
objects to be substituted (bound variables). we try to be smart and do objects to be substituted (bound variables). we try to be smart and do
@ -444,7 +444,7 @@ _psyco_curs_execute(cursorObject *self,
/* At this point, the SQL statement must be str, not unicode */ /* At this point, the SQL statement must be str, not unicode */
tmp = pq_execute(self, Bytes_AS_STRING(self->query), async, no_result, 0); tmp = pq_execute(self, Bytes_AS_STRING(self->query), async, no_result, 0);
Dprintf("psyco_curs_execute: res = %d, pgres = %p", tmp, self->pgres); Dprintf("curs_execute: res = %d, pgres = %p", tmp, self->pgres);
if (tmp < 0) { goto exit; } if (tmp < 0) { goto exit; }
res = 0; /* Success */ res = 0; /* Success */
@ -458,7 +458,7 @@ exit:
} }
static PyObject * static PyObject *
psyco_curs_execute(cursorObject *self, PyObject *args, PyObject *kwargs) curs_execute(cursorObject *self, PyObject *args, PyObject *kwargs)
{ {
PyObject *vars = NULL, *operation = NULL; PyObject *vars = NULL, *operation = NULL;
@ -495,11 +495,11 @@ psyco_curs_execute(cursorObject *self, PyObject *args, PyObject *kwargs)
Py_RETURN_NONE; Py_RETURN_NONE;
} }
#define psyco_curs_executemany_doc \ #define curs_executemany_doc \
"executemany(query, vars_list) -- Execute many queries with bound vars." "executemany(query, vars_list) -- Execute many queries with bound vars."
static PyObject * static PyObject *
psyco_curs_executemany(cursorObject *self, PyObject *args, PyObject *kwargs) curs_executemany(cursorObject *self, PyObject *args, PyObject *kwargs)
{ {
PyObject *operation = NULL, *vars = NULL; PyObject *operation = NULL, *vars = NULL;
PyObject *v, *iter = NULL; PyObject *v, *iter = NULL;
@ -556,7 +556,7 @@ psyco_curs_executemany(cursorObject *self, PyObject *args, PyObject *kwargs)
} }
#define psyco_curs_mogrify_doc \ #define curs_mogrify_doc \
"mogrify(query, vars=None) -> str -- Return query after vars binding." "mogrify(query, vars=None) -> str -- Return query after vars binding."
static PyObject * static PyObject *
@ -565,10 +565,10 @@ _psyco_curs_mogrify(cursorObject *self,
{ {
PyObject *fquery = NULL, *cvt = NULL; PyObject *fquery = NULL, *cvt = NULL;
operation = psyco_curs_validate_sql_basic(self, operation); operation = curs_validate_sql_basic(self, operation);
if (operation == NULL) { goto cleanup; } if (operation == NULL) { goto cleanup; }
Dprintf("psyco_curs_mogrify: starting mogrify"); Dprintf("curs_mogrify: starting mogrify");
/* here we are, and we have a sequence or a dictionary filled with /* here we are, and we have a sequence or a dictionary filled with
objects to be substituted (bound variables). we try to be smart and do objects to be substituted (bound variables). we try to be smart and do
@ -586,7 +586,7 @@ _psyco_curs_mogrify(cursorObject *self,
goto cleanup; goto cleanup;
} }
Dprintf("psyco_curs_mogrify: cvt->refcnt = " FORMAT_CODE_PY_SSIZE_T Dprintf("curs_mogrify: cvt->refcnt = " FORMAT_CODE_PY_SSIZE_T
", fquery->refcnt = " FORMAT_CODE_PY_SSIZE_T, ", fquery->refcnt = " FORMAT_CODE_PY_SSIZE_T,
Py_REFCNT(cvt), Py_REFCNT(fquery)); Py_REFCNT(cvt), Py_REFCNT(fquery));
} }
@ -603,7 +603,7 @@ cleanup:
} }
static PyObject * static PyObject *
psyco_curs_mogrify(cursorObject *self, PyObject *args, PyObject *kwargs) curs_mogrify(cursorObject *self, PyObject *args, PyObject *kwargs)
{ {
PyObject *vars = NULL, *operation = NULL; PyObject *vars = NULL, *operation = NULL;
@ -619,7 +619,7 @@ psyco_curs_mogrify(cursorObject *self, PyObject *args, PyObject *kwargs)
/* cast method - convert an oid/string into a Python object */ /* cast method - convert an oid/string into a Python object */
#define psyco_curs_cast_doc \ #define curs_cast_doc \
"cast(oid, s) -> value\n\n" \ "cast(oid, s) -> value\n\n" \
"Convert the string s to a Python object according to its oid.\n\n" \ "Convert the string s to a Python object according to its oid.\n\n" \
"Look for a typecaster first in the cursor, then in its connection," \ "Look for a typecaster first in the cursor, then in its connection," \
@ -627,7 +627,7 @@ psyco_curs_mogrify(cursorObject *self, PyObject *args, PyObject *kwargs)
"leave the value as a string." "leave the value as a string."
static PyObject * static PyObject *
psyco_curs_cast(cursorObject *self, PyObject *args) curs_cast(cursorObject *self, PyObject *args)
{ {
PyObject *oid; PyObject *oid;
PyObject *s; PyObject *s;
@ -643,7 +643,7 @@ psyco_curs_cast(cursorObject *self, PyObject *args)
/* fetchone method - fetch one row of results */ /* fetchone method - fetch one row of results */
#define psyco_curs_fetchone_doc \ #define curs_fetchone_doc \
"fetchone() -> tuple or None\n\n" \ "fetchone() -> tuple or None\n\n" \
"Return the next row of a query result set in the form of a tuple (by\n" \ "Return the next row of a query result set in the form of a tuple (by\n" \
"default) or using the sequence factory previously set in the\n" \ "default) or using the sequence factory previously set in the\n" \
@ -744,7 +744,7 @@ exit:
} }
static PyObject * static PyObject *
psyco_curs_fetchone(cursorObject *self, PyObject *dummy) curs_fetchone(cursorObject *self, PyObject *dummy)
{ {
PyObject *res; PyObject *res;
@ -763,8 +763,8 @@ psyco_curs_fetchone(cursorObject *self, PyObject *dummy)
if (_psyco_curs_prefetch(self) < 0) return NULL; if (_psyco_curs_prefetch(self) < 0) return NULL;
} }
Dprintf("psyco_curs_fetchone: fetching row %ld", self->row); Dprintf("curs_fetchone: fetching row %ld", self->row);
Dprintf("psyco_curs_fetchone: rowcount = %ld", self->rowcount); Dprintf("curs_fetchone: rowcount = %ld", self->rowcount);
if (self->row >= self->rowcount) { if (self->row >= self->rowcount) {
/* we exausted available data: return None */ /* we exausted available data: return None */
@ -789,11 +789,11 @@ psyco_curs_fetchone(cursorObject *self, PyObject *dummy)
* Fetch several records at time. Return NULL when the cursor is exhausted. * Fetch several records at time. Return NULL when the cursor is exhausted.
*/ */
static PyObject * static PyObject *
psyco_curs_next_named(cursorObject *self) curs_next_named(cursorObject *self)
{ {
PyObject *res; PyObject *res;
Dprintf("psyco_curs_next_named"); Dprintf("curs_next_named");
EXC_IF_CURS_CLOSED(self); EXC_IF_CURS_CLOSED(self);
EXC_IF_ASYNC_IN_PROGRESS(self, next); EXC_IF_ASYNC_IN_PROGRESS(self, next);
if (_psyco_curs_prefetch(self) < 0) return NULL; if (_psyco_curs_prefetch(self) < 0) return NULL;
@ -802,8 +802,8 @@ psyco_curs_next_named(cursorObject *self)
EXC_IF_NO_MARK(self); EXC_IF_NO_MARK(self);
EXC_IF_TPC_PREPARED(self->conn, next); EXC_IF_TPC_PREPARED(self->conn, next);
Dprintf("psyco_curs_next_named: row %ld", self->row); Dprintf("curs_next_named: row %ld", self->row);
Dprintf("psyco_curs_next_named: rowcount = %ld", self->rowcount); Dprintf("curs_next_named: rowcount = %ld", self->rowcount);
if (self->row >= self->rowcount) { if (self->row >= self->rowcount) {
char buffer[128]; char buffer[128];
@ -834,7 +834,7 @@ psyco_curs_next_named(cursorObject *self)
/* fetch many - fetch some results */ /* fetch many - fetch some results */
#define psyco_curs_fetchmany_doc \ #define curs_fetchmany_doc \
"fetchmany(size=self.arraysize) -> list of tuple\n\n" \ "fetchmany(size=self.arraysize) -> list of tuple\n\n" \
"Return the next `size` rows of a query result set in the form of a list\n" \ "Return the next `size` rows of a query result set in the form of a list\n" \
"of tuples (by default) or using the sequence factory previously set in\n" \ "of tuples (by default) or using the sequence factory previously set in\n" \
@ -842,7 +842,7 @@ psyco_curs_next_named(cursorObject *self)
"Return an empty list when no more data is available.\n" "Return an empty list when no more data is available.\n"
static PyObject * static PyObject *
psyco_curs_fetchmany(cursorObject *self, PyObject *args, PyObject *kwords) curs_fetchmany(cursorObject *self, PyObject *args, PyObject *kwords)
{ {
int i; int i;
PyObject *list = NULL; PyObject *list = NULL;
@ -887,7 +887,7 @@ psyco_curs_fetchmany(cursorObject *self, PyObject *args, PyObject *kwords)
size = self->rowcount - self->row; size = self->rowcount - self->row;
} }
Dprintf("psyco_curs_fetchmany: size = %ld", size); Dprintf("curs_fetchmany: size = %ld", size);
if (size <= 0) { if (size <= 0) {
rv = PyList_New(0); rv = PyList_New(0);
@ -927,7 +927,7 @@ exit:
/* fetch all - fetch all results */ /* fetch all - fetch all results */
#define psyco_curs_fetchall_doc \ #define curs_fetchall_doc \
"fetchall() -> list of tuple\n\n" \ "fetchall() -> list of tuple\n\n" \
"Return all the remaining rows of a query result set.\n\n" \ "Return all the remaining rows of a query result set.\n\n" \
"Rows are returned in the form of a list of tuples (by default) or using\n" \ "Rows are returned in the form of a list of tuples (by default) or using\n" \
@ -935,7 +935,7 @@ exit:
"Return `!None` when no more data is available.\n" "Return `!None` when no more data is available.\n"
static PyObject * static PyObject *
psyco_curs_fetchall(cursorObject *self, PyObject *dummy) curs_fetchall(cursorObject *self, PyObject *dummy)
{ {
int i, size; int i, size;
PyObject *list = NULL; PyObject *list = NULL;
@ -996,11 +996,11 @@ exit:
/* callproc method - execute a stored procedure */ /* callproc method - execute a stored procedure */
#define psyco_curs_callproc_doc \ #define curs_callproc_doc \
"callproc(procname, parameters=None) -- Execute stored procedure." "callproc(procname, parameters=None) -- Execute stored procedure."
static PyObject * static PyObject *
psyco_curs_callproc(cursorObject *self, PyObject *args) curs_callproc(cursorObject *self, PyObject *args)
{ {
const char *procname = NULL; const char *procname = NULL;
char *sql = NULL; char *sql = NULL;
@ -1144,13 +1144,13 @@ exit:
/* nextset method - return the next set of data (not supported) */ /* nextset method - return the next set of data (not supported) */
#define psyco_curs_nextset_doc \ #define curs_nextset_doc \
"nextset() -- Skip to next set of data.\n\n" \ "nextset() -- Skip to next set of data.\n\n" \
"This method is not supported (PostgreSQL does not have multiple data \n" \ "This method is not supported (PostgreSQL does not have multiple data \n" \
"sets) and will raise a NotSupportedError exception." "sets) and will raise a NotSupportedError exception."
static PyObject * static PyObject *
psyco_curs_nextset(cursorObject *self, PyObject *dummy) curs_nextset(cursorObject *self, PyObject *dummy)
{ {
EXC_IF_CURS_CLOSED(self); EXC_IF_CURS_CLOSED(self);
@ -1161,12 +1161,12 @@ psyco_curs_nextset(cursorObject *self, PyObject *dummy)
/* setinputsizes - predefine memory areas for execute (does nothing) */ /* setinputsizes - predefine memory areas for execute (does nothing) */
#define psyco_curs_setinputsizes_doc \ #define curs_setinputsizes_doc \
"setinputsizes(sizes) -- Set memory areas before execute.\n\n" \ "setinputsizes(sizes) -- Set memory areas before execute.\n\n" \
"This method currently does nothing but it is safe to call it." "This method currently does nothing but it is safe to call it."
static PyObject * static PyObject *
psyco_curs_setinputsizes(cursorObject *self, PyObject *args) curs_setinputsizes(cursorObject *self, PyObject *args)
{ {
PyObject *sizes; PyObject *sizes;
@ -1181,12 +1181,12 @@ psyco_curs_setinputsizes(cursorObject *self, PyObject *args)
/* setoutputsize - predefine memory areas for execute (does nothing) */ /* setoutputsize - predefine memory areas for execute (does nothing) */
#define psyco_curs_setoutputsize_doc \ #define curs_setoutputsize_doc \
"setoutputsize(size, column=None) -- Set column buffer size.\n\n" \ "setoutputsize(size, column=None) -- Set column buffer size.\n\n" \
"This method currently does nothing but it is safe to call it." "This method currently does nothing but it is safe to call it."
static PyObject * static PyObject *
psyco_curs_setoutputsize(cursorObject *self, PyObject *args) curs_setoutputsize(cursorObject *self, PyObject *args)
{ {
long int size, column; long int size, column;
@ -1201,11 +1201,11 @@ psyco_curs_setoutputsize(cursorObject *self, PyObject *args)
/* scroll - scroll position in result list */ /* scroll - scroll position in result list */
#define psyco_curs_scroll_doc \ #define curs_scroll_doc \
"scroll(value, mode='relative') -- Scroll to new position according to mode." "scroll(value, mode='relative') -- Scroll to new position according to mode."
static PyObject * static PyObject *
psyco_curs_scroll(cursorObject *self, PyObject *args, PyObject *kwargs) curs_scroll(cursorObject *self, PyObject *args, PyObject *kwargs)
{ {
int value, newpos; int value, newpos;
const char *mode = "relative"; const char *mode = "relative";
@ -1263,21 +1263,21 @@ psyco_curs_scroll(cursorObject *self, PyObject *args, PyObject *kwargs)
} }
#define psyco_curs_enter_doc \ #define curs_enter_doc \
"__enter__ -> self" "__enter__ -> self"
static PyObject * static PyObject *
psyco_curs_enter(cursorObject *self, PyObject *dummy) curs_enter(cursorObject *self, PyObject *dummy)
{ {
Py_INCREF(self); Py_INCREF(self);
return (PyObject *)self; return (PyObject *)self;
} }
#define psyco_curs_exit_doc \ #define curs_exit_doc \
"__exit__ -- close the cursor" "__exit__ -- close the cursor"
static PyObject * static PyObject *
psyco_curs_exit(cursorObject *self, PyObject *args) curs_exit(cursorObject *self, PyObject *args)
{ {
PyObject *tmp = NULL; PyObject *tmp = NULL;
PyObject *rv = NULL; PyObject *rv = NULL;
@ -1379,11 +1379,11 @@ exit:
/* extension: copy_from - implements COPY FROM */ /* extension: copy_from - implements COPY FROM */
#define psyco_curs_copy_from_doc \ #define curs_copy_from_doc \
"copy_from(file, table, sep='\\t', null='\\\\N', size=8192, columns=None) -- Copy table from file." "copy_from(file, table, sep='\\t', null='\\\\N', size=8192, columns=None) -- Copy table from file."
static PyObject * static PyObject *
psyco_curs_copy_from(cursorObject *self, PyObject *args, PyObject *kwargs) curs_copy_from(cursorObject *self, PyObject *args, PyObject *kwargs)
{ {
static char *kwlist[] = { static char *kwlist[] = {
"file", "table", "sep", "null", "size", "columns", NULL}; "file", "table", "sep", "null", "size", "columns", NULL};
@ -1443,10 +1443,10 @@ psyco_curs_copy_from(cursorObject *self, PyObject *args, PyObject *kwargs)
PyOS_snprintf(query, query_size, command, PyOS_snprintf(query, query_size, command,
table_name, columnlist, quoted_delimiter, quoted_null); table_name, columnlist, quoted_delimiter, quoted_null);
Dprintf("psyco_curs_copy_from: query = %s", query); Dprintf("curs_copy_from: query = %s", query);
/* This routine stores a borrowed reference. Although it is only held /* This routine stores a borrowed reference. Although it is only held
* for the duration of psyco_curs_copy_from, nested invocations of * for the duration of curs_copy_from, nested invocations of
* Py_BEGIN_ALLOW_THREADS could surrender control to another thread, * Py_BEGIN_ALLOW_THREADS could surrender control to another thread,
* which could invoke the garbage collector. We thus need an * which could invoke the garbage collector. We thus need an
* INCREF/DECREF pair if we store this pointer in a GC object, such as * INCREF/DECREF pair if we store this pointer in a GC object, such as
@ -1473,11 +1473,11 @@ exit:
/* extension: copy_to - implements COPY TO */ /* extension: copy_to - implements COPY TO */
#define psyco_curs_copy_to_doc \ #define curs_copy_to_doc \
"copy_to(file, table, sep='\\t', null='\\\\N', columns=None) -- Copy table to file." "copy_to(file, table, sep='\\t', null='\\\\N', columns=None) -- Copy table to file."
static PyObject * static PyObject *
psyco_curs_copy_to(cursorObject *self, PyObject *args, PyObject *kwargs) curs_copy_to(cursorObject *self, PyObject *args, PyObject *kwargs)
{ {
static char *kwlist[] = {"file", "table", "sep", "null", "columns", NULL}; static char *kwlist[] = {"file", "table", "sep", "null", "columns", NULL};
@ -1535,7 +1535,7 @@ psyco_curs_copy_to(cursorObject *self, PyObject *args, PyObject *kwargs)
PyOS_snprintf(query, query_size, command, PyOS_snprintf(query, query_size, command,
table_name, columnlist, quoted_delimiter, quoted_null); table_name, columnlist, quoted_delimiter, quoted_null);
Dprintf("psyco_curs_copy_to: query = %s", query); Dprintf("curs_copy_to: query = %s", query);
self->copysize = 0; self->copysize = 0;
Py_INCREF(file); Py_INCREF(file);
@ -1563,7 +1563,7 @@ exit:
SQL statement, rather than composing the statement from parameters. SQL statement, rather than composing the statement from parameters.
*/ */
#define psyco_curs_copy_expert_doc \ #define curs_copy_expert_doc \
"copy_expert(sql, file, size=8192) -- Submit a user-composed COPY statement.\n" \ "copy_expert(sql, file, size=8192) -- Submit a user-composed COPY statement.\n" \
"`file` must be an open, readable file for COPY FROM or an open, writable\n" \ "`file` must be an open, readable file for COPY FROM or an open, writable\n" \
"file for COPY TO. The optional `size` argument, when specified for a COPY\n" \ "file for COPY TO. The optional `size` argument, when specified for a COPY\n" \
@ -1571,7 +1571,7 @@ exit:
"buffer size." "buffer size."
static PyObject * static PyObject *
psyco_curs_copy_expert(cursorObject *self, PyObject *args, PyObject *kwargs) curs_copy_expert(cursorObject *self, PyObject *args, PyObject *kwargs)
{ {
Py_ssize_t bufsize = DEFAULT_COPYBUFF; Py_ssize_t bufsize = DEFAULT_COPYBUFF;
PyObject *sql, *file, *res = NULL; PyObject *sql, *file, *res = NULL;
@ -1587,7 +1587,7 @@ psyco_curs_copy_expert(cursorObject *self, PyObject *args, PyObject *kwargs)
EXC_IF_GREEN(copy_expert); EXC_IF_GREEN(copy_expert);
EXC_IF_TPC_PREPARED(self->conn, copy_expert); EXC_IF_TPC_PREPARED(self->conn, copy_expert);
sql = psyco_curs_validate_sql_basic(self, sql); sql = curs_validate_sql_basic(self, sql);
/* Any failure from here forward should 'goto exit' rather than /* Any failure from here forward should 'goto exit' rather than
'return NULL' directly. */ 'return NULL' directly. */
@ -1630,28 +1630,28 @@ exit:
/* extension: closed - return true if cursor is closed */ /* extension: closed - return true if cursor is closed */
#define psyco_curs_closed_doc \ #define curs_closed_doc \
"True if cursor is closed, False if cursor is open" "True if cursor is closed, False if cursor is open"
static PyObject * static PyObject *
psyco_curs_get_closed(cursorObject *self, void *closure) curs_closed_get(cursorObject *self, void *closure)
{ {
return PyBool_FromLong(self->closed || (self->conn && self->conn->closed)); return PyBool_FromLong(self->closed || (self->conn && self->conn->closed));
} }
/* extension: withhold - get or set "WITH HOLD" for named cursors */ /* extension: withhold - get or set "WITH HOLD" for named cursors */
#define psyco_curs_withhold_doc \ #define curs_withhold_doc \
"Set or return cursor use of WITH HOLD" "Set or return cursor use of WITH HOLD"
static PyObject * static PyObject *
psyco_curs_withhold_get(cursorObject *self) curs_withhold_get(cursorObject *self)
{ {
return PyBool_FromLong(self->withhold); return PyBool_FromLong(self->withhold);
} }
RAISES_NEG int RAISES_NEG int
psyco_curs_withhold_set(cursorObject *self, PyObject *pyvalue) curs_withhold_set(cursorObject *self, PyObject *pyvalue)
{ {
int value; int value;
@ -1669,11 +1669,11 @@ psyco_curs_withhold_set(cursorObject *self, PyObject *pyvalue)
return 0; return 0;
} }
#define psyco_curs_scrollable_doc \ #define curs_scrollable_doc \
"Set or return cursor use of SCROLL" "Set or return cursor use of SCROLL"
static PyObject * static PyObject *
psyco_curs_scrollable_get(cursorObject *self) curs_scrollable_get(cursorObject *self)
{ {
PyObject *ret = NULL; PyObject *ret = NULL;
@ -1696,7 +1696,7 @@ psyco_curs_scrollable_get(cursorObject *self)
} }
RAISES_NEG int RAISES_NEG int
psyco_curs_scrollable_set(cursorObject *self, PyObject *pyvalue) curs_scrollable_set(cursorObject *self, PyObject *pyvalue)
{ {
int value; int value;
@ -1718,11 +1718,11 @@ psyco_curs_scrollable_set(cursorObject *self, PyObject *pyvalue)
} }
#define psyco_curs_pgresult_ptr_doc \ #define curs_pgresult_ptr_doc \
"pgresult_ptr -- Get the PGresult structure pointer." "pgresult_ptr -- Get the PGresult structure pointer."
static PyObject * static PyObject *
psyco_curs_pgresult_ptr_get(cursorObject *self) curs_pgresult_ptr_get(cursorObject *self)
{ {
if (self->pgres) { if (self->pgres) {
return PyLong_FromVoidPtr((void *)self->pgres); return PyLong_FromVoidPtr((void *)self->pgres);
@ -1751,8 +1751,8 @@ cursor_next(PyObject *self)
PyObject *res; PyObject *res;
if (NULL == ((cursorObject*)self)->name) { if (NULL == ((cursorObject*)self)->name) {
/* we don't parse arguments: psyco_curs_fetchone will do that for us */ /* we don't parse arguments: curs_fetchone will do that for us */
res = psyco_curs_fetchone((cursorObject*)self, NULL); res = curs_fetchone((cursorObject*)self, NULL);
/* convert a None to NULL to signal the end of iteration */ /* convert a None to NULL to signal the end of iteration */
if (res && res == Py_None) { if (res && res == Py_None) {
@ -1761,7 +1761,7 @@ cursor_next(PyObject *self)
} }
} }
else { else {
res = psyco_curs_next_named((cursorObject*)self); res = curs_next_named((cursorObject*)self);
} }
return res; return res;
@ -1771,44 +1771,44 @@ cursor_next(PyObject *self)
static struct PyMethodDef cursorObject_methods[] = { static struct PyMethodDef cursorObject_methods[] = {
/* DBAPI-2.0 core */ /* DBAPI-2.0 core */
{"close", (PyCFunction)psyco_curs_close, {"close", (PyCFunction)curs_close,
METH_NOARGS, psyco_curs_close_doc}, METH_NOARGS, curs_close_doc},
{"execute", (PyCFunction)psyco_curs_execute, {"execute", (PyCFunction)curs_execute,
METH_VARARGS|METH_KEYWORDS, psyco_curs_execute_doc}, METH_VARARGS|METH_KEYWORDS, curs_execute_doc},
{"executemany", (PyCFunction)psyco_curs_executemany, {"executemany", (PyCFunction)curs_executemany,
METH_VARARGS|METH_KEYWORDS, psyco_curs_executemany_doc}, METH_VARARGS|METH_KEYWORDS, curs_executemany_doc},
{"fetchone", (PyCFunction)psyco_curs_fetchone, {"fetchone", (PyCFunction)curs_fetchone,
METH_NOARGS, psyco_curs_fetchone_doc}, METH_NOARGS, curs_fetchone_doc},
{"fetchmany", (PyCFunction)psyco_curs_fetchmany, {"fetchmany", (PyCFunction)curs_fetchmany,
METH_VARARGS|METH_KEYWORDS, psyco_curs_fetchmany_doc}, METH_VARARGS|METH_KEYWORDS, curs_fetchmany_doc},
{"fetchall", (PyCFunction)psyco_curs_fetchall, {"fetchall", (PyCFunction)curs_fetchall,
METH_NOARGS, psyco_curs_fetchall_doc}, METH_NOARGS, curs_fetchall_doc},
{"callproc", (PyCFunction)psyco_curs_callproc, {"callproc", (PyCFunction)curs_callproc,
METH_VARARGS, psyco_curs_callproc_doc}, METH_VARARGS, curs_callproc_doc},
{"nextset", (PyCFunction)psyco_curs_nextset, {"nextset", (PyCFunction)curs_nextset,
METH_NOARGS, psyco_curs_nextset_doc}, METH_NOARGS, curs_nextset_doc},
{"setinputsizes", (PyCFunction)psyco_curs_setinputsizes, {"setinputsizes", (PyCFunction)curs_setinputsizes,
METH_VARARGS, psyco_curs_setinputsizes_doc}, METH_VARARGS, curs_setinputsizes_doc},
{"setoutputsize", (PyCFunction)psyco_curs_setoutputsize, {"setoutputsize", (PyCFunction)curs_setoutputsize,
METH_VARARGS, psyco_curs_setoutputsize_doc}, METH_VARARGS, curs_setoutputsize_doc},
/* DBAPI-2.0 extensions */ /* DBAPI-2.0 extensions */
{"scroll", (PyCFunction)psyco_curs_scroll, {"scroll", (PyCFunction)curs_scroll,
METH_VARARGS|METH_KEYWORDS, psyco_curs_scroll_doc}, METH_VARARGS|METH_KEYWORDS, curs_scroll_doc},
{"__enter__", (PyCFunction)psyco_curs_enter, {"__enter__", (PyCFunction)curs_enter,
METH_NOARGS, psyco_curs_enter_doc}, METH_NOARGS, curs_enter_doc},
{"__exit__", (PyCFunction)psyco_curs_exit, {"__exit__", (PyCFunction)curs_exit,
METH_VARARGS, psyco_curs_exit_doc}, METH_VARARGS, curs_exit_doc},
/* psycopg extensions */ /* psycopg extensions */
{"cast", (PyCFunction)psyco_curs_cast, {"cast", (PyCFunction)curs_cast,
METH_VARARGS, psyco_curs_cast_doc}, METH_VARARGS, curs_cast_doc},
{"mogrify", (PyCFunction)psyco_curs_mogrify, {"mogrify", (PyCFunction)curs_mogrify,
METH_VARARGS|METH_KEYWORDS, psyco_curs_mogrify_doc}, METH_VARARGS|METH_KEYWORDS, curs_mogrify_doc},
{"copy_from", (PyCFunction)psyco_curs_copy_from, {"copy_from", (PyCFunction)curs_copy_from,
METH_VARARGS|METH_KEYWORDS, psyco_curs_copy_from_doc}, METH_VARARGS|METH_KEYWORDS, curs_copy_from_doc},
{"copy_to", (PyCFunction)psyco_curs_copy_to, {"copy_to", (PyCFunction)curs_copy_to,
METH_VARARGS|METH_KEYWORDS, psyco_curs_copy_to_doc}, METH_VARARGS|METH_KEYWORDS, curs_copy_to_doc},
{"copy_expert", (PyCFunction)psyco_curs_copy_expert, {"copy_expert", (PyCFunction)curs_copy_expert,
METH_VARARGS|METH_KEYWORDS, psyco_curs_copy_expert_doc}, METH_VARARGS|METH_KEYWORDS, curs_copy_expert_doc},
{NULL} {NULL}
}; };
@ -1849,19 +1849,19 @@ static struct PyMemberDef cursorObject_members[] = {
/* object calculated member list */ /* object calculated member list */
static struct PyGetSetDef cursorObject_getsets[] = { static struct PyGetSetDef cursorObject_getsets[] = {
{ "closed", (getter)psyco_curs_get_closed, NULL, { "closed", (getter)curs_closed_get, NULL,
psyco_curs_closed_doc, NULL }, curs_closed_doc, NULL },
{ "withhold", { "withhold",
(getter)psyco_curs_withhold_get, (getter)curs_withhold_get,
(setter)psyco_curs_withhold_set, (setter)curs_withhold_set,
psyco_curs_withhold_doc, NULL }, curs_withhold_doc, NULL },
{ "scrollable", { "scrollable",
(getter)psyco_curs_scrollable_get, (getter)curs_scrollable_get,
(setter)psyco_curs_scrollable_set, (setter)curs_scrollable_set,
psyco_curs_scrollable_doc, NULL }, curs_scrollable_doc, NULL },
{ "pgresult_ptr", { "pgresult_ptr",
(getter)psyco_curs_pgresult_ptr_get, NULL, (getter)curs_pgresult_ptr_get, NULL,
psyco_curs_pgresult_ptr_doc, NULL }, curs_pgresult_ptr_doc, NULL },
{NULL} {NULL}
}; };

View File

@ -61,7 +61,7 @@
* If the cursor or its result isn't available, return None. * If the cursor or its result isn't available, return None.
*/ */
static PyObject * static PyObject *
psyco_diagnostics_get_field(diagnosticsObject *self, void *closure) diagnostics_get_field(diagnosticsObject *self, void *closure)
{ {
const char *errortext; const char *errortext;
@ -76,41 +76,41 @@ psyco_diagnostics_get_field(diagnosticsObject *self, void *closure)
/* object calculated member list */ /* object calculated member list */
static struct PyGetSetDef diagnosticsObject_getsets[] = { static struct PyGetSetDef diagnosticsObject_getsets[] = {
{ "severity", (getter)psyco_diagnostics_get_field, NULL, { "severity", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_SEVERITY }, NULL, (void*) PG_DIAG_SEVERITY },
{ "severity_nonlocalized", (getter)psyco_diagnostics_get_field, NULL, { "severity_nonlocalized", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_SEVERITY_NONLOCALIZED }, NULL, (void*) PG_DIAG_SEVERITY_NONLOCALIZED },
{ "sqlstate", (getter)psyco_diagnostics_get_field, NULL, { "sqlstate", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_SQLSTATE }, NULL, (void*) PG_DIAG_SQLSTATE },
{ "message_primary", (getter)psyco_diagnostics_get_field, NULL, { "message_primary", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_MESSAGE_PRIMARY }, NULL, (void*) PG_DIAG_MESSAGE_PRIMARY },
{ "message_detail", (getter)psyco_diagnostics_get_field, NULL, { "message_detail", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_MESSAGE_DETAIL }, NULL, (void*) PG_DIAG_MESSAGE_DETAIL },
{ "message_hint", (getter)psyco_diagnostics_get_field, NULL, { "message_hint", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_MESSAGE_HINT }, NULL, (void*) PG_DIAG_MESSAGE_HINT },
{ "statement_position", (getter)psyco_diagnostics_get_field, NULL, { "statement_position", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_STATEMENT_POSITION }, NULL, (void*) PG_DIAG_STATEMENT_POSITION },
{ "internal_position", (getter)psyco_diagnostics_get_field, NULL, { "internal_position", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_INTERNAL_POSITION }, NULL, (void*) PG_DIAG_INTERNAL_POSITION },
{ "internal_query", (getter)psyco_diagnostics_get_field, NULL, { "internal_query", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_INTERNAL_QUERY }, NULL, (void*) PG_DIAG_INTERNAL_QUERY },
{ "context", (getter)psyco_diagnostics_get_field, NULL, { "context", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_CONTEXT }, NULL, (void*) PG_DIAG_CONTEXT },
{ "schema_name", (getter)psyco_diagnostics_get_field, NULL, { "schema_name", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_SCHEMA_NAME }, NULL, (void*) PG_DIAG_SCHEMA_NAME },
{ "table_name", (getter)psyco_diagnostics_get_field, NULL, { "table_name", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_TABLE_NAME }, NULL, (void*) PG_DIAG_TABLE_NAME },
{ "column_name", (getter)psyco_diagnostics_get_field, NULL, { "column_name", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_COLUMN_NAME }, NULL, (void*) PG_DIAG_COLUMN_NAME },
{ "datatype_name", (getter)psyco_diagnostics_get_field, NULL, { "datatype_name", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_DATATYPE_NAME }, NULL, (void*) PG_DIAG_DATATYPE_NAME },
{ "constraint_name", (getter)psyco_diagnostics_get_field, NULL, { "constraint_name", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_CONSTRAINT_NAME }, NULL, (void*) PG_DIAG_CONSTRAINT_NAME },
{ "source_file", (getter)psyco_diagnostics_get_field, NULL, { "source_file", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_SOURCE_FILE }, NULL, (void*) PG_DIAG_SOURCE_FILE },
{ "source_line", (getter)psyco_diagnostics_get_field, NULL, { "source_line", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_SOURCE_LINE }, NULL, (void*) PG_DIAG_SOURCE_LINE },
{ "source_function", (getter)psyco_diagnostics_get_field, NULL, { "source_function", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_SOURCE_FUNCTION }, NULL, (void*) PG_DIAG_SOURCE_FUNCTION },
{NULL} {NULL}
}; };

View File

@ -229,7 +229,7 @@ static struct PyGetSetDef error_getsets[] = {
* would require implementing __getstate__, and as of 2012 it's a little * would require implementing __getstate__, and as of 2012 it's a little
* bit too late to care. */ * bit too late to care. */
static PyObject * static PyObject *
psyco_error_reduce(errorObject *self, PyObject *dummy) error_reduce(errorObject *self, PyObject *dummy)
{ {
PyObject *meth = NULL; PyObject *meth = NULL;
PyObject *tuple = NULL; PyObject *tuple = NULL;
@ -288,7 +288,7 @@ error:
} }
PyObject * PyObject *
psyco_error_setstate(errorObject *self, PyObject *state) error_setstate(errorObject *self, PyObject *state)
{ {
PyObject *rv = NULL; PyObject *rv = NULL;
@ -326,8 +326,8 @@ error:
static PyMethodDef error_methods[] = { static PyMethodDef error_methods[] = {
/* Make Error and all its subclasses picklable. */ /* Make Error and all its subclasses picklable. */
{"__reduce__", (PyCFunction)psyco_error_reduce, METH_NOARGS }, {"__reduce__", (PyCFunction)error_reduce, METH_NOARGS },
{"__setstate__", (PyCFunction)psyco_error_setstate, METH_O }, {"__setstate__", (PyCFunction)error_setstate, METH_O },
{NULL} {NULL}
}; };

View File

@ -36,33 +36,33 @@
/* getquoted - return quoted representation for object */ /* getquoted - return quoted representation for object */
#define psyco_isqlquote_getquoted_doc \ #define isqlquote_getquoted_doc \
"getquoted() -- return SQL-quoted representation of this object" "getquoted() -- return SQL-quoted representation of this object"
static PyObject * static PyObject *
psyco_isqlquote_getquoted(isqlquoteObject *self, PyObject *args) isqlquote_getquoted(isqlquoteObject *self, PyObject *args)
{ {
Py_RETURN_NONE; Py_RETURN_NONE;
} }
/* getbinary - return quoted representation for object */ /* getbinary - return quoted representation for object */
#define psyco_isqlquote_getbinary_doc \ #define isqlquote_getbinary_doc \
"getbinary() -- return SQL-quoted binary representation of this object" "getbinary() -- return SQL-quoted binary representation of this object"
static PyObject * static PyObject *
psyco_isqlquote_getbinary(isqlquoteObject *self, PyObject *args) isqlquote_getbinary(isqlquoteObject *self, PyObject *args)
{ {
Py_RETURN_NONE; Py_RETURN_NONE;
} }
/* getbuffer - return quoted representation for object */ /* getbuffer - return quoted representation for object */
#define psyco_isqlquote_getbuffer_doc \ #define isqlquote_getbuffer_doc \
"getbuffer() -- return this object" "getbuffer() -- return this object"
static PyObject * static PyObject *
psyco_isqlquote_getbuffer(isqlquoteObject *self, PyObject *args) isqlquote_getbuffer(isqlquoteObject *self, PyObject *args)
{ {
Py_RETURN_NONE; Py_RETURN_NONE;
} }
@ -75,14 +75,12 @@ psyco_isqlquote_getbuffer(isqlquoteObject *self, PyObject *args)
/* object method list */ /* object method list */
static struct PyMethodDef isqlquoteObject_methods[] = { static struct PyMethodDef isqlquoteObject_methods[] = {
{"getquoted", (PyCFunction)psyco_isqlquote_getquoted, {"getquoted", (PyCFunction)isqlquote_getquoted,
METH_NOARGS, psyco_isqlquote_getquoted_doc}, METH_NOARGS, isqlquote_getquoted_doc},
{"getbinary", (PyCFunction)psyco_isqlquote_getbinary, {"getbinary", (PyCFunction)isqlquote_getbinary,
METH_NOARGS, psyco_isqlquote_getbinary_doc}, METH_NOARGS, isqlquote_getbinary_doc},
{"getbuffer", (PyCFunction)psyco_isqlquote_getbuffer, {"getbuffer", (PyCFunction)isqlquote_getbuffer,
METH_NOARGS, psyco_isqlquote_getbuffer_doc}, METH_NOARGS, isqlquote_getbuffer_doc},
/* {"prepare", (PyCFunction)psyco_isqlquote_prepare,
METH_VARARGS, psyco_isqlquote_prepare_doc}, */
{NULL} {NULL}
}; };

View File

@ -76,11 +76,11 @@ HIDDEN PyObject *psyco_null = NULL;
#define str(s) #s #define str(s) #s
/** connect module-level function **/ /** connect module-level function **/
#define psyco_connect_doc \ #define connect_doc \
"_connect(dsn, [connection_factory], [async]) -- New database connection.\n\n" "_connect(dsn, [connection_factory], [async]) -- New database connection.\n\n"
static PyObject * static PyObject *
psyco_connect(PyObject *self, PyObject *args, PyObject *keywds) connect(PyObject *self, PyObject *args, PyObject *keywds)
{ {
PyObject *conn = NULL; PyObject *conn = NULL;
PyObject *factory = NULL; PyObject *factory = NULL;
@ -96,7 +96,7 @@ psyco_connect(PyObject *self, PyObject *args, PyObject *keywds)
if (async_) { async = async_; } if (async_) { async = async_; }
Dprintf("psyco_connect: dsn = '%s', async = %d", dsn, async); Dprintf("connect: dsn = '%s', async = %d", dsn, async);
/* allocate connection, fill with errors and return it */ /* allocate connection, fill with errors and return it */
if (factory == NULL || factory == Py_None) { if (factory == NULL || factory == Py_None) {
@ -120,11 +120,11 @@ psyco_connect(PyObject *self, PyObject *args, PyObject *keywds)
} }
#define psyco_parse_dsn_doc \ #define parse_dsn_doc \
"parse_dsn(dsn) -> dict -- parse a connection string into parameters" "parse_dsn(dsn) -> dict -- parse a connection string into parameters"
static PyObject * static PyObject *
psyco_parse_dsn(PyObject *self, PyObject *args, PyObject *kwargs) parse_dsn(PyObject *self, PyObject *args, PyObject *kwargs)
{ {
char *err = NULL; char *err = NULL;
PQconninfoOption *options = NULL; PQconninfoOption *options = NULL;
@ -159,14 +159,14 @@ exit:
} }
#define psyco_quote_ident_doc \ #define quote_ident_doc \
"quote_ident(str, conn_or_curs) -> str -- wrapper around PQescapeIdentifier\n\n" \ "quote_ident(str, conn_or_curs) -> str -- wrapper around PQescapeIdentifier\n\n" \
":Parameters:\n" \ ":Parameters:\n" \
" * `str`: A bytes or unicode object\n" \ " * `str`: A bytes or unicode object\n" \
" * `conn_or_curs`: A connection or cursor, required" " * `conn_or_curs`: A connection or cursor, required"
static PyObject * static PyObject *
psyco_quote_ident(PyObject *self, PyObject *args, PyObject *kwargs) quote_ident(PyObject *self, PyObject *args, PyObject *kwargs)
{ {
PyObject *ident = NULL, *obj = NULL, *result = NULL; PyObject *ident = NULL, *obj = NULL, *result = NULL;
connectionObject *conn; connectionObject *conn;
@ -205,7 +205,7 @@ exit:
} }
/** type registration **/ /** type registration **/
#define psyco_register_type_doc \ #define register_type_doc \
"register_type(obj, conn_or_curs) -> None -- register obj with psycopg type system\n\n" \ "register_type(obj, conn_or_curs) -> None -- register obj with psycopg type system\n\n" \
":Parameters:\n" \ ":Parameters:\n" \
" * `obj`: A type adapter created by `new_type()`\n" \ " * `obj`: A type adapter created by `new_type()`\n" \
@ -233,7 +233,7 @@ exit:
" * `baseobj`: Adapter to perform type conversion of a single array item." " * `baseobj`: Adapter to perform type conversion of a single array item."
static PyObject * static PyObject *
psyco_register_type(PyObject *self, PyObject *args) register_type(PyObject *self, PyObject *args)
{ {
PyObject *type, *obj = NULL; PyObject *type, *obj = NULL;
@ -271,7 +271,7 @@ psyco_register_type(PyObject *self, PyObject *args)
/* Make sure libcrypto thread callbacks are set up. */ /* Make sure libcrypto thread callbacks are set up. */
static void static void
psyco_libcrypto_threads_init(void) libcrypto_threads_init(void)
{ {
PyObject *m; PyObject *m;
@ -406,20 +406,20 @@ exit:
return rv; return rv;
} }
#define psyco_libpq_version_doc "Query actual libpq version loaded." #define libpq_version_doc "Query actual libpq version loaded."
static PyObject* static PyObject*
psyco_libpq_version(PyObject *self, PyObject *dummy) libpq_version(PyObject *self, PyObject *dummy)
{ {
return PyInt_FromLong(PQlibVersion()); return PyInt_FromLong(PQlibVersion());
} }
/* encrypt_password - Prepare the encrypted password form */ /* encrypt_password - Prepare the encrypted password form */
#define psyco_encrypt_password_doc \ #define encrypt_password_doc \
"encrypt_password(password, user, [scope], [algorithm]) -- Prepares the encrypted form of a PostgreSQL password.\n\n" "encrypt_password(password, user, [scope], [algorithm]) -- Prepares the encrypted form of a PostgreSQL password.\n\n"
static PyObject * static PyObject *
psyco_encrypt_password(PyObject *self, PyObject *args, PyObject *kwargs) encrypt_password(PyObject *self, PyObject *args, PyObject *kwargs)
{ {
char *encrypted = NULL; char *encrypted = NULL;
PyObject *password = NULL, *user = NULL; PyObject *password = NULL, *user = NULL;
@ -945,9 +945,9 @@ datetime_init(void)
/* Initialize the PyDateTimeAPI everywhere is used */ /* Initialize the PyDateTimeAPI everywhere is used */
PyDateTime_IMPORT; PyDateTime_IMPORT;
if (0 > psyco_adapter_datetime_init()) { return -1; } if (0 > adapter_datetime_init()) { return -1; }
if (0 > psyco_repl_curs_datetime_init()) { return -1; } if (0 > repl_curs_datetime_init()) { return -1; }
if (0 > psyco_replmsg_datetime_init()) { return -1; } if (0 > replmsg_datetime_init()) { return -1; }
Py_TYPE(&pydatetimeType) = &PyType_Type; Py_TYPE(&pydatetimeType) = &PyType_Type;
if (0 > PyType_Ready(&pydatetimeType)) { return -1; } if (0 > PyType_Ready(&pydatetimeType)) { return -1; }
@ -986,23 +986,23 @@ mxdatetime_init(PyObject *module)
/** method table and module initialization **/ /** method table and module initialization **/
static PyMethodDef psycopgMethods[] = { static PyMethodDef psycopgMethods[] = {
{"_connect", (PyCFunction)psyco_connect, {"_connect", (PyCFunction)connect,
METH_VARARGS|METH_KEYWORDS, psyco_connect_doc}, METH_VARARGS|METH_KEYWORDS, connect_doc},
{"parse_dsn", (PyCFunction)psyco_parse_dsn, {"parse_dsn", (PyCFunction)parse_dsn,
METH_VARARGS|METH_KEYWORDS, psyco_parse_dsn_doc}, METH_VARARGS|METH_KEYWORDS, parse_dsn_doc},
{"quote_ident", (PyCFunction)psyco_quote_ident, {"quote_ident", (PyCFunction)quote_ident,
METH_VARARGS|METH_KEYWORDS, psyco_quote_ident_doc}, METH_VARARGS|METH_KEYWORDS, quote_ident_doc},
{"adapt", (PyCFunction)psyco_microprotocols_adapt, {"adapt", (PyCFunction)psyco_microprotocols_adapt,
METH_VARARGS, psyco_microprotocols_adapt_doc}, METH_VARARGS, psyco_microprotocols_adapt_doc},
{"register_type", (PyCFunction)psyco_register_type, {"register_type", (PyCFunction)register_type,
METH_VARARGS, psyco_register_type_doc}, METH_VARARGS, register_type_doc},
{"new_type", (PyCFunction)typecast_from_python, {"new_type", (PyCFunction)typecast_from_python,
METH_VARARGS|METH_KEYWORDS, typecast_from_python_doc}, METH_VARARGS|METH_KEYWORDS, typecast_from_python_doc},
{"new_array_type", (PyCFunction)typecast_array_from_python, {"new_array_type", (PyCFunction)typecast_array_from_python,
METH_VARARGS|METH_KEYWORDS, typecast_array_from_python_doc}, METH_VARARGS|METH_KEYWORDS, typecast_array_from_python_doc},
{"libpq_version", (PyCFunction)psyco_libpq_version, {"libpq_version", (PyCFunction)libpq_version,
METH_NOARGS, psyco_libpq_version_doc}, METH_NOARGS, libpq_version_doc},
{"Date", (PyCFunction)psyco_Date, {"Date", (PyCFunction)psyco_Date,
METH_VARARGS, psyco_Date_doc}, METH_VARARGS, psyco_Date_doc},
@ -1042,8 +1042,8 @@ static PyMethodDef psycopgMethods[] = {
METH_O, psyco_set_wait_callback_doc}, METH_O, psyco_set_wait_callback_doc},
{"get_wait_callback", (PyCFunction)psyco_get_wait_callback, {"get_wait_callback", (PyCFunction)psyco_get_wait_callback,
METH_NOARGS, psyco_get_wait_callback_doc}, METH_NOARGS, psyco_get_wait_callback_doc},
{"encrypt_password", (PyCFunction)psyco_encrypt_password, {"encrypt_password", (PyCFunction)encrypt_password,
METH_VARARGS|METH_KEYWORDS, psyco_encrypt_password_doc}, METH_VARARGS|METH_KEYWORDS, encrypt_password_doc},
{NULL, NULL, 0, NULL} /* Sentinel */ {NULL, NULL, 0, NULL} /* Sentinel */
}; };
@ -1078,7 +1078,7 @@ INIT_MODULE(_psycopg)(void)
Dprintf("psycopgmodule: initializing psycopg %s", xstr(PSYCOPG_VERSION)); Dprintf("psycopgmodule: initializing psycopg %s", xstr(PSYCOPG_VERSION));
/* initialize libcrypto threading callbacks */ /* initialize libcrypto threading callbacks */
psyco_libcrypto_threads_init(); libcrypto_threads_init();
/* initialize types and objects not exposed to the module */ /* initialize types and objects not exposed to the module */
Py_TYPE(&typecastType) = &PyType_Type; Py_TYPE(&typecastType) = &PyType_Type;

View File

@ -50,7 +50,7 @@ typedef struct replicationCursorObject {
} replicationCursorObject; } replicationCursorObject;
RAISES_NEG HIDDEN int psyco_repl_curs_datetime_init(void); RAISES_NEG HIDDEN int repl_curs_datetime_init(void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -38,11 +38,11 @@
#include "datetime.h" #include "datetime.h"
#define psyco_repl_curs_start_replication_expert_doc \ #define start_replication_expert_doc \
"start_replication_expert(command, decode=False) -- Start replication with a given command." "start_replication_expert(command, decode=False) -- Start replication with a given command."
static PyObject * static PyObject *
psyco_repl_curs_start_replication_expert(replicationCursorObject *self, start_replication_expert(replicationCursorObject *self,
PyObject *args, PyObject *kwargs) PyObject *args, PyObject *kwargs)
{ {
cursorObject *curs = &self->cur; cursorObject *curs = &self->cur;
@ -60,12 +60,11 @@ psyco_repl_curs_start_replication_expert(replicationCursorObject *self,
EXC_IF_GREEN(start_replication_expert); EXC_IF_GREEN(start_replication_expert);
EXC_IF_TPC_PREPARED(conn, start_replication_expert); EXC_IF_TPC_PREPARED(conn, start_replication_expert);
if (!(command = psyco_curs_validate_sql_basic( if (!(command = curs_validate_sql_basic((cursorObject *)self, command))) {
(cursorObject *)self, command))) {
goto exit; goto exit;
} }
Dprintf("psyco_repl_curs_start_replication_expert: '%s'; decode: %ld", Dprintf("start_replication_expert: '%s'; decode: %ld",
Bytes_AS_STRING(command), decode); Bytes_AS_STRING(command), decode);
if (pq_execute(curs, Bytes_AS_STRING(command), conn->async, if (pq_execute(curs, Bytes_AS_STRING(command), conn->async,
@ -82,11 +81,11 @@ exit:
return res; return res;
} }
#define psyco_repl_curs_consume_stream_doc \ #define consume_stream_doc \
"consume_stream(consumer, keepalive_interval=10) -- Consume replication stream." "consume_stream(consumer, keepalive_interval=10) -- Consume replication stream."
static PyObject * static PyObject *
psyco_repl_curs_consume_stream(replicationCursorObject *self, consume_stream(replicationCursorObject *self,
PyObject *args, PyObject *kwargs) PyObject *args, PyObject *kwargs)
{ {
cursorObject *curs = &self->cur; cursorObject *curs = &self->cur;
@ -104,7 +103,7 @@ psyco_repl_curs_consume_stream(replicationCursorObject *self,
EXC_IF_GREEN(consume_stream); EXC_IF_GREEN(consume_stream);
EXC_IF_TPC_PREPARED(self->cur.conn, consume_stream); EXC_IF_TPC_PREPARED(self->cur.conn, consume_stream);
Dprintf("psyco_repl_curs_consume_stream"); Dprintf("consume_stream");
if (keepalive_interval < 1.0) { if (keepalive_interval < 1.0) {
psyco_set_error(ProgrammingError, curs, "keepalive_interval must be >= 1 (sec)"); psyco_set_error(ProgrammingError, curs, "keepalive_interval must be >= 1 (sec)");
@ -136,11 +135,11 @@ psyco_repl_curs_consume_stream(replicationCursorObject *self,
return res; return res;
} }
#define psyco_repl_curs_read_message_doc \ #define read_message_doc \
"read_message() -- Try reading a replication message from the server (non-blocking)." "read_message() -- Try reading a replication message from the server (non-blocking)."
static PyObject * static PyObject *
psyco_repl_curs_read_message(replicationCursorObject *self, PyObject *dummy) read_message(replicationCursorObject *self, PyObject *dummy)
{ {
cursorObject *curs = &self->cur; cursorObject *curs = &self->cur;
replicationMessageObject *msg = NULL; replicationMessageObject *msg = NULL;
@ -159,11 +158,11 @@ psyco_repl_curs_read_message(replicationCursorObject *self, PyObject *dummy)
Py_RETURN_NONE; Py_RETURN_NONE;
} }
#define psyco_repl_curs_send_feedback_doc \ #define send_feedback_doc \
"send_feedback(write_lsn=0, flush_lsn=0, apply_lsn=0, reply=False) -- Try sending a replication feedback message to the server and optionally request a reply." "send_feedback(write_lsn=0, flush_lsn=0, apply_lsn=0, reply=False) -- Try sending a replication feedback message to the server and optionally request a reply."
static PyObject * static PyObject *
psyco_repl_curs_send_feedback(replicationCursorObject *self, send_feedback(replicationCursorObject *self,
PyObject *args, PyObject *kwargs) PyObject *args, PyObject *kwargs)
{ {
cursorObject *curs = &self->cur; cursorObject *curs = &self->cur;
@ -196,7 +195,7 @@ psyco_repl_curs_send_feedback(replicationCursorObject *self,
RAISES_NEG int RAISES_NEG int
psyco_repl_curs_datetime_init(void) repl_curs_datetime_init(void)
{ {
PyDateTime_IMPORT; PyDateTime_IMPORT;
@ -207,11 +206,11 @@ psyco_repl_curs_datetime_init(void)
return 0; return 0;
} }
#define psyco_repl_curs_io_timestamp_doc \ #define repl_curs_io_timestamp_doc \
"io_timestamp -- the timestamp of latest IO with the server" "io_timestamp -- the timestamp of latest IO with the server"
static PyObject * static PyObject *
psyco_repl_curs_get_io_timestamp(replicationCursorObject *self) repl_curs_get_io_timestamp(replicationCursorObject *self)
{ {
cursorObject *curs = &self->cur; cursorObject *curs = &self->cur;
PyObject *tval, *res = NULL; PyObject *tval, *res = NULL;
@ -232,14 +231,14 @@ psyco_repl_curs_get_io_timestamp(replicationCursorObject *self)
/* object method list */ /* object method list */
static struct PyMethodDef replicationCursorObject_methods[] = { static struct PyMethodDef replicationCursorObject_methods[] = {
{"start_replication_expert", (PyCFunction)psyco_repl_curs_start_replication_expert, {"start_replication_expert", (PyCFunction)start_replication_expert,
METH_VARARGS|METH_KEYWORDS, psyco_repl_curs_start_replication_expert_doc}, METH_VARARGS|METH_KEYWORDS, start_replication_expert_doc},
{"consume_stream", (PyCFunction)psyco_repl_curs_consume_stream, {"consume_stream", (PyCFunction)consume_stream,
METH_VARARGS|METH_KEYWORDS, psyco_repl_curs_consume_stream_doc}, METH_VARARGS|METH_KEYWORDS, consume_stream_doc},
{"read_message", (PyCFunction)psyco_repl_curs_read_message, {"read_message", (PyCFunction)read_message,
METH_NOARGS, psyco_repl_curs_read_message_doc}, METH_NOARGS, read_message_doc},
{"send_feedback", (PyCFunction)psyco_repl_curs_send_feedback, {"send_feedback", (PyCFunction)send_feedback,
METH_VARARGS|METH_KEYWORDS, psyco_repl_curs_send_feedback_doc}, METH_VARARGS|METH_KEYWORDS, send_feedback_doc},
{NULL} {NULL}
}; };
@ -247,8 +246,8 @@ static struct PyMethodDef replicationCursorObject_methods[] = {
static struct PyGetSetDef replicationCursorObject_getsets[] = { static struct PyGetSetDef replicationCursorObject_getsets[] = {
{ "io_timestamp", { "io_timestamp",
(getter)psyco_repl_curs_get_io_timestamp, NULL, (getter)repl_curs_get_io_timestamp, NULL,
psyco_repl_curs_io_timestamp_doc, NULL }, repl_curs_io_timestamp_doc, NULL },
{NULL} {NULL}
}; };

View File

@ -48,7 +48,7 @@ struct replicationMessageObject {
int64_t send_time; int64_t send_time;
}; };
RAISES_NEG HIDDEN int psyco_replmsg_datetime_init(void); RAISES_NEG HIDDEN int replmsg_datetime_init(void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -31,7 +31,7 @@
#include "datetime.h" #include "datetime.h"
RAISES_NEG int RAISES_NEG int
psyco_replmsg_datetime_init(void) replmsg_datetime_init(void)
{ {
PyDateTime_IMPORT; PyDateTime_IMPORT;
@ -102,11 +102,11 @@ replmsg_dealloc(PyObject* obj)
Py_TYPE(obj)->tp_free(obj); Py_TYPE(obj)->tp_free(obj);
} }
#define psyco_replmsg_send_time_doc \ #define replmsg_send_time_doc \
"send_time - Timestamp of the replication message departure from the server." "send_time - Timestamp of the replication message departure from the server."
static PyObject * static PyObject *
psyco_replmsg_get_send_time(replicationMessageObject *self) replmsg_get_send_time(replicationMessageObject *self)
{ {
PyObject *tval, *res = NULL; PyObject *tval, *res = NULL;
double t; double t;
@ -142,8 +142,8 @@ static struct PyMemberDef replicationMessageObject_members[] = {
}; };
static struct PyGetSetDef replicationMessageObject_getsets[] = { static struct PyGetSetDef replicationMessageObject_getsets[] = {
{ "send_time", (getter)psyco_replmsg_get_send_time, NULL, { "send_time", (getter)replmsg_get_send_time, NULL,
psyco_replmsg_send_time_doc, NULL }, replmsg_send_time_doc, NULL },
{NULL} {NULL}
}; };

View File

@ -291,7 +291,7 @@ typecast_init(PyObject *module)
/* register the date/time typecasters with their original names */ /* register the date/time typecasters with their original names */
#ifdef HAVE_MXDATETIME #ifdef HAVE_MXDATETIME
if (0 == psyco_typecast_mxdatetime_init()) { if (0 == typecast_mxdatetime_init()) {
for (i = 0; typecast_mxdatetime[i].name != NULL; i++) { for (i = 0; typecast_mxdatetime[i].name != NULL; i++) {
t = (typecastObject *)typecast_from_c(&(typecast_mxdatetime[i]), dict); t = (typecastObject *)typecast_from_c(&(typecast_mxdatetime[i]), dict);
if (t == NULL) { goto exit; } if (t == NULL) { goto exit; }
@ -302,7 +302,7 @@ typecast_init(PyObject *module)
} }
#endif #endif
if (0 > psyco_typecast_datetime_init()) { goto exit; } if (0 > typecast_datetime_init()) { goto exit; }
for (i = 0; typecast_pydatetime[i].name != NULL; i++) { for (i = 0; typecast_pydatetime[i].name != NULL; i++) {
t = (typecastObject *)typecast_from_c(&(typecast_pydatetime[i]), dict); t = (typecastObject *)typecast_from_c(&(typecast_pydatetime[i]), dict);
if (t == NULL) { goto exit; } if (t == NULL) { goto exit; }

View File

@ -132,9 +132,9 @@ PyTypeObject chunkType = {
}; };
static char *psycopg_parse_hex( static char *parse_hex(
const char *bufin, Py_ssize_t sizein, Py_ssize_t *sizeout); const char *bufin, Py_ssize_t sizein, Py_ssize_t *sizeout);
static char *psycopg_parse_escape( static char *parse_escape(
const char *bufin, Py_ssize_t sizein, Py_ssize_t *sizeout); const char *bufin, Py_ssize_t sizein, Py_ssize_t *sizeout);
/* The function is not static and not hidden as we use ctypes to test it. */ /* The function is not static and not hidden as we use ctypes to test it. */
@ -154,7 +154,7 @@ typecast_BINARY_cast(const char *s, Py_ssize_t l, PyObject *curs)
* So the only robust option is to parse it ourselves - luckily it's * So the only robust option is to parse it ourselves - luckily it's
* an easy format. * an easy format.
*/ */
if (NULL == (buffer = psycopg_parse_hex(s, l, &len))) { if (NULL == (buffer = parse_hex(s, l, &len))) {
goto exit; goto exit;
} }
} }
@ -169,7 +169,7 @@ typecast_BINARY_cast(const char *s, Py_ssize_t l, PyObject *curs)
* So we'll just have our better integrated parser, let's finish this * So we'll just have our better integrated parser, let's finish this
* story. * story.
*/ */
if (NULL == (buffer = psycopg_parse_escape(s, l, &len))) { if (NULL == (buffer = parse_escape(s, l, &len))) {
goto exit; goto exit;
} }
} }
@ -219,7 +219,7 @@ static const char hex_lut[128] = {
* In case of error set an exception and return NULL. * In case of error set an exception and return NULL.
*/ */
static char * static char *
psycopg_parse_hex(const char *bufin, Py_ssize_t sizein, Py_ssize_t *sizeout) parse_hex(const char *bufin, Py_ssize_t sizein, Py_ssize_t *sizeout)
{ {
char *ret = NULL; char *ret = NULL;
const char *bufend = bufin + sizein; const char *bufend = bufin + sizein;
@ -269,7 +269,7 @@ exit:
* In case of error set an exception and return NULL. * In case of error set an exception and return NULL.
*/ */
static char * static char *
psycopg_parse_escape(const char *bufin, Py_ssize_t sizein, Py_ssize_t *sizeout) parse_escape(const char *bufin, Py_ssize_t sizein, Py_ssize_t *sizeout)
{ {
char *ret = NULL; char *ret = NULL;
const char *bufend = bufin + sizein; const char *bufend = bufin + sizein;

View File

@ -27,7 +27,7 @@
#include "datetime.h" #include "datetime.h"
RAISES_NEG static int RAISES_NEG static int
psyco_typecast_datetime_init(void) typecast_datetime_init(void)
{ {
PyDateTime_IMPORT; PyDateTime_IMPORT;

View File

@ -29,10 +29,10 @@
/* Return 0 on success, -1 on failure, but don't set an exception */ /* Return 0 on success, -1 on failure, but don't set an exception */
static int static int
psyco_typecast_mxdatetime_init(void) typecast_mxdatetime_init(void)
{ {
if (mxDateTime_ImportModuleAndAPI()) { if (mxDateTime_ImportModuleAndAPI()) {
Dprintf("psyco_typecast_mxdatetime_init: mx.DateTime initialization failed"); Dprintf("typecast_mxdatetime_init: mx.DateTime initialization failed");
PyErr_Clear(); PyErr_Clear();
return -1; return -1;
} }