summaryrefslogtreecommitdiff
path: root/lib/output/pq/pqConn.cpp
blob: 78cdc06fa27efc10a2189c0379cfe8bd0e5fe696 (plain)
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
#include "pqConn.h"
#include <helpers.h>
#include <stdexcept>

namespace MyGrate::Output::Pq {
	PqConn::PqConn(const char * const str) : conn {PQconnectdb(str)}
	{
		verify<std::runtime_error>(PQstatus(conn) == CONNECTION_OK, "Connection failure");
		PQsetNoticeProcessor(conn, notice_processor, this);
	}

	PqConn::~PqConn()
	{
		PQfinish(conn);
	}

	void
	PqConn::notice_processor(void * p, const char * n)
	{
		return static_cast<PqConn *>(p)->notice_processor(n);
	}

	void
	PqConn::notice_processor(const char *) const
	{
	}
}