From b6939830041c54607221ad8e9d8ead26dd3c2045 Mon Sep 17 00:00:00 2001
From: Bruce Momjian <bruce@momjian.us>
Date: Sun, 13 Dec 1998 03:53:56 +0000
Subject: [PATCH] New ecpg man page.

---
 src/man/ecpg.1 | 297 ++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 245 insertions(+), 52 deletions(-)

diff --git a/src/man/ecpg.1 b/src/man/ecpg.1
index e5aa8af2848..a44fa61ca91 100644
--- a/src/man/ecpg.1
+++ b/src/man/ecpg.1
@@ -1,67 +1,260 @@
-.\" This is -*-nroff-*-
-.\" XXX standard disclaimer belongs here....
-.TH ECPG UNIX 2/11/98 PostgreSQL PostgreSQL
+.TH ECPG UNIX 11/28/98 PostgreSQL \fIPostgreSQL\fP
 .SH NAME
-ecpg - embedded SQL preprocessor for C
+ecpg - embedded SQL preprocessor for C / PostgreSQL
 .SH SYNOPSIS
-.BR ecpg
-[\c
-.BR "-v"
-]
-[\c
-.BR "-d"
-]
-[\c
-.BR "-o"
-outfile
-]
-file1
-[file2]
-[...]
-.in -5n
+.\" \fBecpg\fR [-v ] [-t] [-I include-path ] [-o outfile ]  file1 [ file2 ] [ ... ]
+\fBecpg\fR [-v ] [-t] [-I include-path ] [-o outfile ]  file1 [ file2 ] [ ... ]
 .SH DESCRIPTION
-ecpg an embedded SQL in C package for PostgreSQL. It enables you to
-develop C programs with embedded SQL code.
+.B \fIecpg\fP
+is an embedded SQL preprocessor for C / PostgreSQL. It
+enables development of C programs with embedded SQL code.
 .PP
-.IR "ecpg"
-understands the following command-line options:
+.B \fIecpg\fP
+is ultimately intended to be as compliant as possible with the         
+ANSI SQL-2 standard and existing commercial ESQL/C packages.                                               
+.SH OPTIONS
+.B \fIecpg\fP
+interprets the following flags when it is invoked               
+on the command line:
+.PP
+.PD 0
+.TP 10
+.BI \-v 
+Print version information. 
+.PD
 .TP
-.BR "-v"
-Print version information.
+.B \-t
+Turn off auto-transactin mode.
+.PD
 .TP
-.BR "-d"
-Turn on debugging.
+.PD
 .TP
-.BR "-o" " outfile"
-Specifies that
-.IR "ecpg"
-should write all its output to 
-.IR "outfile". If no such option is given the output is written to foo.c
-if the input file was name foo.pgc or to foo.bar.c if the input file was
-foo.bar.
+.B \-I include-path
+Specify additional include path. Defaults are \.,
+/usr/local/include, the PostgreSQL include path which is defined at compile
+time (default: /usr/local/pgsql/lib), /usr/include
+.PD
 .TP
-.BR "file1, file2, ..."
-The files to be processed.
-.SH "BUGS"
-The return code is alway -1 in case of an error. You cannot see which error
-occured by examining the return code.
+.B \-o
+Specifies that ecpg should write all its output to outfile.
+If no such option is given the output is written to foo.c
+(if the input file was named foo.pgc.)
+If the input file was named foo.bar the output file will be
+named foo.bar.c. 
+.PD
 .TP
