return 1;
}
+/*
+ * Retrieve database type
+ */
+const char *
+db_get_type(void)
+{
+ return "Internal";
+}
+
/*
* Initialize database data structure. In principal this should
* never have errors, or it is really fatal.
return mdb; /* already open */
}
}
+
Dmsg0(200, "db_open first time\n");
mdb = (B_DB *)malloc(sizeof(B_DB));
memset(mdb, 0, sizeof(B_DB));
#ifdef __SQL_C
+#if defined(BUILDING_CATS)
#ifdef HAVE_SQLITE
#define BDB_VERSION 10
#endif /* HAVE_MYSQL */
#endif /* HAVE_SQLITE */
#endif /* HAVE_POSTGRESQL */
+#endif
/* Use for better error location printing */
#define UPDATE_DB(jcr, db, cmd) UpdateDB(__FILE__, __LINE__, jcr, db, cmd)
bool check_tables_version(JCR *jcr, B_DB *mdb);
void _db_unlock(const char *file, int line, B_DB *mdb);
void _db_lock(const char *file, int line, B_DB *mdb);
+const char *db_get_type(void);
void print_dashes(B_DB *mdb);
void print_result(B_DB *mdb);
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+/*
+ * Retrieve database type
+ */
+const char *
+db_get_type(void)
+{
+ return "MySQL";
+}
+
/*
* Initialize database data structure. In principal this should
* never have errors, or it is really fatal.
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+/*
+ * Retrieve database type
+ */
+const char *
+db_get_type(void)
+{
+ return "PostgreSQL";
+
+}
+
/*
* Initialize database data structure. In principal this should
* never have errors, or it is really fatal.
int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
+/*
+ * Retrieve database type
+ */
+const char *
+db_get_type(void)
+{
+ return "SQLite";
+}
+
/*
* Initialize database data structure. In principal this should
* never have errors, or it is really fatal.
jcr->catalog->db_name, jcr->catalog->db_address,
jcr->catalog->db_user, jcr->catalog->db_password,
jcr->catalog->db_socket, jcr->catalog->db_port,
- catalog_db);
+ db_get_type());
}
bsnprintf(errmsg, sizeof(errmsg), _("Attribute %s not found."), attrname);
FILE *con_fd = NULL; /* Console file descriptor */
brwlock_t con_lock; /* Console lock structure */
-
-#if defined(HAVE_POSTGRESQL)
-char catalog_db[] = "PostgreSQL";
-#elif defined(HAVE_MYSQL)
-char catalog_db[] = "MySQL";
-#elif defined(HAVE_SQLITE)
-char catalog_db[] = "SQLite";
-#else
-char catalog_db[] = "Internal";
-#endif
+static char *catalog_db = NULL; /* database type */
const char *host_os = HOST_OS;
const char *distname = DISTNAME;
}
}
+const char *
+get_db_type(void)
+{
+ return catalog_db != NULL ? catalog_db : "unknown";
+}
+
+void
+set_db_type(const char *name)
+{
+ if (catalog_db != NULL)
+ {
+ free(catalog_db);
+ }
+
+ catalog_db = bstrdup(name);
+}
+
/*
* Initialize message handler for a daemon or a Job
* We make a copy of the MSGS resource passed, so it belows
void Qmsg(JCR *jcr, int type, time_t mtime, const char *fmt,...);
bool get_trace(void);
+const char *get_db_type(void);
+void set_db_type(const char *file);
+
typedef void (*sql_query)(JCR *jcr, const char *cmd);
extern sql_query DLL_IMP_EXP p_sql_query;
extern char DLL_IMP_EXP my_name[];
extern const char * DLL_IMP_EXP working_directory;
extern time_t DLL_IMP_EXP daemon_start_time;
-extern char catalog_db[];
extern int DLL_IMP_EXP console_msg_pending;
extern FILE * DLL_IMP_EXP con_fd; /* Console file descriptor */
; mysql.c:
; postgresql.c:
; sqlite.c:
+_Z11db_get_typev
_Z12db_sql_queryP4B_DBPKcPFiPviPPcES3_
;_Z13db_next_indexP3JCRP4B_DBPcS3_
_Z16db_escape_stringPcS_i