バージョンごとのドキュメント一覧

34.2. 接続状態関数 #

<title>Connection Status Functions</title>

These functions can be used to interrogate the status of an existing database connection object. これらの関数を使用して、既存のデータベース接続オブジェクトの状態を調べることができます。

ヒント

<application>libpq</application> application programmers should be careful to maintain the <structname>PGconn</structname> abstraction. Use the accessor functions described below to get at the contents of <structname>PGconn</structname>. Reference to internal <structname>PGconn</structname> fields using <filename>libpq-int.h</filename> is not recommended because they are subject to change in the future. libpqアプリケーションのプログラマは注意してPGconnという抽象化を維持してください。 PGconnの内容は以下に挙げるアクセス用関数を使って取り出してください。 PGconn構造体中のフィールドは将来予告なく変更されることがありますので、libpq-int.hを使用したフィールドの参照は避けてください。

The following functions return parameter values established at connection. These values are fixed for the life of the connection. If a multi-host connection string is used, the values of <xref linkend="libpq-PQhost"/>, <xref linkend="libpq-PQport"/>, and <xref linkend="libpq-PQpass"/> can change if a new connection is established using the same <structname>PGconn</structname> object. Other values are fixed for the lifetime of the <structname>PGconn</structname> object. 以下の関数は、接続で確立したパラメータの値を返します。 これらの値は接続期間中固定されます。 複数ホストの接続文字列が使用されている場合、同じPGconnオブジェクトを使用して新しい接続が確立されると、PQhostPQportPQpassの値は変わる可能性があります。 他の変数はPGconnの存在期間中固定されます。

PQdb #

Returns the database name of the connection. 接続したデータベース名を返します。

char *PQdb(const PGconn *conn);

PQuser #

Returns the user name of the connection. 接続したユーザ名を返します。

char *PQuser(const PGconn *conn);

PQpass #

Returns the password of the connection. 接続したパスワードを返します。

char *PQpass(const PGconn *conn);

<xref linkend="libpq-PQpass"/> will return either the password specified in the connection parameters, or if there was none and the password was obtained from the <link linkend="libpq-pgpass">password file</link>, it will return that. In the latter case, if multiple hosts were specified in the connection parameters, it is not possible to rely on the result of <xref linkend="libpq-PQpass"/> until the connection is established. The status of the connection can be checked using the function <xref linkend="libpq-PQstatus"/>. PQpassは、接続パラメータで指定されたパスワードを返します。 もし接続パラメータにパスワードがなくて、パスワードファイルからパスワードを取得できる場合には、そのパスワードを返します。 この場合、接続パラメータに複数のホストが指定されていると、接続が確立するまでは、PQpassの結果を当てにすることはできません。 接続の状態は、関数PQstatusで確認できます。

PQhost #

Returns the server host name of the active connection. This can be a host name, an IP address, or a directory path if the connection is via Unix socket. (The path case can be distinguished because it will always be an absolute path, beginning with <literal>/</literal>.) 実際に接続したサーバホスト名を返します。 これはホスト名、IPアドレス、あるいはUnixソケット経由で接続している場合はディレクトリパスになります。 (パスの場合は必ず/で始まる絶対パスになるので、他と区別できます。)

char *PQhost(const PGconn *conn);

If the connection parameters specified both <literal>host</literal> and <literal>hostaddr</literal>, then <xref linkend="libpq-PQhost"/> will return the <literal>host</literal> information. If only <literal>hostaddr</literal> was specified, then that is returned. If multiple hosts were specified in the connection parameters, <xref linkend="libpq-PQhost"/> returns the host actually connected to. hosthostaddrの両方が指定されると、PQhostは、そのhost情報を返します。 hostaddrだけが指定されると、それが返されます。 接続パラメータ中に複数のホストが指定された場合には、PQhostは実際に接続しているホストの情報を返します。

