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

Commitede9b68

Browse files
committed
Use Tcl ByteArray objects to avoid unwanted character set translation
in libpgtcl's lo_read/lo_write commands. Also, deal correctly withfailure return from lo_read(). ljb and Tom Lane.
1 parente84487f commitede9b68

File tree

2 files changed

+37
-25
lines changed

2 files changed

+37
-25
lines changed

‎doc/src/sgml/libpgtcl.sgml

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/libpgtcl.sgml,v 1.38 2003/09/29 18:18:35 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/libpgtcl.sgml,v 1.39 2003/10/31 00:18:55 tgl Exp $
33
-->
44

55
<chapter id="pgtcl">
@@ -1217,7 +1217,7 @@ pg_lo_creat <parameter>conn</parameter> <parameter>mode</parameter>
12171217
<term><parameter>conn</parameter></term>
12181218
<listitem>
12191219
<para>
1220-
The handle of adatabaseconnection in which to create the large
1220+
The handle of a connection to the database in which to create the large
12211221
object.
12221222
</para>
12231223
</listitem>
@@ -1284,8 +1284,8 @@ pg_lo_open <parameter>conn</parameter> <parameter>loid</parameter> <parameter>mo
12841284

12851285
<listitem>
12861286
<para>
1287-
The handle of adatabaseconnection in which the large object to
1288-
be openedexists.
1287+
The handle of a connectionto the databasein which the large object
1288+
exists.
12891289
</para>
12901290
</listitem>
12911291
</varlistentry>
@@ -1354,7 +1354,7 @@ pg_lo_close <parameter>conn</parameter> <parameter>descriptor</parameter>
13541354
<term><parameter>conn</parameter></term>
13551355
<listitem>
13561356
<para>
1357-
The handle of adatabaseconnection in which the large object
1357+
The handle of a connection to the database in which the large object
13581358
exists.
13591359
</para>
13601360
</listitem>
@@ -1417,7 +1417,7 @@ pg_lo_read <parameter>conn</parameter> <parameter>descriptor</parameter> <parame
14171417
<term><parameter>conn</parameter></term>
14181418
<listitem>
14191419
<para>
1420-
The handle of adatabaseconnection in which the large object
1420+
The handle of a connection to the database in which the large object
14211421
exists.
14221422
</para>
14231423
</listitem>
@@ -1458,7 +1458,9 @@ pg_lo_read <parameter>conn</parameter> <parameter>descriptor</parameter> <parame
14581458
<title>Return Value</title>
14591459

14601460
<para>
1461-
None
1461+
The number of bytes actually read is returned; this could be less than
1462+
the number requested if the end of the large object is reached first.
1463+
In event of an error, the return value is negative.
14621464
</para>
14631465
</refsect1>
14641466
</refentry>
@@ -1499,7 +1501,7 @@ pg_lo_write <parameter>conn</parameter> <parameter>descriptor</parameter> <param
14991501
<term><parameter>conn</parameter></term>
15001502
<listitem>
15011503
<para>
1502-
The handle of adatabaseconnection in which the large object
1504+
The handle of a connection to the database in which the large object
15031505
exists.
15041506
</para>
15051507
</listitem>
@@ -1519,7 +1521,8 @@ pg_lo_write <parameter>conn</parameter> <parameter>descriptor</parameter> <param
15191521
<term><parameter>buf</parameter></term>
15201522
<listitem>
15211523
<para>
1522-
The string to write to the large object (not a variable name).
1524+
The string to write to the large object (not a variable name,
1525+
but the value itself).
15231526
</para>
15241527
</listitem>
15251528
</varlistentry>
@@ -1528,7 +1531,8 @@ pg_lo_write <parameter>conn</parameter> <parameter>descriptor</parameter> <param
15281531
<term><parameter>len</parameter></term>
15291532
<listitem>
15301533
<para>
1531-
The maximum number of bytes to write.
1534+
The maximum number of bytes to write. The number written will
1535+
be the smaller of this value and the length of the string.
15321536
</para>
15331537
</listitem>
15341538
</varlistentry>
@@ -1539,7 +1543,9 @@ pg_lo_write <parameter>conn</parameter> <parameter>descriptor</parameter> <param
15391543
<title>Return Value</title>
15401544

