[Kamailio-Devel] Setting mysql socket

Andreas Granig agranig at sipwise.com
Mon Dec 29 20:38:51 CET 2008


Hi Henning,

I've added the my.cnf group definition for mysql urls in a fully 
backward-compatible way like
	mysql://user:pass@[group]host:port/db or
	mysql://user:pass@[group]/db or
	mysql://[group]/db
and any variants of it (it comes down to parsing the group part from the 
host part in my_con.c. There's also a small extension to db_id.c to also 
check usernames for NULL before comparing, otherwise it would segfault 
for the last example.

Attached you can find the patches for trunk (it actually applies to 1.4 
also, except for the generated README because of some date/revision 
changes).

If that's fine for you, please apply the patch. If there's more room for 
improvement, let me know.

Andreas

Henning Westerholt wrote:
> On Fri, December 26, 2008 9:04 am, Andreas Granig wrote:
>> I ran into the issue of having two separate local mysql dbs running on
>> different unix sockets, and two kamailio instances, each accessing one
>> of the dbs. I think there are two ways to approach this, and I'd like to
>> hear your opinions before implementing one of these:
> 
> Hi Andreas,
> 
>> 1. Extending the db_url syntax for mysql to allow a new format
>> "mysql://user:pass@/path/to/sock:0/db" or something similar. Question is
>> how to separate the db name from the path. Maybe either by requiring a
>> port of "0" like shown above, or just taking the last "/" as separator
>> for the db name, which could be a bit confusing.
>>
>> 2. Adding "mysql_options(handle, MYSQL_READ_DEFAULT_GROUP, kam_group)"
>> before mysql_real_connect() to read a my.cnf section, where one could
>> specify the socket path. Again, question is how to specifiy the group
>> name. Simplest thing would be to add a db_mysql module parameter, but
>> one could have the need of connecting to separate dbs with some modules,
>> so again a db_url extension could be needed, like
>> "mysql://user:pass@[group]/db".
>>
>> I personally would rather go with the second approach since it's more
>> flexible (one could also pass specific char-sets etc.). Any comments?
> 
> I would also prefer the second approach, as i prefer to not change the
> db_url syntax that much. There is already a small patch on the tracker
> that implements this option [1]. The author also mentioned the use case of
> setting certain charsets.
> 
> Setting the group with a module parameter in the db_mysql module would
> work. But as you said, this would not satisfy your requirements having
> several unique groups in different modules. If the addition of the 'group'
> db_url parameter could be done in a backward compatible way, then this
> would be ok for me.
> 
> Happy holidays,
> 
> Henning
> 
> 
> [1]
> http://sourceforge.net/tracker/?func=detail&atid=743022&aid=1815631&group_id=139143
> 
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mysql-group-1.5.patch
Type: text/x-patch
Size: 7162 bytes
Desc: not available
Url : http://lists.kamailio.org/pipermail/devel/attachments/20081229/6ec0cc43/attachment.bin 


More information about the Devel mailing list