<xref linkend="libpq-PQhost"/> returns <symbol>NULL</symbol> if the <parameter>conn</parameter> argument is <symbol>NULL</symbol>. Otherwise, if there is an error producing the host information (perhaps if the connection has not been fully established or there was an error), it returns an empty string. conn引数がNULLならば、PQhostNULLを返します。 そうでない場合、もしホスト情報の生成中エラーとなったら(おそらくコネクションがまだ完全には確立されていないか、なんらかのエラーがある場合です)、空文字が返ります。

If multiple hosts were specified in the connection parameters, it is not possible to rely on the result of <xref linkend="libpq-PQhost"/> until the connection is established. The status of the connection can be checked using the function <xref linkend="libpq-PQstatus"/>. 接続パラメータ中に複数のホストが指定されると、接続が確立するまではPQhostの結果を当てにすることはできません。 接続の状態は、PQstatus関数で確認できます。

PQhostaddr #

Returns the server IP address of the active connection. This can be the address that a host name resolved to, or an IP address provided through the <literal>hostaddr</literal> parameter. 実際に接続したサーバIPアドレスを返します。 これはホスト名を解決したアドレス、あるいはhostaddrパラメータ経由で与えられたIPアドレスになります。

char *PQhostaddr(const PGconn *conn);

<xref linkend="libpq-PQhostaddr"/> returns <symbol>NULL</symbol> if the <parameter>conn</parameter> argument is <symbol>NULL</symbol>. Otherwise, if there is an error producing the host information (perhaps if the connection has not been fully established or there was an error), it returns an empty string. conn引数がNULLならば、PQhostaddrNULLを返します。 そうでない場合、もしホスト情報の生成がエラーとなったら(おそらくコネクションがまだ完全には確立されていないか、なんらかのエラーがある場合です)、空文字が返ります。

PQport #

Returns the port of the active connection. 実際に接続したポートを返します。

char *PQport(const PGconn *conn);

If multiple ports were specified in the connection parameters, <xref linkend="libpq-PQport"/> returns the port actually connected to. 接続パラメータ中に複数のポートが指定された場合には、PQportは実際に接続しているポートを返します。

<xref linkend="libpq-PQport"/> returns <symbol>NULL</symbol> if the <parameter>conn</parameter> argument is <symbol>NULL</symbol>. Otherwise, if there is an error producing the port information (perhaps if the connection has not been fully established or there was an error), it returns an empty string. conn引数がNULLならば、PQportNULLを返します。 そうでない場合、もしホスト情報の生成がエラーとなったら(おそらくコネクションがまだ完全には確立されていないか、なんらかのエラーがある場合です)、空文字が返ります。

If multiple ports were specified in the connection parameters, it is not possible to rely on the result of <xref linkend="libpq-PQport"/> until the connection is established. The status of the connection can be checked using the function <xref linkend="libpq-PQstatus"/>. 接続パラメータ中に複数のポートが指定されると、接続が確立するまではPQportの結果を当てにすることはできません。 接続の状態は、PQstatus関数で確認できます。

PQtty #

This function no longer does anything, but it remains for backwards compatibility. The function always return an empty string, or <symbol>NULL</symbol> if the <parameter>conn</parameter> argument is <symbol>NULL</symbol>. この関数はもう何もしませんが、後方互換性のために残っています。 この関数は常に空の文字列を返します。 conn引数がNULLの場合はNULLを返します。

char *PQtty(const PGconn *conn);

PQoptions #

Returns the command-line options passed in the connection request. 接続要求時に渡されたコマンドラインオプションを返します。

char *PQoptions(const PGconn *conn);

The following functions return status data that can change as operations are executed on the <structname>PGconn</structname> object. 以下の関数は、PGconnオブジェクトに対して操作を行うことで変更可能な状態データを返します。

PQstatus #

Returns the status of the connection. 接続の状態を返します。

ConnStatusType PQstatus(const PGconn *conn);

