Re: Apache::DBI problem

2001-05-05 Thread Edmund Mergl

"Grigoriy G. Vovk" wrote:
> 
> Here are my files:
> 
> httpd.conf -
> 
> Alias /perl/ "/usr/local/www/perl/"
> PerlModule Apache::DBI
> PerlRequire /usr/local/www/startup.pl
> PerlModule Apache::Registry
> PerlModule Apache::DBI
> PerlSetEnv PERLDB_OPTS "NonStop=1 LineInfo=/tmp/db.out AutoTrace=1 frame=2"
> PerlModule Apache::DB
> 
> PerlFixupHandler Apache::DB
> SetHandler perl-script
> PerlHandler Apache::Registry
> Options +ExecCGI
> AllowOverride None
> Order allow,deny
> Allow from all
> PerlSendHeader on
> 
> 
> startup.pl -
> 
> use strict;
> $ENV{MOD_PERL} or die "not running under mod_perl!";
> use Apache::DBI ();
> use Apache;
> use Apache::Cookie;
> use Apache::Request;
> use Carp();
> $SIG{__WARN__} = \&Carp::cluck;
> sub My::ProxyRemoteAddr ($) {
>   my $r = shift;
>   return unless ($r->connection->remote_ip eq "127.0.0.1");
>   if (my ($ip) = $r->header_in('X-Forwarded-For') =~ /([^,\s]+)$/) {
> $r->connection->remote_ip($ip);
>   }
>   return ;
> }
> Apache::DBI->connect_on_init
> ("dbi:Pg:dbname=jewelry",'','',
> {
> PrintError => 1,
> RaiseError => 0,
> AutoCommit => 1,
> });
> 
> my programm -
> 
> use strict;
> use Apache::DBI;


  not necessary, your script should run unchanged under Apache::DBI


> $Apache::DBI::DEBUG = 2;
> use Apache;
> use Carp();
> local $SIG{__WARN__} = \$Carp::cluck;
> my $dbh;
> $dbh = DBI->connect("dbi:Pg:dbname=jewelry", '', '');


if you don't use exactly the same connect-string, as in startup.pl, you
will not get a persistent connection.


> my $r=shift;
> $r->send_http_header('text/html');
> my $sql = "select * from tbl_category";
> my $sth = $dbh->prepare($sql);
> my $rs = $sth->execute();
> my @rs;
> while(@rs = $sth->fetchrow_array){
> $r->print("$rs[0]\t$rs[1]\n");
> }
> $sth->finish;
> $dbh->disconnect;
> 
> and httpd-error.log -
> 
> [Sat May  5 16:35:28 2001] [notice] FastCGI: process manager initialized (pid 14154)
> [Sat May  5 16:35:29 2001] [notice] Apache/1.3.19 (Unix) mod_fastcgi/2.2.10 
>mod_perl/1.25
> configured -- resuming normal operations
> Default die handler restored.
> 14156 Apache::DBI need ping: yes
> 14156 Apache::DBI new connect to 
>'dbname=jewelryPrintError=1AutoCommit=1'
> [Sat May  5 16:39:27 2001] [error] Not a subroutine reference at
> (eval 225)[/usr/local/lib/perl5/site_perl/5.6.1/i386-freebsd/Apache/Registry.pm:177] 
>line 73.
> 
> Line 73 is "my $rs = $sth->execute();"


your $sth is undefined.


> 
> So, does anybody understand what's going on?
> Why my programm doesn't work?
> It works as plain perl script perfect.
> And Apache::Session::Store::Postgres works perfect - it mean, mod_perl
> works with Postgres.
> 
> Thank's,
> 
> my best regards,
> -
> Grigoriy G. Vovk


always check the return values of all DBI-methods, eg

instead of: $dbh = DBI->connect(..);

use:$dbh = DBI->connect(..) or die "db connect error";

and instead of: my $sth = $dbh->prepare($sql);

use:my $sth = $dbh->prepare($sql) or die $DBI::errstr;

or something equivalent.



Edmund

-- 
http://www.edmund-mergl.de
fon: +49 700 edemergl



Re: Apache::AuthDBI

2001-04-22 Thread Edmund Mergl

Christian Heiss wrote:

>>and my .htacces is:
>>---
>>>PerlModule Apache::AuthDBI
>>>AuthName "something else"
...


how does your startup.pl look like ?
The configuration 'PerlModule Apache::AuthDBI'
is not supposed to be in .htaccess. Also it
would be helpful to know the version of ApacheDBI.


Edmund

-- 
http://www.edmund-mergl.de
fon: +49 700 edemergl



Re: Apache::Session::Postgres error

2001-01-16 Thread Edmund Mergl

