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
MIME-Version: 1.0
X-Mailer: MIME-tools 5.426 (Entity 5.426)
Charset: utf8
X-RT-Original-Encoding: utf-8
Content-Type: multipart/mixed; boundary="----------=_1222109666-13825-60"
Content-Length: 0
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
Content-Length: 778
Download (untitled) / with headers
text/plain 778b
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
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----------=_1222109666-13825-59"
X-Mailer: MIME-tools 5.426 (Entity 5.426)
Charset: utf8
Content-Length: 0
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: iso-8859-1
Content-Length: 0
Content-Type: text/plain; charset="utf-8"; name="mysql4.pm"
Content-Disposition: inline; filename="mysql4.pm"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: ascii
Content-Length: 651
Download mysql4.pm
text/x-perl 651b
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;
MIME-Version: 1.0
X-Mailer: MIME-tools 5.426 (Entity 5.426)
Content-Disposition: inline
Charset: utf8
Message-Id: <rt-3.6.HEAD-11906-1225510221-1865.39519-0-0 [...] rt.cpan.org>
Content-Type: text/plain
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 1150
Download (untitled) / with headers
text/plain 1.1k
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
MIME-Version: 1.0
In-Reply-To: <rt-3.6.HEAD-11906-1225510221-1865.39519-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Charset: utf8
References: <rt-3.6.HEAD-11906-1225510221-1865.39519-0-0 [...] rt.cpan.org>
Content-Type: multipart/mixed; boundary="----------=_1238203145-2203-180"
Message-ID: <rt-3.6.HEAD-2203-1238203145-540.39519-0-0 [...] rt.cpan.org>
X-RT-Original-Encoding: utf-8
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 1444
Download (untitled) / with headers
text/plain 1.4k
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
>
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Type: multipart/mixed; boundary="----------=_1238203145-2203-179"
Charset: utf8
Content-Length: 0
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: iso-8859-1
Content-Length: 0
Content-Type: application/octet-stream; name="."
Content-Disposition: inline; filename="."
Content-Transfer-Encoding: base64
Content-Length: 0
MIME-Version: 1.0
In-Reply-To: <rt-3.6.HEAD-2203-1238203145-540.39519-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Charset: utf8
References: <rt-3.6.HEAD-11906-1225510221-1865.39519-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-2203-1238203145-540.39519-0-0 [...] rt.cpan.org>
Content-Type: text/plain
Message-ID: <rt-3.6.HEAD-2203-1238209896-1712.39519-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 1095
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 >
MIME-Version: 1.0
X-Spam-Status: No, hits=0.0 required=8.0 tests=
In-Reply-To: <rt-3.6.HEAD-2203-1238203145-540.39519-5-0 [...] rt.cpan.org>
X-Mailer: Evolution 2.22.3.1
References: <RT-Ticket-39519 [...] rt.cpan.org> <rt-3.6.HEAD-11906-1225510221-1865.39519-5-0 [...] rt.cpan.org> <rt-3.6.HEAD-2203-1238203145-540.39519-5-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <1238215115.3227.28.camel [...] zoe.savage.net.au>
X-RT-Original-Encoding: utf-8
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by diesel.bestpractical.com (Postfix) with SMTP id 64F244D80F1 for <bug-CGI-Session [...] rt.cpan.org>; Sat, 28 Mar 2009 00:38:31 -0400 (EDT)
Received: (qmail 5003 invoked by uid 103); 28 Mar 2009 04:38:30 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 28 Mar 2009 04:38:30 -0000
Received: from hosted02.westnet.com.au (HELO hosted02.westnet.com.au) (203.10.1.213) by 16.mx.develooper.com (qpsmtpd/0.80) with ESMTP; Fri, 27 Mar 2009 21:38:26 -0700
Received: from hosted02.westnet.com.au (hosted02.westnet.com.au [127.0.0.1]) by hosted02.westnet.com.au (Postfix) with SMTP id 612BF230499 for <bug-CGI-Session [...] rt.cpan.org>; Sat, 28 Mar 2009 13:38:21 +0900 (WST)
Received: from [192.168.100.2] (dsl-58-6-182-178.nsw.westnet.com.au [58.6.182.178]) by hosted02.westnet.com.au (Postfix) with ESMTP id 12D6622FC7B for <bug-CGI-Session [...] rt.cpan.org>; Sat, 28 Mar 2009 13:38:19 +0900 (WST)
Delivered-To: cpan-bug+CGI-Session [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #39519] Store method fails in CGI::Session::Driver::mysql for MySQL 4.0.16
X-PMX-Branch: TNG-Outgoing
Return-Path: <ron [...] savage.net.au>
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: bug-CGI-Session [...] rt.cpan.org
Date: Sat, 28 Mar 2009 15:38:35 +1100
X-Spam-Level: *
To: bug-CGI-Session [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: Ron Savage <ron [...] savage.net.au>
RT-Message-ID: <rt-3.6.HEAD-2203-1238215119-1650.39519-0-0 [...] rt.cpan.org>
Content-Length: 1524
Download (untitled) / with headers
text/plain 1.4k
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
MIME-Version: 1.0
In-Reply-To: <rt-3.6.HEAD-2203-1238215119-1650.39519-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Charset: utf8
References: <RT-Ticket-39519 [...] rt.cpan.org> <rt-3.6.HEAD-11906-1225510221-1865.39519-5-0 [...] rt.cpan.org> <rt-3.6.HEAD-2203-1238203145-540.39519-5-0 [...] rt.cpan.org> <1238215115.3227.28.camel [...] zoe.savage.net.au> <rt-3.6.HEAD-2203-1238215119-1650.39519-0-0 [...] rt.cpan.org>
Content-Type: text/plain
Message-ID: <rt-3.6.HEAD-2203-1238231491-1553.39519-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 585
Download (untitled) / with headers
text/plain 585b
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. :)
MIME-Version: 1.0
X-Spam-Status: No, hits=-0.0 required=8.0 tests=SPF_PASS
In-Reply-To: <rt-3.6.HEAD-2203-1238231491-1553.39519-5-0 [...] rt.cpan.org>
X-Mailer: Claws Mail 3.7.1 (GTK+ 2.12.9; i486-pc-linux-gnu)
References: <RT-Ticket-39519 [...] rt.cpan.org> <rt-3.6.HEAD-11906-1225510221-1865.39519-5-0 [...] rt.cpan.org> <rt-3.6.HEAD-2203-1238203145-540.39519-5-0 [...] rt.cpan.org> <1238215115.3227.28.camel [...] zoe.savage.net.au> <rt-3.6.HEAD-2203-1238215119-1650.39519-5-0 [...] rt.cpan.org> <rt-3.6.HEAD-2203-1238231491-1553.39519-5-0 [...] rt.cpan.org>
Message-ID: <20090330093044.7f1a3fba [...] summersault.com>
Content-Type: text/plain; charset="utf-8"
X-RT-Original-Encoding: utf-8
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by diesel.bestpractical.com (Postfix) with SMTP id 051E863CEAA for <bug-CGI-Session [...] rt.cpan.org>; Mon, 30 Mar 2009 09:57:33 -0400 (EDT)
Received: (qmail 18144 invoked by uid 103); 30 Mar 2009 13:57:33 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 30 Mar 2009 13:57:33 -0000
Received: from tanagra.summersault.com (HELO tanagra.summersault.com) (12.161.105.149) by 16.mx.develooper.com (qpsmtpd/0.80) with SMTP; Mon, 30 Mar 2009 06:57:30 -0700
Received: (qmail 52773 invoked from network); 30 Mar 2009 09:30:44 -0400
Received: from simba.summersault.com (HELO localhost) (192.168.97.182) by tanagra.summersault.com with SMTP; 30 Mar 2009 09:30:44 -0400
Delivered-To: cpan-bug+CGI-Session [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #39519] Store method fails in CGI::Session::Driver::mysql for MySQL 4.0.16
Return-Path: <mark [...] summersault.com>
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: bug-CGI-Session [...] rt.cpan.org
Date: Mon, 30 Mar 2009 09:30:44 -0400
X-Spam-Level: *
To: bug-CGI-Session [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: Mark Stosberg <mark [...] summersault.com>
RT-Message-ID: <rt-3.6.HEAD-2203-1238421461-919.39519-0-0 [...] rt.cpan.org>
Content-Length: 375
Download (untitled) / with headers
text/plain 375b
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


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.