The status can be one of a number of values. However, only two of these are seen outside of an asynchronous connection procedure: <literal>CONNECTION_OK</literal> and <literal>CONNECTION_BAD</literal>. A good connection to the database has the status <literal>CONNECTION_OK</literal>. A failed connection attempt is signaled by status <literal>CONNECTION_BAD</literal>. Ordinarily, an OK status will remain so until <xref linkend="libpq-PQfinish"/>, but a communications failure might result in the status changing to <literal>CONNECTION_BAD</literal> prematurely. In that case the application could try to recover by calling <xref linkend="libpq-PQreset"/>. この状態は多くの値の中の1つとなるはずです。 しかし非同期接続手順の外部からは、その中でたった2つ、CONNECTION_OKCONNECTION_BADだけが現れます。 データベースへの接続に問題がなければ、CONNECTION_OK状態になります。 接続に失敗している場合はCONNECTION_BAD状態となります。 通常、OK状態はPQfinishまで維持されますが、通信失敗のために早まってCONNECTION_BADになることもあります。 その場合、アプリケーションはPQresetを呼び出して修復を試みることができます。

See the entry for <xref linkend="libpq-PQconnectStartParams"/>, <function>PQconnectStart</function> and <function>PQconnectPoll</function> with regards to other status codes that might be returned. 返される可能性があるその他の状態コードについてはPQconnectStartParamsPQconnectStartおよびPQconnectPollの項目を参照してください。

PQtransactionStatus #

Returns the current in-transaction status of the server. サーバの現在のトランザクション内部状態を返します。

PGTransactionStatusType PQtransactionStatus(const PGconn *conn);

The status can be <literal>PQTRANS_IDLE</literal> (currently idle), <literal>PQTRANS_ACTIVE</literal> (a command is in progress), <literal>PQTRANS_INTRANS</literal> (idle, in a valid transaction block), or <literal>PQTRANS_INERROR</literal> (idle, in a failed transaction block). <literal>PQTRANS_UNKNOWN</literal> is reported if the connection is bad. <literal>PQTRANS_ACTIVE</literal> is reported only when a query has been sent to the server and not yet completed. この状態は、PQTRANS_IDLE (現在待機中)、PQTRANS_ACTIVE (コマンド実行中)、PQTRANS_INTRANS (有効なトランザクションブロック内で待機中)、PQTRANS_INERROR (無効なトランザクションブロック内で待機中)となり得ます。 接続に問題がある場合のみPQTRANS_UNKNOWNが報告されます。 サーバへ問い合わせが送信されたが、まだ完了していない場合のみPQTRANS_ACTIVEが報告されます。

PQparameterStatus #

Looks up a current parameter setting of the server. サーバの現在のパラメータ設定を検索します。

const char *PQparameterStatus(const PGconn *conn, const char *paramName);

Certain parameter values are reported by the server automatically at connection startup or whenever their values change. <xref linkend="libpq-PQparameterStatus"/> can be used to interrogate these settings. It returns the current value of a parameter if known, or <symbol>NULL</symbol> if the parameter is not known. あるパラメータ値は、接続開始時に、もしくは、その値が変更された時は常にサーバによって自動的に報告されます。 PQparameterStatusはそれらの設定の調査に役立ちます。 パラメータの現在値がわかればその値を、わからない場合はNULLを返します。

