Обсуждение: Apache::Session in PostgreSQL
Hi! I want to use the Apache::Session perl module in my WebApps, but when I try to insert the session tuple, the Postgres can't handle the string and abort the operation. I made a dump for the SQL instruction generated by the module, it use the Storable module to generate a "storable" string from the variables, but this string has '\00', '\02', '\v' chars, and I thing that they are the chars that trigger the exception... There are any patch for the module for this? I really don't like MySQL, but it can handle this "storable" strings.... 8-( Thnx Ceyusa
Victor Manuel Jaquez Leal wrote:
>
> Hi!
>
> I want to use the Apache::Session perl module in my WebApps, but when I
> try to insert the session tuple, the Postgres can't handle the string and
> abort the operation.
I had the same problem ;-(. I found no solution for that so I went to
store the session parameters in the file system. I'm also interested
in a solution.
Below the requirements for the Apache::Session::DbI
NAME
Apache::Session::DBI - Session persistence via DBI
SCHEMA
To use this module, you will need these columns in a table
called 'sessions':
id char(16)
length int(11)
a_session text
Where the a_session column needs to be able to handle
arbitrarily long binary data.
Regards Herbie
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Herbert Liechti E-Mail: Herbert.Liechti@thinx.ch
ThinX networked business services Stahlrain 10, CH-5200 Brugg
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
On Fri, Mar 31, 2000 at 08:53:28PM +0200, Herbert Liechti wrote:
> Victor Manuel Jaquez Leal wrote:
> >
> > Hi!
> >
> > I want to use the Apache::Session perl module in my WebApps, but when I
> > try to insert the session tuple, the Postgres can't handle the string and
> > abort the operation.
>
> I had the same problem ;-(. I found no solution for that so I went to
> store the session parameters in the file system. I'm also interested
> in a solution.
>
> Below the requirements for the Apache::Session::DbI
>
> NAME
> Apache::Session::DBI - Session persistence via DBI
>
> SCHEMA
> To use this module, you will need these columns in a table
> called 'sessions':
>
> id char(16)
> length int(11)
> a_session text
>
> Where the a_session column needs to be able to handle
> arbitrarily long binary data.
Hmm, you might try the bytea type:
reedstrm=> create table test2 (b bytea, t text);
CREATE
reedstrm=> \d test2
Table = test2
+----------------------------------+----------------------------------+-------+
| Field | Type | Length|
+----------------------------------+----------------------------------+-------+
| b | bytea | var |
| t | text | var |
+----------------------------------+----------------------------------+-------+
reedstrm=> insert into test2 values ('abdkrxf\02\v\00fges','abdkrxf\02\v\00fges');
INSERT 937909 1
reedstrm=> select * from test2
reedstrm-> ;
b |t
------------+---------
abdkrxf\002v|abdkrxfav
(1 row)
reedstrm=>
it won't take a byte with value \00, but otherwise might work. Interestingly
enough, the cut and paste into this email deleted the funny 50% gray box
that appeared after the 'xf' in the 't' column.
Ross
--
Ross J. Reedstrom, Ph.D., <reedstrm@rice.edu>
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St., Houston, TX 77005
Hi Again!
Thanks for all the people that helped me, I really appreciate it.
Finnally I spent my last saturday night trying to patch the DBIStore perl
module and I got this:
(I don't have probe it with non-scalar variables, so isn't a bullet-proof
patch yet... 8-)...
*** DBIStore.pm.old Sat Apr 1 20:03:48 2000
--- DBIStore.pm Sat Apr 1 20:03:12 2000
***************
*** 135,139 ****
}
! my $serialized = nfreeze $session->{data};
$self->{insert_sth}->bind_param(1, $session->{data}->{_session_id});
--- 135,139 ----
}
! my $serialized = pack "u", nfreeze $session->{data};
$self->{insert_sth}->bind_param(1, $session->{data}->{_session_id});
***************
*** 160,164 ****
! my $serialized = nfreeze $session->{data};
$self->{update_sth}->bind_param(1, length $serialized);
--- 160,164 ----
! my $serialized = pack "u", nfreeze $session->{data};
$self->{update_sth}->bind_param(1, length $serialized);
***************
*** 195,199 ****
$self->{materialize_sth}->finish;
! $session->{data} = thaw $results->[0];
}
--- 195,199 ----
$self->{materialize_sth}->finish;
! $session->{data} = thaw unpack "u", $results->[0];
}