15411545
<para>
1542-
None
1546+
The number of bytes actually written is returned; this will ordinarily
1547+
be the same as the number requested.
1548+
In event of an error, the return value is negative.
15431549
</para>
15441550
</refsect1>
15451551
</refentry>
@@ -1580,7 +1586,7 @@ pg_lo_lseek <parameter>conn</parameter> <parameter>descriptor</parameter> <param
15801586
<term><parameter>conn</parameter></term>
15811587
<listitem>
15821588
<para>
1583-
The handle of adatabaseconnection in which the large object
1589+
The handle of a connection to the database in which the large object
15841590
exists.
15851591
</para>
15861592
</listitem>
@@ -1664,7 +1670,7 @@ pg_lo_tell <parameter>conn</parameter> <parameter>descriptor</parameter>
16641670

16651671
<listitem>
16661672
<para>
1667-
The handle of adatabaseconnection in which the large object
1673+
The handle of a connection to the database in which the large object
16681674
exists.
16691675
</para>
16701676
</listitem>
@@ -1727,7 +1733,7 @@ pg_lo_unlink <parameter>conn</parameter> <parameter>loid</parameter>
17271733
<term><parameter>conn</parameter></term>
17281734
<listitem>
17291735
<para>
1730-
The handle of adatabaseconnection in which the large object
1736+
The handle of a connection to the database in which the large object
17311737
exists.
17321738
</para>
17331739
</listitem>
@@ -1788,7 +1794,7 @@ pg_lo_import <parameter>conn</parameter> <parameter>filename</parameter>
17881794
<term><parameter>conn</parameter></term>
17891795
<listitem>
17901796
<para>
1791-
The handle of adatabaseconnection in which to create the large
1797+
The handle of a connection to the database in which to create the large
17921798
object.
17931799
</para>
17941800
</listitem>
@@ -1858,7 +1864,7 @@ pg_lo_export <parameter>conn</parameter> <parameter>loid</parameter> <parameter>
18581864
<term><parameter>conn</parameter></term>
18591865
<listitem>
18601866
<para>
1861-
The handle of adatabaseconnection in which the large object
1867+
The handle of a connection to the database in which the large object
18621868
exists.
18631869
</para>
18641870
</listitem>

‎src/interfaces/libpgtcl/pgtclCmds.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.73 2003/08/04 02:40:16 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.74 2003/10/31 00:18:55 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1215,17 +1215,21 @@ Pg_lo_read(ClientData cData, Tcl_Interp *interp, int objc,
12151215
buf=ckalloc(len+1);
12161216

12171217
nbytes=lo_read(conn,fd,buf,len);
1218-
bufObj=Tcl_NewStringObj(buf,nbytes);
12191218

1220-
if (Tcl_ObjSetVar2(interp,bufVar,NULL,bufObj,
1221-
TCL_LEAVE_ERR_MSG |TCL_PARSE_PART1)==NULL)
1222-
rc=TCL_ERROR;
1223-
else
1219+
if (nbytes >=0)
1220+
{
1221+
bufObj=Tcl_NewByteArrayObj(buf,nbytes);
1222+
1223+
if (Tcl_ObjSetVar2(interp,bufVar,NULL,bufObj,
1224+
TCL_LEAVE_ERR_MSG |TCL_PARSE_PART1)==NULL)
1225+
rc=TCL_ERROR;
1226+
}
1227+
1228+
if (rc==TCL_OK)
12241229
Tcl_SetObjResult(interp,Tcl_NewIntObj(nbytes));
12251230

12261231
ckfree(buf);
12271232
returnrc;
1228-
12291233
}
12301234

12311235
#else
@@ -1265,7 +1269,9 @@ Pg_lo_read(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
12651269

12661270
nbytes=lo_read(conn,fd,buf,len);
12671271

1268-
Tcl_SetVar(interp,bufVar,buf,TCL_LEAVE_ERR_MSG);
1272+
if (nbytes >=0)
1273+
Tcl_SetVar(interp,bufVar,buf,TCL_LEAVE_ERR_MSG);
1274+
12691275
sprintf(interp->result,"%d",nbytes);
12701276
ckfree(buf);
12711277
returnTCL_OK;
@@ -1307,7 +1313,7 @@ Pg_lo_write(ClientData cData, Tcl_Interp *interp, int objc,
13071313
if (Tcl_GetIntFromObj(interp,objv[2],&fd)!=TCL_OK)
13081314
returnTCL_ERROR;
13091315

1310-
buf=Tcl_GetStringFromObj(objv[3],&nbytes);
1316+
buf=Tcl_GetByteArrayFromObj(objv[3],&nbytes);
13111317

13121318
if (Tcl_GetIntFromObj(interp,objv[4],&len)!=TCL_OK)
13131319
returnTCL_ERROR;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp