25 |
#include "gparam.h" |
#include "gparam.h" |
26 |
#include "db.h" |
#include "db.h" |
27 |
#include "regex.h" |
#include "regex.h" |
|
#ifdef USE_POSTGRES |
|
|
#include "libpq-fe.h" |
|
|
#endif |
|
28 |
#include "strbuf.h" |
#include "strbuf.h" |
29 |
|
|
30 |
#define DBOP_PAGESIZE 8192 |
#define DBOP_PAGESIZE 8192 |
47 |
int keylen; /* key length */ |
int keylen; /* key length */ |
48 |
char prev[MAXKEYLEN+1]; /* previous key value */ |
char prev[MAXKEYLEN+1]; /* previous key value */ |
49 |
int perm; /* file permission */ |
int perm; /* file permission */ |
|
#ifdef USE_POSTGRES |
|
|
/* |
|
|
* (3) POSTGRES PART |
|
|
*/ |
|
|
char tblname[80]; /* table name */ |
|
|
PGresult *res; /* result structure */ |
|
|
/* SQL statement templete */ |
|
|
STRBUF *get_stmt; /* pgop_get() */ |
|
|
int get_stmt_len; |
|
|
STRBUF *getkey_stmt; /* pgop_getkey_by_fid() */ |
|
|
int getkey_stmt_len; |
|
|
STRBUF *put_stmt; /* pgop_put() */ |
|
|
int put_stmt_len; |
|
|
STRBUF *fetch_stmt; /* pgop_first(), pgop_next() */ |
|
|
int fetch_stmt_len; |
|
|
STRBUF *delete_stmt; /* pgop_delete() */ |
|
|
int delete_stmt_len; |
|
|
#endif /* POSTGRES */ |
|
50 |
} DBOP; |
} DBOP; |
51 |
|
|
52 |
/* |
/* |
54 |
*/ |
*/ |
55 |
#define DBOP_DUP 1 /* allow duplicate records */ |
#define DBOP_DUP 1 /* allow duplicate records */ |
56 |
#define DBOP_REMOVE 2 /* remove file when closed */ |
#define DBOP_REMOVE 2 /* remove file when closed */ |
|
#define DBOP_POSTGRES 4 /* use postgres database */ |
|
57 |
/* |
/* |
58 |
* ioflags |
* ioflags |
59 |
*/ |
*/ |
63 |
void dbop_setinfo(char *info); |
void dbop_setinfo(char *info); |
64 |
DBOP *dbop_open(const char *, int, int, int); |
DBOP *dbop_open(const char *, int, int, int); |
65 |
char *dbop_get(DBOP *, const char *); |
char *dbop_get(DBOP *, const char *); |
66 |
void dbop_put(DBOP *, const char *, const char *, const char *); |
void dbop_put(DBOP *, const char *, const char *); |
67 |
void dbop_delete(DBOP *, const char *); |
void dbop_delete(DBOP *, const char *); |
68 |
char *dbop_getkey_by_fid(DBOP *, const char *); |
void dbop_update(DBOP *, const char *, const char *); |
|
void dbop_delete_by_fid(DBOP *, const char *); |
|
|
void dbop_update(DBOP *, const char *, const char *, const char *); |
|
69 |
char *dbop_first(DBOP *, const char *, regex_t *, int); |
char *dbop_first(DBOP *, const char *, regex_t *, int); |
70 |
char *dbop_next(DBOP *); |
char *dbop_next(DBOP *); |
71 |
char *dbop_lastdat(DBOP *); |
char *dbop_lastdat(DBOP *); |