Skip Menu |

This queue is for tickets about the CGI-Session CPAN distribution.

Report information
The Basics
Id: 39519
Status: resolved
Priority: 0/
Queue: CGI-Session

People
Owner: MARKSTOS [...] cpan.org
Requestors: olaf [...] wundersolutions.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Store method fails in CGI::Session::Driver::mysql for MySQL 4.0.16
According to these docs: http://dev.mysql.com/doc/refman/4.1/en/insert-on-duplicate.html "If you specify ON DUPLICATE KEY UPDATE (added in MySQL 4.1.0), and a row is inserted that would cause a duplicate value in a UNIQUE index or PRIMARY KEY, an UPDATE of the old row is performed" So, I was unable to store session data using MySQL 4.0.16 It's not a situation where I can easily upgrade MySQL, so I had to write a custom driver with a store method which uses the "REPLACE INTO " syntax. I've attached it in case anyone finds it helpful. It might be helpful to have some kind of MySQL version parameter that could be passed to the driver in order to support older versions of MySQL. I can supply a patch if that's something that you might consider. All the best, Olaf
Subject: mysql4.pm
package CGI::Session::Driver::mysql4; use strict; use warnings; use base 'CGI::Session::Driver::mysql'; use Carp qw( croak ); sub store { my $self = shift; my ($sid, $datastr) = @_; croak "store(): usage error" unless $sid && $datastr; my $dbh = $self->{Handle}; my $table = $self->table_name; my $replace_query = qq[ REPLACE INTO $table ( $self->{IdColName}, $self->{DataColName} ) VALUES (?, ?) ]; $dbh->do( $replace_query, undef, $sid, $datastr, $datastr ) or return $self->set_error( "store(): \$dbh->do failed " . $dbh->errstr ); return 1; } 1;
Olaf, I would accept a patch that works like follows: The first time that "store" is called, select the database version and store in the CGI::Session object. On future calls, look up the version we've already stored. Using the version returned, decide which SQL to use. Mark On Mon Sep 22 14:54:36 2008, OALDERS wrote: Show quoted text
> According to these docs: > > http://dev.mysql.com/doc/refman/4.1/en/insert-on-duplicate.html > > "If you specify ON DUPLICATE KEY UPDATE (added in MySQL 4.1.0), and a > row is inserted that would cause a duplicate value in a UNIQUE index or > PRIMARY KEY, an UPDATE of the old row is performed" > > So, I was unable to store session data using MySQL 4.0.16 It's not a > situation where I can easily upgrade MySQL, so I had to write a custom > driver with a store method which uses the "REPLACE INTO " syntax. I've > attached it in case anyone finds it helpful. > > It might be helpful to have some kind of MySQL version parameter that > could be passed to the driver in order to support older versions of > MySQL. I can supply a patch if that's something that you might consider. > > All the best, > > > Olaf
Olaf, Any progress on a patch for this? I may close this bug report soon if no one else is interested in maintaining CGI::Session for MySQL 4.0.x in the near future. Mark On Fri Oct 31 23:30:21 2008, MARKSTOS wrote: Show quoted text
> Olaf, > > I would accept a patch that works like follows: > > The first time that "store" is called, select the database version and > store in the CGI::Session object. On future calls, look up the version > we've already stored. Using the version returned, decide which SQL to use. > > Mark > > On Mon Sep 22 14:54:36 2008, OALDERS wrote:
> > According to these docs: > > > > http://dev.mysql.com/doc/refman/4.1/en/insert-on-duplicate.html > > > > "If you specify ON DUPLICATE KEY UPDATE (added in MySQL 4.1.0), and a > > row is inserted that would cause a duplicate value in a UNIQUE index or > > PRIMARY KEY, an UPDATE of the old row is performed" > > > > So, I was unable to store session data using MySQL 4.0.16 It's not a > > situation where I can easily upgrade MySQL, so I had to write a custom > > driver with a store method which uses the "REPLACE INTO " syntax. I've > > attached it in case anyone finds it helpful. > > > > It might be helpful to have some kind of MySQL version parameter that > > could be passed to the driver in order to support older versions of > > MySQL. I can supply a patch if that's something that you might consider. > > > > All the best, > > > > > > Olaf
>
Hi Mark, Thanks for following up on this. I *think* that if nobody else has raised this issue, it's probably not worth the time to patch this. I had hoped to do so, but I haven't really had all that much spare time lately. For me, subclassing CGI::Session::Driver::mysql and overriding the store() method fixed it. I would say, though, that it probably merits a note under "Known Issues" or something like that, since I seem to recall that it originally took me a while to track down the issue. I suppose it's possible that someone with an older version of MySQL could upgrade CGI::Session::Driver::mysql and find themselves dealing with this bug, so a note in the docs would probably be helpful in that case. Maybe a link to this ticket would point those folks at a quick workaround to the problem if you think that's helpful. Best, Olaf On Fri Mar 27 21:19:05 2009, MARKSTOS wrote: Show quoted text
> Olaf, > > Any progress on a patch for this? I may close this bug report soon if > no one else is > interested in maintaining CGI::Session for MySQL 4.0.x in the near > future. > > Mark >
Subject: Re: [rt.cpan.org #39519] Store method fails in CGI::Session::Driver::mysql for MySQL 4.0.16
Date: Sat, 28 Mar 2009 15:38:35 +1100
To: bug-CGI-Session [...] rt.cpan.org
From: Ron Savage <ron [...] savage.net.au>
Hi Olaf Show quoted text
> > > http://dev.mysql.com/doc/refman/4.1/en/insert-on-duplicate.html > > > > > > "If you specify ON DUPLICATE KEY UPDATE (added in MySQL 4.1.0), and a > > > row is inserted that would cause a duplicate value in a UNIQUE index or > > > PRIMARY KEY, an UPDATE of the old row is performed" > > > > > > So, I was unable to store session data using MySQL 4.0.16 It's not a > > > situation where I can easily upgrade MySQL, so I had to write a custom > > > driver with a store method which uses the "REPLACE INTO " syntax. I've > > > attached it in case anyone finds it helpful. > > > > > > It might be helpful to have some kind of MySQL version parameter that > > > could be passed to the driver in order to support older versions of > > > MySQL. I can supply a patch if that's something that you might consider.
I have mixed feelings on this. Of course your position is difficult if you are stuck on an old version of MySQL. And yet, is that version available for download, and hence for testing? Also is the latest version of DB::mysql still compatible with that version? It might be possible to downgrade to develop this code, but frankly, I don't want to :-)! I suspect that so few people would be still using that version, that I'd say your approach of subclassing what needs to be overridden is in fact the best approach. And then there'd sill be the problem: Do we support 4.0.16 /and/ even older versions? I'd say: Sorry, but no. -- Ron Savage ron@savage.net.au http://savage.net.au/index.html
On Sat Mar 28 00:38:39 2009, ron@savage.net.au wrote: Show quoted text
> > I suspect that so few people would be still using that version, that > I'd > say your approach of subclassing what needs to be overridden is in > fact > the best approach. > > And then there'd sill be the problem: Do we support 4.0.16 /and/ even > older versions? I'd say: Sorry, but no. >
I think we're on the same page here -- no need to create work for this sort of backwards compatibility. Most of all, I just wanted to point out that the syntax had changed and that there is, in fact, an available workaround. :)
Subject: Re: [rt.cpan.org #39519] Store method fails in CGI::Session::Driver::mysql for MySQL 4.0.16
Date: Mon, 30 Mar 2009 09:30:44 -0400
To: bug-CGI-Session [...] rt.cpan.org
From: Mark Stosberg <mark [...] summersault.com>
Show quoted text
> I think we're on the same page here -- no need to create work for this > sort of backwards compatibility. Most of all, I just wanted to point > out that the syntax had changed and that there is, in fact, an available > workaround. :)
That's still helpful to do. Someone may still find these pages in the bug tracker ever after the bug is marked 'resolved'. Mark