write (PGlarge)

    /*
     * call-seq:
     *    lrg.write( str )
     *
     * Writes the string _str_ to the large object.
     * Returns the number of bytes written.
     */
    static VALUE
    pglarge_write(obj, buffer)
        VALUE obj, buffer;
    {
        int n;
        PGlarge *pglarge = get_pglarge(obj);

        Check_Type(buffer, T_STRING);

        if( RSTRING(buffer)->len < 0) {
            rb_raise(rb_ePGError, "write buffer zero string");
        }
        if((n = lo_write(pglarge->pgconn, pglarge->lo_fd, StringValuePtr(buffer), RSTRING(buffer)->len)) == -1) {
            rb_raise(rb_ePGError, "buffer truncated during write");
        }

        return INT2FIX(n);
    }