Parameters reported as of the current release include <varname>server_version</varname>, <varname>server_encoding</varname>, <varname>client_encoding</varname>, <varname>application_name</varname>, <varname>default_transaction_read_only</varname>, <varname>in_hot_standby</varname>, <varname>is_superuser</varname>, <varname>session_authorization</varname>, <varname>DateStyle</varname>, <varname>IntervalStyle</varname>, <varname>TimeZone</varname>, <varname>integer_datetimes</varname>, and <varname>standard_conforming_strings</varname>. (<varname>server_encoding</varname>, <varname>TimeZone</varname>, and <varname>integer_datetimes</varname> were not reported by releases before 8.0; <varname>standard_conforming_strings</varname> was not reported by releases before 8.1; <varname>IntervalStyle</varname> was not reported by releases before 8.4; <varname>application_name</varname> was not reported by releases before 9.0; <varname>default_transaction_read_only</varname> and <varname>in_hot_standby</varname> were not reported by releases before 14.) Note that <varname>server_version</varname>, <varname>server_encoding</varname> and <varname>integer_datetimes</varname> cannot change after startup. 現在のリリースで報告されるパラメータには、server_versionserver_encodingclient_encodingapplication_namedefault_transaction_read_onlyin_hot_standbyis_superusersession_authorizationDateStyleIntervalStyleTimeZoneinteger_datetimesおよびstandard_conforming_stringsがあります。 (8.0より前ではserver_encodingTimeZoneおよびinteger_datetimesが、8.1より前ではstandard_conforming_stringsが、そして8.4より前ではIntervalStyleが、9.0より前ではapplication_nameが報告されませんでした。 14より前ではdefault_transaction_read_onlyin_hot_standbyが報告されませんでした。) server_versionserver_encodingおよびinteger_datetimesは起動後変更できないことに注意してください。

If no value for <varname>standard_conforming_strings</varname> is reported, applications can assume it is <literal>off</literal>, that is, backslashes are treated as escapes in string literals. Also, the presence of this parameter can be taken as an indication that the escape string syntax (<literal>E'...'</literal>) is accepted. standard_conforming_stringsの値がないと報告された場合、アプリケーションはoffと推測することができます。 つまり、バックスラッシュは文字リテラル中のエスケープ文字として扱います。 また、このパラメータが存在すると、エスケープ文字構文(E'...')が受付けられることを意味するものと取られます。

Although the returned pointer is declared <literal>const</literal>, it in fact points to mutable storage associated with the <literal>PGconn</literal> structure. It is unwise to assume the pointer will remain valid across queries. 返されるポインタはconstと宣言されていますが、実際にはPGconn構造体に関連付けされた変化する領域を指し示します。 このポインタが諸問い合わせに渡って有効なままであるとみなすのは賢明ではありません。

PQprotocolVersion #

Interrogates the frontend/backend protocol being used. 使用されるフロントエンド/バックエンドプロトコルを調査します。

int PQprotocolVersion(const PGconn *conn);

Applications might wish to use this function to determine whether certain features are supported. Currently, the possible values are 3 (3.0 protocol), or zero (connection bad). The protocol version will not change after connection startup is complete, but it could theoretically change during a connection reset. The 3.0 protocol is supported by <productname>PostgreSQL</productname> server versions 7.4 and above. ある機能がサポートされているかどうかを決定するために、アプリケーションはこの関数を使用することができます。 現在、取り得る値は3(3.0プロトコル)、あるいは0(接続不良)です。 このプロトコルバージョンは接続の開始が完了した後で変更することはできません。 しかし、理論的には接続のリセット時に変更可能です。 3.0プロトコルはPostgreSQLサーババージョン7.4以降でサポートされています。

PQserverVersion #

Returns an integer representing the server version. サーバのバージョンの整数表現を返します。

int PQserverVersion(const PGconn *conn);

Applications might use this function to determine the version of the database server they are connected to. The result is formed by multiplying the server's major version number by 10000 and adding the minor version number. For example, version 10.1 will be returned as 100001, and version 11.0 will be returned as 110000. Zero is returned if the connection is bad. この関数を使用してアプリケーションは接続したデータベースサーバのバージョンを決定することができます。 返却値の形式は、メジャーバージョン番号に10000を掛け、マイナーバージョン番号を加えたものです。 例えば、バージョン10.1では100001を返し、バージョン11.0では110000を返します。 接続不良の場合は0が返されます。

Prior to major version 10, <productname>PostgreSQL</productname> used three-part version numbers in which the first two parts together represented the major version. For those versions, <xref linkend="libpq-PQserverVersion"/> uses two digits for each part; for example version 9.1.5 will be returned as 90105, and version 9.2.0 will be returned as 90200. バージョン10よりも前では、PostgreSQLでは、最初の2つの部分がメジャーバージョンを表す、3つの部分からなるバージョン番号が使われていました。 これらのバージョンでは、PQserverVersionはそれぞれの部分に2桁の数字を使います。 たとえば、バージョン9.1.5では90105が返され、バージョン9.2.0では90200が返されます。

