diff options
Diffstat (limited to 'modules/postgres/postgres.c')
-rw-r--r-- | modules/postgres/postgres.c | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/modules/postgres/postgres.c b/modules/postgres/postgres.c index 3e696ca..1218564 100644 --- a/modules/postgres/postgres.c +++ b/modules/postgres/postgres.c @@ -32,9 +32,8 @@ #include <smap/stream.h> #include <smap/wordsplit.h> -#define MDB_INIT 0x01 -#define MDB_OPEN 0x02 -#define MDB_DEFDB 0x04 +#define MDB_OPEN 0x01 +#define MDB_DEFDB 0x02 struct modpg_db { int flags; @@ -83,12 +82,6 @@ opendb(struct modpg_db *db) return 0; } - if (!(db->flags & MDB_INIT)) { - smap_error("%s: module settings do not include opendb flag", - db->name); - return 1; - } - db->pgconn = PQconnectdb(db->conninfo); if (!db->pgconn) { smap_error("%s: out of memory", db->name); @@ -202,12 +195,9 @@ modpg_init(int argc, char **argv) { int i; int rc; - int opendb = 0; dbgid = smap_debug_alloc("postgres"); struct smap_option init_option[] = { - { SMAP_OPTSTR(open), smap_opt_bool, - &opendb }, { SMAP_OPTSTR(query), smap_opt_string, &def_db.template }, { SMAP_OPTSTR(positive-reply), smap_opt_string, @@ -227,13 +217,7 @@ modpg_init(int argc, char **argv) smap_error("out of memory"); return 1; } - } - if (opendb) { - if (!def_db.conninfo) { - smap_error("no connection info given"); - return 1; - } - def_db.flags = MDB_INIT; + def_db.flags = 0; def_db.name = "postgres"; } return 0; @@ -251,8 +235,6 @@ modpg_init_db(const char *dbid, int argc, char **argv) int i; struct smap_option init_option[] = { - { SMAP_OPTSTR(defaultdb), smap_opt_bitmask, - &flags, { MDB_DEFDB } }, { SMAP_OPTSTR(query), smap_opt_string, &query }, { SMAP_OPTSTR(positive-reply), smap_opt_string, @@ -279,12 +261,10 @@ modpg_init_db(const char *dbid, int argc, char **argv) free(db); return NULL; } - } else if (!(flags & MDB_DEFDB)) { - smap_error("%s: no connection info given", dbid); - return NULL; - } + } else + flags |= MDB_DEFDB; - db->flags = MDB_INIT | flags; + db->flags = flags; db->name = dbid; db->template = query; db->positive_reply = positive_reply; |