-The cursor is opened when the declare statement is issued.
+.B file1, file2...
+The files to be processed.
+.\" 
+.SH INSTALLATION
+The
+.B \fIecpg\fP
+preprocessor is built during the PostgreSQL installation.  Binaries and
+libraries are installed into the PGBASE (i.e., /usr/local/pgsql/... ) 
+subdirectories.
+.SH PREPROCESSING FOR COMPILATION
+.B \fIecpg\fP
+.\" (-d ) (-o file) file.pgc ( 2> ecpf.log)
+(-o file) file.pgc 
+.LP
+.\" The optional \-d flag turns on debugging and 2> ecpg.log
+.\" redirects the debug output.  The .pgc extension is an 
+.\" arbitrary means of denoting ecpg source.
+The .pgc extension is an arbitrary means of denoting ecpg source.
+.SH COMPILING AND LINKING
+Assuming the \fIPostgreSQL\fP binaries are in /usr/local/pgsql:
+.LP
+gcc -g -i /usr/local/pgsql/include (-o file) file.c 
+-L /usr/local/pgsql/lib -lecpg -lpq
+.SH ECPG GRAMMAR
+.LP
+.SH LIBRARIES
+.LP
+The preprocessor will prepend two directives to the source:
+.LP
+\fI#include <ecpgtype.h>\fP and \fI#include <ecpglib.h>\fP
+.SH VARIABLE DECLARATION  
+Variables declared within ecpg source code must be prepended with:
+.LP
+EXEC SQL BEGIN DECLARE SECTION;  
+.LP        
+Similarly, variable declaration sections must terminate with:
+.LP
+EXEC SQL END DECLARE SECTION;
+.LP        
+NOTE: prior to version 2.1.0, each variable had to be declared 
+on a separate line.  As of version 2.1.0 multiple variables may
+be declared on a single line:
+.LP
+char  foo(16), bar(16);
+.LP       
+.SH ERROR HANDLING
+The SQL communication area is defined with:
+.LP
+EXEC SQL INCLUDE sqlca;
+.LP
+NOTE: the lowercase `sqlca'.  While SQL convention may be 
+followed, i.e., using uppercase to separate embedded SQL 
+from C statements, sqlca (which includes the sqlca.h 
+header file) MUST be lowercase.  This is because the EXEC SQL
+prefix indicates that this INCLUDE will be parsed by ecpg.
+ecpg observes case sensitivity (SQLCA.h will not be found.)
+EXEC SQL INCLUDE can be used to include other header files
+as long as case sensitivity is observed.
+.LP
+The sqlprint command is used with the EXEC SQL WHENEVER
+statement to turn on error handling throughout the 
+program:
+.LP
+EXEC SQL WHENEVER sqlerror sqlprint;
+.LP
+EXEC SQL WHENEVER not found sqlprint;
+.LP
+PLEASE NOTE: this is *not* an exhaustive example of usage for
+the EXEC SQL WHENEVER statement.  Further examples of usage may
+be found in SQL manuals (e.g., `The LAN TIMES Guide to SQL' by
+Groff and Weinberg.)
+.LP
+.SH CONNECTING TO THE DATABASE SERVER
+Prior to version 2.1.0 the database name was single quoted:
+.RS
+EXEC SQL CONNECT 'test1';
+.RE
+.LP
+As of version 2.1.0, the syntax has been simplified:
+.LP
+.RS
+EXEC SQL CONNECT test1;
+.RE
+(The database name is no longer quoted.)
+.LP
+Specifying a server and port name in the connect statement is also possible
+as of version 6.4. of PostgreSQL. The syntax is:
+.LP
+.RS
+dbname[@server][:port]
+.RE
+.LP
+or
+.LP
+.RS
+<tcp|unix>:postgresql://server[:port][/dbname][?options]
+.RE
+.SH QUERIES
+.LP
+.SS Create Table:
+.LP
+EXEC SQL CREATE TABLE foo (number int4, ascii char(16));  
+.RS
+EXEC SQL CREATE UNIQUE index num1 on foo(number); 
+.RE
+EXEC SQL COMMIT;
+.LP 
+.SS Insert:
+.LP
+EXEC SQL INSERT INTO foo (number, ascii)
+.RS
+VALUES (9999, 'doodad');
+.RE
+EXEC SQL COMMIT;
+.LP
+.SS Delete:
+.LP
+EXEC SQL DELETE FROM foo
+.RS
+WHERE number = 9999;   
+.RE
+EXEC SQL COMMIT;
+.LP
+.SS Singleton Select:
+.LP
+EXEC SQL SELECT foo INTO :FooBar FROM table1
+.RS
+WHERE ascii = 'doodad';  
+.RE
+.LP
+.SS Select using Cursors:
+.LP
+EXEC SQL DECLARE foo_bar CURSOR FOR     
+.RS
+SELECT number, ascii FROM foo    
+.RS
+ORDER BY ascii;
+.RE
+.RE
+EXEC SQL FETCH foo_bar INTO :FooBar, DooDad;
+.LP
+...
+EXEC SQL CLOSE foo_bar;
+.RS
+EXEC SQL COMMIT;
+.RE
+.LP
+.SS Updates
+.LP
+EXEC SQL UPDATE foo
+.RS
+SET ascii = 'foobar'
+.RE
+.RS
+WHERE number = 9999;
+.RE
+EXEC SQL COMMIT;
+.LP
+.SH BUGS
+.LP
+The is no EXEC SQL PREPARE statement.
+.LP
+The complete structure definition MUST be listed
+inside the declare section.
+.LP
+See the TODO file in the source for some more missing features.
+.LP
+.SH "RETURN VALUE"
+.LP
+ecpg returns 0 to the shell on successful completion, -1
+for errors.
+.LP
+.SH "SEE ALSO"
+.PD 0
 .TP