Edmund Mergl wrote:
> 
> Todd Finney wrote:
> >
> > I'm using Apache::Session::Postgres to track sessions via
> > cookies.  When I access a page, the cookie is correctly
> > sent by the server, and accepted by the client.  However,
> > on the second request, I'm getting a 'Object does not exist
> > in data store' error.
> >
> > It looks like the session is not being stored in the
> > database, although I can't figure out why.  When running
> > postmaster -d 2, I get the following output:
> >
> 
> This problem has been reported several times.
> find below the explanation of Francis J. Lacoste
> from Sun, 17 Oct 1999.
> 
> Edmund
> 
> This is because the DBIStore insert the encoded session data as
> binary data. PostgreSQL doesn't like that. You have to modify
> Apache::Session::DBIStore (or better implement a PGStore)
> to uuencode the session data. You can use for that MIME::Base64
> or better yet
> 
> pack( "u*" ) and unpack ( "u*" ).
> 
> I have a Apache::Session::DBIUUStore that does just that
> and that I use for similar reason. I also added a last_update
> field to the table which tracks the last update to the session
> data. Email me if you want it. (Available on perl licensing terms)
> 
> Hope this helps.
> 



sorry, I forgot the email address: 
 
"Francis J. Lacoste" <[EMAIL PROTECTED]>


Edmund


-- 
http://www.edmund-mergl.de
fon: +49 700 edemergl



Re: Apache::Session::Postgres error

2001-01-16 Thread Edmund Mergl

Todd Finney wrote:
> 
> I'm using Apache::Session::Postgres to track sessions via
> cookies.  When I access a page, the cookie is correctly
> sent by the server, and accepted by the client.  However,
> on the second request, I'm getting a 'Object does not exist
> in data store' error.
> 
> It looks like the session is not being stored in the
> database, although I can't figure out why.  When running
> postmaster -d 2, I get the following output:
> 


This problem has been reported several times.
find below the explanation of Francis J. Lacoste
from Sun, 17 Oct 1999.

Edmund



This is because the DBIStore insert the encoded session data as
binary data. PostgreSQL doesn't like that. You have to modify
Apache::Session::DBIStore (or better implement a PGStore) 
to uuencode the session data. You can use for that MIME::Base64
or better yet

pack( "u*" ) and unpack ( "u*" ).

I have a Apache::Session::DBIUUStore that does just that
and that I use for similar reason. I also added a last_update
field to the table which tracks the last update to the session
data. Email me if you want it. (Available on perl licensing terms)

Hope this helps.




-- 
http://www.edmund-mergl.de
fon: +49 700 edemergl



[Fwd: AuthenDBI idea]

2001-01-15 Thread Edmund Mergl

any comments ?

Edmund
-- 
http://www.edmund-mergl.de
fon: +49 700 edemergl


Edmund,
I have idea for AuthenDBI.pm.  I have not tried to code it yet, however.

The function would come in two parts:
A) Provide an option to keep a count of the number of times a user logs in.
 Store this value in DBI field.  (Other field may also be considered, see
below.)
B) Provide a directive to perform a comparison on any and all fields of the
user who successfully logged in.  If the comparison is true, provide a URL
to REDIRECT the user.

The directives could be something like:
Auth_DBI_logcountusecount
Where usecount is the DBI field name to record the number of times a user
has logged in.

Auth_DBI_compare{regexp}URL
Where regexp is the compare string and  where URL is where to REDIRECT the
user.  I think that the original URL should be passed as a URL ? argument,
so that the REDIRECT cgi target could determine the original request's URL.  

The regexp would have to be able to easily use any arbitrary field values.
Perhaps simply by pre-appending the field name with a '$',  for example:

Auth_DBI_compare{$username='xyz' && $usecount%2}   /cgi/newDBIpasswd.pl
 
This would run the "/cgi/newDBIpasswd.pl?original-URL" script every other
time for user 'xyz'.

Other additional informational fields that may be considered are:
Auth_DBI_timefieldname
to keep track of when the user last logged in.

Auth_DBI_rejectfieldname
to keep track of the number of bad log in attempts.

What do you think?

What did you think of my AuthzDBI.pm, "set field environment variable"
hack, that sent you yesterday?






Re: Edmund Mergl

2001-01-11 Thread Edmund Mergl

John D Groenveld wrote:
> 
> Good to see you alive, well, and still coding Perl.
> 
> Months ago, about the time of the Perl conference so it may have slipped
> under everyone's radar, Jeff Horn from U of Wisconsin sent you some patches
> to Apache::DBI to use Oracle 8's re-authenticate function instead of
> creating and caching a separate Oracle connection for each user. Did you
> decide whether to incorporate them or to suggest another module name for
> him to use? I wasn't  able to participate in the discussion at the time,
> but I now have need for that functionality. I don't know if Jeff Horn is
> still around, but I'll track him down if necessary and offer to work on it.
> 

Last info from Jeff was, that he was working on a patch which would provide 
this functionality as a general feature. I don't like the idea to start 
putting DB-specific features into Apache::DBI. But if this feature is available 
for other databases as well, I would add it to the module.


> Also, I sent you a small patch to fix Apache::DBI warnings under Perl5.6.
> I hate to be a pest, but I'm rolling out software where the installation
> procedure requires the user to fetch Perl from Active State and Apache::DBI
> from CPAN. I'd rather not ship my own version of yours or any CPAN module.
> 
> Thanks,
> John
> [EMAIL PROTECTED]


Edmund


-- 
http://www.edmund-mergl.de
fon: +49 700 edemergl



Re: Too many connections with DBI

2001-01-11 Thread Edmund Mergl

