Changeset 991 for trunk/pgmodule.c


Ignore:
Timestamp:
Apr 24, 2019, 3:46:20 PM (4 months ago)
Author:
cito
Message:

Add some more attributes to the connection object

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pgmodule.c

    r987 r991  
    1919#include <libpq/libpq-fs.h>
    2020
    21 /* the type definitions from <server/catalog/pg_type.h> */
     21/* The type definitions from <server/catalog/pg_type.h> */
    2222#include "pgtypes.h"
    2323
    24 /* macros for single-source Python 2/3 compatibility */
     24/* Macros for single-source Python 2/3 compatibility */
    2525#include "py3c.h"
    2626
     
    3838#endif
    3939
    40 /* default values */
     40/* Default values */
    4141#define PG_ARRAYSIZE 1
    4242
    43 /* flags for object validity checks */
     43/* Flags for object validity checks */
    4444#define CHECK_OPEN   1
    4545#define CHECK_CLOSE  2
     
    4848#define CHECK_DQL   16
    4949
    50 /* query result types */
     50/* Query result types */
    5151#define RESULT_EMPTY 1
    5252#define RESULT_DML   2
     
    5454#define RESULT_DQL   4
    5555
    56 /* flags for move methods */
     56/* Flags for move methods */
    5757#define QUERY_MOVEFIRST 1
    5858#define QUERY_MOVELAST  2
     
    110110*/
    111111
    112 /* forward declarations for types */
     112/* Forward declarations for types */
    113113static PyTypeObject connType, sourceType, queryType, noticeType, largeType;
    114114
    115 /* forward static declarations */
     115/* Forward static declarations */
    116116static void notice_receiver(void *, const PGresult *);
    117117
    118 /* object declarations */
     118/* Object declarations */
    119119
    120120typedef struct
     
    176176#endif /* LARGE_OBJECTS */
    177177
    178 /* internal functions */
     178/* Internal functions */
    179179#include "internal.c"
    180180
    181 /* connection object */
     181/* Connection object */
    182182#include "conn.c"
    183183
    184 /* query object */
     184/* Query object */
    185185#include "query.c"
    186186
    187 /* source object */
     187/* Source object */
    188188#include "source.c"
    189189
    190 /* notice object */
     190/* Notice object */
    191191#include "notice.c"
    192192
    193 /* large objects */
     193/* Large objects */
    194194#ifdef LARGE_OBJECTS
    195195#include "large.c"
     
    198198/* MODULE FUNCTIONS */
    199199
    200 /* connect to a database */
     200/* Connect to a database. */
    201201static char pg_connect__doc__[] =
    202202"connect(dbname, host, port, opt) -- connect to a PostgreSQL database\n\n"
     
    283283}
    284284
    285 /* escape string */
     285/* Escape string */
    286286static char pg_escape_string__doc__[] =
    287287"escape_string(string) -- escape a string for use within SQL";
     
    331331}
    332332
    333 /* escape bytea */
     333/* Escape bytea */
    334334static char pg_escape_bytea__doc__[] =
    335335"escape_bytea(data) -- escape binary data for use within SQL as type bytea";
     
    375375}
    376376
    377 /* unescape bytea */
     377/* Unescape bytea */
    378378static char pg_unescape_bytea__doc__[] =
    379379"unescape_bytea(string) -- unescape bytea data retrieved as text";
     
    416416}
    417417
    418 /* set fixed datestyle */
     418/* Set fixed datestyle. */
    419419static char pg_set_datestyle__doc__[] =
    420420"set_datestyle(style) -- set which style is assumed";
     
    438438}
    439439
    440 /* get fixed datestyle */
     440/* Get fixed datestyle. */
    441441static char pg_get_datestyle__doc__[] =
    442442"get_datestyle() -- get which date style is assumed";
     
    453453}
    454454
    455 /* get decimal point */
     455/* Get decimal point. */
    456456static char pg_get_decimal_point__doc__[] =
    457457"get_decimal_point() -- get decimal point to be used for money values";
     
    474474}
    475475
    476 /* set decimal point */
     476/* Set decimal point. */
    477477static char pg_set_decimal_point__doc__[] =
    478478"set_decimal_point(char) -- set decimal point to be used for money values";
     
    504504}
    505505
    506 /* get decimal type */
     506/* Get decimal type. */
    507507static char pg_get_decimal__doc__[] =
    508508"get_decimal() -- get the decimal type to be used for numeric values";
     
    519519}
    520520
    521 /* set decimal type */
     521/* Set decimal type. */
    522522static char pg_set_decimal__doc__[] =
    523523"set_decimal(cls) -- set a decimal type to be used for numeric values";
     
    545545}
    546546
    547 /* get usage of bool values */
     547/* Get usage of bool values. */
    548548static char pg_get_bool__doc__[] =
    549549"get_bool() -- check whether boolean values are converted to bool";
     
    560560}
    561561
    562 /* set usage of bool values */
     562/* Set usage of bool values. */
    563563static char pg_set_bool__doc__[] =
    564564"set_bool(on) -- set whether boolean values should be converted to bool";
     
    584584}
    585585
    586 /* get conversion of arrays to lists */
     586/* Get conversion of arrays to lists. */
    587587static char pg_get_array__doc__[] =
    588588"get_array() -- check whether arrays are converted as lists";
     
    599599}
    600600
    601 /* set conversion of arrays to lists */
     601/* Set conversion of arrays to lists. */
    602602static char pg_set_array__doc__[] =
    603603"set_array(on) -- set whether arrays should be converted to lists";
     
    623623}
    624624
    625 /* check whether bytea values are unescaped */
     625/* Check whether bytea values are unescaped. */
    626626static char pg_get_bytea_escaped__doc__[] =
    627627"get_bytea_escaped() -- check whether bytea will be returned escaped";
     
    638638}
    639639
    640 /* set usage of bool values */
     640/* Set usage of bool values. */
    641641static char pg_set_bytea_escaped__doc__[] =
    642642"set_bytea_escaped(on) -- set whether bytea will be returned escaped";
     
    684684}
    685685
    686 /* get json decode function */
     686/* Get json decode function. */
    687687static char pg_get_jsondecode__doc__[] =
    688688"get_jsondecode() -- get the function used for decoding json results";
     
    701701}
    702702
    703 /* set json decode function */
     703/* Set json decode function. */
    704704static char pg_set_jsondecode__doc__[] =
    705705"set_jsondecode(func) -- set a function to be used for decoding json results";
     
    729729#ifdef DEFAULT_VARS
    730730
    731 /* gets default host */
     731/* Get default host. */
    732732static char pg_get_defhost__doc__[] =
    733733"get_defhost() -- return default database host";
     
    740740}
    741741
    742 /* sets default host */
     742/* Set default host. */
    743743static char pg_set_defhost__doc__[] =
    744744"set_defhost(string) -- set default database host and return previous value";
     
    772772}
    773773
    774 /* gets default base */
     774/* Get default database. */
    775775static char pg_get_defbase__doc__[] =
    776776"get_defbase() -- return default database name";
     
    783783}
    784784
    785 /* sets default base */
     785/* Set default database. */
    786786static char pg_set_defbase__doc__[] =
    787787"set_defbase(string) -- set default database name and return previous value";
     
    815815}
    816816
    817 /* gets default options */
     817/* Get default options. */
    818818static char pg_get_defopt__doc__[] =
    819819"get_defopt() -- return default database options";
     
    826826}
    827827
    828 /* sets default opt */
     828/* Set default options. */
    829829static char pg_set_defopt__doc__[] =
    830830"set_defopt(string) -- set default options and return previous value";
     
    858858}
    859859
    860 /* gets default username */
     860/* Get default username. */
    861861static char pg_get_defuser__doc__[] =
    862862"get_defuser() -- return default database username";
     
    869869}
    870870
    871 /* sets default username */
     871/* Set default username. */
    872872
    873873static char pg_set_defuser__doc__[] =
     
    902902}
    903903
    904 /* sets default password */
     904/* Set default password. */
    905905static char pg_set_defpasswd__doc__[] =
    906906"set_defpasswd(password) -- set default database password";
     
    931931}
    932932
    933 /* gets default port */
     933/* Get default port. */
    934934static char pg_get_defport__doc__[] =
    935935"get_defport() -- return default database port";
     
    942942}
    943943
    944 /* sets default port */
     944/* Set default port. */
    945945static char pg_set_defport__doc__[] =
    946946"set_defport(port) -- set default port and return previous value";
     
    975975#endif /* DEFAULT_VARS */
    976976
    977 /* cast a string with a text representation of an array to a list */
     977/* Cast a string with a text representation of an array to a list. */
    978978static char pg_cast_array__doc__[] =
    979979"cast_array(string, cast=None, delim=',') -- cast a string as an array";
     
    10321032}
    10331033
    1034 /* cast a string with a text representation of a record to a tuple */
     1034/* Cast a string with a text representation of a record to a tuple. */
    10351035static char pg_cast_record__doc__[] =
    10361036"cast_record(string, cast=None, delim=',') -- cast a string as a record";
     
    10961096}
    10971097
    1098 /* cast a string with a text representation of an hstore to a dict */
     1098/* Cast a string with a text representation of an hstore to a dict. */
    10991099static char pg_cast_hstore__doc__[] =
    11001100"cast_hstore(string) -- cast a string as an hstore";
     
    11321132}
    11331133
    1134 /* List of functions defined in the module */
     1134/* The list of functions defined in the module */
    11351135
    11361136static struct PyMethodDef pg_methods[] = {
     
    13011301    Py_DECREF(s);
    13021302
    1303     /* results type for queries */
     1303    /* Result types for queries */
    13041304    PyDict_SetItemString(dict, "RESULT_EMPTY", PyInt_FromLong(RESULT_EMPTY));
    13051305    PyDict_SetItemString(dict, "RESULT_DML", PyInt_FromLong(RESULT_DML));
     
    13071307    PyDict_SetItemString(dict, "RESULT_DQL", PyInt_FromLong(RESULT_DQL));
    13081308
    1309     /* transaction states */
     1309    /* Transaction states */
    13101310    PyDict_SetItemString(dict,"TRANS_IDLE",PyInt_FromLong(PQTRANS_IDLE));
    13111311    PyDict_SetItemString(dict,"TRANS_ACTIVE",PyInt_FromLong(PQTRANS_ACTIVE));
     
    13151315
    13161316#ifdef LARGE_OBJECTS
    1317     /* create mode for large objects */
     1317    /* Create mode for large objects */
    13181318    PyDict_SetItemString(dict, "INV_READ", PyInt_FromLong(INV_READ));
    13191319    PyDict_SetItemString(dict, "INV_WRITE", PyInt_FromLong(INV_WRITE));
    13201320
    1321     /* position flags for lo_lseek */
     1321    /* Position flags for lo_lseek */
    13221322    PyDict_SetItemString(dict, "SEEK_SET", PyInt_FromLong(SEEK_SET));
    13231323    PyDict_SetItemString(dict, "SEEK_CUR", PyInt_FromLong(SEEK_CUR));
     
    13261326
    13271327#ifdef DEFAULT_VARS
    1328     /* prepares default values */
     1328    /* Prepare default values */
    13291329    Py_INCREF(Py_None);
    13301330    pg_default_host = Py_None;
     
    13411341#endif /* DEFAULT_VARS */
    13421342
    1343     /* store common pg encoding ids */
     1343    /* Store common pg encoding ids */
    13441344
    13451345    pg_encoding_utf8 = pg_char_to_encoding("UTF8");
Note: See TracChangeset for help on using the changeset viewer.