summaryrefslogtreecommitdiffstats
path: root/doc/src/sgml/man1/ecpg.1
blob: 777f7cc5e91161c6903a93c228c94476e31664d4 (plain)
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
'\" t
.\"     Title: ecpg
.\"    Author: The PostgreSQL Global Development Group
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
.\"      Date: 2024
.\"    Manual: PostgreSQL 15.6 Documentation
.\"    Source: PostgreSQL 15.6
.\"  Language: English
.\"
.TH "ECPG" "1" "2024" "PostgreSQL 15.6" "PostgreSQL 15.6 Documentation"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
ecpg \- embedded SQL C preprocessor
.SH "SYNOPSIS"
.HP \w'\fBecpg\fR\ 'u
\fBecpg\fR [\fIoption\fR...] \fIfile\fR...
.SH "DESCRIPTION"
.PP
\fBecpg\fR
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\&.
.PP
\fBecpg\fR
will convert each input file given on the command line to the corresponding C output file\&. If an input file name does not have any extension,
\&.pgc
is assumed\&. The file\*(Aqs extension will be replaced by
\&.c
to construct the output file name\&. But the output file name can be overridden using the
\fB\-o\fR
option\&.
.PP
If an input file name is just
\-,
\fBecpg\fR
reads the program from standard input (and writes to standard output, unless that is overridden with
\fB\-o\fR)\&.
.PP
This reference page does not describe the embedded SQL language\&. See
Chapter\ \&36
for more information on that topic\&.
.SH "OPTIONS"
.PP
\fBecpg\fR
accepts the following command\-line arguments:
.PP
\fB\-c\fR
.RS 4
Automatically generate certain C code from SQL code\&. Currently, this works for
EXEC SQL TYPE\&.
.RE
.PP
\fB\-C \fR\fB\fImode\fR\fR
.RS 4
Set a compatibility mode\&.
\fImode\fR
can be
INFORMIX,
INFORMIX_SE, or
ORACLE\&.
.RE
.PP
\fB\-D \fR\fB\fIsymbol\fR\fR
.RS 4
Define a C preprocessor symbol\&.
.RE
.PP
\fB\-h\fR
.RS 4
Process header files\&. When this option is specified, the output file extension becomes
\&.h
not
\&.c, and the default input file extension is
\&.pgh
not
\&.pgc\&. Also, the
\fB\-c\fR
option is forced on\&.
.RE
.PP
\fB\-i\fR
.RS 4
Parse system include files as well\&.
.RE
.PP
\fB\-I \fR\fB\fIdirectory\fR\fR
.RS 4
Specify an additional include path, used to find files included via
EXEC SQL INCLUDE\&. Defaults are
\&.
(current directory),
/usr/local/include, the
PostgreSQL
include directory which is defined at compile time (default:
/usr/local/pgsql/include), and
/usr/include, in that order\&.
.RE
.PP
\fB\-o \fR\fB\fIfilename\fR\fR
.RS 4
Specifies that
\fBecpg\fR
should write all its output to the given
\fIfilename\fR\&. Write
\-o \-
to send all output to standard output\&.
.RE
.PP
\fB\-r \fR\fB\fIoption\fR\fR
.RS 4
Selects run\-time behavior\&.
\fIOption\fR
can be one of the following:
.PP
\fBno_indicator\fR
.RS 4
Do not use indicators but instead use special values to represent null values\&. Historically there have been databases using this approach\&.
.RE
.PP
\fBprepare\fR
.RS 4
Prepare all statements before using them\&. Libecpg will keep a cache of prepared statements and reuse a statement if it gets executed again\&. If the cache runs full, libecpg will free the least used statement\&.
.RE
.PP
\fBquestionmarks\fR
.RS 4
Allow question mark as placeholder for compatibility reasons\&. This used to be the default long ago\&.
.RE
.RE
.PP
\fB\-t\fR
.RS 4
Turn on autocommit of transactions\&. In this mode, each SQL command is automatically committed unless it is inside an explicit transaction block\&. In the default mode, commands are committed only when
\fBEXEC SQL COMMIT\fR
is issued\&.
.RE
.PP
\fB\-v\fR
.RS 4
Print additional information including the version and the "include" path\&.
.RE
.PP
\fB\-\-version\fR
.RS 4
Print the
ecpg
version and exit\&.
.RE
.PP
\fB\-?\fR
.br
\fB\-\-help\fR
.RS 4
Show help about
ecpg
command line arguments, and exit\&.
.RE
.SH "NOTES"
.PP
When compiling the preprocessed C code files, the compiler needs to be able to find the
ECPG
header files in the
PostgreSQL
include directory\&. Therefore, you might have to use the
\fB\-I\fR
option when invoking the compiler (e\&.g\&.,
\-I/usr/local/pgsql/include)\&.
.PP
Programs using C code with embedded SQL have to be linked against the
libecpg
library, for example using the linker options
\-L/usr/local/pgsql/lib \-lecpg\&.
.PP
The value of either of these directories that is appropriate for the installation can be found out using
\fBpg_config\fR(1)\&.
.SH "EXAMPLES"
.PP
If you have an embedded SQL C source file named
prog1\&.pgc, you can create an executable program using the following sequence of commands:
.sp
.if n \{\
.RS 4
.\}
.nf
ecpg prog1\&.pgc
cc \-I/usr/local/pgsql/include \-c prog1\&.c
cc \-o prog1 prog1\&.o \-L/usr/local/pgsql/lib \-lecpg
.fi
.if n \{\
.RE
.\}