Scott Alexander wrote:
> 
> Hi,
> 
> Why do I see this in the log
> 
> 13402 Apache::DBI need ping: yes
> 13402 Apache::DBI new connect to
> 'my_dbmy_usermy_passwdAutoCommit=1PrintError=1'
> 
> when I have in the startup.pl file
> 
> Apache::DBI->connect_on_init
>  ("DBI:mysql:my_db",
>   "my_user",
>   "my_passwd",
>   {
>PrintError => 1, # warn() on errors
>RaiseError => 0, # don't die on error
>AutoCommit => 1, # commit executes immediately
>   }
>  );
> 
> Is it because the child has reached it's maximum life ?


most probably, check the parameter MaxRequestsPerChild in httpd.conf.


> 
> How many connections can you have open from DBI to mysql ?
> 
> I have 9 db's with 10 children ~ 90 connections .
> 
> All use the same user.
> 
> Should I increase the memory from 256 MB to ?


the number of open connections to mysql may be limited
by the database, but it is not limited by DBI or Apache::DBI.
Memory might help if your machine is swapping. But low on
memory can not be the reason for any re-connect.


> 
> I have read http://perl.apache.org/guide/databases.html
> 
> Scott
> 
> _
> scott alexander
> tietoverkkosuunnittelija
> humak amk - finland
> +358(0)407505640


Edmund


-- 
http://www.edmund-mergl.de
fon: +49 700 edemergl



Re: Apache::DBI keeps re-connecting!

2001-01-10 Thread Edmund Mergl

Foskett Roger wrote:
> 
> Hi, when using Apache::DBI, it keeps re-connecting even though the database
> and user is the same:
> 
> I am using ApacheDBI-0.87, DBD-Oracle-1.06, DBI-1.14, perl5.6.0 on an 8.1.5
> Oracle database (perl -v & -V further below)
> 
> My httpd.conf is setup as:
>  PerlModule  Apache::DBI Apache Apache::Registry Apache::XPP CGI
>  PerlInitHandler Apache::Reload
>  PerlSetVar  ReloadAll Off
>  PerlSetVar  XPPIncludeDir /opt/www/icl/htdocs/include
>  PerlSendHeader  On
> 
> I have an XPP perl script which uses one of my own perl modules to connect
> to a database.
> This works fine and I was able to both Connect & Disconnect as expected
> before using Apache::DBI
> 
> When calling the XPP script multiple times using Apache::DBI (using the same
> username & password) as you can see, it connects twice - leaving an oracle
> process running for each connection.


is is supposed to make one connection per httpd.


> 
> 447 Apache::DBI push PerlCleanupHandler
> 447 Apache::DBI need ping: yes
> 447 Apache::DBI new connect to
> 'PVCSNMPR_RPTNMPR_RPTPrintError=0RaiseError=0AutoCommit=0'
> 447 Apache::DBI disconnect (overloaded)
> 447 Apache::DBI PerlCleanupHandler
> 447 Apache::DBI PerlCleanupHandler rollback for
> PVCSNMPR_RPTNMPR_RPTPrintError=0RaiseError=0AutoCommit=0

ok, so there is one connect for the httpd with pid = 447

> 
> 450 Apache::DBI push PerlCleanupHandler
> 450 Apache::DBI need ping: yes
> 450 Apache::DBI new connect to
> 'PVCSNMPR_RPTNMPR_RPTPrintError=0RaiseError=0AutoCommit=0'
> 450 Apache::DBI disconnect (overloaded)
> 450 Apache::DBI PerlCleanupHandler
> 450 Apache::DBI PerlCleanupHandler rollback for
> PVCSNMPR_RPTNMPR_RPTPrintError=0RaiseError=0AutoCommit=0

here is another connect for the httpd with pid = 450

> 
> 450 Apache::DBI disconnect (overloaded)
> 450 Apache::DBI push PerlCleanupHandler
> 450 Apache::DBI need ping: yes
> 450 Apache::DBI already connected to
> 'PVCSNMPR_RPTNMPR_RPTPrintError=0RaiseError=0AutoCommit=0'
> 450 Apache::DBI disconnect (overloaded)
> 450 Apache::DBI PerlCleanupHandler
> 450 Apache::DBI PerlCleanupHandler rollback for
> PVCSNMPR_RPTNMPR_RPTPrintError=0RaiseError=0AutoCommit=0

this request is proccesed again by the httpd with pid = 450
and consequently it says: 'already connected to ...'

> 
> Would you happen to have any idea as to why this might be happening? I have
> read/searched around everywhere but cant find any reason for this.
> 
> What I have just noticed is that the reconnect works fine providing I access
> the script with the same url.  My URL was changing due to different CGI
> parameters that were being passed.  Does this make a difference? (perhaps
> the request bit needs to somehow first be stripped off - though I would have
> thought that it is totally independant of this, with Apache::DBI working on
> the DBI level)
> 
> Many thanks
> 
> Roger Foskett


everything looks ok.


Edmund

-- 
http://www.edmund-mergl.de
fon: +49 700 edemergl



Re: Edmund Mergl

2001-01-10 Thread Edmund Mergl

John D Groenveld wrote:
> 
> Has anyone seen Edmund? He hasn't responded to mail sent to his
> CPAN address, [EMAIL PROTECTED], for the last few months.
> John
> [EMAIL PROTECTED]

here I am.

Edmund

-- 
http://www.edmund-mergl.de
fon: +49 700 edemergl