Therefore, for purposes of determining feature compatibility, applications should divide the result of <xref linkend="libpq-PQserverVersion"/> by 100 not 10000 to determine a logical major version number. In all release series, only the last two digits differ between minor releases (bug-fix releases). ですから、機能の互換性を見極めるのが目的なら、アプリケーションはPQserverVersionの結果を10000ではなく、100で割り、論理的なメジャーバージョンを求めるべきです。 すべてのリリースで、最後の2桁だけがマイナーリリースで異なります。 (バグ修正リリースです。)

PQerrorMessage #

<indexterm><primary>error message</primary></indexterm> Returns the error message most recently generated by an operation on the connection. 接続における操作において、最も最近に生成されたエラーメッセージを返します。

char *PQerrorMessage(const PGconn *conn);

Nearly all <application>libpq</application> functions will set a message for <xref linkend="libpq-PQerrorMessage"/> if they fail. Note that by <application>libpq</application> convention, a nonempty <xref linkend="libpq-PQerrorMessage"/> result can consist of multiple lines, and will include a trailing newline. The caller should not free the result directly. It will be freed when the associated <structname>PGconn</structname> handle is passed to <xref linkend="libpq-PQfinish"/>. The result string should not be expected to remain the same across operations on the <literal>PGconn</literal> structure. ほとんどすべてのlibpq関数は、失敗時にPQerrorMessage用のメッセージを設定します。 libpqでの決まりとして、空でないPQerrorMessageの結果は複数行に渡ることも可能で、最後に改行が含まれることがある点に注意してください。 呼び出し元はこの結果を直接解放してはいけません。 関連するPGconnハンドルがPQfinishに渡された時にこれは解放されます。 PGconn構造体への操作を跨って、この結果文字列が同一であると想定してはいけません。

PQsocket #

Obtains the file descriptor number of the connection socket to the server. A valid descriptor will be greater than or equal to 0; a result of -1 indicates that no server connection is currently open. (This will not change during normal operation, but could change during connection setup or reset.) サーバとの接続ソケットに対するファイル記述子番号を得ます。 有効な記述子なら値は0以上です。 -1の場合は、サーバとの接続がまだ開いていないことを示します。 (これは通常の操作では変更することはできません。 接続設定中やリセット中に変更されます。)

int PQsocket(const PGconn *conn);

PQbackendPID #

Returns the process <acronym>ID</acronym> (PID)<indexterm> <primary>PID</primary> <secondary>determining PID of server process</secondary> <tertiary>in libpq</tertiary> </indexterm> of the backend process handling this connection. 接続を処理するバックエンドのプロセスID(PID)を返します。

int PQbackendPID(const PGconn *conn);

The backend <acronym>PID</acronym> is useful for debugging purposes and for comparison to <command>NOTIFY</command> messages (which include the <acronym>PID</acronym> of the notifying backend process). Note that the <acronym>PID</acronym> belongs to a process executing on the database server host, not the local host! バックエンドのPIDは、デバッグする場合やNOTIFYメッセージ(これは通知を発行したバックエンドプロセスのPIDを含んでいます)の比較に便利です。 このPIDはデータベースサーバホスト上で実行されているプロセスのものであり、ローカルホスト側のものではありません! 注意してください。

PQconnectionNeedsPassword #

Returns true (1) if the connection authentication method required a password, but none was available. Returns false (0) if not. 接続認証方式がパスワードを要求し、利用可能なパスワードがない場合真(1)を返します。 さもなくば偽(0)を返します。

int PQconnectionNeedsPassword(const PGconn *conn);

This function can be applied after a failed connection attempt to decide whether to prompt the user for a password. この関数を、接続試行に失敗した後でユーザにパスワード入力を促すかどうかを決定するために適用することができます。

PQconnectionUsedPassword #

