DB_POSTGRES :: Data field conversion and type checking functions. More...
#include "pg_fld.h"#include "pg_con.h"#include "pg_mod.h"#include "../../lib/srdb2/db_drv.h"#include "../../mem/mem.h"#include "../../dprint.h"#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#include <stdint.h>#include <string.h>
Go to the source code of this file.
Module: DB_POSTGRES :: the PostgreSQL driver for Kamailio
Definition in file pg_fld.c.
| #define PG_EPOCH_TIME ((int64_t)946684800) |
| int pg_check_fld2pg | ( | db_fld_t * | fld, | |
| pg_type_t * | types | |||
| ) |
The functions checks whether all db_fld fields in the last parameter are compatible with column types on the server, for conversion to postgres format.
| fld | An array of db_fld fields to be checked. | |
| types | An array used to map internal field types to Oids. |
| 0 | on success | |
| A | negative number on error. |
Definition at line 389 of file pg_fld.c.
References pg_type::oid, PG_BIT, PG_BOOL, PG_BPCHAR, PG_BYTE, PG_CHAR, pg_fld(), PG_FLOAT4, PG_FLOAT8, PG_INET, PG_INT2, PG_INT4, PG_INT8, pg_oid2name(), PG_TEXT, PG_TIMESTAMP, PG_TIMESTAMPTZ, PG_VARBIT, and PG_VARCHAR.
Referenced by check_types().


| int pg_check_pg2fld | ( | db_fld_t * | fld, | |
| pg_type_t * | types | |||
| ) |
The functions checks whether all db_fld fields in the last parameter are compatible with column types on the server, for conversion to interal DB format.
| fld | An array of db_fld fields to be checked. | |
| types | An array used to map internal field types to Oids. |
| 0 | on success | |
| A | negative number on error. |
Definition at line 505 of file pg_fld.c.
References pg_type::oid, PG_BIT, PG_BOOL, PG_BPCHAR, PG_BYTE, PG_CHAR, pg_fld(), PG_FLOAT4, PG_FLOAT8, PG_INET, PG_INT2, PG_INT4, PG_INT8, pg_oid2name(), PG_TEXT, PG_TIMESTAMP, PG_TIMESTAMPTZ, PG_VARBIT, and PG_VARCHAR.
Referenced by check_types().


| int pg_fld | ( | db_fld_t * | fld, | |
| char * | table | |||
| ) |
This function creates a new PostgreSQL specific payload structure and attaches the structure to the generic db_fld structure.
| fld | A generic db_fld structure to be exended. | |
| table | Name of the table on the server. |
Definition at line 69 of file pg_fld.c.
References pg_fld(), and pg_fld_free().
Referenced by pg_check_fld2pg(), pg_check_pg2fld(), pg_fld(), and pg_fld2pg().


| int pg_fld2pg | ( | struct pg_params * | dst, | |
| int | off, | |||
| pg_type_t * | types, | |||
| db_fld_t * | src, | |||
| unsigned int | flags | |||
| ) |
The function converts fields in SER db_fld format to parameters suitable for PostgreSQL API functions.
| dst | An array of pointers to values in PostgreSQL format. The function will store pointers to converted values there. | |
| off | offset | |
| types | A type conversion table. | |
| src | An array of db_fld fields to be converted. | |
| flags | Connection flags controlling how values are converted. |
Implement support for bit fields with size bigger than 32
Implement support for varbit properly to remove leading zeroes
Check if timezones are handled properly
Support for DB_NONE in pg_pg2fld and pg_check_pg2fld
local->UTC conversion (also check the SQL command in ser-oob)
Definition at line 267 of file pg_fld.c.
References pg_type::oid, PG_BIT, PG_BOOL, PG_BPCHAR, PG_BYTE, PG_CHAR, pg_fld(), PG_FLOAT4, PG_FLOAT8, PG_INET, PG_INT2, PG_INT4, PG_INT8, PG_TEXT, PG_TIMESTAMP, PG_TIMESTAMPTZ, PG_VARBIT, and PG_VARCHAR.
Referenced by pg_cmd_exec().


| static void pg_fld_free | ( | db_fld_t * | fld, | |
| struct pg_fld * | payload | |||
| ) | [static] |
| int pg_pg2fld | ( | db_fld_t * | dst, | |
| PGresult * | src, | |||
| int | row, | |||
| pg_type_t * | types, | |||
| unsigned int | flags | |||
| ) |
The function converts fields from PostgreSQL result (PGresult structure) into the internal format used in SER. The function converts one row at a time.
| dst | The destination array of db_fld fields to be filled with converted values. | |
| src | A PostgreSQL result structure to be converted into SER format. | |
| row | Number of the row to be converted. | |
| types | A type conversion table. | |
| flags | Connection flags controlling how values are converted. |
| 0 | on success | |
| A | negative number on error. |
Definition at line 794 of file pg_fld.c.
References PG_BIT, PG_BOOL, PG_BPCHAR, PG_BYTE, PG_CHAR, PG_FLOAT4, PG_FLOAT8, PG_INET, PG_INT2, PG_INT4, PG_INT8, PG_TEXT, PG_TIMESTAMP, PG_TIMESTAMPTZ, PG_VARBIT, and PG_VARCHAR.
Referenced by pg_cmd_next().

1.7.1