[horde] pgsql_sessionhandler.sql not working?

Marcus I. Ryan marcus at horde.org
Wed Jul 9 07:41:03 PDT 2003


Quoting Ron Cooper <rcooper at jamesconeyisland.com>:

> Quoting imp <imp at xtremedev.com>:
> Short answer is I think sql.php for pgsql is broken for session
> handling
> because of the session_data field in the postgres table is defined
> as
> TEX, but sql.php assumes it's Binary.

Not true.  If you look at SQL.php *Blob functions for pgsql, these
functions bin2hex and reverse the process when storing and retrieving
respectively.  This is probably not the "best" way to do this, though
no one has made it work with bytea to do comparitive analysis of
performance - we either bin2hex the entire thing or parse the string
to properly quote binary data.  I'm not sure which is faster, but the
former is easier and more reliable.

> is set to TEXT.  So sql.php was obviously trying to send binary
> session
> data to a text field, and well it probably truncated on the first
> EOF
> char sent to it.

Again, it's not obvious because if you look at the code, all session
data should be bin2hex'ed such that it should all be text, so this is
a wrong assumption.

> So is the table defined wrong or is the support lacking in sql.php
> for
> TEXT or BYTEA defined fields?  I suppose you could change the
> session_data field type from TEXT to BYTEA and use the
> configuration
> from before and see if it craps out or not. I have no idea.

The table is correct; there is no support in SQL.php for bytea.  It
would be nice if you actually checked before you tell the world how
to fix a problem you're just guessing about.

All that said, I still haven't gotten pgsql sessions working
perfectly, but they are working at least enough to get logged in. 
The problems I had are most likely with the updateBlob, but I haven't
had time to debug anything.  The problem I had is the session data
would periodically not get updated.  The session would fail to get
updates from IMP about mailbox, messages, etc.  I reverted back and
haven't use it since.

If anyone would like to fix SQL.php to use bytea, that's fine by me,
and encouraged (assuming it's faster).  I just haven't had time to do
anything with it, and I'm the only developer running pgsql as far as
I'm aware.

--
Marcus I. Ryan, marcus at horde.org
-----------------------------------------------------------------------
 "Love is a snowmobile racing across the tundra and then suddenly it
 flips over, pinning you underneath.  At night, the ice weasels come."
                 -- Matt Groening
-----------------------------------------------------------------------





More information about the horde mailing list