Thread: Re: DBD::Pg 1.30_1 WAS (Re: Prepare and prepare ?)

Re: DBD::Pg 1.30_1 WAS (Re: Prepare and prepare ?)

From
Rudy Lippan
Date:
On Thu, 29 May 2003, David Wheeler wrote:
> > statement,
> >       then rewrites the statement as 'EXECUTE "DBD::PG::cached_query n"
> >       ($1, $2, ... $n, $n+1)' for DBD::Pg's execute.  -- Currently
> > disabled
> >       until PREPARE works a little better
> 
> Pity. Do you know if it will work as well as you need in 7.4? Have you 
> tested it with the latest from CVS? I think that it is close-ish to 
> done, so now would be the time to get in any requests for fixes.
> 

I need to test this, I'll play with it next week.

-r



Re: DBD::Pg 1.30_1 WAS (Re: Prepare and prepare ?)

From
Rudy Lippan
Date:
On Thu, 29 May 2003, Dominic Mitchell wrote:
> > 
> > And for anyone who is interested here is the change log:
> 
> One more thing for the change log:  notice messages generated by the 
> database now use the perl warning mechanism instead of going to stderr, 
> so they can be trapped if needed.
> 
Added on my system.. I will check it in on Mondy.

-r

> -Dom
> 
> 



Re: DBD::Pg 1.30_1 WAS (Re: Prepare and prepare ?)

From
Tom Lane
Date:
Rudy Lippan <rlippan@remotelinux.com> writes:
> On Thu, 29 May 2003, David Wheeler wrote:
>>>> disabled until PREPARE works a little better
>> 
>> Pity. Do you know if it will work as well as you need in 7.4? Have you 
>> tested it with the latest from CVS? I think that it is close-ish to 
>> done, so now would be the time to get in any requests for fixes.

> I need to test this, I'll play with it next week.

It *is* done.  The window for offering any feedback is shrinking fast,
so I'd definitely encourage you to look at it ASAP.
        regards, tom lane


Re: DBD::Pg 1.30_1 WAS (Re: Prepare and prepare ?)

From
David Wheeler
Date:
On Thursday, May 29, 2003, at 02:00  AM, Dominic Mitchell wrote:

> One more thing for the change log:  notice messages generated by the 
> database now use the perl warning mechanism instead of going to 
> stderr, so they can be trapped if needed.

Oh, sweet! How did you do that? I've been doing this to catch them:

<hack caveat="ugly">
  open STDERR, "| perl -ne 'print unless /: NOTICE:  /'"    or die "Cannot pipe STDERR: $!\n";

</hack>

Regards,

David
-- 
David Wheeler                                     AIM: dwTheory
david@kineticode.com                              ICQ: 15726394
http://kineticode.com/                         Yahoo!: dew7e                                               Jabber:
Theory@jabber.org
Kineticode. Setting knowledge in motion.[sm]



Re: DBD::Pg 1.30_1 WAS (Re: Prepare and prepare ?)

From
Dominic Mitchell
Date:
David Wheeler wrote:
> On Thursday, May 29, 2003, at 02:00  AM, Dominic Mitchell wrote:
> 
>> One more thing for the change log:  notice messages generated by the 
>> database now use the perl warning mechanism instead of going to 
>> stderr, so they can be trapped if needed.
> 
> 
> Oh, sweet! How did you do that? I've been doing this to catch them:
> 
> <hack caveat="ugly">
> 
>   open STDERR, "| perl -ne 'print unless /: NOTICE:  /'"
>     or die "Cannot pipe STDERR: $!\n";
> 
> </hack>

Just hook up the existing libpq function PQsetNoticeProcessor() to a 
XS's warn in dbdimp.c.  It's about 5 lines of code.  I don't know 
whether it's 100% correct (I'm no XS guru), but it Works For Me[tm].

-Dom



Re: DBD::Pg 1.30_1 WAS (Re: Prepare and prepare ?)

From
Bruce Momjian
Date:
It is back up now --- Marc installed a new kernel.

