From: | Andreas Kretzer <andi(at)kretzer-berlin(dot)de> |
---|---|
To: | Postgres Interface List <pgsql-interfaces(at)postgresql(dot)org> |
Subject: | TCL with large objects on Win |
Date: | 2001-12-03 10:10:26 |
Message-ID: | 3C0B4F92.530A3DA6@kretzer-berlin.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
Hi everybody,
I'm using postgres 7.1.2 with Tcl/Tk (8.3) interface on
Windows (the database is running on Linux, only the
clients are on Windows).
When using the pg_lo_import or pg_lo_export functions,
everything is ok under Linux (where I develop and test
the application). When I started to make a test under
MS I recognized, that all this stuff is broken! It won't
import nor export binary data (while a fist test with some
pure text and RTF files worked ok). So this all is related
to the binary stuff (CR/LF and EOF chars I think).
So I changed the scripts to use the pg_lo_create, pg_lo_open,
pg_lo_write / pg_lo_read and pg_lo_close together with a
filedescriptor of the Tcl/Tk switched to binary mode:
fconfigure $fd -translation binary
This seems to be a solution for importing the objects (at
least they have the correct size when I export them on the
Linux machine), but unfourtunately it doesn't work on export!
The first problem is to find the source of this trouble - it
could be a Tcl/Tk problem!
When reading from the large object with
pg_lo_read $conn $lofd buf 4096
if returns the amount of read bytes (lets say we are at the
beginning of a large file, so it really reads the 4k bytes).
When I test the length of the string, it will be a lot
shorter (varies, most time it is about half the size I expected
it to be). Of course this leads to a corrupt file after
complete export.
I also have reduced the read size to 1 byte! In this case, the
string length function returns often (or always ???) 3!!!!
Because the import runs cleanly with the same data (read from
file, written to the large object) I am in doubt that it really
is a Tcl/Tk concern.
N.B.: While trying to find the reason for my trouble getting this
all to work (blame on me: I frogot to put this all inside a
transaction block) I found an implemention fault in
src/interfaces/libpgtcl/pgtclCmds.c
The second letter of the mode in Pg_lo_open() ANDs its binary
value to the one in the case-statement for the first letter.
This should obviously be an ORing function like
mode |= INV_READ;
or
mode |= INV_WRITE;
respectively. I already posted a mail about this to
pgsql-bugs(at)postgresql(dot)org but maybe some of the developers
read this here before processing the bug-reports :-)
Unfortunately, this has nothing to do with my problem.
Hope that someone can help me. I can't compile the windows
DLLs (got no Microsoft compiler and don't want to use the
cygnus stuff). Is there a chance to compile the DLLs with
GNU C?
Best regards
Andreas
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2001-12-03 14:57:07 | Re: TCL with large objects on Win |
Previous Message | dsmclennan | 2001-12-03 04:57:22 | C interface libpq.so.2 problem |