Thread: [Mysql-cocoa-users] Method to expose MYSQL pointer
Brought to you by:
sergecohen
|
From: Aaron J. <aj...@ed...> - 2004-09-04 01:47:52
Attachments:
PGP.sig
|
I've run across a situation where it would be very unfortunate for my application to automatically and silently re-establish its connection to the MySQL server if it is lost. The only way I've found to disable this behavior is to set the 'reconnect' member of the MYSQL structure to zero, rather than the default of one. So what I need is a method in MCPConnection that simply returns mConnection so that I can set the flag. For now I'll make a subclass of MCPConnection since mConnection is protected, but Serge do you think it would be possible to get such a method officially supported? Thanks, Aaron |
|
From: Serge C. <ser...@us...> - 2004-09-06 21:22:04
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Aaron;=0D =0D Indeed I'd rather not provide the pointer to the connection directly... =0D= just because this breaks the object concept and if some one deadly =0D needs it, the derivation solution (that you use) is still there.=0D Instead I can propose to have an interface to set this kind of =0D parameters directly from the object.=0D I have to check exactly what should be 'settable' and which interface =0D= will be correct with that (trying to avoid having too many functions =0D for that, maybe some kind of -setParameter:forKey: message).=0D =0D If other users are similar requirements or have preferences concerning =0D= the interface to these kind of setting, please answer (to the list so - =0D= - -if necessary- we can have a discution on that).=0D =0D Serge.=0D =0D PS: Aaron, sorry I sent you the mail from a wrong mail account, please =0D= if you answer me use the sourceforge mail account, and don't reply =0D directly to the previous mail. Thanks.=0D =0D Le 4 sept. 04, =E0 03:47, Aaron Jacobs a =E9crit :=0D =0D > I've run across a situation where it would be very unfortunate for my =0D= > application to automatically and silently re-establish its connection =0D= > to the MySQL server if it is lost. The only way I've found to disable = =0D > this behavior is to set the 'reconnect' member of the MYSQL structure =0D= > to zero, rather than the default of one. So what I need is a method =0D= > in MCPConnection that simply returns mConnection so that I can set the = =0D > flag. For now I'll make a subclass of MCPConnection since mConnection = =0D > is protected, but Serge do you think it would be possible to get such =0D= > a method officially supported?=0D >=0D > Thanks,=0D > Aaron=0D >=0D *******************************************=0D Serge Cohen=0D =0D GPG Key ID: 9CBB58FB=0D *******************************************=0D =0D -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (Darwin) iD8DBQFBPNTy5EPeG5y7WPsRAtTMAJ94ccaejFmam0EZIit++eoYd9mWTQCgkAKs 26hTqH7QqWdTFQGyIO8bZ34=3D =3DIARO -----END PGP SIGNATURE----- |
|
From: Aaron J. <aj...@ed...> - 2004-09-07 13:24:27
Attachments:
PGP.sig
|
Serge,
That's fair enough - you're right about the data encapsulation aspect.
In fact, I wasn't able to get the reconnect parameter to work at all -
for some reason it would work when I linked directly against
libmysqlclient, but not when I used SMySQL, even if I put the proper
setting right in the SMySQL code and built SMySQL myself with the same
version of libmysqlclient that worked on its own. I'm still not sure
why this is, but for future reference (in case anybody else needs it)
here is what I did. I just made a category on MCPConnection with one
extra function:
- (MCPResult *)queryStringWithoutReconnect:(NSString *)query
{
static BOOL disconnected = NO;
if (disconnected)
{
NSLog(@"Connection disconnected!");
return nil;
}
MCPResult *result = [self queryString:query];
if (([self getLastErrorID] == CR_SERVER_GONE_ERROR) || ([self
getLastErrorID] == CR_SERVER_LOST))
{
NSLog(@"Connection disconnected!");
disconnected = YES;
}
return result;
}
There are definitely more elegant ways to do this, but all I needed for
my particular application was for no more queries to happen under any
circumstances once the connection was lost.
Serge, you might consider making a method that allows you to set the
reconnect option and then use code similar to the above in the
queryString: method to make sure that a reconnect doesn't occur if not
desired. The reason that this is a big deal is that when
libmysqlclient reconnects it loses any session variables you had set
and, more importantly, it loses locks and transactions that the
application will not be aware are gone.
Aaron
On Sep 6, 2004, at 4:21 PM, Serge Cohen wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi Aaron;
>
> Indeed I'd rather not provide the pointer to the connection
> directly... just because this breaks the object concept and if some
> one deadly needs it, the derivation solution (that you use) is still
> there.
> Instead I can propose to have an interface to set this kind of
> parameters directly from the object.
> I have to check exactly what should be 'settable' and which interface
> will be correct with that (trying to avoid having too many functions
> for that, maybe some kind of -setParameter:forKey: message).
>
> If other users are similar requirements or have preferences concerning
> the interface to these kind of setting, please answer (to the list so
> - - -if necessary- we can have a discution on that).
>
> Serge.
>
> PS: Aaron, sorry I sent you the mail from a wrong mail account, please
> if you answer me use the sourceforge mail account, and don't reply
> directly to the previous mail. Thanks.
>
> Le 4 sept. 04, à 03:47, Aaron Jacobs a écrit :
>
>> I've run across a situation where it would be very unfortunate for my
>> application to automatically and silently re-establish its connection
>> to the MySQL server if it is lost. The only way I've found to
>> disable this behavior is to set the 'reconnect' member of the MYSQL
>> structure to zero, rather than the default of one. So what I need is
>> a method in MCPConnection that simply returns mConnection so that I
>> can set the flag. For now I'll make a subclass of MCPConnection
>> since mConnection is protected, but Serge do you think it would be
>> possible to get such a method officially supported?
>>
>> Thanks,
>> Aaron
>>
> *******************************************
> Serge Cohen
>
> GPG Key ID: 9CBB58FB
> *******************************************
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.3 (Darwin)
>
> iD8DBQFBPNTy5EPeG5y7WPsRAtTMAJ94ccaejFmam0EZIit++eoYd9mWTQCgkAKs
> 26hTqH7QqWdTFQGyIO8bZ34=
> =IARO
> -----END PGP SIGNATURE-----
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by BEA Weblogic Workshop
> FREE Java Enterprise J2EE developer tools!
> Get your free copy of BEA WebLogic Workshop 8.1 today.
> http://ads.osdn.com/?ad_idP47&alloc_id808&op=click
> _______________________________________________
> Mysql-cocoa-users mailing list
> Mys...@li...
> https://lists.sourceforge.net/lists/listinfo/mysql-cocoa-users
|
|
From: Aaron J. <aj...@ed...> - 2004-09-07 13:28:27
Attachments:
PGP.sig
|
Oh, I forgot to mention that to do this I had to build a custom version
of SMySQL that included libmysql's errmsg.h header file. It would
probably be a good idea to do this in the main distribution so that you
can test against various errors returned from getLastErrorID.
While we're talking about that, I also wondered why the version of
libmysqlcient linked against by SMySQL is so old (4.0.14) as well as
its headers, which mention server version 4.0.5. I linked against
fink's version (4.0.17) and that worked great.
Aaron
On Sep 7, 2004, at 8:24 AM, Aaron Jacobs wrote:
> Serge,
>
> That's fair enough - you're right about the data encapsulation aspect.
> In fact, I wasn't able to get the reconnect parameter to work at all
> - for some reason it would work when I linked directly against
> libmysqlclient, but not when I used SMySQL, even if I put the proper
> setting right in the SMySQL code and built SMySQL myself with the same
> version of libmysqlclient that worked on its own. I'm still not sure
> why this is, but for future reference (in case anybody else needs it)
> here is what I did. I just made a category on MCPConnection with one
> extra function:
>
> - (MCPResult *)queryStringWithoutReconnect:(NSString *)query
> {
> static BOOL disconnected = NO;
>
> if (disconnected)
> {
> NSLog(@"Connection disconnected!");
> return nil;
> }
>
> MCPResult *result = [self queryString:query];
>
> if (([self getLastErrorID] == CR_SERVER_GONE_ERROR) || ([self
> getLastErrorID] == CR_SERVER_LOST))
> {
> NSLog(@"Connection disconnected!");
> disconnected = YES;
> }
>
> return result;
> }
>
>
> There are definitely more elegant ways to do this, but all I needed
> for my particular application was for no more queries to happen under
> any circumstances once the connection was lost.
>
> Serge, you might consider making a method that allows you to set the
> reconnect option and then use code similar to the above in the
> queryString: method to make sure that a reconnect doesn't occur if not
> desired. The reason that this is a big deal is that when
> libmysqlclient reconnects it loses any session variables you had set
> and, more importantly, it loses locks and transactions that the
> application will not be aware are gone.
>
> Aaron
>
>
>
> On Sep 6, 2004, at 4:21 PM, Serge Cohen wrote:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Hi Aaron;
>>
>> Indeed I'd rather not provide the pointer to the connection
>> directly... just because this breaks the object concept and if some
>> one deadly needs it, the derivation solution (that you use) is still
>> there.
>> Instead I can propose to have an interface to set this kind of
>> parameters directly from the object.
>> I have to check exactly what should be 'settable' and which interface
>> will be correct with that (trying to avoid having too many functions
>> for that, maybe some kind of -setParameter:forKey: message).
>>
>> If other users are similar requirements or have preferences
>> concerning the interface to these kind of setting, please answer (to
>> the list so - - -if necessary- we can have a discution on that).
>>
>> Serge.
>>
>> PS: Aaron, sorry I sent you the mail from a wrong mail account,
>> please if you answer me use the sourceforge mail account, and don't
>> reply directly to the previous mail. Thanks.
>>
>> Le 4 sept. 04, à 03:47, Aaron Jacobs a écrit :
>>
>>> I've run across a situation where it would be very unfortunate for
>>> my application to automatically and silently re-establish its
>>> connection to the MySQL server if it is lost. The only way I've
>>> found to disable this behavior is to set the 'reconnect' member of
>>> the MYSQL structure to zero, rather than the default of one. So
>>> what I need is a method in MCPConnection that simply returns
>>> mConnection so that I can set the flag. For now I'll make a
>>> subclass of MCPConnection since mConnection is protected, but Serge
>>> do you think it would be possible to get such a method officially
>>> supported?
>>>
>>> Thanks,
>>> Aaron
>>>
>> *******************************************
>> Serge Cohen
>>
>> GPG Key ID: 9CBB58FB
>> *******************************************
>>
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.2.3 (Darwin)
>>
>> iD8DBQFBPNTy5EPeG5y7WPsRAtTMAJ94ccaejFmam0EZIit++eoYd9mWTQCgkAKs
>> 26hTqH7QqWdTFQGyIO8bZ34=
>> =IARO
>> -----END PGP SIGNATURE-----
>>
>>
>>
>> -------------------------------------------------------
>> This SF.Net email is sponsored by BEA Weblogic Workshop
>> FREE Java Enterprise J2EE developer tools!
>> Get your free copy of BEA WebLogic Workshop 8.1 today.
>> http://ads.osdn.com/?ad_idP47&alloc_id808&op=click
>> _______________________________________________
>> Mysql-cocoa-users mailing list
>> Mys...@li...
>> https://lists.sourceforge.net/lists/listinfo/mysql-cocoa-users
|
|
From: Aaron J. <aj...@ed...> - 2004-09-07 13:36:20
Attachments:
PGP.sig
|
Last thing, I swear! (Sorry, I keep forgetting stuff.) I should also mention that when I linked against the fink version of the library it gave me a much smaller framework - for the bundled version it was 408 KB versus 1.5 MB. That was a nice bonus. Aaron On Sep 7, 2004, at 8:28 AM, Aaron Jacobs wrote: > Oh, I forgot to mention that to do this I had to build a custom > version of SMySQL that included libmysql's errmsg.h header file. It > would probably be a good idea to do this in the main distribution so > that you can test against various errors returned from getLastErrorID. > > While we're talking about that, I also wondered why the version of > libmysqlcient linked against by SMySQL is so old (4.0.14) as well as > its headers, which mention server version 4.0.5. I linked against > fink's version (4.0.17) and that worked great. > > Aaron > |