Re: Problem with Apache::DBI under mod_perl!!

2000-11-24 Thread Edmund Mergl

Edmar Edilton da Silva wrote:
> 
> Hi all,
> 
> I am sending again the previous message because I still didn't know how
> 
> to resolve the below problem. Can anyone any idea how help me?
> 
> I have installed on the my machine the following modules:
> apache 1.3.12-2
> perl-5.00503-10
> mod_perl 1.21-10
> DBI 1.14
> 
> DBD::Oracle
> Apache::DBI 0.87
> 
> Oracle Client Software
> 
> For enable the mod_perl module, I added the below code in the
> configuration file of apache ("httpd.conf"):
> 
> # If the perl module is installed, this will be enabled.
> 
> 
>   PerlFreshRestart On
>   Alias /perl-bin/ /home/httpd/perl-bin/
>   
> SetHandler perl-script
> PerlHandler Apache::Registry
> PerlSendHeader On
> Options +ExecCGI
>   
> 
> 
> For load the Apache::DBI module, I also added this line in the
> "httpd.conf" file:
> PerlRequire /etc/httpd/conf/startup.pl
> 
> Inside of "startup.pl" file, I added the following code:
> #!/usr/bin/perl
> 
> use strict;
> 
> # Extend @INC if needed
> use lib qw(/dir/foo /dir/bar);
> 
> # Make sure we are in a sane environment.
> $ENV{MOD_PERL} or die "not running under mod_perl!";
> 
> # For things in the "/perl-bin" URL
> use Apache::Registry;
> 
> # Load Perl modules of your choice here
> # This code is interpreted *once* when the server starts
> use Apache::DBI ();
> $Apache::DBI::DEBUG = 2;
> $Apache::AuthDBI::DEBUG = 2;
> use DBI ();
> 
> # Tell me more about warnings
> use Carp ();
> $SIG{__WARN__} = \&Carp::cluck;
> 
> # Load CGI.pm and call its compile() method to precompile
> # (but not to import) its autoloaded methods.
> use CGI ();
> CGI->compile(':all');
> 
> #Initialize the database connections for each child
> Apache::DBI->connect_on_init
> ("dbi:Oracle:ora8", "travel", "travel",
>{
>PrintError => 1, # Warn() on errors
>RaiseError => 0, # Don't die on error
>AutoCommit => 1, # Commit executes immediately
>}
> );
> 
> But, when I try loading a HTML page of WWW server, the server refuse my
> request. I think that the problem is in the WWW server that don't load
> their child process because to the Apache::DBI to be with some problem.
> During the installation of all the modules didn't have any problem. The
> apache start correctly, but when I try stoping them, I get a error
> message that the process failed. If I don't load the DBI and Apache::DBI module
> 
> in the apache, it works correctly. Using only the DBI and
> DBD::Oracle modules, I can access the Oracle database no problems. Really the
> 
> problem must be in the Apache::DBI ( when it is loaded ), but I don't know exactly
> 
> where. Can anybody help me? Locking the configuration files, can anyone tell me
> 
> what is happening? Any help will very appreciated.
> 
> 
> Edmar Edilton da Silva
> Bacharel em Ciência da Computacão - UFV
>   Mestrando em Ciência da Computacão - UNICAMP
> 


if you have problems with Apache::DBI start with 
a very simple configuration.
First of all make sure your script runs without Apache::DBI.

Then add 
use Apache::DBI ();
$Apache::DBI::DEBUG = 1;

to your startup.pl and watch the eror_log for the appropriate 
messages.

If this works go ahead and use connect_on_init() and any other
option.


Edmund


-- 
http://www.edmund-mergl.de
fon: +49 700 edemergl

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Apache::AuthenDBI NOTICE message

2000-11-18 Thread Edmund Mergl

