1999-07-22 17:09:15 +02:00
|
|
|
<!--
|
2010-09-20 22:08:53 +02:00
|
|
|
doc/src/sgml/ref/ecpg-ref.sgml
|
2001-12-08 04:24:40 +01:00
|
|
|
PostgreSQL documentation
|
1999-07-22 17:09:15 +02:00
|
|
|
-->
|
|
|
|
|
2017-10-20 03:16:39 +02:00
|
|
|
<refentry id="app-ecpg">
|
2014-02-24 03:25:35 +01:00
|
|
|
<indexterm zone="app-ecpg">
|
|
|
|
<primary>ecpg</primary>
|
|
|
|
</indexterm>
|
|
|
|
|
1999-07-22 17:09:15 +02:00
|
|
|
<refmeta>
|
2002-10-21 20:04:05 +02:00
|
|
|
<refentrytitle><application>ecpg</application></refentrytitle>
|
2000-12-26 00:15:27 +01:00
|
|
|
<manvolnum>1</manvolnum>
|
1999-07-22 17:09:15 +02:00
|
|
|
<refmiscinfo>Application</refmiscinfo>
|
|
|
|
</refmeta>
|
2002-07-28 17:22:21 +02:00
|
|
|
|
1999-07-22 17:09:15 +02:00
|
|
|
<refnamediv>
|
2002-10-21 20:04:05 +02:00
|
|
|
<refname><application>ecpg</application></refname>
|
|
|
|
<refpurpose>embedded SQL C preprocessor</refpurpose>
|
1999-07-22 17:09:15 +02:00
|
|
|
</refnamediv>
|
2002-07-28 17:22:21 +02:00
|
|
|
|
1999-07-22 17:09:15 +02:00
|
|
|
<refsynopsisdiv>
|
2001-11-18 21:35:02 +01:00
|
|
|
<cmdsynopsis>
|
|
|
|
<command>ecpg</command>
|
2002-10-21 20:04:05 +02:00
|
|
|
<arg choice="opt" rep="repeat"><replaceable>option</replaceable></arg>
|
2001-11-18 21:35:02 +01:00
|
|
|
<arg choice="plain" rep="repeat"><replaceable>file</replaceable></arg>
|
|
|
|
</cmdsynopsis>
|
2002-07-28 17:22:21 +02:00
|
|
|
</refsynopsisdiv>
|
|
|
|
|
2002-10-21 20:04:05 +02:00
|
|
|
|
2017-10-20 03:16:39 +02:00
|
|
|
<refsect1 id="app-ecpg-description">
|
2002-07-28 17:22:21 +02:00
|
|
|
<title>Description</title>
|
|
|
|
|
|
|
|
<para>
|
2002-10-21 20:04:05 +02:00
|
|
|
<command>ecpg</command> is the embedded SQL preprocessor for C
|
|
|
|
programs. It converts C programs with embedded SQL statements to
|
|
|
|
normal C code by replacing the SQL invocations with special
|
|
|
|
function calls. The output files can then be processed with any C
|
|
|
|
compiler tool chain.
|
2002-07-28 17:22:21 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2002-10-21 20:04:05 +02:00
|
|
|
<command>ecpg</command> will convert each input file given on the
|
|
|
|
command line to the corresponding C output file. Input files
|
2016-12-22 08:28:13 +01:00
|
|
|
preferably have the extension <filename>.pgc</filename>.
|
|
|
|
The extension will be replaced by <filename>.c</filename> to
|
|
|
|
determine the output file name.
|
2002-10-21 20:04:05 +02:00
|
|
|
The output file name can also be overridden using the
|
|
|
|
<option>-o</option> option.
|
2002-07-28 17:22:21 +02:00
|
|
|
</para>
|
1999-07-22 17:09:15 +02:00
|
|
|
|
2002-10-21 20:04:05 +02:00
|
|
|
<para>
|
|
|
|
This reference page does not describe the embedded SQL language.
|
2003-03-25 17:15:44 +01:00
|
|
|
See <xref linkend="ecpg"> for more information on that topic.
|
2002-10-21 20:04:05 +02:00
|
|
|
</para>
|
2002-07-28 17:22:21 +02:00
|
|
|
</refsect1>
|
1999-07-22 17:09:15 +02:00
|
|
|
|
|
|
|
|
2002-07-28 17:22:21 +02:00
|
|
|
<refsect1>
|
2002-10-21 20:04:05 +02:00
|
|
|
<title>Options</title>
|
2000-03-31 08:17:52 +02:00
|
|
|
|
|
|
|
<para>
|
2002-10-21 20:04:05 +02:00
|
|
|
<command>ecpg</command> accepts the following command-line
|
|
|
|
arguments:
|
|
|
|
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><option>-c</option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-03-24 15:32:51 +01:00
|
|
|
Automatically generate certain C code from SQL code. Currently, this
|
2002-10-21 20:04:05 +02:00
|
|
|
works for <literal>EXEC SQL TYPE</literal>.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2003-11-02 13:55:24 +01:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>-C <replaceable>mode</replaceable></option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
Update reference documentation on may/can/might:
Standard English uses "may", "can", and "might" in different ways:
may - permission, "You may borrow my rake."
can - ability, "I can lift that log."
might - possibility, "It might rain today."
Unfortunately, in conversational English, their use is often mixed, as
in, "You may use this variable to do X", when in fact, "can" is a better
choice. Similarly, "It may crash" is better stated, "It might crash".
2007-02-01 00:26:05 +01:00
|
|
|
Set a compatibility mode. <replaceable>mode</replaceable> can
|
2003-11-02 13:55:24 +01:00
|
|
|
be <literal>INFORMIX</literal> or
|
|
|
|
<literal>INFORMIX_SE</literal>.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2002-10-21 20:04:05 +02:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>-D <replaceable>symbol</replaceable></option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Define a C preprocessor symbol.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2003-11-02 13:55:24 +01:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>-i</option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Parse system include files as well.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2002-10-21 20:04:05 +02:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>-I <replaceable class="parameter">directory</replaceable></option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Specify an additional include path, used to find files included
|
|
|
|
via <literal>EXEC SQL INCLUDE</literal>. Defaults are
|
|
|
|
<filename>.</filename> (current directory),
|
|
|
|
<filename>/usr/local/include</filename>, the
|
|
|
|
<productname>PostgreSQL</productname> include directory which
|
|
|
|
is defined at compile time (default:
|
|
|
|
<filename>/usr/local/pgsql/include</filename>), and
|
|
|
|
<filename>/usr/include</filename>, in that order.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><option>-o <replaceable>filename</replaceable></option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-03-24 15:32:51 +01:00
|
|
|
Specifies that <command>ecpg</command> should write all
|
2002-10-21 20:04:05 +02:00
|
|
|
its output to the given <replaceable>filename</replaceable>.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2003-11-02 13:55:24 +01:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>-r <replaceable>option</replaceable></option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2011-03-24 22:18:11 +01:00
|
|
|
Selects run-time behavior. <replaceable>Option</replaceable> can be
|
|
|
|
one of the following:
|
|
|
|
<variablelist>
|
2011-03-25 16:20:14 +01:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>no_indicator</option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Do not use indicators but instead use special values to represent
|
2011-05-19 00:14:45 +02:00
|
|
|
null values. Historically there have been databases using this approach.
|
2011-03-25 16:20:14 +01:00
|
|
|
</para>
|
|
|
|
</listitem>
|
2011-03-24 22:18:11 +01:00
|
|
|
</varlistentry>
|
2011-03-25 16:20:14 +01:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>prepare</option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Prepare all statements before using them. Libecpg will keep a cache of
|
2011-05-19 00:14:45 +02:00
|
|
|
prepared statements and reuse a statement if it gets executed again. If the
|
2011-03-25 16:20:14 +01:00
|
|
|
cache runs full, libecpg will free the least used statement.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><option>questionmarks</option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2011-05-19 00:14:45 +02:00
|
|
|
Allow question mark as placeholder for compatibility reasons.
|
2011-03-25 16:20:14 +01:00
|
|
|
This used to be the default long ago.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
2011-03-24 22:18:11 +01:00
|
|
|
</varlistentry>
|
2011-08-07 09:49:45 +02:00
|
|
|
</variablelist></para>
|
2003-11-02 13:55:24 +01:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2002-10-21 20:04:05 +02:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>-t</option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-03-24 15:32:51 +01:00
|
|
|
Turn on autocommit of transactions. In this mode, each SQL command is
|
2002-10-21 20:04:05 +02:00
|
|
|
automatically committed unless it is inside an explicit
|
2003-03-24 15:32:51 +01:00
|
|
|
transaction block. In the default mode, commands are committed
|
2002-10-21 20:04:05 +02:00
|
|
|
only when <command>EXEC SQL COMMIT</command> is issued.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2010-11-23 21:27:50 +01:00
|
|
|
|
2002-10-21 20:04:05 +02:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>-v</option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Print additional information including the version and the
|
2010-02-19 15:36:45 +01:00
|
|
|
"include" path.
|
2002-10-21 20:04:05 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2010-02-19 15:36:45 +01:00
|
|
|
<term><option>--version</option></term>
|
2002-10-21 20:04:05 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2010-02-19 15:36:45 +01:00
|
|
|
Print the <application>ecpg</application> version and exit.
|
2002-10-21 20:04:05 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2012-06-18 01:44:00 +02:00
|
|
|
<term><option>-?</option></term>
|
2010-02-19 15:36:45 +01:00
|
|
|
<term><option>--help</option></term>
|
2002-10-21 20:04:05 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2010-02-19 15:36:45 +01:00
|
|
|
Show help about <application>ecpg</application> command line
|
|
|
|
arguments, and exit.
|
2002-10-21 20:04:05 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2010-02-19 15:36:45 +01:00
|
|
|
|
2002-10-21 20:04:05 +02:00
|
|
|
</variablelist>
|
2000-03-31 08:17:52 +02:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
2002-07-28 17:22:21 +02:00
|
|
|
|
|
|
|
<refsect1>
|
2002-10-21 20:04:05 +02:00
|
|
|
<title>Notes</title>
|
2000-03-31 08:17:52 +02:00
|
|
|
|
2002-10-21 20:04:05 +02:00
|
|
|
<para>
|
|
|
|
When compiling the preprocessed C code files, the compiler needs to
|
2017-10-09 03:44:17 +02:00
|
|
|
be able to find the <application>ECPG</application> header files in the
|
|
|
|
<productname>PostgreSQL</productname> include directory. Therefore, you might
|
|
|
|
have to use the <option>-I</option> option when invoking the compiler
|
2002-11-15 04:11:18 +01:00
|
|
|
(e.g., <literal>-I/usr/local/pgsql/include</literal>).
|
2002-10-21 20:04:05 +02:00
|
|
|
</para>
|
2000-03-31 08:17:52 +02:00
|
|
|
|
2002-10-21 20:04:05 +02:00
|
|
|
<para>
|
|
|
|
Programs using C code with embedded SQL have to be linked against
|
|
|
|
the <filename>libecpg</filename> library, for example using the
|
2003-03-24 15:32:51 +01:00
|
|
|
linker options <literal>-L/usr/local/pgsql/lib -lecpg</literal>.
|
2002-10-21 20:04:05 +02:00
|
|
|
</para>
|
2000-03-31 08:17:52 +02:00
|
|
|
|
2002-10-21 20:04:05 +02:00
|
|
|
<para>
|
|
|
|
The value of either of these directories that is appropriate for
|
|
|
|
the installation can be found out using <xref
|
|
|
|
linkend="app-pgconfig">.
|
|
|
|
</para>
|
2000-03-31 08:17:52 +02:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
|
2002-10-21 20:04:05 +02:00
|
|
|
<refsect1>
|
|
|
|
<title>Examples</title>
|
2000-03-31 08:17:52 +02:00
|
|
|
|
2002-10-21 20:04:05 +02:00
|
|
|
<para>
|
|
|
|
If you have an embedded SQL C source file named
|
|
|
|
<filename>prog1.pgc</filename>, you can create an executable
|
|
|
|
program using the following sequence of commands:
|
2001-11-28 21:49:10 +01:00
|
|
|
<programlisting>
|
2002-10-21 20:04:05 +02:00
|
|
|
ecpg prog1.pgc
|
|
|
|
cc -I/usr/local/pgsql/include -c prog1.c
|
|
|
|
cc -o prog1 prog1.o -L/usr/local/pgsql/lib -lecpg
|
2011-08-07 09:49:45 +02:00
|
|
|
</programlisting></para>
|
1999-07-22 17:09:15 +02:00
|
|
|
</refsect1>
|
2002-07-28 17:22:21 +02:00
|
|
|
|
1999-07-22 17:09:15 +02:00
|
|
|
</refentry>
|