File: pgsql.hpp

package info (click to toggle)
osm2pgsql 0.96.0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,304 kB
  • sloc: cpp: 11,462; python: 543; sh: 98; makefile: 17
file content (38 lines) | stat: -rw-r--r-- 1,177 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* Helper functions for pgsql access */

/* Current middle and output-pgsql do a lot of things similarly, this should
 * be used to abstract to commonalities */

#ifndef PGSQL_H
#define PGSQL_H

#include <string>
#include <cstring>
#include <libpq-fe.h>
#include <memory>

struct pg_result_deleter_t
{
    void operator()(PGresult *p) const { PQclear(p); }
};

typedef std::unique_ptr<PGresult, pg_result_deleter_t> pg_result_t;

pg_result_t pgsql_execPrepared(PGconn *sql_conn, const char *stmtName,
                               int nParams, const char *const *paramValues,
                               ExecStatusType expect);
void pgsql_CopyData(const char *context, PGconn *sql_conn, std::string const &sql);

pg_result_t pgsql_exec_simple(PGconn *sql_conn, ExecStatusType expect,
                              std::string const &sql);
pg_result_t pgsql_exec_simple(PGconn *sql_conn, ExecStatusType expect,
                              const char *sql);

int pgsql_exec(PGconn *sql_conn, const ExecStatusType expect, const char *fmt, ...)
#ifndef _MSC_VER
 __attribute__ ((format (printf, 3, 4)))
#endif
;

void escape(const std::string &src, std::string& dst);
#endif