Also, with our current CVS of DBD:pg, perl 5.005_03 can no longer do
'gmake test'.  I get:PERL_DL_NONLAZY=1 /usr/bin/perl -Iblib/arch -Iblib/lib -I/usr/libdata/perl5/5.00503/i386-bsdos
-I/usr/libdata/perl5/5.00503-e 'use Test::Harness qw(&runtests $verbose); $verbose=0; runtests @ARGV;'
t/*.tt/00basic...........Can'tlocate 5.61 in @INC (@INC contains: blib/arch blib/lib
/usr/libdata/perl5/5.00503/i386-bsdos/usr/libdata/perl5/5.00503/i386-bsdos /usr/libdata/perl5/5.00503/i386-bsdos
/usr/libdata/perl5/5.00503/usr/libdata/perl5/5.00503/i386-bsdos /usr/libdata/perl5/5.00503/i386-bsdos
/usr/libdata/perl5/5.00503/usr/libdata/perl5/site_perl/i386-bsdos /usr/libdata/perl5/site_perl/i386-bsdos
/usr/libdata/perl5/site_perl/usr/libdata/perl5/site_perl/i386-bsdos/include . /usr/libdata/perl5/5.00503/i386-bsdos
/usr/libdata/perl5/5.00503/usr/libdata/perl5/site_perl/i386-bsdos /usr/libdata/perl5/site_perl
/usr/libdata/perl5/site_perl/i386-bsdos/include.) at blib/lib/DBD/Pg.pm line 12.BEGIN failed--compilation aborted at
t/00basic.tline 4.dubious        Test returned status 2 (wstat 512, 0x200)t/01connect.........skipping test on this
platformt/01constants.......Can'tlocate 5.61 in @INC (@INC contains: blib/arch blib/lib
/usr/libdata/perl5/5.00503/i386-bsdos/usr/libdata/perl5/5.00503/i386-bsdos /usr/libdata/perl5/5.00503/i386-bsdos
/usr/libdata/perl5/5.00503/usr/libdata/perl5/5.00503/i386-bsdos /usr/libdata/perl5/5.00503/i386-bsdos
/usr/libdata/perl5/5.00503/usr/libdata/perl5/site_perl/i386-bsdos /usr/libdata/perl5/site_perl/i386-bsdos
/usr/libdata/perl5/site_perl/usr/libdata/perl5/site_perl/i386-bsdos/include . /usr/libdata/perl5/5.00503/i386-bsdos
/usr/libdata/perl5/5.00503/usr/libdata/perl5/site_perl/i386-bsdos /usr/libdata/perl5/site_perl
/usr/libdata/perl5/site_perl/i386-bsdos/include.) at blib/lib/DBD/Pg.pm line 12.BEGIN failed--compilation aborted at
t/01constants.tline 4.# Looks like your test died before it could output anything.dubious        Test returned status 2
(wstat512, 0x200)DIED. FAILED tests 1-20        Failed 20/20 tests, 0.00% okayt/01setup...........skipping test on this
platformt/02prepare.........skippingtest on this platformt/03bind............skipping test on this
platformt/04execute.........skippingtest on this platformt/04rows............skipping test on this
platformt/05fetch...........skippingtest on this platformt/06disconnect......skipping test on this
platformt/07reuse...........skippingtest on this platformt/08txn.............skipping test on this
platformt/09autocommit......skippingtest on this platformt/11quoting.........skipping test on this
platformt/12placeholders....skippingtest on this platformt/13pgtype..........skipping test on this
platformt/15funct...........skippingtest on this platformt/16pgbooltf........skipping test on this
platformt/17arrays..........skippingtest on this platformt/99cleanup.........skipping test on this platformFailed Test
StatusWstat Total Fail  Failed  List of
failed-------------------------------------------------------------------------------t/00basic.t      2   512    ??
??      %  ??t/01constants.t   2   512    20   20 100.00%  1-20
 
Any ideas?

---------------------------------------------------------------------------

Tom Lane wrote:
> Rudy Lippan <rlippan@remotelinux.com> writes:
> > developer.postgresql.org seems to be down?  Grrr.
> 
> Tell me about it :-(.  But you can read the 7.4 protocol document at
> Bruce's machine,
> http://candle.pha.pa.us/main/writings/pgsql/sgml/protocol.html
> The extended-query stuff is what you want.
> 
>             regards, tom lane
> 

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073
 


Re: DBD::Pg 1.30_1 WAS (Re: Prepare and prepare ?)

From
Bruce Momjian
Date:
Rudy Lippan wrote:
> > Also, with our current CVS of DBD:pg, perl 5.005_03 can no longer do
> > 'gmake test'.  I get:
> >     
> >     PERL_DL_NONLAZY=1 /usr/bin/perl -Iblib/arch -Iblib/lib -I/usr/libdata/perl5/5.00503/i386-bsdos
-I/usr/libdata/perl5/5.00503-e
 
> >      'use Test::Harness qw(&runtests $verbose); $verbose=0; runtests @ARGV;' t/*.t
> >     t/00basic...........Can't locate 5.61 in @INC (@INC contains: blib/arch blib/lib
/usr/libdata/perl5/5.00503/i386-bsdos/usr/li
 
> 
> Looks like it is set to require perl 5.6.1 now.
> 
> I modified Makefile.PL so that it also requires 5.6.1 -- This should cause
> the error to be thown much earlier.  The DBI version also needs to be
> bumped (I have to go back and look to find out what version of DBI was
> decided upon).

Good idea.

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073
 


Re: DBD::Pg 1.30_1 WAS (Re: Prepare and prepare ?)

From
Rudy Lippan
Date:
On Fri, 6 Jun 2003, Bruce Momjian wrote:

> Date: Fri, 6 Jun 2003 01:03:49 -0400 (EDT)
> From: Bruce Momjian <pgman@candle.pha.pa.us>
> To: Tom Lane <tgl@sss.pgh.pa.us>
> Cc: Rudy Lippan <rlippan@remotelinux.com>, David Wheeler <david@wheeler.net>,
>      Dominic Mitchell <dom@semantico.com>, pgsql-interfaces@postgresql.org,
>      'DBI developers' <dbi-dev@perl.org>
> Subject: Re: DBD::Pg 1.30_1 WAS (Re: [INTERFACES] Prepare and prepare ?)
> 
> 
> It is back up now --- Marc installed a new kernel.
> 
> Also, with our current CVS of DBD:pg, perl 5.005_03 can no longer do
> 'gmake test'.  I get:
>     
>     PERL_DL_NONLAZY=1 /usr/bin/perl -Iblib/arch -Iblib/lib -I/usr/libdata/perl5/5.00503/i386-bsdos
-I/usr/libdata/perl5/5.00503-e
 
>      'use Test::Harness qw(&runtests $verbose); $verbose=0; runtests @ARGV;' t/*.t
>     t/00basic...........Can't locate 5.61 in @INC (@INC contains: blib/arch blib/lib
/usr/libdata/perl5/5.00503/i386-bsdos/usr/li
 

Looks like it is set to require perl 5.6.1 now.

I modified Makefile.PL so that it also requires 5.6.1 -- This should cause
the error to be thown much earlier.  The DBI version also needs to be
bumped (I have to go back and look to find out what version of DBI was
decided upon).


Rudy



Re: DBD::Pg 1.30_1 WAS (Re: Prepare and prepare ?)

From
Bruce Momjian
Date:
Thanks.  Patch applied.

---------------------------------------------------------------------------

Dominic Mitchell wrote:
> Tim Bunce wrote:
> > Ah, you're passing it the address of (probably temporary) reference.
> > It's the underlying object (which the ref points to) that you need.
> > 
> > Try something like:
> > 
> >   PQsetNoticeProcessor(imp_dbh->conn, pg_warn, (void *)SvRV(dbh));
> > 
> > the D_imp_dbh( (SV *)arg ) will do-the-right-thing *if* the
> > handle is the 'last handle used' ($DBI::lasth) whenever it's called.
> > 
> > That's probably not a safe assumption so you could try something
> > more like this:
> > 
> >     D_imp_dbh( sv_2mortal(newRV((SV*)arg)) );
> 
> Thank you!  This worked a treat.  It turned out that sv_2mortal() was 
> necessary after all.  I'm going to go away and read up on XS before I 
> try this sort of thing again, I think.
> 
> Could somebody with a commit bit for dbdpg please apply the attached 
> patch?  It passes all tests here on perl 5.8.0 / postgres 7.3.2.  I 
> don't think that it will cause any problems for other perl versions...
> 
> -Dom
> 
> -- 
> | Semantico: creators of major online resources          |
> |       URL: http://www.semantico.com/                   |
> |       Tel: +44 (1273) 722222                           |
> |   Address: 33 Bond St., Brighton, Sussex, BN1 1RD, UK. |

> ? Pg.xsi
> Index: dbdimp.c
> ===================================================================
> RCS file: /usr/local/cvsroot/dbdpg/dbdpg/dbdimp.c,v
> retrieving revision 1.23
> diff -u -r1.23 dbdimp.c
> --- dbdimp.c    29 May 2003 08:37:46 -0000    1.23
> +++ dbdimp.c    2 Jun 2003 16:33:51 -0000
> @@ -76,7 +76,10 @@
>      void *arg;
>      const char *message;
>  {
> -    warn( message );
> +    D_imp_dbh( sv_2mortal(newRV((SV*)arg)) );
> +
> +    if (DBIc_WARN(imp_dbh))
> +    warn( message );
>  }
>  
>  /* Database specific error handling. */
> @@ -178,7 +181,7 @@
>      }
>  
>      /* Enable warnings to go through perl */
> -    PQsetNoticeProcessor(imp_dbh->conn, pg_warn, NULL);
> +    PQsetNoticeProcessor(imp_dbh->conn, pg_warn, (void *)SvRV(dbh));
>  
>      /* Quick basic version check -- not robust a'tall TODO: rewrite */
>      pgres_ret = PQexec(imp_dbh->conn, "SELECT version()");
> Index: t/01setup.t
> ===================================================================
> RCS file: /usr/local/cvsroot/dbdpg/dbdpg/t/01setup.t,v
> retrieving revision 1.5
> diff -u -r1.5 01setup.t
> --- t/01setup.t    6 May 2003 21:46:52 -0000    1.5
> +++ t/01setup.t    2 Jun 2003 16:33:51 -0000
> @@ -3,7 +3,7 @@
>  use Test::More;
>  
>  if (defined $ENV{DBI_DSN}) {
> -  plan tests => 4;
> +  plan tests => 5;
>  } else {
>    plan skip_all => 'cannot test without DB info';
>  }
> @@ -32,6 +32,7 @@
>     'create table'
>    );
>  
> +# First, test that we can trap warnings.
>  eval { local $dbh->{PrintError} = 0; $dbh->do( "drop table test2" ) };
>  {
>      my $warning;
> @@ -43,6 +44,19 @@
>       'PQsetNoticeProcessor working' );
>  }
>  eval { local $dbh->{PrintError} = 0; $dbh->do( "drop table test2" ) };
> +
> +# Next, test that we can disable warnings using $dbh.
> +eval { local $dbh->{PrintError} = 0; $dbh->do( "drop table test3" ) };
> +{
> +    my $warning;
> +    local $SIG{__WARN__} = sub { $warning = "@_" };
> +    local $dbh->{Warn} = 0;
> +    $dbh->do( "create table test3 (id integer primary key)" );
> +    # XXX This will have to be updated if PostgreSQL ever changes its
> +    # warnings...
> +    is( $warning, undef, 'PQsetNoticeProcessor respects dbh->{Warn}' );
> +}
> +eval { local $dbh->{PrintError} = 0; $dbh->do( "drop table test3" ) };
>  
>  ok($dbh->disconnect(),
>     'disconnect'

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073
 


Re: DBD::Pg 1.30_1 WAS (Re: Prepare and prepare ?)

From
Bruce Momjian
Date:
I meant to say "Already applied by someone else --- not me".

---------------------------------------------------------------------------

Dominic Mitchell wrote:
> Tim Bunce wrote:
> > Ah, you're passing it the address of (probably temporary) reference.
> > It's the underlying object (which the ref points to) that you need.
> > 
> > Try something like:
> > 
> >   PQsetNoticeProcessor(imp_dbh->conn, pg_warn, (void *)SvRV(dbh));
> > 
> > the D_imp_dbh( (SV *)arg ) will do-the-right-thing *if* the
> > handle is the 'last handle used' ($DBI::lasth) whenever it's called.
> > 
> > That's probably not a safe assumption so you could try something
> > more like this:
> > 
> >     D_imp_dbh( sv_2mortal(newRV((SV*)arg)) );
> 
> Thank you!  This worked a treat.  It turned out that sv_2mortal() was 
> necessary after all.  I'm going to go away and read up on XS before I 
> try this sort of thing again, I think.
> 
> Could somebody with a commit bit for dbdpg please apply the attached 
> patch?  It passes all tests here on perl 5.8.0 / postgres 7.3.2.  I 
> don't think that it will cause any problems for other perl versions...

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073