km_dbase.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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_init2(const str* _url, db_pooling_t pooling);
  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. * Do a query and lock rows for update
  67. */
  68. int db_postgres_query_lock(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op,
  69. const db_val_t* _v, const db_key_t* _c, const int _n, const int _nc,
  70. const db_key_t _o, db1_res_t** _r);
  71. /*
  72. * Raw SQL query
  73. */
  74. int db_postgres_raw_query(const db1_con_t* _h, const str* _s, db1_res_t** _r);
  75. /*
  76. * Insert a row into table
  77. */
  78. int db_postgres_insert(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v,
  79. const int _n);
  80. /*
  81. * Delete a row from table
  82. */
  83. int db_postgres_delete(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
  84. const db_val_t* _v, const int _n);
  85. /*
  86. * Update a row in table
  87. */
  88. int db_postgres_update(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
  89. const db_val_t* _v, const db_key_t* _uk, const db_val_t* _uv, const int _n,
  90. const int _un);
  91. /*
  92. * fetch rows from a result
  93. */
  94. int db_postgres_fetch_result(const db1_con_t* _h, db1_res_t** _r, const int nrows);
  95. /*
  96. * number of rows affected by the last DB query/statement
  97. */
  98. int db_postgres_affected_rows(const db1_con_t* _h);
  99. /*
  100. * SQL BEGIN
  101. */
  102. int db_postgres_start_transaction(db1_con_t* _h, db_locking_t _l);
  103. /*
  104. * SQL COMMIT
  105. */
  106. int db_postgres_end_transaction(db1_con_t* _h);
  107. /*
  108. * SQL ROLLBACK
  109. */
  110. int db_postgres_abort_transaction(db1_con_t* _h);
  111. /*
  112. * Store name of table that will be used by
  113. * subsequent database functions
  114. */
  115. int db_postgres_use_table(db1_con_t* _h, const str* _t);
  116. /*
  117. * Replace a row in table (via update/insert)
  118. */
  119. int db_postgres_replace(const db1_con_t* _h, const db_key_t* _k,
  120. const db_val_t* _v, const int _n, const int _un, const int _m);
  121. #endif /* KM_DBASE_H */