km_dbase.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2003 August.Net Services, LLC
  5. * Copyright (C) 2008 1&1 Internet AG
  6. *
  7. * This file is part of Kamailio, a free SIP server.
  8. *
  9. * Kamailio is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version
  13. *
  14. * Kamailio is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. *
  23. * History
  24. * -------
  25. * 2003-04-06 initial code written (Greg Fausak/Andy Fullford)
  26. */
  27. /*! \file
  28. * \brief DB_POSTGRES :: Core
  29. * \ingroup db_postgres
  30. * Module: \ref db_postgres
  31. */
  32. #ifndef KM_DBASE_H
  33. #define KM_DBASE_H
  34. #include "../../lib/srdb1/db_con.h"
  35. #include "../../lib/srdb1/db_res.h"
  36. #include "../../lib/srdb1/db_key.h"
  37. #include "../../lib/srdb1/db_op.h"
  38. #include "../../lib/srdb1/db_val.h"
  39. /*
  40. * Initialize database connection
  41. */
  42. db1_con_t* db_postgres_init(const str* _url);
  43. /*
  44. * Initialize database connection - no pooling
  45. */
  46. db1_con_t* db_postgres_init_nopool(const str* _url);
  47. /*
  48. * Close a database connection
  49. */
  50. void db_postgres_close(db1_con_t* _h);
  51. /*
  52. * Return result of previous query
  53. */
  54. int db_postgres_store_result(const db1_con_t* _h, db1_res_t** _r);
  55. /*
  56. * Free all memory allocated by get_result
  57. */
  58. int db_postgres_free_result(db1_con_t* _h, db1_res_t* _r);
  59. /*
  60. * Do a query
  61. */
  62. int db_postgres_query(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op,
  63. const db_val_t* _v, const db_key_t* _c, const int _n, const int _nc,
  64. const db_key_t _o, db1_res_t** _r);
  65. /*
  66. * Raw SQL query
  67. */
  68. int db_postgres_raw_query(const db1_con_t* _h, const str* _s, db1_res_t** _r);
  69. /*
  70. * Insert a row into table
  71. */
  72. int db_postgres_insert(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v,
  73. const int _n);
  74. /*
  75. * Delete a row from table
  76. */
  77. int db_postgres_delete(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
  78. const db_val_t* _v, const int _n);
  79. /*
  80. * Update a row in table
  81. */
  82. int db_postgres_update(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
  83. const db_val_t* _v, const db_key_t* _uk, const db_val_t* _uv, const int _n,
  84. const int _un);
  85. /*
  86. * fetch rows from a result
  87. */
  88. int db_postgres_fetch_result(const db1_con_t* _h, db1_res_t** _r, const int nrows);
  89. /*
  90. * number of rows affected by the last DB query/statement
  91. */
  92. int db_postgres_affected_rows(const db1_con_t* _h);
  93. /*
  94. * Store name of table that will be used by
  95. * subsequent database functions
  96. */
  97. int db_postgres_use_table(db1_con_t* _h, const str* _t);
  98. /*
  99. * Replace a row in table (via update/insert)
  100. */
  101. int db_postgres_replace(const db1_con_t* _h, const db_key_t* _k,
  102. const db_val_t* _v, const int _n, const int _un, const int _m);
  103. #endif /* KM_DBASE_H */