Patrick, The code is copied below. It is Brian’s example from the FAQ section 5.4.6. I get similar results without -x and running cobcrun (which then can’t find PGTest.so). I haven’t statically linked stuff yet … will try in a bit. Have a customer on the phone at the moment. —— START CODE —— OCOBOL*> ***************************************************************
*> Author: Brian Tiffin
*> Date: 20091129
*> Purpose: PostgreSQL connection test
*> Tectonics: cobc -x -lpq pgcob.cob
*> ***************************************************************
identification division.
program-id. pgcob.
data division.
working-storage section.
01 pgconn usage pointer.
01 pgres usage pointer.
01 resptr usage pointer.
01 resstr pic x(80) based.
01 result usage binary-long.
01 answer pic x(80).
*> ***************************************************************
procedure division.
display "Before connect:" pgconn end-display
call "PQconnectdb" using
by reference "dbname = postgres" & x"00"
returning pgconn
end-call
display "After connect: " pgconn end-display
call "PQstatus" using by value pgconn returning result end-call
display "Status: " result end-display
call "PQuser" using by value pgconn returning resptr end-call
set address of resstr to resptr
string resstr delimited by x"00" into answer end-string
display "User: " function trim(answer) end-display
display "call PQexec" end-display
call "PQexec" using
by value pgconn
by reference "select version();" & x"00"
returning pgres
end-call
display pgres end-display
*> Pull out a result. row 0, field 0 <*
call "PQgetvalue" using
by value pgres
by value 0
by value 0
returning resptr
end-call
set address of resstr to resptr
string resstr delimited by x"00" into answer end-string
display "Version: " answer end-display
call "PQfinish" using by value pgconn returning null end-call
display "After finish: " pgconn end-display
call "PQstatus" using by value pgconn returning result end-call
display "Status: " result end-display
*> this will now return garbage <*
call "PQuser" using by value pgconn returning resptr end-call
set address of resstr to resptr
string resstr delimited by x"00" into answer end-string
display "User after: " function trim(answer) end-display
goback.
end program pgcob. — END CODE — start cobc -v output ——— address@hidden:~/Projects/PlanBTest/mhWork$ cobc -L/usr/lib -lpq -std=mvs -v ../cobol_source/PGTest.cbl
Command line: cobc -L/usr/lib -lpq -std=mvs -v ../cobol_source/PGTest.cbl
Preprocessing: ../cobol_source/PGTest.cbl -> /tmp/cob41797_0.cob
Return status: 0
Parsing: /tmp/cob41797_0.cob (../cobol_source/PGTest.cbl)
Return status: 0
Translating: /tmp/cob41797_0.cob -> /tmp/cob41797_0.c (../cobol_source/PGTest.cbl)
Executing: gcc -std=gnu99 -I/usr/local/include -pipe -Wno-unused
-fsigned-char -Wno-pointer-sign -shared -fPIC -DPIC
-Wl,--export-dynamic -o "PGTest.so" "/tmp/cob41797_0.c"
-L/usr/local/lib -lcob -lm -lgmp -lncurses -ldb -ldl -l"pq"
-L"/usr/lib"
Return status: 0
address@hidden:~/Projects/PlanBTest/mhWork$ ——— END cobc -v output ——— > Patrick wrote > Hi Marty
> Do you have a little snippet of test code you could share ?
> I am on Debian Stable. I don't seem to be having trouble but maybe I am
> missing something and have the bug too.
> Is it possible to statically link to see if the problem goes away?
> Could you compile in verbose mode and share?
Thanks
— Marty Heyman 510-290-6484 (Mobile)
|