OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I686LINUX / util / I686LINUX / doc / postgresql / html / libpq-threading.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <HTML
3 ><HEAD
4 ><TITLE
5 >Behavior in Threaded Programs</TITLE
6 ><META
7 NAME="GENERATOR"
8 CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
9 REV="MADE"
10 HREF="mailto:pgsql-docs@postgresql.org"><LINK
11 REL="HOME"
12 TITLE="PostgreSQL 7.4.1 Documentation"
13 HREF="index.html"><LINK
14 REL="UP"
15 TITLE="libpq - C Library"
16 HREF="libpq.html"><LINK
17 REL="PREVIOUS"
18 TITLE="The Password File"
19 HREF="libpq-pgpass.html"><LINK
20 REL="NEXT"
21 TITLE="Building libpq Programs"
22 HREF="libpq-build.html"><LINK
23 REL="STYLESHEET"
24 TYPE="text/css"
25 HREF="stylesheet.css"><META
26 NAME="creation"
27 CONTENT="2003-12-22T03:48:47"></HEAD
28 ><BODY
29 CLASS="SECT1"
30 ><DIV
31 CLASS="NAVHEADER"
32 ><TABLE
33 SUMMARY="Header navigation table"
34 WIDTH="100%"
35 BORDER="0"
36 CELLPADDING="0"
37 CELLSPACING="0"
38 ><TR
39 ><TH
40 COLSPAN="5"
41 ALIGN="center"
42 VALIGN="bottom"
43 >PostgreSQL 7.4.1 Documentation</TH
44 ></TR
45 ><TR
46 ><TD
47 WIDTH="10%"
48 ALIGN="left"
49 VALIGN="top"
50 ><A
51 HREF="libpq-pgpass.html"
52 ACCESSKEY="P"
53 >Prev</A
54 ></TD
55 ><TD
56 WIDTH="10%"
57 ALIGN="left"
58 VALIGN="top"
59 ><A
60 HREF="libpq.html"
61 >Fast Backward</A
62 ></TD
63 ><TD
64 WIDTH="60%"
65 ALIGN="center"
66 VALIGN="bottom"
67 >Chapter 27. <SPAN
68 CLASS="APPLICATION"
69 >libpq</SPAN
70 > - C Library</TD
71 ><TD
72 WIDTH="10%"
73 ALIGN="right"
74 VALIGN="top"
75 ><A
76 HREF="libpq.html"
77 >Fast Forward</A
78 ></TD
79 ><TD
80 WIDTH="10%"
81 ALIGN="right"
82 VALIGN="top"
83 ><A
84 HREF="libpq-build.html"
85 ACCESSKEY="N"
86 >Next</A
87 ></TD
88 ></TR
89 ></TABLE
90 ><HR
91 ALIGN="LEFT"
92 WIDTH="100%"></DIV
93 ><DIV
94 CLASS="SECT1"
95 ><H1
96 CLASS="SECT1"
97 ><A
98 NAME="LIBPQ-THREADING"
99 >27.12. Behavior in Threaded Programs</A
100 ></H1
101 ><A
102 NAME="AEN21902"
103 ></A
104 ><P
105 ><SPAN
106 CLASS="APPLICATION"
107 >libpq</SPAN
108 > is reentrant and thread-safe if the
109 <TT
110 CLASS="FILENAME"
111 >configure</TT
112 > command-line option
113 <TT
114 CLASS="LITERAL"
115 >--enable-thread-safety</TT
116 > has been used when the PostgreSQL
117 distribution was built.
118 In addition, you might need to use additional compiler command-line 
119 options when you compile your application code.  Refer to your system's
120 documentation for information about how to build thread-enabled
121 applications.</P
122 ><P
123 >One restriction is that no two threads attempt to manipulate the same
124 <TT
125 CLASS="STRUCTNAME"
126 >PGconn</TT
127 > object at the same time. In particular, you cannot
128 issue concurrent commands from different threads through the same
129 connection object. (If you need to run concurrent commands, start up
130 multiple connections.)</P
131 ><P
132 ><TT
133 CLASS="STRUCTNAME"
134 >PGresult</TT
135 > objects are read-only after creation, and so can be 
136 passed around freely between threads.</P
137 ><P
138 >The deprecated functions <CODE
139 CLASS="FUNCTION"
140 >PQoidStatus</CODE
141 > and
142 <CODE
143 CLASS="FUNCTION"
144 >fe_setauthsvc</CODE
145 > are not thread-safe and should not be
146 used in multithread programs.  <CODE
147 CLASS="FUNCTION"
148 >PQoidStatus</CODE
149 > can be
150 replaced by <CODE
151 CLASS="FUNCTION"
152 >PQoidValue</CODE
153 >.  There is no good reason to
154 call <CODE
155 CLASS="FUNCTION"
156 >fe_setauthsvc</CODE
157 > at all.</P
158 ><P
159 ><SPAN
160 CLASS="APPLICATION"
161 >libpq</SPAN
162 > applications that use the
163 <TT
164 CLASS="LITERAL"
165 >crypt</TT
166 > authentication method rely on the
167 <TT
168 CLASS="LITERAL"
169 >crypt()</TT
170 > operating system function, which is often
171 not thread-safe.<A
172 NAME="AEN21923"
173 ></A
174 > It is better to use the <TT
175 CLASS="LITERAL"
176 >md5</TT
177 > method,
178 which is thread-safe on all platforms.</P
179 ></DIV
180 ><DIV
181 CLASS="NAVFOOTER"
182 ><HR
183 ALIGN="LEFT"
184 WIDTH="100%"><TABLE
185 SUMMARY="Footer navigation table"
186 WIDTH="100%"
187 BORDER="0"
188 CELLPADDING="0"
189 CELLSPACING="0"
190 ><TR
191 ><TD
192 WIDTH="33%"
193 ALIGN="left"
194 VALIGN="top"
195 ><A
196 HREF="libpq-pgpass.html"
197 ACCESSKEY="P"
198 >Prev</A
199 ></TD
200 ><TD
201 WIDTH="34%"
202 ALIGN="center"
203 VALIGN="top"
204 ><A
205 HREF="index.html"
206 ACCESSKEY="H"
207 >Home</A
208 ></TD
209 ><TD
210 WIDTH="33%"
211 ALIGN="right"
212 VALIGN="top"
213 ><A
214 HREF="libpq-build.html"
215 ACCESSKEY="N"
216 >Next</A
217 ></TD
218 ></TR
219 ><TR
220 ><TD
221 WIDTH="33%"
222 ALIGN="left"
223 VALIGN="top"
224 >The Password File</TD
225 ><TD
226 WIDTH="34%"
227 ALIGN="center"
228 VALIGN="top"
229 ><A
230 HREF="libpq.html"
231 ACCESSKEY="U"
232 >Up</A
233 ></TD
234 ><TD
235 WIDTH="33%"
236 ALIGN="right"
237 VALIGN="top"
238 >Building <SPAN
239 CLASS="APPLICATION"
240 >libpq</SPAN
241 > Programs</TD
242 ></TR
243 ></TABLE
244 ></DIV
245 ></BODY
246 ></HTML
247 >