pg_sql.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * $Id$
  3. *
  4. * PostgreSQL Database Driver for SER
  5. *
  6. * Portions Copyright (C) 2001-2003 FhG FOKUS
  7. * Copyright (C) 2003 August.Net Services, LLC
  8. * Portions Copyright (C) 2005-2008 iptelorg GmbH
  9. *
  10. * This file is part of SER, a free SIP server.
  11. *
  12. * SER is free software; you can redistribute it and/or modify it under the
  13. * terms of the GNU General Public License as published by the Free Software
  14. * Foundation; either version 2 of the License, or (at your option) any later
  15. * version
  16. *
  17. * For a license to use the ser software under conditions other than those
  18. * described here, or to purchase support for this software, please contact
  19. * iptel.org by e-mail at the following addresses: [email protected]
  20. *
  21. * SER is distributed in the hope that it will be useful, but WITHOUT ANY
  22. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  23. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  24. * details.
  25. *
  26. * You should have received a copy of the GNU General Public License along
  27. * with this program; if not, write to the Free Software Foundation, Inc., 59
  28. * Temple Place, Suite 330, Boston, MA 02111-1307 USA
  29. */
  30. #ifndef _PG_SQL_H
  31. #define _PG_SQL_H
  32. /** \addtogroup postgres
  33. * @{
  34. */
  35. /** \file
  36. * Implementation of various functions that assemble SQL query strings for
  37. * PostgreSQL.
  38. */
  39. #include "../../lib/srdb2/db_cmd.h"
  40. #include "../../str.h"
  41. /** Builds an UPDATE SQL statement.
  42. * This function creates an UPDATE SQL statement where column values are
  43. * replaced with special markers. The resulting SQL statement is suitable
  44. * for submitting as prepared statement. The result string is zero terminated.
  45. * @param sql_cmd Pointer to a str variable where the resulting SQL statement
  46. * will be stored. The buffer in sql_cmd->s is allocated using
  47. * pkg_malloc and the caller of the function is responsible for
  48. * freeing it.
  49. * @param cmd The command whose data will be used to generate the query.
  50. * @return 0 on success, negative number on error
  51. */
  52. int build_update_sql(str* sql_cmd, db_cmd_t* cmd);
  53. /** Builds an INSERT SQL statement.
  54. * This function creates an INSERT SQL statement where column values are
  55. * replaced with special markers. The resulting SQL statement is suitable
  56. * for submitting as prepared statement. The result string is zero terminated.
  57. * @param sql_cmd Pointer to a str variable where the resulting SQL statement
  58. * will be stored. The buffer in sql_cmd->s is allocated using
  59. * pkg_malloc and the caller of the function is responsible for * freeing it.
  60. * @param cmd The command whose data will be used to generate the query.
  61. * @return 0 on success, negative number on error
  62. */
  63. int build_insert_sql(str* sql_cmd, db_cmd_t* cmd);
  64. /** Builds a DELETE SQL statement.
  65. * This function creates a DELETE SQL statement where column values are
  66. * replaced with special markers. The resulting SQL statement is suitable
  67. * for submitting as prepared statement. The result string is zero terminated.
  68. * @param sql_cmd Pointer to a str variable where the resulting SQL statement
  69. * will be stored. The buffer in sql_cmd->s is allocated using
  70. * pkg_malloc and the caller of the function is responsible for
  71. * freeing it.
  72. * @param cmd The command whose data will be used to generate the query.
  73. * @return 0 on success, negative number on error
  74. */
  75. int build_delete_sql(str* sql_cmd, db_cmd_t* cmd);
  76. /** Builds a SELECT SQL statement.
  77. * This function creates a SELECT SQL statement where column values are
  78. * replaced with special markers. The resulting SQL statement is suitable
  79. * for submitting as prepared statement. The result string is zero terminated.
  80. * @param sql_cmd Pointer to a str variable where the resulting SQL statement
  81. * will be stored. The buffer in sql_cmd->s is allocated using
  82. * pkg_malloc and the caller of the function is responsible for
  83. * freeing it.
  84. * @param cmd The command whose data will be used to generate the query.
  85. * @return 0 on success, negative number on error
  86. */
  87. int build_select_sql(str* sql_cmd, db_cmd_t* cmd);
  88. /* Builds SQL query used to obtain the list of supported field types.
  89. * This function builds a special SQL query that is used to obtain the list
  90. * of supported field type from the server's system catalogs.
  91. */
  92. int build_select_oid_sql(str* sql_cmd);
  93. /** Builds the SQL query used to determine the format of timestamp fields.
  94. * This function builds a special SQL query that is sent to the server
  95. * immediately after establishing a connection to determine the format of
  96. * timestamp fields used on the server.
  97. */
  98. int build_timestamp_format_sql(str* sql_cmd);
  99. /** @} */
  100. #endif /* _PG_SQL_H */