Thread: Re: [PATCHES] PQescapeBytea documentation patch
On Tue, Nov 20, 2001 at 12:21:00PM -0800, Joe Conway wrote: > Here's a patch adding documentation for the PQescapeBytea function to > libpq.sgml ... + <function>PQescapeBytea</function> + Escapes a binary string (bytea type) for use within an SQL query. + <synopsis> + unsigned char *PQescapeBytea(unsigned char *from, + size_t from_length, + size_t *to_length); This makes me wonder: should libpq contain a function to do the opposite too? eg. string=GetValue(from a bytea type column) PQunescapeBytea(string, some buffer, buffer's size) - or is there already another way of doing it? It seems to me that anyone using bytea with libpq will end up having to reinvent this wheel. (Something worthy of being knocked up in my Copious Free Time (tm)) Cheers, Patrick
Patrick Welche wrote: > This makes me wonder: should libpq contain a function to do the opposite > too? eg. > > string=GetValue(from a bytea type column) > PQunescapeBytea(string, some buffer, buffer's size) > > - or is there already another way of doing it? > > It seems to me that anyone using bytea with libpq will end up having > to reinvent this wheel. (Something worthy of being knocked up in my > Copious Free Time (tm)) I thought about that, but did not write it for a couple of reasons: First, there wasn't a strong consensus that this type of function belonged as part of libpq in the first place, so I didn't want to push my luck ;-) Second, at least in my current work, I'm using binary cursors, in which case no unescaping is necessary. I do agree that a standard bytea unescape function should be available in the client library somewhere. Maybe for 7.3 . . . Joe
Hi Guys, I have just begun coding in tcl/tk and hence sorry for this simple question. I am using tcl8.3 / tk8.3 and postgreSQL 7.3 . I am not able to load pgtclsh library into to my TK application for giving it backend support. Can you please suggest me how to proceed? Thanks, Amit ----- Original Message ----- From: "Patrick Welche" <prlw1@newn.cam.ac.uk> To: "Joe Conway" <joseph.conway@home.com> Cc: <pgsql-interfaces@postgresql.org> Sent: Wednesday, November 21, 2001 9:25 PM Subject: Re: [INTERFACES] [PATCHES] PQescapeBytea documentation patch > On Tue, Nov 20, 2001 at 12:21:00PM -0800, Joe Conway wrote: > > Here's a patch adding documentation for the PQescapeBytea function to > > libpq.sgml > ... > + <function>PQescapeBytea</function> > + Escapes a binary string (bytea type) for use within an SQL query. > + <synopsis> > + unsigned char *PQescapeBytea(unsigned char *from, > + size_t from_length, > + size_t *to_length); > > > This makes me wonder: should libpq contain a function to do the opposite > too? eg. > > string=GetValue(from a bytea type column) > PQunescapeBytea(string, some buffer, buffer's size) > > - or is there already another way of doing it? > > It seems to me that anyone using bytea with libpq will end up having > to reinvent this wheel. (Something worthy of being knocked up in my > Copious Free Time (tm)) > > Cheers, > > Patrick > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
"Amit Padgaonkar" <amit@nsat.co.jp> writes: > I am using tcl8.3 / tk8.3 and postgreSQL 7.3 . I am not able to > load pgtclsh library into to my TK application for giving it backend > support. pgtclsh is not a library, it is a prebuilt tclsh application with the libpgtcl library already loaded into it. You can load the libpgtcl library into your own application with the usual Tcl "load" command. pgaccess does it like so: if {[info exists env(PGLIB)]} { set libpgtclpath [file join $env(PGLIB) libpgtcl]} else { set libpgtclpath {libpgtcl}}load${libpgtclpath}[info sharedlibextension] regards, tom lane
Tom Lane wrote: > "Amit Padgaonkar" <amit@nsat.co.jp> writes: > > I am using tcl8.3 / tk8.3 and postgreSQL 7.3 . I am not able to > > load pgtclsh library into to my TK application for giving it backend > > support. > > pgtclsh is not a library, it is a prebuilt tclsh application with the > libpgtcl library already loaded into it. You can load the libpgtcl > library into your own application with the usual Tcl "load" command. > pgaccess does it like so: > > if {[info exists env(PGLIB)]} { > set libpgtclpath [file join $env(PGLIB) libpgtcl] > } else { > set libpgtclpath {libpgtcl} > } > load ${libpgtclpath}[info sharedlibextension] > > regards, tom lane I use to have a directory .../tcl8.x/lib/pgtcl where I put a symlink to the libpgtcl.so and the appropriate pgkIndex.tcl file. The pgkIndex can be created by cd'ing into that directory, starting a tclsh and issuing thecommand pkg_mkIndex . ./libpgtcl.so Once you have that, your Tcl scripts just need to do a package require Pgtcl No need for the user to set PGLIB or even know where it is installed. Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #================================================== JanWieck@Yahoo.com # _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com
Hi all, I am using the PGLIB C lib to connect to PgSql to finish the query of the GEOMETRY of a table. At first, everything was OK. I could insert, update, delete and select of whatever I wanted while the geometry data was small one. So I wanted to try a bigger one. I uploaded a ESRI shape file into database which was in the attachment --- Canada.sql. Then I tried the query. res = PQexec(conn, "DECLARE mycursor BINARY CURSOR FOR select gid, name, asbinary(the_geom) from canada"); if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) { fprintf(stderr, "DECLARE CURSOR command failed\n"); PQclear(res); exit_nicely(conn); } PQclear(res); res = PQexec(conn, "FETCH ALL in mycursor"); if (!res || PQresultStatus(res) != PGRES_TUPLES_OK) { fprintf(stderr,"FETCH ALL command didn't return tuples properly\n"); PQclear(res); exit_nicely(conn); } Then I got the error when try to "FETCH ALL in mycursor". Could you help me to figure out the problem? Thanks. I have attached the files needed for you. Best regards, Tony --- Tony Jiang, MSc Research & Development Programmer/Analyst MRF Geosystems Corp (www.mrf.com) Suite 700, 665 8th Street SW, Calgary, AB T2P 3K7 (403) 216-5515 ext:226