↑↓ 选择↵ 打开⌫ 切换范围完整搜索

PG.CENTER 连接 PostgreSQL 文档、百科与生态知识。由 Pigsty 维护。

Wiki / 命令行工具

ecpg

ecpg — embedded SQL C preprocessor

当前阅读 PG 18·选择有来源记录的版本

此版本暂无所选语言的定义,以下显示原始英文内容。

Documented executable
ecpg
Executable version
18.6
Reference inventory
Client applications
Option definition groups
12
environment
未知
manual path
app-ecpg.html
signature
ecpg [ option ...] file ...
synopsis
ecpg [ option ...] file ...

版本定义 PG 18

ecpg

ecpg — embedded SQL C preprocessor

Synopsis

ecpg [option...] file...

Description

ecpg 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.

ecpg 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's extension will be replaced by .c to construct the output file name. But the output file name can be overridden using the -o option.

If an input file name is just -, ecpg reads the program from standard input (and writes to standard output, unless that is overridden with -o).

This reference page does not describe the embedded SQL language. See Chapter 34 for more information on that topic.

Options

ecpg accepts the following command-line arguments:

-c

Automatically generate certain C code from SQL code. Currently, this works for EXEC SQL TYPE.

-C mode

Set a compatibility mode. mode can be INFORMIX, INFORMIX_SE, or ORACLE.

-D symbol[=value]

Define a preprocessor symbol, equivalently to the EXEC SQL DEFINE directive. If no value is specified, the symbol is defined with the value 1.

-h

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 -c option is forced on.

-i

Parse system include files as well.

-I directory

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.

-o filename

Specifies that ecpg should write all its output to the given filename. Write -o - to send all output to standard output.

-r option

Selects run-time behavior. Option can be one of the following:

no_indicator

Do not use indicators but instead use special values to represent null values. Historically there have been databases using this approach.

prepare

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.

questionmarks

Allow question mark as placeholder for compatibility reasons. This used to be the default long ago.

-t

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 EXEC SQL COMMIT is issued.

-v

Print additional information including the version and the "include" path.

--version

Print the ecpg version and exit.

-?
--help

Show help about ecpg command line arguments, and exit.

Notes

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 -I option when invoking the compiler (e.g., -I/usr/local/pgsql/include).

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.

The value of either of these directories that is appropriate for the installation can be found out using pg_config.

Examples

If you have an embedded SQL C source file named prog1.pgc, you can create an executable program using the following sequence of commands:

ecpg prog1.pgc
cc -I/usr/local/pgsql/include -c prog1.c
cc -o prog1 prog1.o -L/usr/local/pgsql/lib -lecpg

Documented options

Option and argumentsDescription
-cAutomatically generate certain C code from SQL code. Currently, this works for EXEC SQL TYPE .
-C modeSet a compatibility mode. mode can be INFORMIX , INFORMIX_SE , or ORACLE .
-D symbol [= value ]Define a preprocessor symbol, equivalently to the EXEC SQL DEFINE directive. If no value is specified, the symbol is defined with the value 1 .
-hProcess 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 -c option is forced on.
-iParse system include files as well.
-I directorySpecify 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.
-o filenameSpecifies that ecpg should write all its output to the given filename . Write -o - to send all output to standard output.
-r optionSelects run-time behavior. Option can be one of the following:
-tTurn 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 EXEC SQL COMMIT is issued.
-vPrint additional information including the version and the "include" path.
--versionPrint the ecpg version and exit.
-? --helpShow help about ecpg command line arguments, and exit.

比较版本

完整来源事实

options

map[description:Automatically generate certain C code from SQL code. Currently, this works for EXEC SQL TYPE . names:[-c] signature:-c source_url:/docs/18/app-ecpg.html summary:Automatically generate certain C code from SQL code. Currently, this works for EXEC SQL TYPE .], map[description:Set a compatibility mode. mode can be INFORMIX , INFORMIX_SE , or ORACLE . names:[-C mode] signature:-C mode source_url:/docs/18/app-ecpg.html summary:Set a compatibility mode. mode can be INFORMIX , INFORMIX_SE , or ORACLE .], map[description:Define a preprocessor symbol, equivalently to the EXEC SQL DEFINE directive. If no value is specified, the symbol is defined with the value 1 . names:[-D symbol [= value ]] signature:-D symbol [= value ] source_url:/docs/18/app-ecpg.html summary:Define a preprocessor symbol, equivalently to the EXEC SQL DEFINE directive. If no value is specified, the symbol is defined with the value 1 .], map[description: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 -c option is forced on. names:[-h] signature:-h source_url:/docs/18/app-ecpg.html summary: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 -c option is forced on.], map[description:Parse system include files as well. names:[-i] signature:-i source_url:/docs/18/app-ecpg.html summary:Parse system include files as well.], map[description: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. names:[-I directory] signature:-I directory source_url:/docs/18/app-ecpg.html summary: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.], map[description:Specifies that ecpg should write all its output to the given filename . Write -o - to send all output to standard output. names:[-o filename] signature:-o filename source_url:/docs/18/app-ecpg.html summary:Specifies that ecpg should write all its output to the given filename . Write -o - to send all output to standard output.], map[description:Selects run-time behavior. Option can be one of the following: no_indicator Do not use indicators but instead use special values to represent null values. Historically there have been databases using this approach. prepare 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. questionmarks Allow question mark as placeholder for compatibility reasons. This used to be the default long ago. names:[-r option] signature:-r option source_url:/docs/18/app-ecpg.html summary:Selects run-time behavior. Option can be one of the following:], map[description: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 EXEC SQL COMMIT is issued. names:[-t] signature:-t source_url:/docs/18/app-ecpg.html summary: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 EXEC SQL COMMIT is issued.], map[description:Print additional information including the version and the "include" path. names:[-v] signature:-v source_url:/docs/18/app-ecpg.html summary:Print additional information including the version and the "include" path.], map[description:Print the ecpg version and exit. names:[--version] signature:--version source_url:/docs/18/app-ecpg.html summary:Print the ecpg version and exit.], map[description:Show help about ecpg command line arguments, and exit. names:[-? --help] signature:-? --help source_url:/docs/18/app-ecpg.html summary:Show help about ecpg command line arguments, and exit.]

来源引用

完整定义与证据 JSON

定义来源

center · PostgreSQL 18 · ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8

正文语言: en · ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8