Support A2Billing :

provided by Star2Billing S.L.

Support A2Billing :
It is currently Fri Apr 19, 2024 1:14 am
Voice Broadcast System


All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject:
PostPosted: Thu Aug 09, 2007 8:47 am 
Offline

Joined: Sun Mar 12, 2006 2:49 pm
Posts: 954
Location: Barcelona
Follow up of discuss between Steve Dommet & Areski Belaid :

Quote:
> > Concerning #33
> >
> > then you come back on the last solution with :
> > $QUERY = "SELECT cc_did.id, cc_did_destination.id, billingtype,
> > tariff, destination, voip_call, username".
> > " FROM cc_did, cc_did_destination, cc_card ".
> > " WHERE id_cc_did=cc_did.id and
> > cc_card.id=id_cc_card and cc_did_destination.activated=1 and
> > cc_did.activated=1 and did='$mydnid' ".
> > - " AND cc_did.startingdate<= CURRENT_TIMESTAMP
> > AND (cc_did.expirationdate > CURRENT_TIMESTAMP OR
> > cc_did.expirationdate IS NULL OR ".
> > - " cc_did.expirationdate = '0000-00-00
> > 00:00:00') ORDER BY priority ASC";
> > + " AND cc_did.startingdate<= CURRENT_TIMESTAMP
> > AND (cc_did.expirationdate > CURRENT_TIMESTAMP OR
> > cc_did.expirationdate IS NULL";
> > + if ($A2B->config["database"]['dbtype'] != "postgres"){
> > + // MYSQL
> > + $QUERY .= " OR cc_did.expirationdate =
> > '0000-00-00 00:00:00'";
> > + }
> > + $QUERY .= ") ORDER BY priority ASC";
> >
> >
> >
> > can we clear this :D
> >
> >
> That last patch simply removes the check that causes the AGI to fail on
> DIDs, and works well for me here.
> http://trac.asterisk2billing.org/cgi-bi ... dates.diff
>
> I was looking at all the instances in the code where "0000-00-00" is
> referenced and there are many. It seemed like I would like introduce
> more bugs trying to change all instances to a new different default
> date. Then I learned that MySQL substitutes any invalid date with
> '0000-00-00', whereas Postgres will refuse to do the insert/update.
>
> I'm not sure what the best long-term solution is for A2B to remain
> database agnostic with respect to these dates. Perhaps we can change
> the tests to be <'1980-01-01' or some other obviously bogus date, then
> each database can have it's own preferred default date easily. I know
> Postgresql evaluates '0001-01-01'<'1980-01-01'::timestamp to be true. I
> think if MySQL evaluates '0000-00-00'<'1980-01-01' to be true this may
> be the solution. I don't have a MySQL install handy to test this.
>
> Then I noticed '-infinity' in table 8-13 in section 8.5.1.5 Special
> values: http://www.postgresql.org/docs/8.0/stat ... etime.html
> Perhaps we could set a global variable NULL_TIMESTAMP based on the
> dbtype to either '0000-00-00' or '-infinity' and use it within all the
> queries. I might have a play with that tomorrow if I get some time.
>
> I also noticed in the Postgres schema some fields use 'timestamp', and
> others use 'timestamp without timezone'. Surely they should all be the
> same? So I want to fix that too, but I'm unsure whether to use 'with'
> or 'without timezone' on all columns. I think they should all have
> 'without timezone', yes?
> I think this would fix a couple of bugs I've seen: on non-UTC timezones
> immediately after creating a ratecard/callplan it won't work until
> $UTC_offset hours later.


Added after 10 minutes:


Indeed the 0000-00-00 00:00:00 seems a bit tricky in mysql,
the cc_did table as some other is the several timestamp :
creationdate TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
startingdate TIMESTAMP,
expirationdate TIMESTAMP,

only one can be initiate at CURRENT_TIMESTAMP, if you have more than 1 you will get the following error :
ERROR 1293 (HY000): Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause

So when postgresql will use a NULL Value mysql will replace it by 0000-00-00 00:00:00.
Well the point here also is that we should not to have any null or 0000 value on those field if they are correctly initiate, so this is more a security measure in order to avoid sql error (well the intent fails :D)


maybe an other simple solution would be that we initiate the value to a usable date like,
creationdate TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
startingdate TIMESTAMP DEFAULT '2000-01-01 00:00:00',
expirationdate TIMESTAMP DEFAULT '2000-01-01 00:00:00',


this is just a quick idea, probably it will request more thoughts
:?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 09, 2007 7:33 pm 
Offline
Moderator
User avatar

Joined: Thu Jun 22, 2006 2:19 pm
Posts: 2890
Location: Devon, UK
I've done a lot of tidying of the Postgres schema today, and tried to smooth the way for upgrades in preparation for the mass migration of customers from versions <1.3.0. :P

I'd love to hear from anyone who tries upgrading from an older version after applying the patch on this ticket: http://trac.asterisk2billing.org/cgi-bin/trac.cgi/ticket/93

I did fix a couple of small problems with the MySQL schema too whilst I was at it, so perhaps MySQL users might like to test too. The MySQL schema looked to be in much better shape to start with though.

Cheers folks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 16, 2007 1:59 am 
Offline
Moderator
User avatar

Joined: Thu Jun 22, 2006 2:19 pm
Posts: 2890
Location: Devon, UK
I've just added a new file to the ticket mentioned above. It fixes more breakages I found in the database after a v1.2.3 to v1.3.0 upgrade. I only tested in on Postgres, but I can't see any reason why it wouldn't work on MySQL 5 too.

So please everyone if you upgraded from v1.2.3 check your SIP/IAX friends, if the first column is blank then this program will fix it up for you.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 
VoIP Billing solution


All times are UTC


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group