Re: [pmacct-discussion] Source port column name depends on database

2010-09-14 Thread Paolo Lucente
Hi Chris,

Agree. I seem to reckon this legacy issue is limited to the TCP/UDP
ports only and i'm thinking perhaps the best way to approach it is
to issue a true/false config switch, ie. sql_table_compat, for the
purpose. But for consistency with the rest, these fields should be
aligned to port_src and port_dst. Agree?

Cheers,
Paolo


On Mon, Sep 13, 2010 at 11:14:18AM +0200, Chris Wilson wrote:
 Hi all,
 
 We just had a bug report in pmGraph because it assumed that the source 
 port database column was called src_port always, as it is in MySQL. The 
 user is using a postgres database, and it appears that the column is 
 called port_src there instead:
 
 if (!strcmp(config.type, mysql) || !strcmp(config.type, sqlite3)) 
 {
   strncat(insert_clause, src_port, SPACELEFT(insert_clause));
   strncat(where[primitive].string, src_port=%u, 
 SPACELEFT(where[primitive].string));
 }
 else {
   strncat(insert_clause, port_src, SPACELEFT(insert_clause));
   strncat(where[primitive].string, port_src=%u, 
 SPACELEFT(where[primitive].string));
 }
 
 I would be much happier writing database-independent code around 
 pmacct if it didn't do things like this.
 
 I understand that there is a backwards compatibility issue with changing 
 it, but perhaps it could be done in a new version of the mysql or postgres 
 schema?
 
 Cheers, Chris.
 -- 
 Aptivate | http://www.aptivate.org | Phone: +44 1223 760887
 The Humanitarian Centre, Fenner's, Gresham Road, Cambridge CB1 2ES
 
 Aptivate is a not-for-profit company registered in England and Wales
 with company number 04980791.
 
 ___
 pmacct-discussion mailing list
 http://www.pmacct.net/#mailinglists

___
pmacct-discussion mailing list
http://www.pmacct.net/#mailinglists


Re: [pmacct-discussion] Source port column name depends on database

2010-09-14 Thread Chris Wilson
Hi Paolo,

On Tue, 14 Sep 2010, Paolo Lucente wrote:

 Agree. I seem to reckon this legacy issue is limited to the TCP/UDP 
 ports only and i'm thinking perhaps the best way to approach it is to 
 issue a true/false config switch, ie. sql_table_compat, for the purpose. 
 But for consistency with the rest, these fields should be aligned to 
 port_src and port_dst. Agree?

Agree definitely on consistency, and don't really mind which way the name 
goes.

I'm not sure about adding a new config switch, do we actually need it? I 
seem to recall some wiser counsel to not add configuration options where 
possible, as it exponentially multiplies the complexity of the software 
code and also linearly increases the complexity of using it.

If our intention is to rename the MySQL fields going forward, why not just 
use a new schema version to grandfather the old column names?

Cheers, Chris.
-- 
Aptivate | http://www.aptivate.org | Phone: +44 1223 760887
The Humanitarian Centre, Fenner's, Gresham Road, Cambridge CB1 2ES

Aptivate is a not-for-profit company registered in England and Wales
with company number 04980791.

___
pmacct-discussion mailing list
http://www.pmacct.net/#mailinglists