{
    "mode": "man",
    "parameter": "pg_wrapper",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/pg_wrapper/1/json",
    "generated": "2026-09-01T12:29:13Z",
    "synopsis": "client-program [--cluster version/cluster] [...]\n(client-program: psql, createdb, dropuser, and all other client programs installed in\n/usr/lib/postgresql/version/bin).",
    "sections": {
        "NAME": {
            "content": "pgwrapper - wrapper for PostgreSQL client commands\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "client-program [--cluster version/cluster] [...]\n\n(client-program: psql, createdb, dropuser, and all other client programs installed in\n/usr/lib/postgresql/version/bin).\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This program is run only as a link to names which correspond to PostgreSQL programs in\n/usr/lib/postgresql/version/bin. It determines the configured cluster and database for the\nuser and calls the appropriate version of the desired program to connect to that cluster and\ndatabase, supplying any specified options to that command.\n\nThe target cluster is selected by the following means, in descending order of precedence:\n\n•   explicit specification with the --host option\n\n•   explicit specification with the --cluster option\n\n•   if the PGHOST environment variable is set, no further cluster selection is performed. The\ndefault  PostgreSQL  version  and  port  number  (from  the command line, the environment\nvariable PGPORT, or default 5432) will be used.\n\n•   explicit specification with the PGCLUSTER environment variable\n\n•   if a port is given (either via -p, --port, or PGPORT), and no host is  given,  the  local\ncluster matching that port number is used\n\n•   matching entry in ~/.postgresqlrc (see postgresqlrc(5)), if that file exists\n\n•   matching  entry  in  /etc/postgresql-common/userclusters (see userclusters(5)), if that\nfile exists\n\n•   If only one cluster exists on the local system, that one will be selected.\n\n•   If several clusters exist on the local system, the one listening on the default port 5432\nwill be selected.\n\nIf none of these rules match, pgwrapper does not  set  any  environment  variables  and  the\nprogram  called  will  likely  error  out  with  a message like \"could not connect to server:\nConnection refused\".\n\nFor psql, pgarchivecleanup, and pgisready, pgwrapper will always use the binary  from  the\nnewest  PostgreSQL  version  installed,  as  these  are downwards compatible.  If the cluster\nversion is older than 9.2, the newest considered binary version is 14.\n\nNote that pgwrapper needs to be able to read the server config to get  the  port  number  to\nconnect  to.  If  a  non-standard  port is configured in a place that pgwrapper cannot read,\nconnecting will fail. This particularly holds if the port was configured via ALTER SYSTEM  in\npostgresql.auto.conf and pgwrapper is invoked as any user other than postgres and root.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "--cluster version/cluster\n--cluster version/host:[port]\ncluster  is either the name of a cluster on the local system, or takes the form host:port\nfor a remote cluster. If port is left empty (i. e. you just specify host:),  it  defaults\nto 5432.\n",
            "subsections": []
        },
        "ENVIRONMENT": {
            "content": "PGCLUSTER\nIf  $PGCLUSTER  is  set,  its  value  (of the form version/cluster) specifies the desired\ncluster, similar to  the  --cluster  option.  However,  if  --cluster  is  specified,  it\noverrides the value of $PGCLUSTER.\n\nPGCLUSTERCONFROOT\nThis  specifies an alternative base directory for cluster configurations. This is usually\n/etc/postgresql/, but for testing/development purposes you can change this to point to e.\ng. your home directory, so that you can use  the  postgresql-common  tools  without  root\nprivileges.\n\nPGSYSCONFDIR\nThis  is the location of PostgreSQL's and postgresql-common's global configuration (e. g.\npgservice.conf, userclusters(5)). The default is /etc/postgresql-common/.\n",
            "subsections": []
        },
        "FILES": {
            "content": "/etc/postgresql-common/userclusters\nstores  the  default  cluster  and  database  for  users  and  groups  as  set   by   the\nadministrators.\n\n$HOME/.postgresqlrc\nstores defaults set by the user himself.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "userclusters(5), postgresqlrc(5)\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Martin Pitt <mpitt@debian.org>\n\nDebian                                       2024-08-09                                PGWRAPPER(1)",
            "subsections": []
        }
    },
    "summary": "pgwrapper - wrapper for PostgreSQL client commands",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "userclusters",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/userclusters/5/json"
        },
        {
            "name": "postgresqlrc",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/postgresqlrc/5/json"
        }
    ]
}