head	1.2;
access;
symbols
	REL-08_01_0006:1.1
	REL-08_01_0005:1.1
	REL-08_01_0004:1.1;
locks; strict;
comment	@# @;


1.2
date	2005.11.04.10.50.52;	author petere;	state dead;
branches;
next	1.1;

1.1
date	2005.08.27.19.44.47;	author dpage;	state Exp;
branches;
next	;


desc
@@


1.2
log
@Remove wildly outdated Debian and Red Hat HOWTOs.
@
text
@<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
    <title>psqlODBC HOWTO - Redhat</title>
  </HEAD>

  <body bgcolor="#ffffff" text="#000000" link="#ff0000" vlink="#a00000" alink="#0000ff">
  
<h1>psqlODBC HOWTO - Redhat</h1>

<p>

<i>
Author: Pavel Cenek (xcenek@@fi.muni.cz)<br>
Release Date: 12 February 2002<br>
Description: Installation and configuration of PostgreSQL & ODBC on Redhat Linux
</i>
<br><br>

<b>0) Notes</b><p>

I tried the installation on Red Hat Linux 7.1 with PostgreSQL 7.1.3 Some tricks which are not 
documented in one place (or are not documented at all) are written here. This file is not 
intended to replace PostgreSQL documentation. If you have any trouble read the 
<a href="http://www.postgresql.org/docs">manual</a>!!<br><br>

Every rpm has version number in the name, I use names without versions to 
refer to rpm files in the following text.<br><br>


<b>1) Installing and configuring PostgreSQL</b><p>

From <a href="ftp://ftp.postgresql.org">ftp://ftp.postgresql.org</a> or preferrably from a mirror site download the following rpms:<br><br>

<center>
<table border=1 width="424" cellpadding="2" cellspacing="1">
  <tr><td width="157">postgresql</td><td width="257">client binaries, docs, man pages</td></tr>
  <tr><td width="157">postgresql-server</td><td width="257">server binaries, some docs</td></tr>
  <tr><td width="157">postgresql-libs</td><td width="257">shared libraries</td></tr>
  <tr><td width="157">postgresql-test</td><td width="257">files for testing DB functionality</td></tr>
  <tr><td width="157">postgresql-devel</td><td width="257">header files and developers libraries</td></tr>
</table>
</center>

<br><br>

Type
<blockquote>
 <p> <i>rpm -i <list of rpms></i> </p>
</blockquote>
<p>for installing, or </p>
<blockquote>
 <p> <i>rpm -U <list of rpms></i> </p>
</blockquote>
<p>for upgrade.<br><br>

After installing we ensure that PostgreSQL will be started at boot time.<br><br>

Add a symlink from</p>
<blockquote>
<p> <i>/etc/rc.d/rcL.d/KXYpostgresql</i> </p>
</blockquote>
<p>and </p>
<blockquote>
<p> <i>/etc/rc.d/rcL.d/SXYpostgresql</i> </p>
</blockquote>
<p>to </p>
<blockquote>
<p> <i>/etc/rc.d/init.d/postgresql</i> </p>
</blockquote>
<p>for every runlevel L on which you want postgres to be started (XY is a number).

If you want to access the DB via TCP/IP (required for ODBC access),  in the file
    <i>/etc/rc.d/init.d/postgresql</i>
add to the line looking like this:</p>
<blockquote>
<p><i> su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl  -D  -p /usr/bin/postmaster start  > /dev/null 2>&1" < /dev/null </i></p>
</blockquote>
<p>the parameters -o & -i
    e.g.</p>
<blockquote>
<p><i>su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl  -D  -o -i -p /usr/bin/postmaster start  > /dev/null 2>&1" < /dev/null

</i></p>
</blockquote>
<p>The last thing to do is to set up access rights in file
    /var/lib/pgsql/data/pg_hba.conf as required. </p>
<p>Now, type:</p>
<blockquote>
<p><i>/etc/rc.d/init.d/postgresql start</i></p>
</blockquote>
<p>to start the DB server.

You can go to the directory
    <i>/usr/lib/pgsql/test/regress</i>
and run tests of DB functionality (read README in that directory) if required.</p>
<p><b>2) Installing and configuring ODBC</b> </p>
<p>From <a href="ftp://ftp.postgresql.org">ftp://ftp.postgresql.org</a> or from a mirror site get from the section "software" following rpm:


</p>

<center>
<table border=1 width="424" cellpadding="2" cellspacing="1">
  <tr>
    <td width="157">postgresql-odbc</td>
    <td width="257">libraries and ini files</td>
  </tr>
</table>
</center>

Type
<blockquote>
 <p> <i>rpm -i <list of rpms></i> </p>
</blockquote>
<p>for installing, or </p>
<blockquote>
 <p> <i>rpm -U <list of rpms></i> </p>
</blockquote>
<p>for upgrade.<br><br>

Type:</p>
<blockquote>
<p><i>psql -d template1 -f /usr/share/pgsql/odbc.sql </i>


</p>
</blockquote>
<p>to add some extra sql definitions to the template1 database.