George Sanderson wrote:
> 
> >> So far, using Apache::AuthenDBI, I get an error_log message:
> >>
> >> NOTICE:  Unrecognized variable client_encoding
> >>
> >> Every time the DBI ping is called.
> >> I have not been able to tack down the origin of this message.
> >> Any ideas or suggestions?
> >
> >never seen before. What database do you use ?
> >
> I am using PostgreSQL 7.0.2
> More details. . .
> I am also using the latest Apache::AuthenDBI and Apache::AuthzDBI.
> In startup.pl I have:
> Apache::DBI->connect_on_init("dbi:Pg:dbname=atable", "webuser", "webuser",
>  {
>   PrintError => 1, # warn() on errors
>   RaiseError => 0, # don't die on error
>   AutoCommit => 1  # commit executes immediately
>  }
> );
> #
> I did try seting PrintError=>0 with no change on the NOTICE message.
> 
> Note: I am not using any of the following (in startup.pl):
> Apache::DBI->setPingTimeOut("dbi:driver:database", $timeout);
> Apache::AuthDBI->setCacheTime(0);
> Apache::AuthDBI->setCleanupTime(-1);
> Apache::AuthDBI->initIPC(5);
> 
> When I start httpd I get the following error log output.
> ==
> [Wed Nov 15 17:47:48 2000] [info] created shared memory segment #12928
> [Wed Nov 15 17:47:48 2000] [notice] Apache/1.3.14 (Unix) mod_perl/1.24_01
> mod_layout/2.8 configured -- resuming normal operations
> [Wed Nov 15 17:47:48 2000] [notice] suEXEC mechanism enabled (wrapper:
> /usr/local/apache/bin/suexec)
> [Wed Nov 15 17:47:48 2000] [info] Server built: Nov  5 2000 10:26:07
> 12052 Apache::DBI PerlChildInitHandler
> 12051 Apache::DBI PerlChildInitHandler
> 12053 Apache::DBI PerlChildInitHandler
> NOTICE:  Unrecognized variable client_encoding
> Database handle destroyed without explicit disconnect at
> /usr/local/lib/perl5/5.6.0/site_perl/Apache/DBI.pm line 140.
> require 0 called at
> /usr/local/lib/perl5/5.6.0/site_perl/Apache/DBI.pm line 140
> Apache::DBI::childinit('Apache=SCALAR(0x874565c)') called at
> /dev/null line 0
> require 0 called at /dev/null line 0
> 12054 Apache::DBI PerlChildInitHandler
> NOTICE:  Unrecognized variable client_encoding
> Database handle destroyed without explicit disconnect at
> /usr/local/lib/perl5/5.6.0/site_perl/Apache/DBI.pm line 140.
> require 0 called at
> /usr/local/lib/perl5/5.6.0/site_perl/Apache/DBI.pm line 140
> Apache::DBI::childinit('Apache=SCALAR(0x874565c)') called at
> /dev/null line 0
> require 0 called at /dev/null line 0
> 12055 Apache::DBI PerlChildInitHandler
> 12056 Apache::DBI PerlChildInitHandler
> =
> The NOTICE and etc messages are repeated several (12) times for the 6
> Apache children and the 1 Apache root processes running (i.e. 2 NOTICE
> messages per child).
> The Apache::DBI.pm is version 0.87 and near line 140 I see:
> sub childinit {
> my $prefix = "$$ Apache::DBI";
> print STDERR "$prefix PerlChildInitHandler \n" if $Apache::DBI::DEBUG > 1;
> #if (defined @ChildConnect) {
> if (@ChildConnect) {
> for my $aref (@ChildConnect) {
> shift @$aref;
> DBI->connect(@$aref);
> $LastPingTime{@$aref[0]} = time;
> }
> }
> 1;
> }
> Note that I changed the "if(defined @ChildConnect" line because, "defined
> on aggregates (hashes and arrays) is deprecated."  Line 140 is:
> $LastPingTime{@$aref[0]} = time;



please read postgresql-7.0.2/doc/postgres/trouble18031.htm.

Edmund

-- 
http://www.edmund-mergl.de
fon: +49 700 edemergl

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Help needed for using Apache::DBI

2000-07-17 Thread Edmund Mergl

PHANI MADHAVI wrote:
> 
> Hi All,
> we have installed Apache::DBI module ( system os is linux, web server
> apache, running mod_perl and mysql is rdbms) in our systems. But it is not
> working.
> When i try to compile a sample file to test db connectivity using
> Apache::DBI, it does not work.
> Same thing works if I use DBI.
> The error is " can't locate object method "module" in the DBI.pm file"
> We checked the DBI.pm file  and there is one statement which goes like this:
> if ($INC{"Apache.pm"} and Apache->module("Apache::Status"));
> And we searched for Apache.pm. We could find the file but not the "module".
> Please let me know how should we proceed.
> 
> Regards,
> Madhavi
> 



in the next release I'll mention it in the README twice and in
bold letters:

  It's not only supposed to be used with the Apache server 
  together with an embedded perl interpreter like mod_perl,
  it can ONLY be used when running as mod_perl script.
  It can NOT be run in any script from the command-line.


Edmund


-- 
Edmund Mergl
mailto:[EMAIL PROTECTED]
http://www.edmund-mergl.de
fon: +49 700 EDEMERGL



Re: Apache::DBI broken?

2000-06-16 Thread Edmund Mergl

Ian Mahuron wrote:
> 
> I've been searching through the mailing list and have seen several people
> with the same problem I'm experiencing.  Yet I've seen no solid answers to
> this problem... so maybe I'll try again.
> 
> System is:
> FreeBSD 4.0
> Apache 1.3.12
> perl 5.005_03
> mod_perl 1.24
> DBI 1.14
> Apache::DBI 0.87
> 
> # Apache::DBI preloaded via:
> use Apache::DBI; # in startup.pl
> 
> # DB handles created via:
> my $dbh = DBI->connect('...');
> 
> Every module that contains DBI->connect causes the server to segfault:
> [Fri Jun 16 12:05:41 2000] [notice] child pid 41672 exit signal Segmentation
> fault (11)
> 
> I wrote up a quick script in perl to test DBI and it works fine.
> 
> If any other information is required, please let me know.


in order to check whether Apache::DBI makes the trouble, just remove
the 'use Apache::DBI;' from startup.pl and check if the problem
disappears.

Do you use statically linked mod_perl or is mod_perl a DSO ?

Edmund


-- 
Edmund Mergl
mailto:[EMAIL PROTECTED]
http://www.edmund-mergl.de
fon: +49 700 EDEMERGL



Re: Apache::DBI strategy/philosophy

2000-06-16 Thread Edmund Mergl

