Unix Technical Forum

Another small pl/perl patch

This is a discussion on Another small pl/perl patch within the Pgsql Patches forums, part of the PostgreSQL category; --> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Another quick little patch to clean up the docs. If we are going ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Patches

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-18-2008, 12:00 AM
Greg Sabino Mullane
 
Posts: n/a
Default Another small pl/perl patch


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Another quick little patch to clean up the docs. If we are going
to provide examples of perl code, no matter how trivial, we might
as well provide well-written perl code.

- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200510231745
http://biglumber.com/x/web?pk=2529DF...9B906714964AC8

Index: plperl.sgml
================================================== =================
RCS file: /projects/cvsroot/pgsql/doc/src/sgml/plperl.sgml,v
retrieving revision 2.47
diff -c -r2.47 plperl.sgml
*** plperl.sgml 18 Oct 2005 22:53:54 -0000 2.47
- --- plperl.sgml 23 Oct 2005 21:44:00 -0000
***************
*** 554,561 ****
system operations are not allowed for security reasons:
<programlisting>
CREATE FUNCTION badfunc() RETURNS integer AS $$
! open(TEMP, "&gt;/tmp/badfile");
! print TEMP "Gotcha!\n";
return 1;
$$ LANGUAGE plperl;
</programlisting>
- --- 554,564 ----
system operations are not allowed for security reasons:
<programlisting>
CREATE FUNCTION badfunc() RETURNS integer AS $$
! my $tmpfile = "/tmp/badfile";
! open my $fh, '&gt;', $tmpfile
! or elog(ERROR, qq{Could not open the file "$tmpfile": $!});
! print $fh "Testing writing to a file\n";
! close $fh or elog(ERROR, qq{Could not close the file "$tmpfile": $!});
return 1;
$$ LANGUAGE plperl;
</programlisting>

-----BEGIN PGP SIGNATURE-----

iD8DBQFDXATPvJuQZxSWSsgRAsWQAJ9hKI+mIJmRhUuqC+kVM7 3P78ZjxACfejgE
ESnpPV0+8hs4DDbXVE60YcE=
=zLS9
-----END PGP SIGNATURE-----



---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-18-2008, 12:00 AM
Andrew Dunstan
 
Posts: n/a
Default Re: Another small pl/perl patch


Well, I personally almost always use indirect file handles rather than
globals. But I don't know that using globals file handles (which is what
I gather you are objecting to) is deprecated, is it? The perl docs are
absolutely littered with examples.

(I also use BSD style intentation consistently across my C, perl and
Java ... which is unusual at least in the latter 2 cases but works well
for me ;-) )

I don't mind applying this patch, if other people think it matters more
than I do.

cheers

andrew

Greg Sabino Mullane wrote:

>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>
>Another quick little patch to clean up the docs. If we are going
>to provide examples of perl code, no matter how trivial, we might
>as well provide well-written perl code.
>
>- --
>Greg Sabino Mullane greg@turnstep.com
>PGP Key: 0x14964AC8 200510231745
>http://biglumber.com/x/web?pk=2529DF...9B906714964AC8
>
>Index: plperl.sgml
>================================================= ==================
>RCS file: /projects/cvsroot/pgsql/doc/src/sgml/plperl.sgml,v
>retrieving revision 2.47
>diff -c -r2.47 plperl.sgml
>*** plperl.sgml 18 Oct 2005 22:53:54 -0000 2.47
>- --- plperl.sgml 23 Oct 2005 21:44:00 -0000
>***************
>*** 554,561 ****
> system operations are not allowed for security reasons:
> <programlisting>
> CREATE FUNCTION badfunc() RETURNS integer AS $$
>! open(TEMP, "&gt;/tmp/badfile");
>! print TEMP "Gotcha!\n";
> return 1;
> $$ LANGUAGE plperl;
> </programlisting>
>- --- 554,564 ----
> system operations are not allowed for security reasons:
> <programlisting>
> CREATE FUNCTION badfunc() RETURNS integer AS $$
>! my $tmpfile = "/tmp/badfile";
>! open my $fh, '&gt;', $tmpfile
>! or elog(ERROR, qq{Could not open the file "$tmpfile": $!});
>! print $fh "Testing writing to a file\n";
>! close $fh or elog(ERROR, qq{Could not close the file "$tmpfile": $!});
> return 1;
> $$ LANGUAGE plperl;
> </programlisting>
>
>-----BEGIN PGP SIGNATURE-----
>
>iD8DBQFDXATPvJuQZxSWSsgRAsWQAJ9hKI+mIJmRhUuqC+kVM 73P78ZjxACfejgE
>ESnpPV0+8hs4DDbXVE60YcE=
>=zLS9
>-----END PGP SIGNATURE-----
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match
>
>
>


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-18-2008, 12:00 AM
Greg Sabino Mullane
 
Posts: n/a
Default Re: Another small pl/perl patch


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


> Well, I personally almost always use indirect file handles rather than
> globals. But I don't know that using globals file handles (which is what
> I gather you are objecting to) is deprecated, is it? The perl docs are
> absolutely littered with examples.


No, my primary objection was using open() without checking the result.
Everything else was icing.

> (I also use BSD style intentation consistently across my C, perl and
> Java ... which is unusual at least in the latter 2 cases but works well
> for me ;-) )


I tried to match the indenting to what is already in the docs, which is
fairly close to my own style.

- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200510241105
http://biglumber.com/x/web?pk=2529DF...9B906714964AC8

-----BEGIN PGP SIGNATURE-----

iD8DBQFDXPhjvJuQZxSWSsgRAm6RAKD0RmrD5U5Uzv73wBVIfi CAIpAWewCg6XzJ
cPfuNaMX/gD+vA1VugR2YYo=
=va+e
-----END PGP SIGNATURE-----



---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-18-2008, 12:00 AM
Andrew Dunstan
 
Posts: n/a
Default Re: Another small pl/perl patch



Greg Sabino Mullane wrote:

>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>
>
>
>>Well, I personally almost always use indirect file handles rather than
>>globals. But I don't know that using globals file handles (which is what
>>I gather you are objecting to) is deprecated, is it? The perl docs are
>>absolutely littered with examples.
>>
>>

>
>No, my primary objection was using open() without checking the result.
>Everything else was icing.
>
>



I see. Well, given that it is meant to illustrate something that won't
run, I don't think that matters too much. But there is another error on
that page, where we state that the function will be created but fail to
run. In fact, now that we have a validator, it will not even be created:

andrew=# CREATE FUNCTION badfunc() RETURNS integer AS $$
andrew$# open(TEMP, ">/tmp/badfile");
andrew$# print TEMP "Gotcha!\n";
andrew$# return 1;
andrew$# $$ LANGUAGE plperl;
ERROR: creation of Perl function failed: 'open' trapped by operation
mask at line 2.
andrew=#



I'll make your change and fix the incorrect wording shortly.

cheers

andrew



---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:43 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com