summaryrefslogtreecommitdiff
path: root/src/sql.cpp
blob: 801a90545e8cd452b81d8eeb7b1c1a109d8bda5a (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
28
29
30
31
32
33
34
#include "sql.hpp"
#include <command.h>
#include <dbpp-postgresql/pq-command.h>

namespace WebStat::SQL {
	// ccache doesn't play nicely with #embed
	// https://github.com/ccache/ccache/issues/1540
	// ccache:disable

	const std::string ACCESS_LOG_INSERT {
#embed "sql/accessLogInsert.sql"
	};
	const std::string ACCESS_LOG_PURGE_OLD {
#embed "sql/accessLogPurgeOld.sql"
	};
	const std::string ENTITY_INSERT {
#embed "sql/entityInsert.sql"
	};
	const std::string ENTITY_UPDATE_DETAIL {
#embed "sql/entityUpdateDetail.sql"
	};
	const std::string HOST_UPSERT {
#embed "sql/hostUpsert.sql"
	};
#define HASH_OPTS(VAR) \
	const DB::CommandOptionsPtr VAR##_OPTS \
			= std::make_shared<PQ::CommandOptions>(std::hash<std::string> {}(VAR), 35, false)
	HASH_OPTS(ACCESS_LOG_INSERT);
	HASH_OPTS(ACCESS_LOG_PURGE_OLD);
	HASH_OPTS(ENTITY_INSERT);
	HASH_OPTS(ENTITY_UPDATE_DETAIL);
	HASH_OPTS(HOST_UPSERT);
#undef HASH_OPTS
}