Browse code

- Database capability check in AVP - Typo fixed

Jan Janak authored on 14/09/2004 12:49:29
Showing 3 changed files
... ...
@@ -40,6 +40,7 @@
40 40
 #include "db_con.h"
41 41
 #include "db_row.h"
42 42
 #include "db_res.h"
43
+#include "db_cap.h"
43 44
 
44 45
 
45 46
 /*
... ...
@@ -42,16 +42,17 @@ typedef enum db_cap {
42 42
 
43 43
 
44 44
 /*
45
- * All database functions except raw_query
45
+ * All database capabilities except raw_query which should be checked
46
+ * separately when needed
46 47
  */
47
-#define DB_CAP_ALL (DB_CAP_QUERY | DB_CAP_INSERT | DB_CAP_DELETE | DB_CAP_UPDATE)	
48
+#define DB_CAP_ALL (DB_CAP_QUERY | DB_CAP_INSERT | DB_CAP_DELETE | DB_CAP_UPDATE)
48 49
 
49 50
 
50 51
 /*
51 52
  * True if all the capabilities in cpv are supported by module
52 53
  * represented by dbf, false otherwise
53 54
  */
54
-#define DB_CAPABILITY(dbf, cpv) ((dbf)->cap & (cpv)) == (cpv))
55
+#define DB_CAPABILITY(dbf, cpv) (((dbf).cap & (cpv)) == (cpv))
55 56
 
56 57
 
57 58
 #endif /* DB_CAP_H */
... ...
@@ -567,6 +567,12 @@ static inline void print_res(db_res_t* res, FILE *rpl)
567 567
 int init_db_fifo(char* fifo_db_url)
568 568
 {
569 569
 	if ( bind_dbmod(fifo_db_url, &fifo_dbf)==0 ) {
570
+		if (!DB_CAPABILITY(fifo_dbf, DB_CAP_ALL | DB_CAP_RAW_QUERY)) {
571
+			LOG(L_ERR, "ERROR: init_db_fifo: Database module does "
572
+			    "not implement all function needed by AVP code\n");
573
+			return -1;
574
+		}
575
+
570 576
 		if ( (fifo_db_con=fifo_dbf.init( fifo_db_url ))==0) {
571 577
 			/* connection failed */
572 578
 			LOG(L_ERR,"ERROR: init_db_fifo: unable to connect to database -> "