LoginSignup
1
0

More than 5 years have passed since last update.

PostgreSQLのバージョン毎の接続時のパラメータ

Last updated at Posted at 2017-01-07

C言語でPostgreSQLに接続するAPIのパラメータについて調べました。PHPのpdo_pgsqlやRubyのruby-pgなど、libpqをラップしている他の言語のライブラリでもおそらく同様のパラメータが使えると思います。

ドキュメントから拾ってきたので正しいかどうかはわかりません。

ポイント

  • client_encodingは9.1から
  • application_nameは9.0から

尚これらは古いバージョンでは、client_encoding=utf8 application_name=app_nameの代わりに
options='-c client_encoding=utf8 -c application_name=app_name'と書くことができます。

7.2
[
    "host",
    "hostaddr",
    "port",
    "dbname",
    "user",
    "password",
    "options",
    "tty",
    "requiressl"
]
7.3
[
    "connect_timeout"
]
8.2
[
    "sslmode",
    "krbsrvname",
    "service"
]
8.3
[
    "gsslib"
]
8.4
[
    "sslcert",
    "sslkey",
    "sslrootcert",
    "sslcrl"
]
9.0
[
    "application_name",
    "fallback_application_name",
    "keepalives",
    "keepalives_idle",
    "keepalives_interval",
    "keepalives_count"
]
9.1
[
    "client_encoding",
    "requirepeer"
]
9.2
[
    "sslcompression"
]
9.3
[]
9.4
[]
9.5
[]
9.6
[]

ソース

<?php
require __DIR__.'/vendor/autoload.php';

use Goutte\Client;

$versions = [
    "7.2",
    "7.3",
    "8.2",
    "8.3",
    "8.4",
    "9.0",
    "9.1",
    "9.2",
    "9.3",
    "9.4",
    "9.5",
    "9.6",
];

$client = new Client();

$previous = [];
foreach ($versions as $version) {
    $crawler = $client->request('GET', "https://www.postgresql.org/docs/$version/static/libpq-connect.html");

    $params = $crawler->filterXpath("//dl/dt/tt[text()=\"host\"]/../../dt/tt")
        ->extract(["_text"]);

    echo PHP_EOL, $version, PHP_EOL;
    echo json_encode(
        array_values(array_diff($params, $previous))
        , JSON_PRETTY_PRINT
    );
    $previous = $params;
}
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0