@@ -191,11 +191,12 @@ ____________________________________________________________________________-->
191
191
If an error occurs while executing any one of these functions, the
192
192
function will return an otherwise-impossible value, typically 0 or -1.
193
193
A message describing the error is stored in the connection object and
194
- can be retrieved with <function> PQerrorMessage</function >.
194
+ can be retrieved with <xref linkend="libpq- PQerrorMessage"/ >.
195
195
</para>
196
196
____________________________________________________________________________-->
197
197
<para>
198
- 在执行任何一个这种函数期间如果发生一个错误,该函数将会返回一个其他的不可能值,典型的是0或-1。一个关于该错误的消息亦会被保存在连接对象中,可以通过<function>PQerrorMessage</function>检索到。
198
+ 在执行任何一个这种函数期间如果发生一个错误,该函数将会返回一个其他的不可能值,典型的是0或-1。
199
+ 一个关于该错误的消息亦会被保存在连接对象中,可以通过<xref linkend="libpq-PQerrorMessage"/>检索到。
199
200
</para>
200
201
201
202
<!--==========================orignal english content==========================
@@ -913,130 +914,153 @@ ____________________________________________________________________________-->
913
914
<xref linkend="lo-funcs-table"/>中列出了为从 SQL 操纵大对象定制的服务器端函数。
914
915
</para>
915
916
916
- <table id="lo-funcs-table">
917
- <!--==========================orignal english content==========================
918
- <title>SQL-Oriented Large Object Functions</title>
919
- ____________________________________________________________________________-->
920
- <title>面向 SQL 的大对象函数</title>
921
- <tgroup cols="5">
922
- <thead>
923
- <!--==========================orignal english content==========================
924
- <row>
925
- <entry>Function</entry>
926
- <entry>Return Type</entry>
927
- <entry>Description</entry>
928
- <entry>Example</entry>
929
- <entry>Result</entry>
930
- </row>
931
- ____________________________________________________________________________-->
932
- <row>
933
- <entry>函数</entry>
934
- <entry>返回类型</entry>
935
- <entry>描述</entry>
936
- <entry>实例</entry>
937
- <entry>结果</entry>
938
- </row>
939
- </thead>
940
-
941
- <tbody>
942
- <!--==========================orignal english content==========================
943
- <row>
944
- <entry>
945
- <indexterm>
946
- <primary>lo_from_bytea</primary>
947
- </indexterm>
948
- <literal><function>lo_from_bytea(<parameter>loid</parameter> <type>oid</type>, <parameter>string</parameter> <type>bytea</type>)</function></literal>
949
- </entry>
950
- <entry><type>oid</type></entry>
951
- <entry>
952
- Create a large object and store data there, returning its OID.
953
- Pass <literal>0</literal> to have the system choose an OID.
954
- </entry>
955
- <entry><literal>lo_from_bytea(0, '\xffffff00')</literal></entry>
956
- <entry><literal>24528</literal></entry>
957
- </row>
958
- ____________________________________________________________________________-->
959
- <row>
960
- <entry>
961
- <indexterm>
962
- <primary>lo_from_bytea</primary>
963
- </indexterm>
964
- <literal><function>lo_from_bytea(<parameter>loid</parameter> <type>oid</type>, <parameter>string</parameter> <type>bytea</type>)</function></literal>
965
- </entry>
966
- <entry><type>oid</type></entry>
967
- <entry>
968
- 创建一个大对象并且在其中存储数据,返回它的 OID。
969
- 传递<literal>0</literal>会让系统选择一个 OID。
970
- </entry>
971
- <entry><literal>lo_from_bytea(0, '\xffffff00')</literal></entry>
972
- <entry><literal>24528</literal></entry>
973
- </row>
974
-
975
- <!--==========================orignal english content==========================
976
- <row>
977
- <entry>
978
- <indexterm>
979
- <primary>lo_put</primary>
980
- </indexterm>
981
- <literal><function>lo_put(<parameter>loid</parameter> <type>oid</type>, <parameter>offset</parameter> <type>bigint</type>, <parameter>str</parameter> <type>bytea</type>)</function></literal>
982
- </entry>
983
- <entry><type>void</type></entry>
984
- <entry>
985
- Write data at the given offset.
986
- </entry>
987
- <entry><literal>lo_put(24528, 1, '\xaa')</literal></entry>
988
- <entry></entry>
989
- </row>
990
- ____________________________________________________________________________-->
991
- <row>
992
- <entry>
993
- <indexterm>
994
- <primary>lo_put</primary>
995
- </indexterm>
996
- <literal><function>lo_put(<parameter>loid</parameter> <type>oid</type>, <parameter>offset</parameter> <type>bigint</type>, <parameter>str</parameter> <type>bytea</type>)</function></literal>
997
- </entry>
998
- <entry><type>void</type></entry>
999
- <entry>
1000
- 在给定的偏移位置写入数据。
1001
- </entry>
1002
- <entry><literal>lo_put(24528, 1, '\xaa')</literal></entry>
1003
- <entry></entry>
1004
- </row>
1005
-
1006
- <!--==========================orignal english content==========================
1007
- <row>
1008
- <entry>
1009
- <indexterm>
1010
- <primary>lo_get</primary>
1011
- </indexterm>
1012
- <literal><function>lo_get(<parameter>loid</parameter> <type>oid</type> <optional>, <parameter>from</parameter> <type>bigint</type>, <parameter>for</parameter> <type>int</type></optional>)</function></literal>
1013
- </entry>
1014
- <entry><type>bytea</type></entry>
1015
- <entry>
1016
- Extract contents or a substring thereof.
1017
- </entry>
1018
- <entry><literal>lo_get(24528, 0, 3)</literal></entry>
1019
- <entry><literal>\xffaaff</literal></entry>
1020
- </row>
1021
- ____________________________________________________________________________-->
1022
- <row>
1023
- <entry>
1024
- <indexterm>
1025
- <primary>lo_get</primary>
1026
- </indexterm>
1027
- <literal><function>lo_get(<parameter>loid</parameter> <type>oid</type> <optional>, <parameter>from</parameter> <type>bigint</type>, <parameter>for</parameter> <type>int</type></optional>)</function></literal>
1028
- </entry>
1029
- <entry><type>bytea</type></entry>
1030
- <entry>
1031
- 在其中抽取内容或一个子串。
1032
- </entry>
1033
- <entry><literal>lo_get(24528, 0, 3)</literal></entry>
1034
- <entry><literal>\xffaaff</literal></entry>
1035
- </row>
1036
-
1037
- </tbody>
1038
- </tgroup>
1039
- </table>
917
+ <table id="lo-funcs-table">
918
+ <!--==========================orignal english content==========================
919
+ <title>SQL-Oriented Large Object Functions</title>
920
+ ____________________________________________________________________________-->
921
+ <title>面向 SQL 的大对象函数</title>
922
+ <tgroup cols="1">
923
+ <thead>
924
+ <!--==========================orignal english content==========================
925
+ <row>
926
+ <entry role="func_table_entry"><para role="func_signature">
927
+ Function
928
+ </para>
929
+ <para>
930
+ Description
931
+ </para>
932
+ <para>
933
+ Example(s)
934
+ </para></entry>
935
+ </row>
936
+ ____________________________________________________________________________-->
937
+ <row>
938
+ <entry role="func_table_entry"><para role="func_signature">
939
+ 函数
940
+ </para>
941
+ <para>
942
+ 描述
943
+ </para>
944
+ <para>
945
+ 例子
946
+ </para></entry>
947
+ </row>
948
+ </thead>
949
+
950
+ <tbody>
951
+ <!--==========================orignal english content==========================
952
+ <row>
953
+ <entry role="func_table_entry"><para role="func_signature">
954
+ <indexterm>
955
+ <primary>lo_from_bytea</primary>
956
+ </indexterm>
957
+ <function>lo_from_bytea</function> ( <parameter>loid</parameter> <type>oid</type>, <parameter>data</parameter> <type>bytea</type> )
958
+ <returnvalue>oid</returnvalue>
959
+ </para>
960
+ <para>
961
+ Creates a large object and stores <parameter>data</parameter> in it.
962
+ If <parameter>loid</parameter> is zero then the system will choose a
963
+ free OID, otherwise that OID is used (with an error if some large
964
+ object already has that OID). On success, the large object's OID is
965
+ returned.
966
+ </para>
967
+ <para>
968
+ <literal>lo_from_bytea(0, '\xffffff00')</literal>
969
+ <returnvalue>24528</returnvalue>
970
+ </para></entry>
971
+ </row>
972
+ ____________________________________________________________________________-->
973
+ <row>
974
+ <entry role="func_table_entry"><para role="func_signature">
975
+ <indexterm>
976
+ <primary>lo_from_bytea</primary>
977
+ </indexterm>
978
+ <function>lo_from_bytea</function> ( <parameter>loid</parameter> <type>oid</type>, <parameter>data</parameter> <type>bytea</type> )
979
+ <returnvalue>oid</returnvalue>
980
+ </para>
981
+ <para>
982
+ 创建一个大对象并在其中存储<parameter>数据</parameter>。
983
+ 如果<parameter>loid</parameter>为0,则系统将选择一个空闲OID,否则该OID已被使用(如果某个大对象已经拥有该OID,则会出现错误)。在成功时,将返回大对象的OID。
984
+ </para>
985
+ <para>
986
+ <literal>lo_from_bytea(0, '\xffffff00')</literal>
987
+ <returnvalue>24528</returnvalue>
988
+ </para></entry>
989
+ </row>
990
+
991
+ <!--==========================orignal english content==========================
992
+ <row>
993
+ <entry role="func_table_entry"><para role="func_signature">
994
+ <indexterm>
995
+ <primary>lo_put</primary>
996
+ </indexterm>
997
+ <function>lo_put</function> ( <parameter>loid</parameter> <type>oid</type>, <parameter>offset</parameter> <type>bigint</type>, <parameter>data</parameter> <type>bytea</type> )
998
+ <returnvalue>void</returnvalue>
999
+ </para>
1000
+ <para>
1001
+ Writes <parameter>data</parameter> starting at the given offset within
1002
+ the large object; the large object is enlarged if necessary.
1003
+ </para>
1004
+ <para>
1005
+ <literal>lo_put(24528, 1, '\xaa')</literal>
1006
+ <returnvalue></returnvalue>
1007
+ </para></entry>
1008
+ </row>
1009
+ ____________________________________________________________________________-->
1010
+ <row>
1011
+ <entry role="func_table_entry"><para role="func_signature">
1012
+ <indexterm>
1013
+ <primary>lo_put</primary>
1014
+ </indexterm>
1015
+ <function>lo_put</function> ( <parameter>loid</parameter> <type>oid</type>, <parameter>offset</parameter> <type>bigint</type>, <parameter>data</parameter> <type>bytea</type> )
1016
+ <returnvalue>void</returnvalue>
1017
+ </para>
1018
+ <para>
1019
+ 在大对象中写入从给定偏移量开始的<parameter>数据</parameter>;如有必要,可以把大对象扩大。
1020
+ </para>
1021
+ <para>
1022
+ <literal>lo_put(24528, 1, '\xaa')</literal>
1023
+ <returnvalue></returnvalue>
1024
+ </para></entry>
1025
+ </row>
1026
+
1027
+ <!--==========================orignal english content==========================
1028
+ <row>
1029
+ <entry role="func_table_entry"><para role="func_signature">
1030
+ <indexterm>
1031
+ <primary>lo_get</primary>
1032
+ </indexterm>
1033
+ <function>lo_get</function> ( <parameter>loid</parameter> <type>oid</type> <optional>, <parameter>offset</parameter> <type>bigint</type>, <parameter>length</parameter> <type>integer</type> </optional> )
1034
+ <returnvalue>bytea</returnvalue>
1035
+ </para>
1036
+ <para>
1037
+ Extracts the large object's contents, or a substring thereof.
1038
+ </para>
1039
+ <para>
1040
+ <literal>lo_get(24528, 0, 3)</literal>
1041
+ <returnvalue>\xffaaff</returnvalue>
1042
+ </para></entry>
1043
+ </row>
1044
+ ____________________________________________________________________________-->
1045
+ <row>
1046
+ <entry role="func_table_entry"><para role="func_signature">
1047
+ <indexterm>
1048
+ <primary>lo_get</primary>
1049
+ </indexterm>
1050
+ <function>lo_get</function> ( <parameter>loid</parameter> <type>oid</type> <optional>, <parameter>offset</parameter> <type>bigint</type>, <parameter>length</parameter> <type>integer</type> </optional> )
1051
+ <returnvalue>bytea</returnvalue>
1052
+ </para>
1053
+ <para>
1054
+ 提取大对象的内容,或在其中的子字符串。
1055
+ </para>
1056
+ <para>
1057
+ <literal>lo_get(24528, 0, 3)</literal>
1058
+ <returnvalue>\xffaaff</returnvalue>
1059
+ </para></entry>
1060
+ </row>
1061
+ </tbody>
1062
+ </tgroup>
1063
+ </table>
1040
1064
1041
1065
<!--==========================orignal english content==========================
1042
1066
<para>
@@ -1194,19 +1218,19 @@ ____________________________________________________________________________-->
1194
1218
<title>用<application>libpq</application>操作大对象的例子程序</title>
1195
1219
<!--==========================orignal english content==========================
1196
1220
<programlisting><![CDATA[
1197
- /*-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-
1221
+ /*-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-
1198
1222
*
1199
1223
* testlo.c
1200
1224
* test using large objects with libpq
1201
1225
*
1202
- * Portions Copyright (c) 1996-2019 , PostgreSQL Global Development Group
1226
+ * Portions Copyright (c) 1996-2020 , PostgreSQL Global Development Group
1203
1227
* Portions Copyright (c) 1994, Regents of the University of California
1204
1228
*
1205
1229
*
1206
1230
* IDENTIFICATION
1207
1231
* src/test/examples/testlo.c
1208
1232
*
1209
- *-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-
1233
+ *-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-−-
1210
1234
*/
1211
1235
#include <stdio.h>
1212
1236
#include <stdlib.h>
@@ -1471,19 +1495,19 @@ main(int argc, char **argv)
1471
1495
</programlisting>
1472
1496
____________________________________________________________________________-->
1473
1497
<programlisting><![CDATA[
1474
- /*-------------------------------------------------------------------------
1498
+ /*-----------------------------------------------------------------
1475
1499
*
1476
1500
* testlo.c
1477
- * 测试通过 libpq 使用大对象
1501
+ * 测试通过libpq实用大对象
1478
1502
*
1479
- * Portions Copyright (c) 1996-2018 , PostgreSQL Global Development Group
1503
+ * Portions Copyright (c) 1996-2020 , PostgreSQL Global Development Group
1480
1504
* Portions Copyright (c) 1994, Regents of the University of California
1481
1505
*
1482
1506
*
1483
1507
* IDENTIFICATION
1484
1508
* src/test/examples/testlo.c
1485
1509
*
1486
- *-------------------------------------------------------------------------
1510
+ *-----------------------------------------------------------------
1487
1511
*/
1488
1512
#include <stdio.h>
1489
1513
#include <stdlib.h>
@@ -1496,10 +1520,10 @@ ____________________________________________________________________________-->
1496
1520
#include "libpq-fe.h"
1497
1521
#include "libpq/libpq-fs.h"
1498
1522
1499
- #define BUFSIZE 1024
1523
+ #define BUFSIZE 1024
1500
1524
1501
1525
/*
1502
- * importFile
1526
+ * importFile -
1503
1527
* 把文件 "in_filename" 作为一个大对象 "lobjOid" 载入到数据库
1504
1528
*
1505
1529
*/
@@ -1613,6 +1637,7 @@ overwrite(PGconn *conn, Oid lobjId, int start, int len)
1613
1637
lo_close(conn, lobj_fd);
1614
1638
}
1615
1639
1640
+
1616
1641
/*
1617
1642
* exportFile -
1618
1643
* 把大对象 "lobjOid" 导出成文件 "out_filename"
0 commit comments