OSDN Git Service

BLOBs containing NUL characters (ASCII 0) can be written to the
authorBruce Momjian <bruce@momjian.us>
Wed, 13 Oct 1999 02:26:37 +0000 (02:26 +0000)
committerBruce Momjian <bruce@momjian.us>
Wed, 13 Oct 1999 02:26:37 +0000 (02:26 +0000)
commit7ee7ee1398acb2ba8e1738a4d959025e43df8820
treece63ab0bb06c9c7769478417b36188c10a7e1fe2
parent714efa88db22dab1b78f7002dbd190881621005b
BLOBs containing NUL characters (ASCII 0) can be written to the
database, but they get truncated at the first NUL by lo_read
when they are read back. The reason for this is that lo_read in
Pg.xs is using the default:
    OUTPUT:
        RETVAL
        buf
which uses C's strlen() to work out the length of the scalar.

The code ought to read something more like:
    OUTPUT:
        RETVAL
        buf sv_setpvn((SV*)ST(2), buf, RETVAL);

I am not sure if this needs to be done on both lo_read methods
in this file, but I changed both and have not since had any
problems with truncated BLOBs.

Douglas Thomson <dougt@mugc.cc.monash.edu.au>
src/interfaces/perl5/Pg.xs