summaryrefslogtreecommitdiffstats
path: root/server/parser/pgsql.h
blob: e40b7d2300dca244c887623c6efcc0ea8680d6fb (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
 * Copyright (C) 2009 Red Hat Inc.
 *
 * This application is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; version 2.
 *
 * This application is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 */

/**
 * @file   pgsql.h
 * @author David Sommerseth <davids@redhat.com>
 * @date   Wed Oct 13 17:44:35 2009
 *
 * @brief  Database API for the PostgreSQL database.
 *
 *
 */

#ifndef _RTEVAL_PGSQL_H
#define _RTEVAL_PGSQL_H

#include <libpq-fe.h>
#include <libxml/parser.h>
#include <libxslt/transform.h>

#include <log.h>
#include <eurephia_values.h>
#include <parsethread.h>

/**
 *  A unified database abstraction layer, providing log support
 */
typedef struct {
	unsigned int id;  /**< Unique connection ID, used for debugging */
	LogContext *log;  /**< Initialised log context */
	PGconn *db;       /**< Database connection handler */
} dbconn;

/* Generic database function */
dbconn *db_connect(eurephiaVALUES *cfg, unsigned int id, LogContext *log);
int db_ping(dbconn *dbc);
void db_disconnect(dbconn *dbc);
int db_begin(dbconn *dbc);
int db_commit(dbconn *dbc);
int db_rollback(dbconn *dbc);

/* rteval specific database functions */
int db_wait_notification(dbconn *dbc, const int *shutdown, const char *listenfor);
parseJob_t *db_get_submissionqueue_job(dbconn *dbc, pthread_mutex_t *mtx);
int db_update_submissionqueue(dbconn *dbc, unsigned int submid, int status);
int db_register_system(dbconn *dbc, xsltStylesheet *xslt, xmlDoc *summaryxml);
int db_get_new_rterid(dbconn *dbc);
int db_register_rtevalrun(dbconn *dbc, xsltStylesheet *xslt, xmlDoc *summaryxml,
			  unsigned int submid, int syskey, int rterid, const char *report_fname);
int db_register_cyclictest(dbconn *dbc, xsltStylesheet *xslt, xmlDoc *summaryxml, int rterid);

#endif