dbcl_api.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * $Id$
  3. *
  4. * DB CLuster core functions
  5. *
  6. * Copyright (C) 2012 Daniel-Constantin Mierla (asipto.com)
  7. *
  8. * This file is part of Kamailio, a free SIP server.
  9. *
  10. * Kamailio is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version
  14. *
  15. * Kamailio is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. */
  24. /*! \file
  25. * \brief DB_CLUSTER :: Core
  26. * \ingroup db_cluster
  27. * Module: \ref db_cluster
  28. */
  29. #ifndef _DBCL_API_H_
  30. #define _DBCL_API_H_
  31. #include "../../lib/srdb1/db_con.h"
  32. #include "../../lib/srdb1/db_res.h"
  33. #include "../../lib/srdb1/db_key.h"
  34. #include "../../lib/srdb1/db_op.h"
  35. #include "../../lib/srdb1/db_val.h"
  36. #include "../../str.h"
  37. /*! \brief
  38. * Initialize database connection
  39. */
  40. db1_con_t* db_cluster_init(const str* _sqlurl);
  41. /*! \brief
  42. * Close a database connection
  43. */
  44. void db_cluster_close(db1_con_t* _h);
  45. /*! \brief
  46. * Free all memory allocated by get_result
  47. */
  48. int db_cluster_free_result(db1_con_t* _h, db1_res_t* _r);
  49. /*! \brief
  50. * Do a query
  51. */
  52. int db_cluster_query(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op,
  53. const db_val_t* _v, const db_key_t* _c, const int _n, const int _nc,
  54. const db_key_t _o, db1_res_t** _r);
  55. /*! \brief
  56. * fetch rows from a result
  57. */
  58. int db_cluster_fetch_result(const db1_con_t* _h, db1_res_t** _r, const int nrows);
  59. /*! \brief
  60. * Raw SQL query
  61. */
  62. int db_cluster_raw_query(const db1_con_t* _h, const str* _s, db1_res_t** _r);
  63. /*! \brief
  64. * Insert a row into table
  65. */
  66. int db_cluster_insert(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v, const int _n);
  67. /*! \brief
  68. * Delete a row from table
  69. */
  70. int db_cluster_delete(const db1_con_t* _h, const db_key_t* _k, const
  71. db_op_t* _o, const db_val_t* _v, const int _n);
  72. /*! \brief
  73. * Update a row in table
  74. */
  75. int db_cluster_update(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
  76. const db_val_t* _v, const db_key_t* _uk, const db_val_t* _uv, const int _n,
  77. const int _un);
  78. /*! \brief
  79. * Just like insert, but replace the row if it exists
  80. */
  81. int db_cluster_replace(const db1_con_t* handle, const db_key_t* keys,
  82. const db_val_t* vals, const int n, const int _un, const int _m);
  83. /*! \brief
  84. * Returns the last inserted ID
  85. */
  86. int db_cluster_last_inserted_id(const db1_con_t* _h);
  87. /*! \brief
  88. * Returns number of affected rows for last query
  89. */
  90. int db_cluster_affected_rows(const db1_con_t* _h);
  91. /*! \brief
  92. * Insert a row into table, update on duplicate key
  93. */
  94. int db_cluster_insert_update(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v,
  95. const int _n);
  96. /*! \brief
  97. * Insert a row into table
  98. */
  99. int db_cluster_insert_delayed(const db1_con_t* _h, const db_key_t* _k,
  100. const db_val_t* _v, const int _n);
  101. /*! \brief
  102. * Store name of table that will be used by
  103. * subsequent database functions
  104. */
  105. int db_cluster_use_table(db1_con_t* _h, const str* _t);
  106. #endif /* KM_DBASE_H */