]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/cats/myingres.sh
backport code from master
[bacula/bacula] / bacula / src / cats / myingres.sh
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2009-2010 Free Software Foundation Europe e.V.
5
6    The main author of Bacula is Kern Sibbald, with contributions from
7    many others, a complete list can be found in the file AUTHORS.
8    This program is Free Software; you can redistribute it and/or
9    modify it under the terms of version two of the GNU General Public
10    License as published by the Free Software Foundation and included
11    in the file LICENSE.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23    Bacula® is a registered trademark of Kern Sibbald.
24    The licensor of Bacula is the Free Software Foundation Europe
25    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26    Switzerland, email:ftf@fsfeurope.org.
27 */
28 #ifndef _MYINGRES_SH
29 #define _MYINGRES_SH
30
31 EXEC SQL INCLUDE SQLDA;
32
33 /* ---typedefs--- */
34
35 typedef struct ing_timestamp {
36    unsigned short year;
37    unsigned char month;
38    unsigned char day;
39    unsigned int secs;
40    unsigned int nsecs;
41    unsigned char tzh;
42    unsigned char tzm;
43 } ING_TIMESTAMP;
44
45 typedef struct ing_field {
46    char *name;
47    int max_length;
48    unsigned int type;
49    unsigned int flags;          /* 1 == not null */
50 } INGRES_FIELD;
51
52 typedef struct ing_row {
53    IISQLVAR *sqlvar;            /* ptr to sqlvar[sqld] for one row */
54    struct ing_row *next;
55    int row_number;
56 } ING_ROW;
57
58 typedef enum ing_status {
59    ING_COMMAND_OK,
60    ING_TUPLES_OK,
61    ING_NO_RESULT,
62    ING_NO_ROWS_PROCESSED,
63    ING_EMPTY_RESULT,
64    ING_ERROR
65 } ING_STATUS;
66
67 typedef struct ing_varchar {
68    short len;
69    char* value;
70 } ING_VARCHAR;
71
72 /* It seems, Bacula needs the complete query result stored in one data structure */
73 typedef struct ing_result {
74    IISQLDA *sqlda;              /* descriptor */
75    INGRES_FIELD *fields;
76    int num_rows;
77    int num_fields;
78    ING_STATUS status;
79    ING_ROW *first_row;
80    ING_ROW *act_row;            /* just for iterating */
81 } INGresult;
82
83 typedef struct ing_conn {
84    char *dbname;
85    char *user;
86    char *password;
87    int session_id;
88    char *msg;
89 } INGconn;
90
91 /* ---Prototypes--- */
92 int INGgetCols(INGconn *dbconn, const char *query, bool transaction);
93 char *INGgetvalue(INGresult *ing_res, int row_number, int column_number);
94 bool INGgetisnull(INGresult *ing_res, int row_number, int column_number);
95 int INGntuples(const INGresult *ing_res);
96 int INGnfields(const INGresult *ing_res);
97 char *INGfname(const INGresult *ing_res, int column_number);
98 short INGftype(const INGresult *ing_res, int column_number);
99 int INGexec(INGconn *dbconn, const char *query, bool transaction);
100 INGresult *INGquery(INGconn *dbconn, const char *query, bool transaction);
101 void INGclear(INGresult *ing_res);
102 void INGcommit(const INGconn *dbconn);
103 INGconn *INGconnectDB(char *dbname, char *user, char *passwd, int session_id);
104 void INGsetDefaultLockingMode(INGconn *dbconn);
105 void INGdisconnectDB(INGconn *dbconn);
106 char *INGerrorMessage(const INGconn *dbconn);
107 char *INGcmdTuples(INGresult *ing_res);
108
109 #endif /* _MYINGRES_SH */