Postgres Session Storage
Concerned version
Version: %2.0.14
Platform: (Nginx/Apache/Node.js)
Summary
When following the how-to cli documentation to move session storage into Postgres (https://lemonldap-ng.org/documentation/latest/cli_examples.html#configure-sessions-backend)
The sessions storage fails because the column user is not quoted.
Logs
LINE 1: ...T INTO sessions (id,a_session,ipAddr,_whatToTrace,user) VALU...
^ at /usr/share/perl5/Apache/Session/Browseable/Store/DBI.pm line 37
Backends used
Postgres 12-alpine
Possible fixes
This is from yadd on IRC. The change works as it correctly quotes the columns names.
--- a/lib/Apache/Session/Browseable/Store/DBI.pm
+++ b/lib/Apache/Session/Browseable/Store/DBI.pm
@@ -19,9 +19,9 @@ sub insert {
if ( !defined $self->{insert_sth} ) {
$self->{insert_sth} =
- $self->{dbh}->prepare_cached( "INSERT INTO $self->{table_name} ("
- . join( ',', 'id', 'a_session', map { s/'/''/g; $_ } @$index )
- . ') VALUES ('
+ $self->{dbh}->prepare_cached( "INSERT INTO $self->{table_name} (\""
+ . join( '","', 'id', 'a_session', map { s/'/''/g; $_ } @$index )
+ . '") VALUES ('
. join( ',', ('?') x ( 2 + @$index ) )
. ')' );
}