</p>
<p>From the PostgreSQL interactive terminal (psql), in the template1 database, execute the following SQL:</p>
<blockquote>
<p><i>create type lo ( <br>
  internallength=4, <br>
  externallength=10, <br>
  input=int4in, <br>
  output=int4out, <br>
  default='', <br>
  passedbyvalue <br>
); </i>


</p>
</blockquote>
<p>to add support for blobs accessible via ODBC. Quit psql with the \q command. Every created database inherits all 
definitions from template1 unless specified otherwise, so you should have all definitions in every DB you create.


</p>
<p><b>3) Installing and configuring iODBC Driver Manager</b></p>
<p>From <a href="http://www.iodbc.org/">http://www.iodbc.org/</a> get from the section "software download", the 
iODBC Driver Manager, i.e. following rpms:

</p>

<center>
<table border=1 width="424" cellpadding="2" cellspacing="1">
  <tr>
    <td width="157">libiodbc</td>
    <td width="257">iODBC Driver Manager Runtime Package (libraries, config files)</td>
  </tr>
  <tr>
    <td width="157">libiodbc-devel</td>
    <td width="257">iODBC Developers Kit (odbc header files and developers libraries)</td>
  </tr>
</table>
</center>

Type
<blockquote>
 <p> <i>rpm -i <list of rpms></i> </p>
</blockquote>
<p>for installing, or </p>
<blockquote>
 <p> <i>rpm -U <list of rpms></i> </p>
</blockquote>
<p>for upgrade.<br><br>

Now we have to configure /etc/odbc.ini and and /etc/odbcinst.ini if you only use PostgreSQL via ODBC, you can replace <i>/etc/odbcinst.ini</i> with <i>/etc/pgsql/odbcinst.ini:</i></p>
<blockquote>
<p><i>cp /etc/pgsql/odbcinst.ini /etc/odbcinst.ini </i>

</p>
</blockquote>
<p>Otherwise you have to edit <i>/etc/odbcinst.ini</i> and copy the relevant parts from <i>/etc/pgsql/odbcinst.ini</i>. Be careful, this file is PARTIALLY case sensitive. It means some attributes are, some are not. If you have trouble with connection to PostgreSQL via ODBC, check if parameters in your /etc/odbc.ini have the same case as in the following example:

</p>
<blockquote>
 <i>
<code>------ /etc/odbc.ini file begin ----- <br>
 ;<br>
 ; odbc.ini <br>
 ; <br>
 [ODBC Data Sources] <br>
 test = PostgreSQL Test<br>
 <br>
 [test] <br>
 Driver=/usr/lib/libpsqlodbc.so <br>
 Description=Sample PostgreSQL DSN <br>
 DSN=test<br>
 Servername=localhost <br>
 Username=gin2 <br>
 Database=mydb <br>
 ReadOnly=No <br>
 Servertype=postgres <br>
 Port=5432 <br>
 FetchBufferSize=99 <br>
 ServerOptions= <br>
 ConnectOptions= <br>
 Options= <br>
 ReadOnly=no <br>
 Trace=1 <br>
 TraceFile=/home/gin2/odbc.trace <br>
 Debug=1 <br>
 DebugFile=/home/gin2/odbc.debug <br>
 CommLog=1 <br>
 </code></i><p><i>
<code>[Default] <br>
 Driver = /usr/lib/libpsqlodbc.so <br>
 <br>
 [ODBC] <br>
 InstallDir = /usr/lib/libiodbc.so <br>
 <br>
 ------ /etc/odbc.ini file end ----- </code>
 </i></p>
</blockquote>
<p>If you have done everything properly :-), the installation and setup is now finished. </p>
<p><b>4. Testing ODBC</b></p>
<p>With iODBC Driver Manager package should be distributed a small testing program <i>odbctest</i>. I haven't found it, so I took its source directly from CVS and compiled it myself. This command worked fine for me: <http://www.iodbc.org/cgi-bin/cvsweb.cgi/iODBC/samples/odbctest.c>

</p>
<blockquote>
<p><i>gcc -c odbctest.c -o odbctest.o gcc -s -o odbctest odbctest.o -liodbc</i>
</p>
</blockquote>
<p>Notice the <i>-liodbc</i> -- every program using ODBC must be linked with iodbc library. It is also not very well documented (at least I found it nowhere). You can now run the <i>odbctest</i> binary. If you run it without parameters, it asks you for an ODBC connect string. If you enter '?', it lists all dsn names (taken from <i>/etc/odbc.ini</i>. Be careful, the right ODBC connect string is not "name", but "dsn=name"!!! If you have trouble, look into ~/odbc.trace If you don't have trouble, continue reading...</p>
<p>Congratulations, now everything should work fine :) </p>
<p>I hope I saved you couple of days, which I spent looking for this information.</p>

<p><b>The following additional notes were supplied by Dick Wieland</b></p>
<p>- The iODBC documentation species HOST, not SERVERNAME as the parameter used to
designate the remote server. If you use HOST, the odbctest program returns with nothing more than “Have a nice day”.</p>
<p>- The iODBC documentation lists /usr/local/etc as the default location for odbc.ini. /etc is the default location.</p>

</p>

</body>
</html>@


1.1
log
@Move docs into the source tree.
@
text
@@

