globals.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #include <libpq-fe.h>
  2. /* cursors */
  3. typedef struct _cursor {
  4. PGresult *res;
  5. int nrows; /* number of rows in query result */
  6. int row; /* current row */
  7. dbToken token;
  8. int type; /* type of cursor: SELECT, UPDATE, INSERT */
  9. int *cols; /* indexes of known (type) columns */
  10. int ncols; /* number of known columns */
  11. } cursor;
  12. typedef struct {
  13. char *host, *port, *options, *tty, *dbname, *user, *password, *schema;
  14. } PGCONN;
  15. /* PostgreSQL data types defined in GRASS
  16. (see also: /usr/include/pgsql/server/catalog/pg_type.h)
  17. PostGIS types are encoded as 17xxx.
  18. Types/OIDs are fetched in db.c from server.
  19. */
  20. typedef enum { /* name in pg_type, aliases */
  21. PG_TYPE_UNKNOWN, /* all types not supported by GRASS */
  22. PG_TYPE_BIT, /* bit */
  23. PG_TYPE_INT2, /* int2, smallint */
  24. PG_TYPE_INT4, /* int4, integer, int */
  25. PG_TYPE_INT8, /* int8, bigint */
  26. PG_TYPE_SERIAL, /* serial */
  27. PG_TYPE_OID, /* oid */
  28. PG_TYPE_FLOAT4, /* float4, real */
  29. PG_TYPE_FLOAT8, /* float8, double precision */
  30. PG_TYPE_NUMERIC, /* numeric, decimal */
  31. PG_TYPE_CHAR, /* char, character */
  32. PG_TYPE_BPCHAR, /* ??? blank padded character, oid of this type is returned for char fields */
  33. PG_TYPE_VARCHAR, /* varchar, character varying */
  34. PG_TYPE_TEXT, /* text */
  35. PG_TYPE_DATE, /* date */
  36. PG_TYPE_TIME, /* time */
  37. PG_TYPE_TIMESTAMP, /* timestamp */
  38. PG_TYPE_BOOL, /* bool, boolean */
  39. PG_TYPE_POSTGIS_GEOM /* Geometry column of PostGIS, GRASS internal type */
  40. } PG_TYPES;
  41. #ifdef MAIN
  42. PGconn *pg_conn; /* Database connection */
  43. int (*pg_types)[2] = NULL; /* array of types, first is internal code, second PG_TYPE_* */
  44. int pg_ntypes = 0;
  45. dbString *errMsg = NULL; /* error message */
  46. #else
  47. extern PGconn *pg_conn;
  48. extern dbString *errMsg;
  49. extern int (*pg_types)[2];
  50. extern int pg_ntypes;
  51. #endif