-ecpg does not understand enum datatypes.
+\fIcc\fP(1), \fIpgintro\fP(l), \fIcommit\fP(l), \fIdelete\fP(l)
 .TP
-The is no exec sql prepare statement.
+\fIfetch\fP(l), \fIselect\fP(l), \fIsql\fP(l) , \fIupdate\fP(l)
+.PD
+.SH FILES
+.PD 0
 .TP
-The complete structure definition has to be listed inside the declare section for ecpg to be able to understand it.
+.B /usr/src/pgsql/postgresql-${ver}/src/interfaces...
+ ./ecpg/include.......source for \fIecpg\fP header files.
+ ./ecpg/lib...........source for \fIecpg\fP libraries.
+ ./ecpg/preproc.......source for \fIecpg\fP header files.
+ ./ecpg/test..........source for \fIecpg\fP libraries.
+ (test contains examples of syntax for ecpg SQL-C.)
+.PD
 .TP
-Each variable has to be defined on a line on its own.
+.B /usr/local/pgsql/bin 
+\fIPostgreSQL\fP binaries including \fIecpg\fP.
+.PD
 .TP
-There is no way yet to fill a complete array with one call except arrays of [unsigned] char
-which are considered strings.
+.B /usr/local/pgsql/include 
+\fIPostgreSQL\fP headers including \fIecpglib.h\fP \fIecpgtype.h\fP 
+and \fIsqlca.h\fP.
+.PD
 .TP
-ecpg cannot use pointer variables except [unsigned] char *
-.SH "RETURN VALUE"
-.IR ecpg
-returns 0 to the shell on successful completion, -1 for errors,
-.SH "SEE ALSO"
-cc(1).
+.B /usr/local/pgsql/lib 
+\fIPostgreSQL\fP libraries including \fIlibecpg.a\fP and 
+\fIlibecpg.so\fP.
+.SH AUTHORS
+Linus Tolke \fI<linus@epact.se>\fP
+- original author of ECPG (up to version 0.2).
+.br
+.PP
+Michael Meskes \fI<meskes@debian.org>\fP
+- actual author and maintainer of ECPG.
+.br
+.PP
+Thomas Good \fI<tomg@q8.nrnet.org>\fP
+- author of this revision of the ecpg man page.
+.br
+.zZ
\ No newline at end of file
-- 
GitLab