Tim Gardner wrote:
> 
> I have been using DBI without Apache::DBI and have been simply
> storing db connections in a global variable as a sort of poor man's
> persistent connection when running under Apache::Registry.
> 
> Now I want to do things "right" and am trying to understand
> Apache::DBI.  Before looking at the module  I imagined that it would
> work by providing a library of persistent connections.  You would
> check a connnection out of the library, use it, and then put it back
> when you are done, like checking a book out of the library.  If you
> disconnected the connection, you just wouldn't return it, and the
> pool would have to create a new connection for the next user.
> 
> But this is not the way Apache::DBI works.  Instead, if I understand
> correctly after glancing at the module this morning, two consecutive
> identical connect calls will return the same connection!  Why isn't
> this a problem?  Is the assumption that two different transactions
> will use different user/pwd combinations?
> 
> Thanks,
> Tim


Apache (version 1.x) uses a multi-process approach for serving as 
many requests as possible in parallel. Every httpd process has its
own address space. A database connection opened by one specific
httpd can not be shared with another httpd. At most you will get
a segmentation violation. Hence every httpd needs to keep its own
pool of persistent database connections.

As a direct consequence it is not possible to use more than one
HTTP request inside one transaction, because you can not control
which httpd will server a specific request. Very likely two requests
will be served by two different httpds where both do not know 
anything about a common transaction.


Edmund



-- 
Edmund Mergl
mailto:[EMAIL PROTECTED]
http://www.edmund-mergl.de
fon: +49 700 EDEMERGL



Re: Problems with Apache::DBI

2000-06-12 Thread Edmund Mergl

Matt Carothers wrote:
> 
> On Mon, 12 Jun 2000, Rob Tanner wrote:
> 
> > Believe it or not, it's the simplest task in the world.  In startup.pl add
> > the line "PerlModule Apache::DBI"
> 
> You can either stick "PerlModule Apache::DBI" in your httpd.conf or add
> 'use Apache::DBI ();' to your startup.pl.  Also, for mysql, you'll need
> to add a keepalive routine to your startup.pl:
> 
> sub Apache::DBI::db::ping {
> my $dbh = shift;
> return $dbh->do('select 1');
> }
> 
> - Matt



this is safer:


sub Apache::DBI::db::ping {
my $dbh = shift;
my $ret = 0;
eval {
local $SIG{__DIE__}  = sub { return (0); };
local $SIG{__WARN__} = sub { return (0); };
        $ret = $dbh->do('select 1');
};
return ($@) ? 0 : $ret;
}


Edmund

-- 
Edmund Mergl
mailto:[EMAIL PROTECTED]
http://www.edmund-mergl.de
fon: +49 700 EDEMERGL



[Fwd: Apache::DBI, bug?]

2000-05-23 Thread Edmund Mergl

 




Hi,
 
I installed Apache::DBI a while ago and it worked 
fine then on Apache 1.3.12 using mod_perl 1.21.
 
Now I'm reinstalling apache still 1.3.12 with php4, 
mod_perl 1.24, apache::dbi (most recent version) and the child processes of the 
apache segfault on start. This happens as soon as I try to use PerlRequire in 
httpd.conf.
 
The startup.pl file comes from 
wwwthread.
 
The line the server segfaults in:
Apache::DBI->connect_on_init("DBI:$w3tvars::config{'dbdriver'}:$w3tvars::config{'dbname'}:$w3tvars::config{'dbserver'}", 
"$w3tvars::config{'dbuser'}", "$w3tvars::config{'dbpass'}");
 
I've put the debug level to 2 and this is what I 
get into the error_log:
 
[Tue May 23 17:36:40 2000] [notice] Apache/1.3.12 
(Unix) mod_perl/1.24 PHP/4.0.0 configured -- resuming normal operations[Tue 
May 23 17:36:40 2000] [info] Server built: May 23 2000 09:59:4120965 
Apache::DBI 
PerlChildInitHandler20966 
Apache::DBI 
PerlChildInitHandler20965 
Apache::DBI 
need ping: yes20966 
Apache::DBI 
need ping: yes20967 
Apache::DBI 
PerlChildInitHandler20969 
Apache::DBI 
PerlChildInitHandler20967 
Apache::DBI 
need ping: yes20969 
Apache::DBI 
need ping: yes20968 
Apache::DBI 
PerlChildInitHandler20968 
Apache::DBI 
need ping: yes[Tue May 23 17:36:41 2000] [notice] child pid 20969 exit 
signal Segmentation fault (11)[Tue May 23 17:36:41 2000] [notice] child pid 
20968 exit signal Segmentation fault (11)[Tue May 23 17:36:41 2000] [notice] 
child pid 20967 exit signal Segmentation fault (11)[Tue May 23 17:36:41 
2000] [notice] child pid 20966 exit signal Segmentation fault (11)[Tue May 
23 17:36:41 2000] [notice] child pid 20965 exit signal Segmentation fault 
(11)
 
It would be very nice if you could help me with 
this one.
 
regards,
Gudmundur.



Re: Apache::DBI

2000-05-23 Thread Edmund Mergl

Mark Holt wrote:
> 
> Newbie to the list, apologies if this is a FAQ, but I checked the
> archives...
> I built a modperl-enabled server, (Apache/1.3.9 Ben-SSL/1.37 (Unix)
> mod_perl/1.21) and have been running it for some time.  I have the
> mod_perl as a shared module, and I recently enabled it to start
 

