MYSQL / PGSQL / SQLite missing v9 table reference and SQLite documentation fix
snuffy22 opened this issue · comments
Description
The pmacct-create-table_v9.sqlite3 exists, but there is no updated reference in src/sqlite3_plugin.c
Just noticed that PSQL/MYSQL did not have it either so have added the parts for those.
Also the README.sqlite3 talks about using v9 tables, but specifies v7
Have attached a diff for the minor fixes
Version
(found in ) pmacct-1.7.8
all changes against git
diff --git a/sql/README.sqlite3 b/sql/README.sqlite3
index d9aa05c5..08e7212e 100644
--- a/sql/README.sqlite3
+++ b/sql/README.sqlite3
@@ -32,7 +32,7 @@ Similarly, v2 to v9 tables:
- To use v9 tables:
* data will be available in 'acct_v9' table of 'pmacct' DB.
- * Add 'sql_table_version: 7' line to your configuration.
+ * Add 'sql_table_version: 9' line to your configuration.
Similarly, BGP tables:
diff --git a/src/sqlite3_plugin.c b/src/sqlite3_plugin.c
index 1a85ea29..82e75e84 100644
--- a/src/sqlite3_plugin.c
+++ b/src/sqlite3_plugin.c
@@ -36,6 +36,7 @@ char sqlite3_table_v5[] = "acct_v5";
char sqlite3_table_v6[] = "acct_v6";
char sqlite3_table_v7[] = "acct_v7";
char sqlite3_table_v8[] = "acct_v8";
+char sqlite3_table_v9[] = "acct_v9";
char sqlite3_table_bgp[] = "acct_bgp";
/* Functions */
@@ -753,6 +754,7 @@ void SQLI_init_default_values(struct insert_data *idata)
if (!config.sql_db) config.sql_db = sqlite3_db;
if (!config.sql_table) {
if (config.sql_table_version == (SQL_TABLE_VERSION_BGP+1)) config.sql_table = sqlite3_table_bgp;
+ else if (config.sql_table_version == 9) config.sql_table = sqlite3_table_v9;
else if (config.sql_table_version == 8) config.sql_table = sqlite3_table_v8;
else if (config.sql_table_version == 7) config.sql_table = sqlite3_table_v7;
else if (config.sql_table_version == 6) config.sql_table = sqlite3_table_v6;
diff --git a/src/sqlite3_plugin.h b/src/sqlite3_plugin.h
index 921b7fba..06aa0398 100644
--- a/src/sqlite3_plugin.h
+++ b/src/sqlite3_plugin.h
@@ -51,4 +51,5 @@ extern char sqlite3_table_v5[];
extern char sqlite3_table_v6[];
extern char sqlite3_table_v7[];
extern char sqlite3_table_v8[];
+extern char sqlite3_table_v9[];
extern char sqlite3_table_bgp[];
diff --git a/src/pgsql_plugin.c b/src/pgsql_plugin.c
index 78354f2f..3405562b 100644
--- a/src/pgsql_plugin.c
+++ b/src/pgsql_plugin.c
@@ -40,6 +40,7 @@ char pgsql_table_v5[] = "acct_v5";
char pgsql_table_v6[] = "acct_v6";
char pgsql_table_v7[] = "acct_v7";
char pgsql_table_v8[] = "acct_v8";
+char pgsql_table_v9[] = "acct_v9";
char pgsql_table_bgp[] = "acct_bgp";
char pgsql_table_uni[] = "acct_uni";
char pgsql_table_uni_v2[] = "acct_uni_v2";
@@ -957,6 +958,7 @@ void PG_init_default_values(struct insert_data *idata)
if (typed) {
if (config.sql_table_version == (SQL_TABLE_VERSION_BGP+1)) config.sql_table = pgsql_table_bgp;
+ else if (config.sql_table_version == 9) config.sql_table = pgsql_table_v9;
else if (config.sql_table_version == 8) config.sql_table = pgsql_table_v8;
else if (config.sql_table_version == 7) config.sql_table = pgsql_table_v7;
else if (config.sql_table_version == 6) config.sql_table = pgsql_table_v6;
@@ -982,6 +984,10 @@ void PG_init_default_values(struct insert_data *idata)
}
}
else {
+ if (config.sql_table_version == 9) {
+ Log(LOG_WARNING, "WARN ( %s/%s ): Unified data are no longer supported. Switching to typed data.\n", config.name, config.type);
+ config.sql_table = pgsql_table_v9;
+ }
if (config.sql_table_version == 8) {
Log(LOG_WARNING, "WARN ( %s/%s ): Unified data are no longer supported. Switching to typed data.\n", config.name, config.type);
config.sql_table = pgsql_table_v8;
diff --git a/src/pgsql_plugin.h b/src/pgsql_plugin.h
index 6efb4a40..05e8e06b 100644
--- a/src/pgsql_plugin.h
+++ b/src/pgsql_plugin.h
@@ -61,6 +61,7 @@ extern char pgsql_table_v5[];
extern char pgsql_table_v6[];
extern char pgsql_table_v7[];
extern char pgsql_table_v8[];
+extern char pgsql_table_v9[];
extern char pgsql_table_bgp[];
extern char pgsql_table_uni[];
extern char pgsql_table_uni_v2[];
diff --git a/src/mysql_plugin.c b/src/mysql_plugin.c
index 98bbe495..32f1f0ea 100644
--- a/src/mysql_plugin.c
+++ b/src/mysql_plugin.c
@@ -41,6 +41,7 @@ char mysql_table_v5[] = "acct_v5";
char mysql_table_v6[] = "acct_v6";
char mysql_table_v7[] = "acct_v7";
char mysql_table_v8[] = "acct_v8";
+char mysql_table_v9[] = "acct_v9";
char mysql_table_bgp[] = "acct_bgp";
/* Functions */
@@ -795,6 +796,7 @@ void MY_init_default_values(struct insert_data *idata)
if (!config.sql_port) config.sql_port = mysql_prt;
if (!config.sql_table) {
if (config.sql_table_version == (SQL_TABLE_VERSION_BGP+1)) config.sql_table = mysql_table_bgp;
+ else if (config.sql_table_version == 9) config.sql_table = mysql_table_v9;
else if (config.sql_table_version == 8) config.sql_table = mysql_table_v8;
else if (config.sql_table_version == 7) config.sql_table = mysql_table_v7;
else if (config.sql_table_version == 6) config.sql_table = mysql_table_v6;
diff --git a/src/mysql_plugin.h b/src/mysql_plugin.h
index 2e535aef..f5922712 100644
--- a/src/mysql_plugin.h
+++ b/src/mysql_plugin.h
@@ -59,4 +59,5 @@ extern char mysql_table_v5[];
extern char mysql_table_v6[];
extern char mysql_table_v7[];
extern char mysql_table_v8[];
+extern char mysql_table_v9[];
extern char mysql_table_bgp[];
Hi @snuffy22 ,
This looks good. Why don't you contribute this with a Pull Request instead of an Issue? This way your contribution will be tracked! But of course i can apply the patch on your behalf, just let me know what works best for you.
Paolo
Hi @paololucente ,
Please apply on my behalf, I struggle with git most of the time with the pull/merge requests.
Thanks for your software
Done! Thanks!