Returns true (1) if the connection authentication method used a password. Returns false (0) if not. 接続認証方式でパスワードを使用する場合は真(1)、さもなくば偽(0)を返します。

int PQconnectionUsedPassword(const PGconn *conn);

This function can be applied after either a failed or successful connection attempt to detect whether the server demanded a password. この関数は、接続の試みが失敗したか成功したかの後に、サーバがパスワードを要求したかどうかを検出するために適用できます。

PQconnectionUsedGSSAPI #

Returns true (1) if the connection authentication method used GSSAPI. Returns false (0) if not. 《機械翻訳》接続認証方式が GSSAPI を使用している場合は true (1) を返します。 使用していない場合は false (0) を返します。

int PQconnectionUsedGSSAPI(const PGconn *conn);

This function can be applied to detect whether the connection was authenticated with GSSAPI. 《機械翻訳》この関数は、接続がGSSAPIで認証されたかどうかを検出するために適用できます。

The following functions return information related to SSL. This information usually doesn't change after a connection is established. 以下の関数はSSLに関連した情報を返します。 この情報は通常、接続の確立後には変更されません。

PQsslInUse #

Returns true (1) if the connection uses SSL, false (0) if not. 接続がSSLを使っていれば真(1)、使っていなければ偽(0)を返します。

int PQsslInUse(const PGconn *conn);

PQsslAttribute #

Returns SSL-related information about the connection. 接続におけるSSL関連の情報を返します。

const char *PQsslAttribute(const PGconn *conn, const char *attribute_name);

The list of available attributes varies depending on the SSL library being used and the type of connection. Returns NULL if the connection does not use SSL or the specified attribute name is not defined for the library in use. 利用可能な属性のリストは使用されているSSLライブラリおよび接続の種類によって異なります。 接続でSSLが使用されない場合、または指定した属性名が使用中のライブラリに定義されていない場合は、NULLが返されます。

The following attributes are commonly available: 一般的には、以下の属性が利用可能です。

library

Name of the SSL implementation in use. (Currently, only <literal>"OpenSSL"</literal> is implemented) 使用されているSSLの実装の名前です。 (現在は"OpenSSL"だけが実装されています。)

protocol

SSL/TLS version in use. Common values are <literal>"TLSv1"</literal>, <literal>"TLSv1.1"</literal> and <literal>"TLSv1.2"</literal>, but an implementation may return other strings if some other protocol is used. 使用されているSSL/TLSのバージョンです。 一般的な値は、"TLSv1""TLSv1.1""TLSv1.2"ですが、他のプロトコルが使用されれば、異なる文字列が返されるかもしれません。

key_bits

Number of key bits used by the encryption algorithm. 暗号アルゴリズムで使用されている鍵のビット数です。

cipher

A short name of the ciphersuite used, e.g., <literal>"DHE-RSA-DES-CBC3-SHA"</literal>. The names are specific to each SSL implementation. 使用されている暗号スイートの短縮名、例えば"DHE-RSA-DES-CBC3-SHA"です。 この名前は各SSLの実装に固有のものです。

compression

Returns "on" if SSL compression is in use, else it returns "off". SSL圧縮が使用されている場合は"on"を返し、使用されていない場合は"off"を返します。

As a special case, the <literal>library</literal> attribute may be queried without a connection by passing NULL as the <literal>conn</literal> argument. The result will be the default SSL library name, or NULL if <application>libpq</application> was compiled without any SSL support. (Prior to <productname>PostgreSQL</productname> version 15, passing NULL as the <literal>conn</literal> argument always resulted in NULL. Client programs needing to differentiate between the newer and older implementations of this case may check the <literal>LIBPQ_HAS_SSL_LIBRARY_DETECTION</literal> feature macro.) 特殊なケースとして、library属性は、conn引数としてNULLを渡すことによって接続なしで照会することができます。 結果はデフォルトのSSLライブラリ名、またはlibpqがSSLサポートなしでコンパイルされた場合にNULLになります。 (PostgreSQLバージョン15より前では、conn引数としてNULLを渡すと常にNULLになりました。 このケースの新しい実装と古い実装を区別する必要があるクライアントプログラムは、LIBPQ_HAS_SSL_LIBRARY_DETECTION機能マクロをチェックしてください。)