currently this does not work with DBI modules.
You have to re-build mod_perl + apache as a
statically linked binary.


> development.  I have a startup script in operation and things work fine,
> until I try to preload any sort of DBI module.  I tried Mysql,
> DBI::mysql, Apache::DBI, all to no avail.  The server gives no error
> message, it simply acts as though it is starting, but does not show up
> in the process list.  Is there something I'm missing?
> 
> Thanks in advance.


Edmund

-- 
Edmund Mergl
mailto:[EMAIL PROTECTED]
http://www.edmund-mergl.de
fon: +49 700 EDEMERGL



Re: help me under those Apache::DBI log info.

2000-01-28 Thread Edmund Mergl

vinecent hong wrote:
> 
> What I've found out...
> 
> > 1) debug in single server mode - I'm sure you realize that Apache::DBI
> > creates one connection per httpd child, not just one connection that is
> > shared by all httpd processes.
> 
> Sorry,At first I really think  that all Apache child will share one Mysql
> connection :-) Though Not now,but what a nice feature to add later?just
> create the mysql connection when apache startup then pass the dbh also as a
> GLOBAL var to apache child to share with.Not hard to add I think?

at a first glance this sounds interesting, but it is depreciated.
See the documentation of ApacheDBI for details.

Edmund

-- 
Edmund Mergl
mailto:[EMAIL PROTECTED]
http://www.bawue.de/~mergl



Re: problems with Apache::DBI

2000-01-08 Thread Edmund Mergl

"Cere M. Davis" wrote:
> 
> I am trying to get the DBI::Ingres stuff to work with Apache::DBI.
> 
> Once the server tries to open the inital connections through the
> startup.pl file with the "Apache::DBI->connect_on_init" command it throws
> an error message like this:
> 
> 168 Apache::DBI PerlChildInitHandler
> [Fri Jan  7 12:46:35 2000] [error] install_driver(Ingres) failed: Can't
> load
> '/uns/mind/usr/local/perl5/lib/site_perl/5.005/alpha-dec_osf/auto/DBD/Ingres/Ing
> res.so'
> for module DBD::Ingres: dlopen: cannot load
> /uns/mind/usr/local/perl5/lib/site_perl/5.005/alpha-dec_osf/auto/DBD/Ingres/Ingr
> es.so
> at /uns/mind/usr/local/perl5/lib/5.00503/alpha-dec_osf/DynaLoader.pm
> line 169.
> 
>  at (eval 15) line 3
> 
>  at /uns/mind/usr/local/perl5/lib/site_perl/5.005/Apache/DBI.pm line 138
> 
> in the error_log when I run httpsd -X (single thread mode).
> 
> I can run the DBI drivers to ingres with no problems outside
> 
> of Apache just not with the Apache mod_perl stuff.
> 
> Does anyone know what's going on here?  I expect that DynaLoader
> 
> is used to load the DBI standalone stuff - and that works fine -
> 
> so why is it that DynaLoader would have trouble loading Ingres.so
> 
> when requested through Apache::DBI?
> 
> -Cere
> 
> *
> Cere Davis  *
> Systems Administrator   *
> MCIS University of Washington   *
> 206.221.4717        *
> [EMAIL PROTECTED]   *
> *


Did you try to run your scripts under mod_perl but without ApacheDBI ?


Edmund

-- 
Edmund Mergl
mailto:[EMAIL PROTECTED]
http://www.bawue.de/~mergl



Re: Apache::AuthzDBI giving me grief

2000-01-04 Thread Edmund Mergl

Craig Vincent wrote:
> 
> > what version of ApacheDBI do you use ?
> > can you send me the relevant part of the
> > error_log ?
> 
> I'm using 0.86 of Apache::AuthzDBI
> And using 0.87 Apache::DBI


strange, since 0.84 the two modules AuthzDBI and AuthenDBI
have been combined into one module AuthDBI. So which one
do you use ?


Edmund

-- 
Edmund Mergl
mailto:[EMAIL PROTECTED]
http://www.bawue.de/~mergl



Re: ApacheDBI vs DBI for TicketMaster

2000-01-02 Thread Edmund Mergl

Ed Loehr wrote:
> 
> Randy Harmon wrote:
> 
> > On Sun, Jan 02, 2000 at 01:48:58AM -0600, Ed Loehr wrote:
> > > My apache children are seg faulting due to some combination of
> > > DBI usage and the cookie-based authentication/authorization
> > [...]
> > > child seg faults.  If I comment out all DBI references in the
> >
> > Hm, are you connecting to your database prior to Apache's forking - i.e., in
> > your startup.pl?  That could cause trouble, especially on older versions of
> > Apache and Apache::DBI.
> 
> No.  I'm only connecting in the child servers.  I verified that via PIDs in the
> log file with debugging prints, and logically as well since the DBI::connect()
> command is only executed during a query reached via a handler...
> 
> BTW, this is all on apache 1.3.9 with mod_ssl 2.4.9 and mod_perl 1.21 on Redhat
> 6.1 (2.2.12-20smp)...
> 
> Anyone else have any suspicions/ideas/leads?


