File: dbd_pgsql.sgml

package info (click to toggle)
libdbi-drivers 0.9.0-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 6,148 kB
  • ctags: 1,900
  • sloc: ansic: 18,980; sh: 10,942; xml: 2,759; makefile: 577
file content (304 lines) | stat: -rw-r--r-- 11,767 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
<!DOCTYPE Book PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [

<!ENTITY freedoc-license SYSTEM "../../doc/include/copying-fdl.sgml">
<!ENTITY www 'http://libdbi-drivers.sourceforge.net'>
<!ENTITY www-libdbi 'http://libdbi.sourceforge.net'>

<!-- customize these and the bookinfo section -->
<!ENTITY author-email 'david@neongoat.com'>
<!ENTITY author-name 'David A. Parker'>
<!ENTITY dbd-name 'pgsql'>
<!ENTITY proper-name 'PostgreSQL'>
<!ENTITY www-upstream 'http://www.postgresql.org'>

]>

<!-- $Id: dbd_pgsql.sgml,v 1.7 2008/05/16 15:09:43 mhoenicka Exp $ -->

<book id="dbd-&dbd-name;">

  <bookinfo>
    <title>&proper-name; Driver Notes</title>
    <subtitle>Details about the libdbi driver providing support for &proper-name; backends</subtitle>
    <author>
      <firstname>David</firstname>
      <othername>A.</othername>
      <surname>Parker</surname>
      <affiliation>
	<orgname>Neon Goat Productions</orgname>
	<address><email>david@neongoat.com</email></address>
      </affiliation>
    </author>
    <edition>Document revision: $Id: dbd_pgsql.sgml,v 1.7 2008/05/16 15:09:43 mhoenicka Exp $</edition>
    <pubdate>$Date: 2008/05/16 15:09:43 $</pubdate>
    <revhistory>
      <revision>
	<revnumber>0.2</revnumber>
	<date>2005-07-17</date>
      </revision>
      <revision>
	<revnumber>0.1</revnumber>
	<date>2003-4-17</date>
      </revision>
    </revhistory>
    <copyright>
      <year>2001-2003</year>
      <holder>David Parker, Neon Goat Productions</holder>
    </copyright>
    <legalnotice>
      <para>
	Permission is granted to copy, distribute and/or modify this
	document under the terms of the <link linkend="copying-FDL">
	  <citetitle>GNU Free Documentation License</citetitle></link>,
	Version 1.1 or any later version published by the Free Software
	Foundation; with no Invariant Sections, with no	Front-Cover Texts,
	and with no Back-Cover Texts.  A copy of the license is included in
	<xref linkend="copying-FDL">.
      </para>
    </legalnotice>
  </bookinfo>

  <preface><title>Preface</title>
    <para>
      <ulink url="&www-libdbi;">libdbi</ulink> is a database abstraction
      layer written in C. It implements a framework that can utilize
      separate driver libraries for specific database servers. The <ulink
	url="&www;">libdbi-drivers</ulink> project provides the drivers
      necessary to talk to the supported database servers.
    </para>
    <para>
      This manual provides information about the &dbd-name; driver, which
      provides support for &proper-name; databases. The manual is
      intended for programmers who write applications linked against libdbi
      and who want their applications to use this database backend.
    </para>
    <para>
      Questions and comments about this driver should be sent to the
      libdbi-drivers-devel mailing list (see the <ulink
	url="&www;">website</ulink>). Questions and comments about the libdbi
      library should be sent to the appropriate libdbi mailing list.
    </para>
    <para>
      This driver is maintained by <ulink url="mailto:&author-email;">&author-name;</ulink>.
    </para>
  </preface>

  <chapter id="intro"><title>Introduction</title>
    <para>
      PostgreSQL is an object-relational database management system
      (ORDBMS) based on  POSTGRES, Version 4.2, developed at the University
      of California at Berkeley Computer Science Department. The POSTGRES
      project, led by Professor Michael Stonebraker, was sponsored by the
      Defense Advanced Research Projects Agency (DARPA), the Army Research
      Office (ARO), the National Science Foundation (NSF), and ESL, Inc.
    </para>
    <para>
      PostgreSQL is an open-source descendant of this original Berkeley
      code. It provides SQL92/SQL99 language support and other modern
      features.
    </para>
    <para>
      More information can be found from the <ulink url="&www-upstream;">&proper-name; website</ulink>.
    </para>
  </chapter>

  <chapter id="install"><title>Installation</title>
    <para>
      This chapter describes the prerequisites and the procedures to build
      and install this driver from source code.
    </para>
    <section id="install-prereq"><title>Prerequisites</title>
      <para>
	The following packages must be installed on your system:
      </para>
      <variablelist>
	<varlistentry>
	  <term>libdbi</term>
	  <listitem>
	    <para>
	      This library implements the core database abstraction
	      layer, which provides your application with database
	      backend functionality when paired with this driver.
	      More information about libdbi, including mailing
	      lists, documentation, bug reports, and downloads, is
	      available from the <ulink url="&www-libdbi;">libdbi
		website</ulink>.
	    </para>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term>libpq</term>
	  <listitem>
	    <para>
	      This is the C shared library to enable user programs
	      to communicate with the PostgreSQL database backend.
	      The backend can be on another machine and accessed
	      through TCP/IP. This library is distributed as part of
	      PostgreSQL, and can be found on their website. It may
	      also be packaged independently for your operating
	      system, depending on what you use.
	    </para>
	    <para>
	      The current version of the dbd_pgsql driver was
	      written and tested with libpq3 from PostgreSQL 8.0.1.</para>
	  </listitem>
	</varlistentry>
      </variablelist>
    </section>
    <section id="install-build"><title>Build and install the driver</title>
      <para>
	First you have to unpack the libdbi-drivers archive in a suitable
	directory. Unpacking will create a new subdirectory with the
	version number, such as <filename
	  class="directory">libdbi-drivers-0.8.0</filename>
      </para>
      <screen><prompt>$ </prompt><userinput>tar xfvz libdbi-drivers-0.8.0.tar.gz</userinput></screen>
      <para>
	The libdbi-drivers project consists of several drivers that use a
	common build system. Therefore you <emphasis>must</emphasis> explicitly tell
	the configuration script that you want to build the &dbd-name; driver (you
	can list as many drivers as you want to build):
      </para>
      <screen><prompt>$ </prompt><userinput>cd libdbi-drivers-0.8.0</userinput></screen>
      <screen><prompt>$ </prompt><userinput>./configure --with-&dbd-name;</userinput></screen>
      <para>
	Run <command>./configure --help</command> to find out about
	additional options and other available drivers.
      </para>
      <para>
	Then build the driver with the command:
      </para>
      <screen><prompt>$ </prompt><userinput>make</userinput></screen>
      <note>
	<para>
	  Please note that you may have to invoke
	  <command>gmake</command>, the GNU version of make, on some
	  systems.
	</para>
      </note>
      <para>
	Then install the driver with the command (you'll need root
	permissions to do this):
      </para>
      <screen><prompt>$ </prompt><userinput>make install</userinput></screen>
      <para>
	To test the operation of the newly installed driver, use the
	command:
      </para>
      <screen><prompt>$ </prompt><userinput>make check</userinput></screen>
      <para>
	This command creates and runs a test program that performs a few
	basic input and output tests.
      </para>
      <note>
	<para>
	  If for some reason you need to re-create the
	  autoconf/automake-related files, try running <command
	    moreinfo="none">./autogen.sh</command>. In some situations,
	  the current stable autoconf/automake/libtool versions (as
	  found in FreeBSD 4.7 and Debian 3.0) do not cooperate well, so
	  it may be necessary to run the older autoconf 2.13. If
	  necessary, edit <filename
	    moreinfo="none">autogen.sh</filename> so that it will catch
	  the older autoconf version on your system.
	</para>
      </note>
    </section>
  </chapter>

  <chapter id="options"><title>Driver options</title>
    <para>
      Before you can initiate a connection, you must usually specify
      options that tell the database driver what to connect to. This
      driver supports the standard options of <varname>host</varname>,
      <varname>username</varname>, <varname>password</varname>,
      <varname>dbname</varname>, <varname>timeout</varname>, and
      <varname>port</varname>, as well as PostgreSQL-specific
      options. You only need to set options that are specific to your
      application -- sensible defaults will be used for all
      unspecified options.
    </para>
    <variablelist>
      <varlistentry>
	<term>host</term>
	<listitem>
	  <para>
	    If this begins with a slash, it specifies Unix-domain
	    communication rather than TCP/IP communication; the value
	    is the name of the directory in which the socket file is
	    stored.  The default behavior when <varname>host</varname>
	    is not specified is to connect to a Unix-domain socket in
	    /tmp (or whatever socket directory was specified when
	    PostgreSQL was built).
	  </para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>port</term>
	<listitem>
	  <para>
	    Port number to connect to at the server host, or socket
	    file name extension for Unix-domain connections.
	  </para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>username</term>
	<listitem>
	  <para>The name of the user accessing the database.</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>password</term>
	<listitem>
	  <para>The password of the user accessing the database.</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>dbname</term>
	<listitem>
	  <para>The name of the database used for the initial connection. If your program must be able to connect to a fresh PostgreSQL installation, use the system database <filename moreinfo="none">template1</filename>.</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>timeout (numeric)</term>
	<listitem>
	  <para>The connection timeout in seconds. If the option is not specified, or if it is 0 (zero), stale connections never time out.</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>encoding</term>
	<listitem>
	  <para>The IANA name of a character encoding which is to be used as the connection encoding. Input and output data will be silently converted from and to this character encoding, respectively. The list of available character encodings depends on your local PostgreSQL installation. If you set this option to "auto", the connection encoding will be the same as the database encoding.</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>pgsql_foo</term>
	<listitem>
	  <para>Pass option <varname>foo</varname> directly to libpq.  For valid options, refer to the <ulink url="http://www.postgresql.org/docs/current/static/libpq-connect.html">libpq documentation</ulink>.
	  </para>
	</listitem>
      </varlistentry>
    </variablelist>
  </chapter>

  <chapter id="specific"><title>&proper-name;-specific Peculiarities</title>
    <para>
      This chapter lists known peculiarities of the &dbd-name; driver.
      Wherever possible, nonstandard driver behavior is hidden by libdbi's
      abstractions, but occasionally special considerations must be taken or
      extra functionality may be utilized for particular drivers.
    </para>
    <para>
      PostgreSQL has no intrinsic concept of unsigned fields (although you
      can still use the "OID" type as an unsigned long, or define your own
      user-defined unsigned types). User-defined types are not handled
      specially. All unrecognized datatypes are preserved as strings.
    </para>
    <para>PostgreSQL does not support a 1-byte numeric datatype.</para>
  </chapter>

  &freedoc-license;

</book>