PQsslAttributeNames #

Returns an array of SSL attribute names that can be used in <function>PQsslAttribute()</function>. The array is terminated by a NULL pointer. 《機械翻訳》PQsslAttributeNames(conn)で使用できるSSL属性名の配列を返します。 配列はNULLポインタで終了します。

const char * const * PQsslAttributeNames(const PGconn *conn);

If <literal>conn</literal> is NULL, the attributes available for the default SSL library are returned, or an empty list if <application>libpq</application> was compiled without any SSL support. If <literal>conn</literal> is not NULL, the attributes available for the SSL library in use for the connection are returned, or an empty list if the connection is not encrypted. 《機械翻訳》connがNULLの場合、デフォルトのSSLライブラリで使用可能な属性が返されます。 または、libpqが暗号化なしでコンパイルされた場合は空のリストが返されます。 connがNULLの場合、接続に使用可能なSSLライブラリで使用可能な属性が返されます。 接続が暗号化されていない場合は空のリストが返されます。

PQsslStruct #

Returns a pointer to an SSL-implementation-specific object describing the connection. Returns NULL if the connection is not encrypted or the requested type of object is not available from the connection's SSL implementation. SSLの実装に固有な接続を説明するオブジェクトへのポインタを返します。 接続が暗号化されていないか、要求されたタイプのオブジェクトが接続のSSLの実装から利用できない場合はNULLを返します。

void *PQsslStruct(const PGconn *conn, const char *struct_name);

The struct(s) available depend on the SSL implementation in use. For <productname>OpenSSL</productname>, there is one struct, available under the name <literal>OpenSSL</literal>, and it returns a pointer to <productname>OpenSSL</productname>'s <literal>SSL</literal> struct. To use this function, code along the following lines could be used: 利用可能な構造体は、使用されるSSLの実装に依存します。 OpenSSLでは、OpenSSLの名前の下に利用可能な構造体が1つあり、OpenSSLSSL構造体へのポインタを返します。 この関数を使用するには、以下のようなプログラムが利用できます。

#include <libpq-fe.h>
#include <openssl/ssl.h>

...

    SSL *ssl;

    dbconn = PQconnectdb(...);
    ...

    ssl = PQsslStruct(dbconn, "OpenSSL");
    if (ssl)
    {

        /* use OpenSSL functions to access ssl */

        /* sslにアクセスするためOpenSSLの関数を使う */
    }

This structure can be used to verify encryption levels, check server certificates, and more. Refer to the <productname>OpenSSL</productname> documentation for information about this structure. この構造体は、暗号化レベルの確認、サーバ証明書の検証、その他に使用できます。 この構造体に関する情報についてはOpenSSLのドキュメントを参照して下さい。

PQgetssl #

Returns the SSL structure used in the connection, or NULL if SSL is not in use. 接続で使用されているSSLの構造体を返します。 SSLが使われていなければNULLを返します。

void *PQgetssl(const PGconn *conn);

This function is equivalent to <literal>PQsslStruct(conn, "OpenSSL")</literal>. It should not be used in new applications, because the returned struct is specific to <productname>OpenSSL</productname> and will not be available if another <acronym>SSL</acronym> implementation is used. To check if a connection uses SSL, call <xref linkend="libpq-PQsslInUse"/> instead, and for more details about the connection, use <xref linkend="libpq-PQsslAttribute"/>. この関数はPQsslStruct(conn, "OpenSSL")と同等です。 返される構造体はOpenSSLに固有のもので他のSSL実装が利用されていると使用できないので、新しく作成するアプリケーションでは使うべきではありません。 接続がSSLを使用しているかどうかを調べるには、代わりにPQsslInUseを呼び出して下さい。 また、接続に関するより詳細についてはPQsslAttributeを使って下さい。