do you use rpm's or did you compile everything by yourself ?

Edmund

-- 
Edmund Mergl
mailto:[EMAIL PROTECTED]
http://www.bawue.de/~mergl



Re: installing ApacheDBI..

2000-01-01 Thread Edmund Mergl

"[EMAIL PROTECTED]" wrote:
> 
> Hi,
> 
> I've looked in the archives and the docs, but can't seem to find an answer. I can't 
>be the only one having this problem. I'm trying to install ApacheDBI and it goes on 
>fine, but whenever I try and use it I get a compilation error:
> 
> Can't locate object method "module" via package "Apache" at /usr/lib/perl5/site_
> perl/5.005/Apache/DBI.pm line 202.
> 
> Sure enough, as far as I can tell Apache.pm or any of it's base classe's don't 
>implement sub module, so I'm not sure how this should work in Apache::DBI:
> 
> 202: ) if ($INC{'Apache.pm'} and Apache->module('Apache::Status'));
> 
> (which looks like a nice feature, being able to see the status). Once I comment out 
>this block everything works fine. I have mod_perl 1.21 installed and running fine.
> 
> Any ideas?
> 
> Alex


are you trying to use it from the command-line ?
this won't work, you can only use it running with
apache/mod_perl.


Edmund


-- 
Edmund Mergl
mailto:[EMAIL PROTECTED]
http://www.bawue.de/~mergl



how to use ApacheDBI with RedHat 6.1

1999-11-01 Thread Edmund Mergl


in order to prevent more questions on this topic:

  ApacheDBI on Redhat 6.1 using the default rpm's
  apache-1.3.9-4 and mod_perl-1.21-2 does not work. 

In particular loading any compiled module (*.so) in
a startup script via PerlRequire will produce a core 
dump.

There is a nice web page, which describes some possible
solutions:  

 http://perl.apache.org/guide/install.html#using_RPM_DEB_and_other_package

Personally I prefer the first solution: grab the latest 
Apache and mod_perl sources and compile the sources yourself.


Edmund

-- 
Edmund Mergl
mailto:[EMAIL PROTECTED]
http://www.bawue.de/~mergl



Re: BUG?? Weird server startup prob w/ Apache::DBI

1999-10-15 Thread Edmund Mergl

Tom Lancaster wrote:
> 
> Hi all,
> I've searched the list for this, but to no avail.
> I'm using 1.3.9 / 1.21 / latest Apache::DBI, Embperl 1.2b7, Perl 5.00503
> 
> Anywho, this the problem:
> When I enable Apache::DBI in httpd.conf, the server simply won't start.
> No error log messages, no nothing. It claims to have started ( output
> from apachectl ) but, hasn't.
> 
> Odd thing is through sheer persistence I got it to start earlier today,
> and everything worked peachy, but I made some changes to mods ( I just
> checked, and they all compile fine ),  stopped the server, and now it
> won't restart.
> 
> The server starts fine if I comment out PerlModule Apache::DBI.
> 
> This is rather a show stopper. Has anyone else seen anything like this.
> If so, please tell me how you fixed it!!!
> 
> Thanks,
> 
> Tom
> --
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> Tom Lancaster   iQualify, inc..
> [EMAIL PROTECTED]   Walnut Creek, CA  1-925-906-5881
> MIME spoken herehttp://www.iqualify.com/


this has been reported several times.
If you have a pre-configured database conection
and the connect does not succeeed, your server won't 
start until the connect times out (database dependent) !

Edmund

-- 
Edmund Mergl
mailto:[EMAIL PROTECTED]
http://www.bawue.de/~mergl



Re: Apache::DBI and Apache::AuthenDBI questions.

1999-10-02 Thread Edmund Mergl

"Sergey V. Kolychev" wrote:
> 
> Good day.
> I have 2 things are not very clear to me.
> I'm working with ApacheDBI-0.82.
> 1) Does Apache::DBI cashing for Apache::AuthenDBI and for regular
> DBI->connect by Apache::Registry in same time.
> I mean one connection per child for authentification and for
> Apache::Registry scripts.
> The userid/password and dsn are same for both.

Yes:
for every connect the DBI module checks, if the module Apache::DBI 
has been loaded. In this case every connect request will be forwarded 
to the Apache::DBI module. 


> Second:
> Is there any difference in configuration for mod_perl(below) ?
> --
> 1) httpd.conf
> 
> PerlModule Apache::DBI Apache::AuthenDBI DBI DBD::Oracle
> ---
> 2) httpd.conf
> PerlModule Apache::DBI
> PerlModule Apache::AuthenDBI DBI DBD::Oracle


I don't know the order of loading, if you specify more than
one module in the same line. So better use the second approach.
Both examples have one thing in common: you never need to
specify a DBD-module. This handled by the DBI module.


> -
> Thanks.
> 
>--Alchevsk Linux User Group---
>   I don't call, I don't cry , I don't apologize
>   All will be gone like a apple tree's white smoke... (S.Esenin)
>   http://www.ic.al.lg.ua/~ksv | e-mail: [EMAIL PROTECTED]
>   PGP key: finger [EMAIL PROTECTED]


Edmund

-- 
Edmund Mergl
mailto:[EMAIL PROTECTED]
http://www.bawue.de/~mergl