From: Billy G. A. <bal...@us...> - 2001-09-06 04:42:31
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv2907 Modified Files: pglargeobject.c pgnotify.c pgresult.c pgversion.c Log Message: 06SEP2001 bga Clean up lint-like warning from gcc. Index: pglargeobject.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pglargeobject.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pglargeobject.c 2001/08/31 05:49:00 1.6 --- pglargeobject.c 2001/09/06 04:42:21 1.7 *************** *** 30,33 **** --- 30,34 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 06SEP2001 bga Removed an un-used variable. | | 30AUG2001 bga Use PyObject_Del() instead of PyMem_Free() in dealloc() | | to delete the object. | *************** *** 141,145 **** static PyObject *PgLargeObject_repr(PgLargeObject *self) { - int i; char buf[128], *state, *mode = ""; --- 142,145 ---- Index: pgnotify.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgnotify.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pgnotify.c 2001/08/31 05:49:00 1.5 --- pgnotify.c 2001/09/06 04:42:21 1.6 *************** *** 30,33 **** --- 30,34 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 06SEP2001 bga Clarified an embedded assignment within an if test. | | 30AUG2001 bga Use PyObject_Del() instead of PyMem_Free() in dealloc() | | to delete the object. | *************** *** 60,64 **** self = (PgNotify *)Py_None; } ! else if (self = (PgNotify *)PyObject_New(PgNotify, &PgNotify_Type)) { self->relname = Py_BuildValue("s", &(note->relname)); --- 61,66 ---- self = (PgNotify *)Py_None; } ! else if ((self = (PgNotify *)PyObject_New(PgNotify, &PgNotify_Type)) != ! (PgNotify *)NULL) { self->relname = Py_BuildValue("s", &(note->relname)); Index: pgresult.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgresult.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** pgresult.c 2001/09/04 21:24:11 1.7 --- pgresult.c 2001/09/06 04:42:21 1.8 *************** *** 2,8 **** /* vi:set sw=4 ts=8 showmode ai: */ /**(H+)*****************************************************************\ ! | Name: pgconnection.c | | | ! | Description: This file implements the PgConnection Object for Python | |=======================================================================| | Copyright 2001 by Billy G. Allie. | --- 2,8 ---- /* vi:set sw=4 ts=8 showmode ai: */ /**(H+)*****************************************************************\ ! | Name: pgresult.c | | | ! | Description: This file implements the PgResult Object for Python | |=======================================================================| | Copyright 2001 by Billy G. Allie. | *************** *** 29,32 **** --- 29,37 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 06SEP2001 bga Fixed a gcc reported int format <-> long int arguement | + | mis-match. | + | 05SEP2001 bga Added check to make sure that the result was from a DQL | + | (Data Query Language) statement in methods that only | + | make sense for DQL statement results (fname(), etc.). | | 03SEP2001 bga Methods that take field and/or tuple indices will now | | raise an exception if those indices are out of range. | *************** *** 205,208 **** --- 210,233 ---- /*--------------------------------------------------------------------------*/ + static int PgResult_is_DQL(PgResult *self) + { + /*******************************************************************\ + | Since this is only called from within pgresult.c, and we can en- | + | sure that it is only called with a PgResult object, we don't have | + | to check self. | + \*******************************************************************/ + + if (PyInt_AS_LONG(self->type) != RESULT_DQL) + { + PyErr_SetString(PqErr_InterfaceError, + "PgResult object was not generated by a DQL statement"); + return FALSE; + } + + return TRUE; + } + + /*--------------------------------------------------------------------------*/ + static int PgResult_ntuple_check(PgResult *self, int tnum) { *************** *** 217,221 **** char buf[256]; ! sprintf(buf, "tuple index outside valid range of 0..%d.", (PyInt_AS_LONG(self->ntuples) - 1)); PyErr_SetString(PyExc_ValueError, buf); --- 242,246 ---- char buf[256]; ! sprintf(buf, "tuple index outside valid range of 0..%ld.", (PyInt_AS_LONG(self->ntuples) - 1)); PyErr_SetString(PyExc_ValueError, buf); *************** *** 240,244 **** char buf[256]; ! sprintf(buf, "field index outside valid range of 0..%d.", (PyInt_AS_LONG(self->nfields) - 1)); PyErr_SetString(PyExc_ValueError, buf); --- 265,269 ---- char buf[256]; ! sprintf(buf, "field index outside valid range of 0..%ld.", (PyInt_AS_LONG(self->nfields) - 1)); PyErr_SetString(PyExc_ValueError, buf); *************** *** 264,267 **** --- 289,295 ---- return (PyObject *)NULL; + if (!PgResult_is_DQL(self)) + return (PyObject *)NULL; + if (!PyArg_ParseTuple(args, "i:fname", &fnum)) return (PyObject *)NULL; *************** *** 287,290 **** --- 315,321 ---- return (PyObject *)NULL; + if (!PgResult_is_DQL(self)) + return (PyObject *)NULL; + if (!PyArg_ParseTuple(args, "s:fnumber", &fieldName)) return (PyObject *)NULL; *************** *** 315,318 **** --- 346,352 ---- return (PyObject *)NULL; + if (!PgResult_is_DQL(self)) + return (PyObject *)NULL; + if (!PyArg_ParseTuple(args, "i:ftype", &fnum)) return (PyObject *)NULL; *************** *** 340,343 **** --- 374,380 ---- return (PyObject *)NULL; + if (!PgResult_is_DQL(self)) + return (PyObject *)NULL; + if (!PyArg_ParseTuple(args, "i:fsize", &fnum)) return (PyObject *)NULL; *************** *** 363,366 **** --- 400,406 ---- return NULL; + if (!PgResult_is_DQL(self)) + return (PyObject *)NULL; + if (!PyArg_ParseTuple(args, "i:fmod", &fnum)) return NULL; *************** *** 390,393 **** --- 430,436 ---- return NULL; + if (!PgResult_is_DQL(self)) + return (PyObject *)NULL; + if (!PyArg_ParseTuple(args, "ii:getvalue", &tnum, &fnum)) return NULL; *************** *** 597,600 **** --- 640,646 ---- return NULL; + if (!PgResult_is_DQL(self)) + return (PyObject *)NULL; + if (!PyArg_ParseTuple(args, "ii:getlength", &tnum, &fnum)) return NULL; *************** *** 622,625 **** --- 668,674 ---- if (!PgResult_check((PyObject *)self)) return NULL; + + if (!PgResult_is_DQL(self)) + return (PyObject *)NULL; if (!PyArg_ParseTuple(args, "ii:getisnull", &tnum, &fnum)) Index: pgversion.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgversion.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pgversion.c 2001/08/29 04:05:35 1.4 --- pgversion.c 2001/09/06 04:42:21 1.5 *************** *** 32,35 **** --- 32,37 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 06SEP2001 bga Initialize a variable (value) in ver_coerce() to quite | + | an erroneous gcc warning message. | | 28AUG2001 bga Picked some lint from the code. | | 24AUG2001 bga Removed a variable that was no longer used/needed. | *************** *** 126,130 **** PgVersion *s; char *vstr; - long value; if (PyString_Check(*r)) --- 128,131 ---- *************** *** 141,144 **** --- 142,147 ---- else { + long value = 0; + if ((vstr = PyMem_Malloc(128)) == (char *)NULL) { |