db_postgres/km_dbase.h

Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  *
00004  * Copyright (C) 2003 August.Net Services, LLC
00005  * Copyright (C) 2008 1&1 Internet AG
00006  *
00007  * This file is part of Kamailio, a free SIP server.
00008  *
00009  * Kamailio is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version
00013  *
00014  * Kamailio is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License 
00020  * along with this program; if not, write to the Free Software 
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022  *
00023  * History
00024  * -------
00025  * 2003-04-06 initial code written (Greg Fausak/Andy Fullford)
00026  */
00027 
00034 #ifndef KM_DBASE_H
00035 #define KM_DBASE_H
00036 
00037 #include "../../lib/srdb1/db_con.h"
00038 #include "../../lib/srdb1/db_res.h"
00039 #include "../../lib/srdb1/db_key.h"
00040 #include "../../lib/srdb1/db_op.h"
00041 #include "../../lib/srdb1/db_val.h"
00042 
00043 
00044 /*
00045  * Initialize database connection
00046  */
00047 db1_con_t* db_postgres_init(const str* _url);
00048 
00049 /*
00050  * Initialize database connection - no pooling
00051  */
00052 db1_con_t* db_postgres_init2(const str* _url, db_pooling_t pooling);
00053 
00054 /*
00055  * Close a database connection
00056  */
00057 void db_postgres_close(db1_con_t* _h);
00058 
00059 /*
00060  * Return result of previous query
00061  */
00062 int db_postgres_store_result(const db1_con_t* _h, db1_res_t** _r);
00063 
00064 
00065 /*
00066  * Free all memory allocated by get_result
00067  */
00068 int db_postgres_free_result(db1_con_t* _h, db1_res_t* _r);
00069 
00070 
00071 /*
00072  * Do a query
00073  */
00074 int db_postgres_query(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op,
00075                 const db_val_t* _v, const db_key_t* _c, const int _n, const int _nc,
00076                 const db_key_t _o, db1_res_t** _r);
00077 
00078 /*
00079  * Raw SQL query
00080  */
00081 int db_postgres_raw_query(const db1_con_t* _h, const str* _s, db1_res_t** _r);
00082 
00083 
00084 /*
00085  * Insert a row into table
00086  */
00087 int db_postgres_insert(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v,
00088                 const int _n);
00089 
00090 
00091 /*
00092  * Delete a row from table
00093  */
00094 int db_postgres_delete(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
00095                 const db_val_t* _v, const int _n);
00096 
00097 
00098 /*
00099  * Update a row in table
00100  */
00101 int db_postgres_update(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
00102                 const db_val_t* _v, const db_key_t* _uk, const db_val_t* _uv, const int _n,
00103                 const int _un);
00104 
00105 /*
00106  * fetch rows from a result
00107  */
00108 int db_postgres_fetch_result(const db1_con_t* _h, db1_res_t** _r, const int nrows);
00109 
00110 /*
00111  * number of rows affected by the last DB query/statement
00112  */
00113 int db_postgres_affected_rows(const db1_con_t* _h);
00114 
00115 /*
00116  * SQL BEGIN
00117  */
00118 int db_postgres_start_transaction(db1_con_t* _h);
00119 
00120 /*
00121  * SQL COMMIT
00122  */
00123 int db_postgres_end_transaction(db1_con_t* _h);
00124 
00125 /*
00126  * SQL ROLLBACK
00127  */
00128 int db_postgres_abort_transaction(db1_con_t* _h);
00129 
00130 /*
00131  * Store name of table that will be used by
00132  * subsequent database functions
00133  */
00134 int db_postgres_use_table(db1_con_t* _h, const str* _t);
00135 
00136 /*
00137  * Replace a row in table (via update/insert)
00138  */
00139 int db_postgres_replace(const db1_con_t* _h, const db_key_t* _k,
00140                 const db_val_t* _v, const int _n, const int _un, const int _m);
00141 
00142 #endif /* KM_DBASE_H */