Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit68e190c

Browse files
committed
>has anyone ever successfully done copy to/from stdout with the
>tcl-extension for postgreSQL.>I'm currently using 7.0 and always getting a seg fault when I try to>read from the database connection after issueing a "COPY table TO>stdout;" (I'm using the connection handle, *not* the result handle).>Maybe this is fixed in a later release.>The README file in src/interfaces/libpgtcl tells me, that this should>work, but unforunately it doesn't.Yes, it seems broken. It is a bug in libpgtcl. Are you running Tcl >= 8.3.2?That's when the Tcl team changed the data structure for channelcallbacks. The change itself was designed to be backward compatible, but Isuspect a related change made the code more sensitive to errors in thestructure (NULL pointers where functions are required). Either that, ornobody has tried to use libpgtcl with COPY in a long time.First, I have to say I can't think of a good reason to use PostgreSQL'sCOPY command from a Tcl application. I think it should only be used withpsql for importing data from another source into PostgreSQL, or forexporting PostgreSQL data into another database (but why would anyone dothat?) If it was me, I would stick with SELECT and INSERT and be "SQLCompliant".OK, editorial is over. Try applying the patch below to fix src/interfaces/libpgtcl/pgtclId.cand let us know if it works. I did little testing on it, but my test didsegfault before and ran fine (copy in and copy out) after the patch. Thisis for PostgreSQL-7.1.2 - since you are running older 7.0, I don't know ifthis will work, but I suspect it will.PS It's the absence of PgWatchProc which kills it. I didn't upgrade itto the "V2" channel type structure, so it should be compatible with olderTcl's. But aside from gets and puts, I doubt any other file operationswould work on the handle during a copy.ljb
1 parenta926c70 commit68e190c

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

‎src/interfaces/libpgtcl/pgtclId.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
1515
* IDENTIFICATION
16-
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.26 2001/09/06 02:54:56 momjian Exp $
16+
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.27 2001/09/07 21:55:00 momjian Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -138,17 +138,32 @@ PgGetFileProc(ClientData cData, int direction)
138138

139139
#endif
140140

141+
/*
142+
* The WatchProc and GetHandleProc are no-ops but must be present.
143+
*/
144+
staticvoid
145+
PgWatchProc(ClientDatainstanceData,intmask)
146+
{
147+
}
148+
staticint
149+
PgGetHandleProc(ClientDatainstanceData,intdirection,
150+
ClientData*handlePtr)
151+
{
152+
returnTCL_ERROR;
153+
}
154+
141155
Tcl_ChannelTypePg_ConnType= {
142156
"pgsql",/* channel type */
143157
NULL,/* blockmodeproc */
144158
PgDelConnectionId,/* closeproc */
145159
PgInputProc,/* inputproc */
146160
PgOutputProc,/* outputproc */
147-
148-
/*
149-
* Note the additional stuff can be left NULL, or is initialized
150-
* during a PgSetConnectionId
151-
*/
161+
NULL,/* SeekProc, Not used */
162+
NULL,/* SetOptionProc, Not used */
163+
NULL,/* GetOptionProc, Not used */
164+
PgWatchProc,/* WatchProc, must be defined */
165+
PgGetHandleProc,/* GetHandleProc, must be defined */
166+
NULL/* Close2Proc, Not used */
152167
};
153168

154169
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp